aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/admin.php17
-rw-r--r--engine/lib/elgglib.php57
-rw-r--r--engine/lib/users.php2
3 files changed, 62 insertions, 14 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index c8ca90a2f..8d9ffeba0 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -48,17 +48,12 @@ function admin_init() {
register_action('admin/user/resetpassword', false, "", true);
register_action('admin/user/makeadmin', false, "", true);
register_action('admin/user/removeadmin', false, "", true);
+ register_action('admin/site/update_basic', false, "", true);
+ register_action('admin/menu_items', false, "", true);
- // Register some actions
- register_action('admin/site/update_basic', false, "", true); // Register basic site admin action
// Page handler
- register_page_handler('admin','admin_settings_page_handler');
-
-// if (isadminloggedin()) {
-// global $is_admin;
-// $is_admin = true;
-// }
+ register_page_handler('admin', 'admin_settings_page_handler');
}
/**
@@ -74,6 +69,7 @@ function admin_pagesetup() {
add_submenu_item(elgg_echo('admin:site'), $CONFIG->wwwroot . 'pg/admin/site/');
add_submenu_item(elgg_echo('admin:user'), $CONFIG->wwwroot . 'pg/admin/user/');
add_submenu_item(elgg_echo('admin:plugins'), $CONFIG->wwwroot . 'pg/admin/plugins/');
+ add_submenu_item(elgg_echo('admin:menu_items'), $CONFIG->wwwroot . 'pg/admin/menu_items/');
}
}
@@ -94,6 +90,7 @@ function admin_settings_page_handler($page) {
case 'statistics' : $path = $CONFIG->path . "admin/statistics.php"; break;
case 'plugins' : $path = $CONFIG->path . "admin/plugins.php"; break;
case 'site' : $path = $CONFIG->path . "admin/site.php"; break;
+ case 'menu_items' : $path = $CONFIG->path . 'admin/menu_items.php'; break;
}
}
@@ -136,8 +133,8 @@ function send_admin_message($subject, $message) {
*/
function list_admin_messages($limit = 10) {
return elgg_list_entities(array(
- 'type' => 'object',
- 'subtype' => 'admin_message',
+ 'type' => 'object',
+ 'subtype' => 'admin_message',
'limit' => $limit
));
}
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 95292a2d7..5a7fca837 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1453,11 +1453,12 @@ function get_register($register_name) {
* @param string $menu_name The name of the menu item
* @param string $menu_url The URL of the page
* @param array $menu_children Optionally, an array of submenu items (not currently used)
- * @param string $context (not used and will likely be deprecated)
+ * @param string $context
* @return true|false Depending on success
*/
function add_menu($menu_name, $menu_url, $menu_children = array(), $context = "") {
global $CONFIG;
+
if (!isset($CONFIG->menucontexts)) {
$CONFIG->menucontexts = array();
}
@@ -1466,8 +1467,12 @@ function add_menu($menu_name, $menu_url, $menu_children = array(), $context = ""
$context = get_plugin_name();
}
+ $value = new stdClass();
+ $value->url = $menu_url;
+ $value->context = $context;
+
$CONFIG->menucontexts[] = $context;
- return add_to_register('menu', $menu_name, $menu_url, $menu_children);
+ return add_to_register('menu', $menu_name, $value, $menu_children);
}
/**
@@ -2885,6 +2890,50 @@ function elgg_api_test($hook, $type, $value, $params) {
}
/**
+ * Sorts out the topbar menu and the featured URLs
+ * and saves them to $CONFIG->menu_items = array ('featured_urls' and 'toolbar')
+ *
+ */
+function ui_page_setup() {
+ global $CONFIG;
+
+ $hide_toolbar_dupes = get_config('menu_items_hide_toolbar_entries') == 'yes' ? TRUE : FALSE;
+ $menu_items = get_register('menu');
+ $featured_urls_info = get_config('menu_items_featured_urls');
+ $toolbar = array();
+ $featured_urls = array();
+ $featured_urls_sanitised = array();
+
+ // easier to compare with in_array() than embedded foreach()es
+ $valid_urls = array();
+ foreach ($menu_items as $info) {
+ $valid_urls[] = $info->value->url;
+ }
+
+ // make sure the url is a valid link.
+ // this prevents disabled plugins leaving behind
+ // valid links when no using a pagehandler.
+ foreach ($featured_urls_info as $info) {
+ if (in_array($info->value->url, $valid_urls)) {
+ $featured_urls[] = $info->value->url;
+ $featured_urls_sanitised[] = $info;
+ }
+ }
+
+ // add toolbar entries if not hiding dupes.
+ foreach ($menu_items as $name => $info) {
+ if (!($hide_toolbar_dupes && in_array($info->value->url, $featured_urls))) {
+ $toolbar[] = $info;
+ }
+ }
+
+ $CONFIG->menu_items = array(
+ 'featured_urls' => $featured_urls_sanitised,
+ 'toolbar' => $toolbar
+ );
+}
+
+/**
* Some useful constant definitions
*/
define('ACCESS_DEFAULT', -1);
@@ -2898,4 +2947,6 @@ define('ELGG_ENTITIES_NO_VALUE', 0);
register_elgg_event_handler('init', 'system', 'elgg_init');
register_elgg_event_handler('boot', 'system', 'elgg_boot', 1000);
-register_plugin_hook('unit_test', 'system', 'elgg_api_test'); \ No newline at end of file
+register_plugin_hook('unit_test', 'system', 'elgg_api_test');
+
+register_elgg_event_handler('pagesetup', 'system', 'ui_page_setup', 1000); \ No newline at end of file
diff --git a/engine/lib/users.php b/engine/lib/users.php
index a0bdeabc5..46ccd8dc3 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1628,7 +1628,7 @@ function users_init() {
// add Friends to tools menu - if profile mod is running
if ( isloggedin() && is_plugin_enabled('profile') ) {
$user = get_loggedin_user();
- add_menu(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . $user->username);
+ add_menu(elgg_echo('friends'), $CONFIG->wwwroot . "pg/friends/" . $user->username, array(), 'core:friends');
}
register_page_handler('friends', 'friends_page_handler');