aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-07-08 12:21:19 +0200
committerSem <sembrestels@riseup.net>2012-07-08 12:21:19 +0200
commit8c0897d92395d897a8e40a2d1b97e5f838520296 (patch)
tree53f85cefb13bdc377bef6585144a812507c356d6 /mod/groups
parent7fd67bc8ac6882f1a73aa7f8f907cd6c2a694272 (diff)
downloadelgg-8c0897d92395d897a8e40a2d1b97e5f838520296.tar.gz
elgg-8c0897d92395d897a8e40a2d1b97e5f838520296.tar.bz2
Fixes #1792. Added pluggin setting in groups to set who can create groups, logged in users or only admins.
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/actions/groups/edit.php6
-rw-r--r--mod/groups/languages/en.php4
-rw-r--r--mod/groups/lib/groups.php10
-rw-r--r--mod/groups/views/default/plugins/groups/settings.php18
4 files changed, 34 insertions, 4 deletions
diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php
index b513a6098..a76bde0ac 100644
--- a/mod/groups/actions/groups/edit.php
+++ b/mod/groups/actions/groups/edit.php
@@ -39,10 +39,14 @@ $user = elgg_get_logged_in_user_entity();
$group_guid = (int)get_input('group_guid');
$new_group_flag = $group_guid == 0;
+if ($new_group_flag && elgg_get_plugin_setting('limited_groups', 'groups') == 'yes' && !elgg_is_admin_logged_in()) {
+ 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())) {
register_error(elgg_echo("groups:cantedit"));
-
forward(REFERER);
}
diff --git a/mod/groups/languages/en.php b/mod/groups/languages/en.php
index 4868aa334..0ca980108 100644
--- a/mod/groups/languages/en.php
+++ b/mod/groups/languages/en.php
@@ -41,6 +41,7 @@ $english = array(
'groups:noaccess' => 'No access to group',
'groups:permissions:error' => 'You do not have the permissions for this',
'groups:ingroup' => 'in the group',
+ 'groups:cantcreate' => 'You can not create a group. Only admins can.',
'groups:cantedit' => 'You can not edit this group',
'groups:saved' => 'Group saved',
'groups:featured' => 'Featured groups',
@@ -259,6 +260,7 @@ or click below to view the group's join requests:
'groups:forumtopic:edited' => 'Forum topic successfully edited.',
'groups:allowhiddengroups' => 'Do you want to allow private (invisible) groups?',
+ 'groups:whocancreate' => 'Who can create new groups?',
/**
* Action messages
@@ -285,4 +287,4 @@ or click below to view the group's join requests:
);
-add_translation("en", $english); \ No newline at end of file
+add_translation("en", $english);
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
index 51ae89a87..dfbb1154b 100644
--- a/mod/groups/lib/groups.php
+++ b/mod/groups/lib/groups.php
@@ -12,7 +12,9 @@ function groups_handle_all_page() {
elgg_pop_breadcrumb();
elgg_push_breadcrumb(elgg_echo('groups'));
- elgg_register_title_button();
+ if (elgg_get_plugin_setting('limited_groups', 'groups') != 'yes' || elgg_is_admin_logged_in()) {
+ elgg_register_title_button();
+ }
$selected_tab = get_input('filter', 'newest');
@@ -184,7 +186,11 @@ function groups_handle_edit_page($page, $guid = 0) {
elgg_set_page_owner_guid(elgg_get_logged_in_user_guid());
$title = elgg_echo('groups:add');
elgg_push_breadcrumb($title);
- $content = elgg_view('groups/edit');
+ if (elgg_get_plugin_setting('limited_groups', 'groups') != 'yes' || elgg_is_admin_logged_in()) {
+ $content = elgg_view('groups/edit');
+ } else {
+ $content = elgg_echo('groups:cantcreate');
+ }
} else {
$title = elgg_echo("groups:edit");
$group = get_entity($guid);
diff --git a/mod/groups/views/default/plugins/groups/settings.php b/mod/groups/views/default/plugins/groups/settings.php
index 7197dcb37..41ea146db 100644
--- a/mod/groups/views/default/plugins/groups/settings.php
+++ b/mod/groups/views/default/plugins/groups/settings.php
@@ -8,6 +8,11 @@ if (!isset($vars['entity']->hidden_groups)) {
$vars['entity']->hidden_groups = 'no';
}
+// set default value
+if (!isset($vars['entity']->limited_groups)) {
+ $vars['entity']->limited_groups = 'no';
+}
+
echo '<div>';
echo elgg_echo('groups:allowhiddengroups');
echo ' ';
@@ -20,3 +25,16 @@ echo elgg_view('input/dropdown', array(
'value' => $vars['entity']->hidden_groups,
));
echo '</div>';
+
+echo '<div>';
+echo elgg_echo('groups:whocancreate');
+echo ' ';
+echo elgg_view('input/dropdown', array(
+ 'name' => 'params[limited_groups]',
+ 'options_values' => array(
+ 'no' => elgg_echo('LOGGED_IN'),
+ 'yes' => elgg_echo('admin')
+ ),
+ 'value' => $vars['entity']->limited_groups,
+));
+echo '</div>';