]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #1854. Removing old owner icons when changing the owner and changing the icon...
authorSem <sembrestels@riseup.net>
Tue, 17 Jul 2012 17:59:48 +0000 (19:59 +0200)
committerSteve Clay <steve@mrclay.org>
Mon, 19 Nov 2012 13:01:02 +0000 (08:01 -0500)
mod/groups/actions/groups/edit.php

index fa96345e0e164c751c316e33f48b0734545f3652..d8c7a7566354931de4721d84141f1f85c577f260 100644 (file)
@@ -100,7 +100,10 @@ if (!$new_group_flag && $owner_guid && $owner_guid != $group->owner_guid) {
        if($group->isMember($owner_guid) && ($group->owner_guid == $loggedin_guid || $is_admin)) {
                $old_owner_guid = $group->owner_guid;
                $group->owner_guid = $owner_guid;
+               
+               // @todo Remove this when #4683 fixed
                $owner_changed_flag = true;
+               $old_icontime = $group->icontime; 
        }
 }
 
@@ -180,11 +183,22 @@ if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))
                $group->icontime = time();
        }
        
-       if ($owner_changed_flag) {
-               // @todo remove other user's pictures
+       if ($owner_changed_flag && $old_icontime) { // @todo Remove this when #4683 fixed
+               
+               $filehandler = new ElggFile();
+               $filehandler->setFilename('groups');
+               
+               $filehandler->owner_guid = $old_owner_guid;
+               $old_path = $filehandler->getFilenameOnFilestore();
+               
+               $sizes = array('', 'tiny', 'small', 'medium', 'large');
+       
+               foreach($sizes as $size) {
+                       unlink("$old_path/{$group_guid}{$size}.jpg");
+               }
        }
        
-} elseif ($owner_changed_flag) {
+} elseif ($owner_changed_flag && $old_icontime) { // @todo Remove this when #4683 fixed
        
        $filehandler = new ElggFile();
        $filehandler->setFilename('groups');