aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/users.php37
-rw-r--r--views/default/user/default.php31
2 files changed, 53 insertions, 15 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index c16ae1176..43b6980b2 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1309,6 +1309,41 @@ function elgg_user_hover_menu($hook, $type, $return, $params) {
return $return;
}
+function elgg_users_setup_entity_menu($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ if (!elgg_instanceof($entity, 'user')) {
+ return $return;
+ }
+
+ if ($entity->isBanned()) {
+ $banned = elgg_echo('banned');
+ $options = array(
+ 'name' => 'banned',
+ 'text' => "<span>$banned</span>",
+ 'href' => false,
+ 'priority' => 0,
+ );
+ $return = array(ElggMenuItem::factory($options));
+ } else {
+ $return = array();
+ if (isset($entity->location)) {
+ $options = array(
+ 'name' => 'location',
+ 'text' => "<span>$entity->location</span>",
+ 'href' => false,
+ 'priority' => 150,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+ }
+
+ return $return;
+}
+
/**
* This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
* add and delete fields.
@@ -1529,6 +1564,8 @@ function users_init() {
// Register the user type
elgg_register_entity_type('user', '');
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_users_setup_entity_menu', 501);
+
elgg_register_event_handler('create', 'user', 'user_create_hook_add_site_relationship');
}
diff --git a/views/default/user/default.php b/views/default/user/default.php
index 71eb273f0..501949306 100644
--- a/views/default/user/default.php
+++ b/views/default/user/default.php
@@ -6,25 +6,26 @@
* @uses $vars['size'] Size of the icon
*/
-$user = $vars['entity'];
+$entity = $vars['entity'];
$size = elgg_extract('size', $vars, 'tiny');
-$icon = elgg_view_entity_icon($user, $size);
+$icon = elgg_view_entity_icon($entity, $size);
// Simple XFN
$rel = '';
-if (elgg_get_logged_in_user_guid() == $user->guid) {
+if (elgg_get_logged_in_user_guid() == $entity->guid) {
$rel = 'rel="me"';
-} elseif (check_entity_relationship(elgg_get_logged_in_user_guid(), 'friend', $user->guid)) {
+} elseif (check_entity_relationship(elgg_get_logged_in_user_guid(), 'friend', $entity->guid)) {
$rel = 'rel="friend"';
}
-$title = "<a href=\"" . $user->getUrl() . "\" $rel>" . $user->name . "</a>";
+$title = "<a href=\"" . $entity->getUrl() . "\" $rel>" . $entity->name . "</a>";
-
-$metadata = "<ul class=\"elgg-menu elgg-menu-metadata\"><li>$user->location</li>";
-$metadata .= elgg_view("entity/metadata", array('entity' => $user));
-$metadata .= "</ul>";
+$metadata = elgg_view_menu('entity', array(
+ 'entity' => $entity,
+ 'sort_by' => 'priority',
+ 'class' => 'elgg-menu-hz',
+));
if (elgg_in_context('owner_block') || elgg_in_context('widgets')) {
$metadata = '';
@@ -33,20 +34,20 @@ if (elgg_in_context('owner_block') || elgg_in_context('widgets')) {
if (elgg_get_context() == 'gallery') {
echo $icon;
} else {
- if ($user->isBanned()) {
+ if ($entity->isBanned()) {
$banned = elgg_echo('banned');
$params = array(
- 'entity' => $user,
+ 'entity' => $entity,
'title' => $title,
- 'metadata' => '<ul class="elgg-menu elgg-menu-metadata"><li>$banned</li></ul>',
+ 'metadata' => $metadata,
);
} else {
$params = array(
- 'entity' => $user,
+ 'entity' => $entity,
'title' => $title,
'metadata' => $metadata,
- 'subtitle' => $user->briefdescription,
- 'content' => elgg_view('user/status', array('entity' => $user)),
+ 'subtitle' => $entity->briefdescription,
+ 'content' => elgg_view('user/status', array('entity' => $entity)),
);
}