diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-27 02:14:56 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-12-27 02:14:56 +0000 |
commit | 543e50d2aabfbd3c116cbb670018c66fae535955 (patch) | |
tree | d84b51988a755c03f8794e3c11cf38b78015ea65 /engine/lib/users.php | |
parent | 07a1585f3eee1211aeaf55ea436135f637520102 (diff) | |
download | elgg-543e50d2aabfbd3c116cbb670018c66fae535955.tar.gz elgg-543e50d2aabfbd3c116cbb670018c66fae535955.tar.bz2 |
moved most of the code for the user hover menu into the new menu system
git-svn-id: http://code.elgg.org/elgg/trunk@7723 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r-- | engine/lib/users.php | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php index c9ac6603e..353575307 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -382,7 +382,7 @@ function user_remove_friend($user_guid, $friend_guid) { * @return bool */ function user_is_friend($user_guid, $friend_guid) { - return check_entity_relationship($user_guid, "friend", $friend_guid); + return check_entity_relationship($user_guid, "friend", $friend_guid) !== false; } /** @@ -1476,6 +1476,73 @@ function user_avatar_hook($hook, $entity_type, $returnvalue, $params){ } /** + * Setup the default user hover menu + */ +function elgg_user_hover_menu($hook, $type, $return, $params) { + $user = $params['entity']; + + if (isloggedin()) { + if (get_loggedin_userid() != $user->guid) { + if ($user->isFriend()) { + $url = "action/friends/remove?friend={$user->guid}"; + $text = elgg_echo('friend:remove'); + } else { + $url = "action/friends/add?friend={$user->guid}"; + $text = elgg_echo('friend:add'); + } + $url = elgg_add_action_tokens_to_url($url); + $item = new ElggMenuItem('addfriend', $text, $url); + $item->setSection('action'); + elgg_register_menu_item('user_hover', $item); + } else { + $url = "pg/profile/$user->username/edit"; + $item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url); + $item->setSection('action'); + elgg_register_menu_item('user_hover', $item); + + $url = "pg/avatar/edit/$user->username"; + $item = new ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url); + $item->setSection('action'); + elgg_register_menu_item('user_hover', $item); + } + } + + // prevent admins from banning or deleting themselves + if (get_loggedin_userid() == $user->guid) { + return; + } + + if (isadminloggedin()) { + $actions = array(); + if (!$user->isBanned()) { + $actions[] = 'ban'; + } else { + $actions[] = 'unban'; + } + $actions[] = 'delete'; + $actions[] = 'resetpassword'; + if (!$user->isAdmin()) { + $actions[] = 'makeadmin'; + } else { + $actions[] = 'removeadmin'; + } + + foreach ($actions as $action) { + $url = "action/admin/user/$action?guid={$user->guid}"; + $url = elgg_add_action_tokens_to_url($url); + $item = new ElggMenuItem($action, elgg_echo($action), $url); + $item->setSection('admin'); + elgg_register_menu_item('user_hover', $item); + } + + $url = "pg/profile/$user->username/edit"; + $item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url); + $item->setSection('admin'); + elgg_register_menu_item('user_hover', $item); + } +} + +/** * Setup the user admin menu */ function elgg_user_admin_menu($hook, $type, $return, $params) { @@ -1682,6 +1749,7 @@ function users_init() { elgg_register_menu_item('page', $params); } + elgg_register_plugin_hook_handler('register', 'menu:user_hover', 'elgg_user_hover_menu'); elgg_register_plugin_hook_handler('register', 'menu:user_admin', 'elgg_user_admin_menu'); elgg_register_action("register", '', 'public'); |