]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Registering new plugin hooks to extend the owner block profile menu.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 21 May 2010 21:53:49 +0000 (21:53 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 21 May 2010 21:53:49 +0000 (21:53 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6130 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/start.php
mod/bookmarks/start.php
mod/file/start.php
views/default/page_elements/owner_block.php

index 20f51937ffff903f3b0dc2e3e91cb16a2540257c..9829f708cb2214ba030af660b74f55c5ec886de9 100644 (file)
@@ -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');
index 205069197f77651b53d591bb66514e7edfa7a93b..ef8a4e01199076162f63493de9152975877ed79d 100644 (file)
@@ -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');
index a257a90acda73ad787ce59f955a75a5646f38665..b8a26fab59e5c9d426cbcc3c606539f67e0a8347 100644 (file)
                                    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}",
-                       ));
-               }
        }
 
        /**
index 311d277670d27d239018abcb6d47be5af717af65..7ddc7e55abeda351e9cf7b3ddc31722be38404f2 100644 (file)
@@ -45,7 +45,19 @@ if(is_plugin_enabled('profile')) {
                
                $location = elgg_view('output/tags', array('value' => $owner->location));
                $display .= "<p class=\"profile_info location\">$location</p>";
-
+               
+               // Trigger owner block menu
+               $params = array('owner' => $owner);
+               $links = trigger_plugin_hook('profile_menu', 'profile', $params, array());
+               if (is_array($links) && !empty($links)) {
+                       $display .= '<div><ul>';
+                       foreach ($links as $link) {
+                               $display .= "<li><a href=\"{$link['href']}\">{$link['text']}</a></li>";
+                       }
+                       $display .= '</ul></div>';
+               }
+               
+               // Allow plugins to extend the owner block contents
                $display .= elgg_view('owner_block/profile_extend');
                
                // close owner_block_content