diff options
author | Sem <sembrestels@riseup.net> | 2012-07-08 19:31:39 +0200 |
---|---|---|
committer | Steve Clay <steve@mrclay.org> | 2012-11-19 08:01:01 -0500 |
commit | 8183d5bbc2c18b6825da8ebfc15581231e23de04 (patch) | |
tree | 103ba017a78bad5df11e9d88b29291677be4746c /mod | |
parent | d857c68fd91b1bcf586a30d86108b1898c2bb2d3 (diff) | |
download | elgg-8183d5bbc2c18b6825da8ebfc15581231e23de04.tar.gz elgg-8183d5bbc2c18b6825da8ebfc15581231e23de04.tar.bz2 |
Fixes #1854. Group owners can delegate the ownership to another group member.
Diffstat (limited to 'mod')
-rw-r--r-- | mod/groups/actions/groups/edit.php | 33 | ||||
-rw-r--r-- | mod/groups/languages/en.php | 1 | ||||
-rw-r--r-- | mod/groups/views/default/forms/groups/edit.php | 31 | ||||
-rw-r--r-- | mod/groups/views/default/groups/js.php | 25 |
4 files changed, 90 insertions, 0 deletions
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') { <?php } +if (isset($vars['entity'])) { + $entity = $vars['entity']; + $owner_guid = $vars['entity']->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)"; + } +?> + +<div> + <label> + <?php echo elgg_echo('groups:owner'); ?><br /> + <?php echo elgg_view('input/dropdown', array( + 'name' => 'owner_guid', + 'value' => $owner_guid, + 'options_values' => $members, + 'class' => 'groups-owner-input', + )); + ?> + </label> +</div> + +<?php +} + $tools = elgg_get_config('group_tool_options'); if ($tools) { usort($tools, create_function('$a,$b', 'return strcmp($a->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 @@ +<?php +/** + * Javascript for Groups forms + * + * @package ElggGroups + */ +?> // 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($( + '<?php + echo elgg_view('output/url', array( + 'text' => elgg_echo('groups:handover'), + 'rel' => 'toggle', + 'class' => 'elgg-button elgg-button-delete', + )); + ?>' + ).click(function(){ + $(this).hide() + .prev().show(); + })); + }); +}); |