From 33d589650db886fa580aa5bd47672a71bb4fc4c0 Mon Sep 17 00:00:00 2001 From: nickw Date: Fri, 21 May 2010 21:53:49 +0000 Subject: Registering new plugin hooks to extend the owner block profile menu. git-svn-id: http://code.elgg.org/elgg/trunk@6130 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/blog/start.php | 21 ++++++++++++++------- mod/bookmarks/start.php | 21 ++++++++++++++------- mod/file/start.php | 7 ------- views/default/page_elements/owner_block.php | 14 +++++++++++++- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/mod/blog/start.php b/mod/blog/start.php index 20f51937f..9829f708c 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -61,6 +61,9 @@ function blog_init() { // ecml register_plugin_hook('get_views', 'ecml', 'blog_ecml_views_hook'); + + // Register profile menu hook + register_plugin_hook('profile_menu', 'profile', 'blog_profile_menu'); } /** @@ -193,13 +196,6 @@ function blog_page_setup() { add_submenu_item(elgg_echo('blog:groups:group_blogs'), $url); } } - - if ($page_owner instanceof ElggEntity) { - elgg_add_submenu_item(array( - 'text' => elgg_echo('blog'), - 'href' => "{$CONFIG->url}pg/blog/{$page_owner->username}/read", - )); - } } /** @@ -216,4 +212,15 @@ function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) { return $return_value; } +function blog_profile_menu($hook, $entity_type, $return_value, $params) { + global $CONFIG; + + $return_value[] = array( + 'text' => elgg_echo('blog'), + 'href' => "{$CONFIG->url}pg/blog/{$params['owner']->username}/read", + ); + + return $return_value; +} + register_elgg_event_handler('init', 'system', 'blog_init'); diff --git a/mod/bookmarks/start.php b/mod/bookmarks/start.php index 205069197..ef8a4e011 100644 --- a/mod/bookmarks/start.php +++ b/mod/bookmarks/start.php @@ -45,6 +45,9 @@ function bookmarks_init() { // Extend Groups profile page elgg_extend_view('groups/tool_latest','bookmarks/group_bookmarks'); + + // Register profile menu hook + register_plugin_hook('profile_menu', 'profile', 'bookmarks_profile_menu'); } /** @@ -63,13 +66,6 @@ function bookmarks_pagesetup() { add_submenu_item(sprintf(elgg_echo("bookmarks:group"),$page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . '/items'); } } - - if ($page_owner instanceof ElggEntity) { - elgg_add_submenu_item(array( - 'text' => elgg_echo('bookmarks'), - 'href' => "{$CONFIG->url}pg/bookmarks/{$page_owner->username}", - )); - } } } @@ -301,6 +297,17 @@ function create_wire_url_code(){ return $code; } +function bookmarks_profile_menu($hook, $entity_type, $return_value, $params) { + global $CONFIG; + + $return_value[] = array( + 'text' => elgg_echo('bookmarks'), + 'href' => "{$CONFIG->url}pg/bookmarks/{$params['owner']->username}", + ); + + return $return_value; +} + // Make sure the initialisation function is called on initialisation register_elgg_event_handler('init','system','bookmarks_init'); register_elgg_event_handler('pagesetup','system','bookmarks_pagesetup'); diff --git a/mod/file/start.php b/mod/file/start.php index a257a90ac..b8a26fab5 100644 --- a/mod/file/start.php +++ b/mod/file/start.php @@ -79,13 +79,6 @@ add_submenu_item(sprintf(elgg_echo("file:group"),$page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username); } } - - if ($page_owner instanceof ElggEntity) { - elgg_add_submenu_item(array( - 'text' => elgg_echo('file'), - 'href' => "{$CONFIG->url}pg/file/{$page_owner->username}", - )); - } } /** diff --git a/views/default/page_elements/owner_block.php b/views/default/page_elements/owner_block.php index 311d27767..7ddc7e55a 100644 --- a/views/default/page_elements/owner_block.php +++ b/views/default/page_elements/owner_block.php @@ -45,7 +45,19 @@ if(is_plugin_enabled('profile')) { $location = elgg_view('output/tags', array('value' => $owner->location)); $display .= "

$location

"; - + + // Trigger owner block menu + $params = array('owner' => $owner); + $links = trigger_plugin_hook('profile_menu', 'profile', $params, array()); + if (is_array($links) && !empty($links)) { + $display .= '
'; + } + + // Allow plugins to extend the owner block contents $display .= elgg_view('owner_block/profile_extend'); // close owner_block_content -- cgit v1.2.3