diff options
author | cash <cash.costello@gmail.com> | 2011-06-26 15:56:35 -0400 |
---|---|---|
committer | cash <cash.costello@gmail.com> | 2011-06-26 15:56:35 -0400 |
commit | fe1e3b3923659a4bea73e1596e0ba946f473635c (patch) | |
tree | ae8e98a12caa77f78dbfdbc9c492ee808c411c1c /mod/groups | |
parent | 3c34ddf59804767e6a7deea3e3ee6c81d4a09601 (diff) | |
download | elgg-fe1e3b3923659a4bea73e1596e0ba946f473635c.tar.gz elgg-fe1e3b3923659a4bea73e1596e0ba946f473635c.tar.bz2 |
this should update all the core pages and plugins using 'buttons'
Diffstat (limited to 'mod/groups')
-rw-r--r-- | mod/groups/lib/discussion.php | 9 | ||||
-rw-r--r-- | mod/groups/lib/groups.php | 64 | ||||
-rw-r--r-- | mod/groups/views/default/groups/profile/buttons.php | 57 |
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>'; -} |