aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/actions/groups/edit.php33
-rw-r--r--mod/groups/languages/en.php1
-rw-r--r--mod/groups/views/default/forms/groups/edit.php31
-rw-r--r--mod/groups/views/default/groups/js.php25
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();
+ }));
+ });
+});