From cbf1943fe9b17ba371c533d2d6482ea8b2149d2e Mon Sep 17 00:00:00 2001 From: Matt Beckett Date: Wed, 7 Nov 2012 15:16:49 -0700 Subject: Fixes #4896: Limit group profile RSS to seachable object types --- mod/groups/views/rss/groups/profile/layout.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/views/rss/groups/profile/layout.php b/mod/groups/views/rss/groups/profile/layout.php index 3eeb9eaf2..0dafe78ad 100644 --- a/mod/groups/views/rss/groups/profile/layout.php +++ b/mod/groups/views/rss/groups/profile/layout.php @@ -7,7 +7,12 @@ * @uses $vars['entity'] ElggGroup object */ -echo elgg_list_entities(array( - 'type' => 'object', - 'container_guid' => $vars['entity']->getGUID(), -)); +$entities = elgg_get_config('registered_entities'); + +if (!empty($entities['object'])) { + echo elgg_list_entities(array( + 'type' => 'object', + 'subtypes' => $entities['object'], + 'container_guid' => $vars['entity']->getGUID(), + )); +} -- cgit v1.2.3 From d857c68fd91b1bcf586a30d86108b1898c2bb2d3 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Mon, 29 Oct 2012 20:59:21 -0400 Subject: Fixes #4895: Output valid ETag and Expires headers --- engine/handlers/cache_handler.php | 6 +++--- engine/lib/elgglib.php | 2 +- mod/file/thumbnail.php | 2 +- mod/groups/icon.php | 6 +++--- mod/profile/icondirect.php | 18 +++++++----------- pages/avatar/view.php | 2 +- 6 files changed, 16 insertions(+), 20 deletions(-) (limited to 'mod/groups') diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php index b332ec379..7706c2c92 100644 --- a/engine/handlers/cache_handler.php +++ b/engine/handlers/cache_handler.php @@ -64,7 +64,7 @@ $ts = $matches[4]; // If is the same ETag, content didn't changed. $etag = $ts; -if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { +if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$etag\"") { header("HTTP/1.1 304 Not Modified"); exit; } @@ -80,10 +80,10 @@ switch ($type) { break; } -header('Expires: ' . date('r', strtotime("+6 months")), true); +header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); header("Pragma: public", true); header("Cache-Control: public", true); -header("ETag: $etag"); +header("ETag: \"$etag\""); $filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view); diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 974f38aad..dd3cba25d 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1885,7 +1885,7 @@ function elgg_cacheable_view_page_handler($page, $type) { header("Content-type: $content_type"); // @todo should js be cached when simple cache turned off - //header('Expires: ' . date('r', time() + 864000)); + //header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true); //header("Pragma: public"); //header("Cache-Control: public"); //header("Content-Length: " . strlen($return)); diff --git a/mod/file/thumbnail.php b/mod/file/thumbnail.php index 35bf8c7f7..851f13a8f 100644 --- a/mod/file/thumbnail.php +++ b/mod/file/thumbnail.php @@ -46,7 +46,7 @@ if ($simpletype == "image") { // caching images for 10 days header("Content-type: $mime"); - header('Expires: ' . date('r',time() + 864000)); + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true); header("Pragma: public", true); header("Cache-Control: public", true); header("Content-Length: " . strlen($contents)); diff --git a/mod/groups/icon.php b/mod/groups/icon.php index 1bd240ea6..ebdc1eb6d 100644 --- a/mod/groups/icon.php +++ b/mod/groups/icon.php @@ -18,7 +18,7 @@ if (!($group instanceof ElggGroup)) { // If is the same ETag, content didn't changed. $etag = $group->icontime . $group_guid; -if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { +if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$etag\"") { header("HTTP/1.1 304 Not Modified"); exit; } @@ -46,9 +46,9 @@ if (!$success) { } header("Content-type: image/jpeg"); -header('Expires: ' . date('r',time() + 864000)); +header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true); header("Pragma: public"); header("Cache-Control: public"); header("Content-Length: " . strlen($contents)); -header("ETag: $etag"); +header("ETag: \"$etag\""); echo $contents; diff --git a/mod/profile/icondirect.php b/mod/profile/icondirect.php index c4439f78c..dbab5d31f 100644 --- a/mod/profile/icondirect.php +++ b/mod/profile/icondirect.php @@ -23,7 +23,7 @@ $guid = (int)$_GET['guid']; // If is the same ETag, content didn't changed. $etag = $last_cache . $guid; -if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { +if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"$etag\"") { header("HTTP/1.1 304 Not Modified"); exit; } @@ -55,19 +55,15 @@ if ($mysql_dblink) { $user_path = date('Y/m/d/', $join_date) . $guid; $filename = "$data_root$user_path/profile/{$guid}{$size}.jpg"; - $contents = @file_get_contents($filename); - if (!empty($contents)) { + $size = @filesize($filename); + if ($size) { header("Content-type: image/jpeg"); - header('Expires: ' . date('r', strtotime("+6 months")), true); + header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); header("Pragma: public"); header("Cache-Control: public"); - header("Content-Length: " . strlen($contents)); - header("ETag: $etag"); - // this chunking is done for supposedly better performance - $split_string = str_split($contents, 1024); - foreach ($split_string as $chunk) { - echo $chunk; - } + header("Content-Length: $size"); + header("ETag: \"$etag\""); + readfile($filename); exit; } } diff --git a/pages/avatar/view.php b/pages/avatar/view.php index bd6c95821..10d81fef1 100644 --- a/pages/avatar/view.php +++ b/pages/avatar/view.php @@ -46,7 +46,7 @@ if (!$success) { } header("Content-type: image/jpeg", true); -header('Expires: ' . date('r', strtotime("+6 months")), true); +header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+6 months")), true); header("Pragma: public", true); header("Cache-Control: public", true); header("Content-Length: " . strlen($contents)); -- cgit v1.2.3 From 8183d5bbc2c18b6825da8ebfc15581231e23de04 Mon Sep 17 00:00:00 2001 From: Sem Date: Sun, 8 Jul 2012 19:31:39 +0200 Subject: Fixes #1854. Group owners can delegate the ownership to another group member. --- mod/groups/actions/groups/edit.php | 33 ++++++++++++++++++++++++++ mod/groups/languages/en.php | 1 + mod/groups/views/default/forms/groups/edit.php | 31 ++++++++++++++++++++++++ mod/groups/views/default/groups/js.php | 25 +++++++++++++++++++ 4 files changed, 90 insertions(+) (limited to 'mod/groups') diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php index 2d7e1f023..fa96345e0 100644 --- a/mod/groups/actions/groups/edit.php +++ b/mod/groups/actions/groups/edit.php @@ -92,6 +92,18 @@ if ($new_group_flag) { $group->access_id = ACCESS_PUBLIC; } +$owner_guid = (int) get_input('owner_guid'); +$loggedin_guid = elgg_get_logged_in_user_guid(); +$is_admin = elgg_is_admin_logged_in(); + +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; + $owner_changed_flag = true; + } +} + $group->save(); // Invisible group support @@ -167,6 +179,27 @@ if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/')) $group->icontime = time(); } + + if ($owner_changed_flag) { + // @todo remove other user's pictures + } + +} elseif ($owner_changed_flag) { + + $filehandler = new ElggFile(); + $filehandler->setFilename('groups'); + + $filehandler->owner_guid = $old_owner_guid; + $old_path = $filehandler->getFilenameOnFilestore(); + + $filehandler->owner_guid = $group->owner_guid; + $new_path = $filehandler->getFilenameOnFilestore(); + + $sizes = array('', 'tiny', 'small', 'medium', 'large'); + + foreach($sizes as $size) { + rename("$old_path/{$group_guid}{$size}.jpg", "$new_path/{$group_guid}{$size}.jpg"); + } } system_message(elgg_echo("groups:saved")); diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index 0ca980108..67b0bbb89 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -19,6 +19,7 @@ $english = array( 'groups:add' => "Create a new group", 'groups:edit' => "Edit group", 'groups:delete' => 'Delete group', + 'groups:handover' => 'Hand over', 'groups:membershiprequests' => 'Manage join requests', 'groups:invitations' => 'Group invitations', diff --git a/mod/groups/views/default/forms/groups/edit.php b/mod/groups/views/default/forms/groups/edit.php index 532e89c35..52900d2d9 100644 --- a/mod/groups/views/default/forms/groups/edit.php +++ b/mod/groups/views/default/forms/groups/edit.php @@ -83,6 +83,37 @@ if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') { owner_guid; +} else { + $entity = false; +} + +if ($entity && ($owner_guid == elgg_get_logged_in_user_guid() || elgg_is_admin_logged_in())) { + $owner_guid = $vars['entity']->owner_guid; + $members = array(); + foreach ($vars['entity']->getMembers(0) as $member) { + $members[$member->guid] = "$member->name (@$member->username)"; + } +?> + +
+ +
+ +label,$b->label);')); diff --git a/mod/groups/views/default/groups/js.php b/mod/groups/views/default/groups/js.php index 1b4d33f32..c3698aadc 100644 --- a/mod/groups/views/default/groups/js.php +++ b/mod/groups/views/default/groups/js.php @@ -1,6 +1,31 @@ + // this adds a class to support IE8 and older elgg.register_hook_handler('init', 'system', function() { // jQuery uses 0-based indexing $('#groups-tools').children('li:even').addClass('odd'); }); + +// Hide group owner dropdown +elgg.register_hook_handler('init', 'system', function() { + $('.groups-owner-input').hide().each(function(){ + $(this).after($( + ' elgg_echo('groups:handover'), + 'rel' => 'toggle', + 'class' => 'elgg-button elgg-button-delete', + )); + ?>' + ).click(function(){ + $(this).hide() + .prev().show(); + })); + }); +}); -- cgit v1.2.3 From 004c2fbbb557ba2de60c2f05853d0f892383df45 Mon Sep 17 00:00:00 2001 From: Sem Date: Tue, 17 Jul 2012 18:18:28 +0200 Subject: Refs #1854. Using text to warn of the handover, instead the toggle with javascript. --- mod/groups/languages/en.php | 2 +- mod/groups/views/default/forms/groups/edit.php | 5 +++++ mod/groups/views/default/groups/js.php | 18 ------------------ 3 files changed, 6 insertions(+), 19 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php index 67b0bbb89..0d57f1680 100644 --- a/mod/groups/languages/en.php +++ b/mod/groups/languages/en.php @@ -19,7 +19,6 @@ $english = array( 'groups:add' => "Create a new group", 'groups:edit' => "Edit group", 'groups:delete' => 'Delete group', - 'groups:handover' => 'Hand over', 'groups:membershiprequests' => 'Manage join requests', 'groups:invitations' => 'Group invitations', @@ -36,6 +35,7 @@ $english = array( 'groups:membership' => "Group membership permissions", 'groups:access' => "Access permissions", 'groups:owner' => "Owner", + 'groups:owner:warning' => "Warning: if you change this value, you will no longer be the owner of this group.", 'groups:widget:num_display' => 'Number of groups to display', 'groups:widget:membership' => 'Group membership', 'groups:widgets:description' => 'Display the groups you are a member of on your profile', diff --git a/mod/groups/views/default/forms/groups/edit.php b/mod/groups/views/default/forms/groups/edit.php index 52900d2d9..7a740b878 100644 --- a/mod/groups/views/default/forms/groups/edit.php +++ b/mod/groups/views/default/forms/groups/edit.php @@ -109,6 +109,11 @@ if ($entity && ($owner_guid == elgg_get_logged_in_user_guid() || elgg_is_admin_l )); ?> + ' . elgg_echo('groups:owner:warning') . ''; + } + ?> elgg_echo('groups:handover'), - 'rel' => 'toggle', - 'class' => 'elgg-button elgg-button-delete', - )); - ?>' - ).click(function(){ - $(this).hide() - .prev().show(); - })); - }); -}); -- cgit v1.2.3 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 From f189ceb861d8456844f9d588f1582a5a5c49a9dc Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Sun, 18 Nov 2012 10:59:17 -0500 Subject: Group edit action refactoring --- mod/groups/actions/groups/edit.php | 164 +++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 89 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php index d8c7a7566..d0689be2e 100644 --- a/mod/groups/actions/groups/edit.php +++ b/mod/groups/actions/groups/edit.php @@ -5,9 +5,6 @@ * @package ElggGroups */ -// Load configuration -global $CONFIG; - elgg_make_sticky_form('groups'); /** @@ -19,9 +16,10 @@ function profile_array_decoder(&$v) { // Get group fields $input = array(); -foreach ($CONFIG->group as $shortname => $valuetype) { - // another work around for Elgg's encoding problems: #561, #1963 +foreach (elgg_get_config('group') as $shortname => $valuetype) { $input[$shortname] = get_input($shortname); + + // @todo treat profile fields as unescaped: don't filter, encode on output if (is_array($input[$shortname])) { array_walk_recursive($input[$shortname], 'profile_array_decoder'); } else { @@ -38,15 +36,17 @@ $input['name'] = htmlspecialchars(get_input('name', '', false), ENT_QUOTES, 'UTF $user = elgg_get_logged_in_user_entity(); $group_guid = (int)get_input('group_guid'); -$new_group_flag = $group_guid == 0; +$is_new_group = $group_guid == 0; -if ($new_group_flag && elgg_get_plugin_setting('limited_groups', 'groups') == 'yes' && !elgg_is_admin_logged_in()) { +if ($is_new_group + && (elgg_get_plugin_setting('limited_groups', 'groups') == 'yes') + && !$user->isAdmin()) { register_error(elgg_echo("groups:cantcreate")); forward(REFERER); } $group = new ElggGroup($group_guid); // load if present, if not create a new group -if (($group_guid) && (!$group->canEdit())) { +if ($group_guid && !$group->canEdit()) { register_error(elgg_echo("groups:cantedit")); forward(REFERER); } @@ -61,52 +61,46 @@ if (sizeof($input) > 0) { // Validate create if (!$group->name) { register_error(elgg_echo("groups:notitle")); - forward(REFERER); } // Set group tool options -if (isset($CONFIG->group_tool_options)) { - foreach ($CONFIG->group_tool_options as $group_option) { - $group_option_toggle_name = $group_option->name . "_enable"; - if ($group_option->default_on) { - $group_option_default_value = 'yes'; - } else { - $group_option_default_value = 'no'; - } - $group->$group_option_toggle_name = get_input($group_option_toggle_name, $group_option_default_value); +$tool_options = elgg_get_config('group_tool_options'); +if ($tool_options) { + foreach ($tool_options as $group_option) { + $option_toggle_name = $group_option->name . "_enable"; + $option_default = $group_option->default_on ? 'yes' : 'no'; + $group->$option_toggle_name = get_input($option_toggle_name, $option_default); } } // Group membership - should these be treated with same constants as access permissions? -switch (get_input('membership')) { - case ACCESS_PUBLIC: - $group->membership = ACCESS_PUBLIC; - break; - default: - $group->membership = ACCESS_PRIVATE; -} +$is_public_membership = (get_input('membership') == ACCESS_PUBLIC); +$group->membership = $is_public_membership ? ACCESS_PUBLIC : ACCESS_PRIVATE; -if ($new_group_flag) { +if ($is_new_group) { $group->access_id = ACCESS_PUBLIC; } -$owner_guid = (int) get_input('owner_guid'); -$loggedin_guid = elgg_get_logged_in_user_guid(); -$is_admin = elgg_is_admin_logged_in(); +$old_owner_guid = $is_new_group ? 0 : $group->owner_guid; +$new_owner_guid = (int) get_input('owner_guid'); -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; +$owner_has_changed = false; +$old_icontime = null; +if (!$is_new_group && $new_owner_guid && $new_owner_guid != $old_owner_guid) { + // verify new owner is member and old owner/admin is logged in + if (is_group_member($group_guid, $new_owner_guid) && ($old_owner_guid == $user->guid || $user->isAdmin())) { + $group->owner_guid = $new_owner_guid; // @todo Remove this when #4683 fixed - $owner_changed_flag = true; - $old_icontime = $group->icontime; + $owner_has_changed = true; + $old_icontime = $group->icontime; } } +$must_move_icons = ($owner_has_changed && $old_icontime); + $group->save(); // Invisible group support @@ -130,14 +124,18 @@ $group->save(); elgg_clear_sticky_form('groups'); // group creator needs to be member of new group and river entry created -if ($new_group_flag) { +if ($is_new_group) { + + // @todo this should not be necessary... elgg_set_page_owner_guid($group->guid); + $group->join($user); add_to_river('river/group/create', 'create', $user->guid, $group->guid, $group->access_id); } -// Now see if we have a file icon -if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/'))) { +$has_uploaded_icon = (!empty($_FILES['icon']['type']) && substr_count($_FILES['icon']['type'], 'image/')); + +if ($has_uploaded_icon) { $icon_sizes = elgg_get_config('icon_sizes'); @@ -149,70 +147,58 @@ if ((isset($_FILES['icon'])) && (substr_count($_FILES['icon']['type'],'image/')) $filehandler->open("write"); $filehandler->write(get_uploaded_file('icon')); $filehandler->close(); + $filename = $filehandler->getFilenameOnFilestore(); + + $sizes = array('tiny', 'small', 'medium', 'large'); + + $thumbs = array(); + foreach ($sizes as $size) { + $thumbs[$size] = get_resized_image_from_existing_file( + $filename, + $icon_sizes[$size]['w'], + $icon_sizes[$size]['h'], + $icon_sizes[$size]['square'] + ); + } - $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['tiny']['w'], $icon_sizes['tiny']['h'], $icon_sizes['tiny']['square']); - $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['small']['w'], $icon_sizes['small']['h'], $icon_sizes['small']['square']); - $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['medium']['w'], $icon_sizes['medium']['h'], $icon_sizes['medium']['square']); - $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $icon_sizes['large']['w'], $icon_sizes['large']['h'], $icon_sizes['large']['square']); - if ($thumbtiny) { - + if ($thumbs['tiny']) { // just checking if resize successful $thumb = new ElggFile(); $thumb->owner_guid = $group->owner_guid; $thumb->setMimeType('image/jpeg'); - $thumb->setFilename($prefix."tiny.jpg"); - $thumb->open("write"); - $thumb->write($thumbtiny); - $thumb->close(); - - $thumb->setFilename($prefix."small.jpg"); - $thumb->open("write"); - $thumb->write($thumbsmall); - $thumb->close(); - - $thumb->setFilename($prefix."medium.jpg"); - $thumb->open("write"); - $thumb->write($thumbmedium); - $thumb->close(); - - $thumb->setFilename($prefix."large.jpg"); - $thumb->open("write"); - $thumb->write($thumblarge); - $thumb->close(); + foreach ($sizes as $size) { + $thumb->setFilename("{$prefix}{$size}.jpg"); + $thumb->open("write"); + $thumb->write($thumbs[$size]); + $thumb->close(); + } $group->icontime = time(); } - - 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 && $old_icontime) { // @todo Remove this when #4683 fixed - +} + +// @todo Remove this when #4683 fixed +if ($must_move_icons) { $filehandler = new ElggFile(); $filehandler->setFilename('groups'); - $filehandler->owner_guid = $old_owner_guid; $old_path = $filehandler->getFilenameOnFilestore(); - - $filehandler->owner_guid = $group->owner_guid; - $new_path = $filehandler->getFilenameOnFilestore(); - + $sizes = array('', 'tiny', 'small', 'medium', 'large'); - - foreach($sizes as $size) { - rename("$old_path/{$group_guid}{$size}.jpg", "$new_path/{$group_guid}{$size}.jpg"); + + if ($has_uploaded_icon) { + // delete those under old owner + foreach ($sizes as $size) { + unlink("$old_path/{$group_guid}{$size}.jpg"); + } + } else { + // move existing to new owner + $filehandler->owner_guid = $group->owner_guid; + $new_path = $filehandler->getFilenameOnFilestore(); + + foreach ($sizes as $size) { + rename("$old_path/{$group_guid}{$size}.jpg", "$new_path/{$group_guid}{$size}.jpg"); + } } } -- cgit v1.2.3 From ce1cff247caf418af1fab52c5c2182883b7a26d0 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Wed, 5 Dec 2012 09:45:31 -0500 Subject: Fixes fatal error in groups/add page. --- mod/groups/views/default/forms/groups/edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/groups') diff --git a/mod/groups/views/default/forms/groups/edit.php b/mod/groups/views/default/forms/groups/edit.php index 7a740b878..41d97e6c3 100644 --- a/mod/groups/views/default/forms/groups/edit.php +++ b/mod/groups/views/default/forms/groups/edit.php @@ -147,7 +147,7 @@ if ($tools) {
'group_guid', 'value' => $entity->getGUID(), @@ -156,7 +156,7 @@ if (isset($entity)) { echo elgg_view('input/submit', array('value' => elgg_echo('save'))); -if (isset($entity)) { +if ($entity) { $delete_url = 'action/groups/delete?guid=' . $entity->getGUID(); echo elgg_view('output/confirmlink', array( 'text' => elgg_echo('groups:delete'), -- cgit v1.2.3