aboutsummaryrefslogtreecommitdiff
path: root/mod/groups
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-06-27 03:12:42 -0700
committerCash Costello <cash.costello@gmail.com>2011-06-27 03:12:42 -0700
commite82534d0bceb80f7a9e7ba8f00748ee1eb32b214 (patch)
treeae8e98a12caa77f78dbfdbc9c492ee808c411c1c /mod/groups
parent33f5c59d5318bc1e9a607215a31e48c6f7ab5b29 (diff)
parentfe1e3b3923659a4bea73e1596e0ba946f473635c (diff)
downloadelgg-e82534d0bceb80f7a9e7ba8f00748ee1eb32b214.tar.gz
elgg-e82534d0bceb80f7a9e7ba8f00748ee1eb32b214.tar.bz2
Merge pull request #52 from cash/banishing-auto-button
Fixes #3616 Banishing auto 'add' button
Diffstat (limited to 'mod/groups')
-rw-r--r--mod/groups/lib/discussion.php9
-rw-r--r--mod/groups/lib/groups.php64
-rw-r--r--mod/groups/views/default/groups/profile/buttons.php57
3 files changed, 58 insertions, 72 deletions
diff --git a/mod/groups/lib/discussion.php b/mod/groups/lib/discussion.php
index 342115c81..52df7e18d 100644
--- a/mod/groups/lib/discussion.php
+++ b/mod/groups/lib/discussion.php
@@ -23,7 +23,6 @@ function discussion_handle_all_page() {
'content' => $content,
'title' => elgg_echo('discussion:latest'),
'filter' => '',
- 'buttons' => '',
);
$body = elgg_view_layout('content', $params);
@@ -46,6 +45,8 @@ function discussion_handle_list_page($guid) {
}
elgg_push_breadcrumb($group->name);
+ elgg_register_add_button();
+
group_gatekeeper();
$title = elgg_echo('item:object:groupforumtopic');
@@ -67,10 +68,6 @@ function discussion_handle_list_page($guid) {
'filter' => '',
);
- if (!$group->canWriteToContainer()) {
- $params['buttons'] = '';
- }
-
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
@@ -131,7 +128,6 @@ function discussion_handle_edit_page($type, $guid) {
'content' => $content,
'title' => $title,
'filter' => '',
- 'buttons' => '',
);
$body = elgg_view_layout('content', $params);
@@ -190,7 +186,6 @@ function discussion_handle_view_page($guid) {
'content' => $content,
'title' => $topic->title,
'filter' => '',
- 'buttons' => '',
);
$body = elgg_view_layout('content', $params);
diff --git a/mod/groups/lib/groups.php b/mod/groups/lib/groups.php
index c3986e53c..c47ad0ab2 100644
--- a/mod/groups/lib/groups.php
+++ b/mod/groups/lib/groups.php
@@ -12,6 +12,8 @@ function groups_handle_all_page() {
elgg_pop_breadcrumb();
elgg_push_breadcrumb(elgg_echo('groups'));
+ elgg_register_add_button();
+
$selected_tab = get_input('filter', 'newest');
switch ($selected_tab) {
@@ -81,7 +83,6 @@ function groups_search_page() {
'content' => $content,
'sidebar' => $sidebar,
'filter' => false,
- 'buttons' => false,
'title' => $title,
);
$body = elgg_view_layout('content', $params);
@@ -99,6 +100,8 @@ function groups_handle_owned_page() {
$title = elgg_echo('groups:owned');
elgg_push_breadcrumb($title);
+ elgg_register_add_button();
+
$content = elgg_list_entities(array(
'type' => 'group',
'owner_guid' => elgg_get_page_owner_guid(),
@@ -125,6 +128,8 @@ function groups_handle_mine_page() {
$title = elgg_echo('groups:yours');
elgg_push_breadcrumb($title);
+ elgg_register_add_button();
+
$content = elgg_list_entities_from_relationship_count(array(
'type' => 'group',
'relationship' => 'member',
@@ -175,7 +180,6 @@ function groups_handle_edit_page($page, $guid = 0) {
'content' => $content,
'title' => $title,
'filter' => '',
- 'buttons' => '',
);
$body = elgg_view_layout('content', $params);
@@ -201,7 +205,6 @@ function groups_handle_invitations_page() {
'content' => $content,
'title' => $title,
'filter' => '',
- 'buttons' => '',
);
$body = elgg_view_layout('content', $params);
@@ -234,11 +237,12 @@ function groups_handle_profile_page($guid) {
$sidebar = '';
}
+ groups_register_profile_buttons($group);
+
$params = array(
'content' => $content,
'sidebar' => $sidebar,
'title' => $group->name,
- 'buttons' => elgg_view('groups/profile/buttons', array('entity' => $group)),
'filter' => '',
);
$body = elgg_view_layout('content', $params);
@@ -280,7 +284,6 @@ function groups_handle_activity_page($guid) {
$params = array(
'content' => $content,
'title' => $title,
- 'buttons' => '',
'filter' => '',
);
$body = elgg_view_layout('content', $params);
@@ -320,7 +323,6 @@ function groups_handle_members_page($guid) {
$params = array(
'content' => $content,
'title' => $title,
- 'buttons' => '',
'filter' => '',
);
$body = elgg_view_layout('content', $params);
@@ -359,7 +361,6 @@ function groups_handle_invite_page($guid) {
$params = array(
'content' => $content,
'title' => $title,
- 'buttons' => '',
'filter' => '',
);
$body = elgg_view_layout('content', $params);
@@ -403,10 +404,57 @@ function groups_handle_requests_page($guid) {
$params = array(
'content' => $content,
'title' => $title,
- 'buttons' => '',
'filter' => '',
);
$body = elgg_view_layout('content', $params);
echo elgg_view_page($title, $body);
}
+
+/**
+ * Registers the buttons for title area of the group profile page
+ *
+ * @param ElggGroup $group
+ */
+function groups_register_profile_buttons($group) {
+
+ $actions = array();
+
+ // group owners
+ if ($group->canEdit()) {
+ // edit and invite
+ $url = elgg_get_site_url() . "groups/edit/{$group->getGUID()}";
+ $actions[$url] = elgg_echo('groups:edit');
+ $url = elgg_get_site_url() . "groups/invite/{$group->getGUID()}";
+ $actions[$url] = elgg_echo('groups:invite');
+ }
+
+ // group members
+ if ($group->isMember($user)) {
+ // leave
+ $url = elgg_get_site_url() . "action/groups/leave?group_guid={$group->getGUID()}";
+ $url = elgg_add_action_tokens_to_url($url);
+ $actions[$url] = 'groups:leave';
+ } else {
+ // join - admins can always join.
+ $url = elgg_get_site_url() . "action/groups/join?group_guid={$group->getGUID()}";
+ $url = elgg_add_action_tokens_to_url($url);
+ if ($group->isPublicMembership() || $group->canEdit()) {
+ $actions[$url] = 'groups:join';
+ } else {
+ // request membership
+ $actions[$url] = 'groups:joinrequest';
+ }
+ }
+
+ if ($actions) {
+ foreach ($actions as $url => $text) {
+ elgg_register_menu_item('title', array(
+ 'name' => $text,
+ 'href' => $url,
+ 'text' => elgg_echo($text),
+ 'link_class' => 'elgg-button elgg-button-action',
+ ));
+ }
+ }
+}
diff --git a/mod/groups/views/default/groups/profile/buttons.php b/mod/groups/views/default/groups/profile/buttons.php
deleted file mode 100644
index 55e99f59c..000000000
--- a/mod/groups/views/default/groups/profile/buttons.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
- * Content header action buttons
- *
- * @uses $vars['entity']
- *
- * @todo This should be done by registering menu items with the page actions menu
- */
-
-if (!elgg_is_logged_in()) {
- return true;
-}
-
-
-$actions = array();
-
-// group owners
-if ($vars['entity']->canEdit()) {
- // edit and invite
- $url = elgg_get_site_url() . "groups/edit/{$vars['entity']->getGUID()}";
- $actions[$url] = elgg_echo('groups:edit');
- $url = elgg_get_site_url() . "groups/invite/{$vars['entity']->getGUID()}";
- $actions[$url] = elgg_echo('groups:invite');
-}
-
-// group members
-if ($vars['entity']->isMember($user)) {
- // leave
- $url = elgg_get_site_url() . "action/groups/leave?group_guid={$vars['entity']->getGUID()}";
- $url = elgg_add_action_tokens_to_url($url);
- $actions[$url] = elgg_echo('groups:leave');
-} else {
- // join - admins can always join.
- $url = elgg_get_site_url() . "action/groups/join?group_guid={$vars['entity']->getGUID()}";
- $url = elgg_add_action_tokens_to_url($url);
- if ($vars['entity']->isPublicMembership() || $vars['entity']->canEdit()) {
- $actions[$url] = elgg_echo('groups:join');
- } else {
- // request membership
- $actions[$url] = elgg_echo('groups:joinrequest');
- }
-}
-
-// display action buttons
-if ($actions) {
- echo '<ul class="elgg-menu elgg-menu-title elgg-menu-hz">';
- foreach ($actions as $url => $action) {
- echo '<li>';
- echo elgg_view('output/url', array(
- 'text' => $action,
- 'href' => $url,
- 'class' => 'elgg-button elgg-button-action',
- ));
- echo '</li>';
- }
- echo '</ul>';
-}