solved Moving a media image file

TiG
TiG
@tig
5 years ago
184 posts
We have a need to move an image media file from one profile to another. The ideal function would be a rename because there is no functional need to read and write the file - just to literally change the hosting profile.

Basically I want like to build a function like jrCore_rename_media_file($profile_id, $current_name, $new_name); but with a $from_profile_id and a $to_profile_id parameter instead of simply $profile_id.

My concern is twofold:

1. Want to avoid reading and writing the image file if possible (no need to consume the needed resources)
2. Want to implement a future-proof solution. That is, to avoid accessing volatile functions.

How would you recommend I approach this problem?


--
TiG

updated by @tig: 04/20/19 12:05:59PM
michael
@michael
5 years ago
7,714 posts
There's a module that moves stuff from one profile to another. Im looking for it now. Cant remember the name. That will have how to do it in it.

--edit--
Found it, its called jrChangeOwner.

Look in the index.php view_jrChangeOwner_change_save() function.

The bit on moving files around is this:

                    // Check for and move any files
                    $_files = jrCore_get_directory_files(jrCore_get_media_directory($_xt['_profile_id']));
                    if ($_files && is_array($_files) && count($_files) > 0) {
                        foreach ($_files as $file) {
                            if (strstr($file, "{$_post['module']}_{$_xt['_item_id']}")) {
                                $sdir = jrCore_get_media_directory($_xt['_profile_id']);
                                rename("{$sdir}/{$file}", "{$tdir}/{$file}");
                            }
                        }
                    }

updated by @michael: 01/15/19 07:44:29PM
TiG
TiG
@tig
5 years ago
184 posts
Michael

It is amazing what you know of JR. Will locate this module and follow its lead.

Thanks!,
TiG


--
TiG
Strumelia
Strumelia
@strumelia
5 years ago
3,603 posts
I use the Change Owner module often, it's so helpful! Just this week i changed the owner of a longtime 'Group' that has a lot of valuable site content, because the original group owner had drifted away from my site. In effect I could 'give' the group to a new more active member to oversee, thus ensuring the survival of the group and its content.
BTW you don't see the tools in the ChangeOwner module itself, you just make it 'active' with the checkbox, and then... once active, you go to various modules like group, forum, comment, image, etc... and you'll then find "change owner" as one of the options under the Tools section of that module.


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015

updated by @strumelia: 01/16/19 02:44:19PM

Tags