Permalink
Browse files

fix(menus): make sure entity passed to user hover menu hook is a user

Accidentally passing an entity that is not an ElggUser was resulting in WSOD.
  • Loading branch information...
hypeJunction committed Nov 13, 2015
1 parent d408ae3 commit f5bbcc652078a317479c8e845a8f4951f37d5435
Showing with 18 additions and 12 deletions.
  1. +18 −12 engine/lib/users.php
View
@@ -460,21 +460,27 @@ function user_avatar_hook($hook, $entity_type, $returnvalue, $params) {
* @access private
*/
function elgg_user_hover_menu($hook, $type, $return, $params) {
$user = $params['entity'];
$user = elgg_extract('entity', $params);
/* @var \ElggUser $user */
if (elgg_is_logged_in()) {
if (elgg_get_logged_in_user_guid() == $user->guid) {
$url = "profile/$user->username/edit";
$item = new \ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('action');
$return[] = $item;
if (!$user instanceof \ElggUser) {
return;
}
$url = "avatar/edit/$user->username";
$item = new \ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url);
$item->setSection('action');
$return[] = $item;
}
if (!elgg_is_logged_in()) {
return;
}
if (elgg_get_logged_in_user_guid() == $user->guid) {
$url = "profile/$user->username/edit";
$item = new \ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url);
$item->setSection('action');
$return[] = $item;
$url = "avatar/edit/$user->username";
$item = new \ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url);
$item->setSection('action');
$return[] = $item;
}
// prevent admins from banning or deleting themselves

0 comments on commit f5bbcc6

Please sign in to comment.