From 158a02f263a2d48e9832b5f403b04f3fdcf21ac4 Mon Sep 17 00:00:00 2001 From: Sem Date: Tue, 17 Jul 2012 19:59:48 +0200 Subject: Refs #1854. Removing old owner icons when changing the owner and changing the icon at the same time. --- mod/groups/actions/groups/edit.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php index fa96345e0..d8c7a7566 100644 --- a/mod/groups/actions/groups/edit.php +++ b/mod/groups/actions/groups/edit.php @@ -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'); -- cgit v1.2.3