aboutsummaryrefslogtreecommitdiff
path: root/mod/groups/lib/groups.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/groups/lib/groups.php')
-rw-r--r--mod/groups/lib/groups.php86
1 files changed, 82 insertions, 4 deletions
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
index 498766df0..505cacd01 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');
@@ -106,7 +108,11 @@ function groups_handle_owned_page() {
$page_owner = elgg_get_page_owner_entity();
- $title = elgg_echo('groups:owned');
+ if ($page_owner->guid == elgg_get_logged_in_user_guid()) {
+ $title = elgg_echo('groups:owned');
+ } else {
+ $title = elgg_echo('groups:owned:user', array($page_owner->name));
+ }
elgg_push_breadcrumb($title);
elgg_register_title_button();
@@ -137,7 +143,11 @@ function groups_handle_mine_page() {
$page_owner = elgg_get_page_owner_entity();
- $title = elgg_echo('groups:yours');
+ if ($page_owner->guid == elgg_get_logged_in_user_guid()) {
+ $title = elgg_echo('groups:yours');
+ } else {
+ $title = elgg_echo('groups:user', array($page_owner->name));
+ }
elgg_push_breadcrumb($title);
elgg_register_title_button();
@@ -176,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);
@@ -238,6 +252,8 @@ function groups_handle_profile_page($guid) {
global $autofeed;
$autofeed = true;
+ elgg_push_context('group_profile');
+
$group = get_entity($guid);
if (!$group) {
forward('groups/all');
@@ -481,3 +497,65 @@ function groups_register_profile_buttons($group) {
}
}
}
+
+/**
+ * Prepares variables for the group edit form view.
+ *
+ * @param mixed $group ElggGroup or null. If a group, uses values from the group.
+ * @return array
+ */
+function groups_prepare_form_vars($group = null) {
+ $values = array(
+ 'name' => '',
+ 'membership' => ACCESS_PUBLIC,
+ 'vis' => ACCESS_PUBLIC,
+ 'guid' => null,
+ 'entity' => null
+ );
+
+ // handle customizable profile fields
+ $fields = elgg_get_config('group');
+
+ if ($fields) {
+ foreach ($fields as $name => $type) {
+ $values[$name] = '';
+ }
+ }
+
+ // handle tool options
+ $tools = elgg_get_config('group_tool_options');
+ if ($tools) {
+ foreach ($tools as $group_option) {
+ $option_name = $group_option->name . "_enable";
+ $values[$option_name] = $group_option->default_on ? 'yes' : 'no';
+ }
+ }
+
+ // get current group settings
+ if ($group) {
+ foreach (array_keys($values) as $field) {
+ if (isset($group->$field)) {
+ $values[$field] = $group->$field;
+ }
+ }
+
+ if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) {
+ // group only access - this is done to handle access not created when group is created
+ $values['vis'] = ACCESS_PRIVATE;
+ }
+
+ $values['entity'] = $group;
+ }
+
+ // get any sticky form settings
+ if (elgg_is_sticky_form('groups')) {
+ $sticky_values = elgg_get_sticky_values('groups');
+ foreach ($sticky_values as $key => $value) {
+ $values[$key] = $value;
+ }
+ }
+
+ elgg_clear_sticky_form('groups');
+
+ return $values;
+}