aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-19 03:17:51 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-19 03:17:51 +0000
commit7303fb1a0960e6bb3b6e11f51372d1ed689e3b84 (patch)
tree76e202bff895a45c5ed40dcd0020b0e49b6d8125
parent72c83e4904a13c0e07d0d328ccbd201d16a617cc (diff)
downloadelgg-7303fb1a0960e6bb3b6e11f51372d1ed689e3b84.tar.gz
elgg-7303fb1a0960e6bb3b6e11f51372d1ed689e3b84.tar.bz2
added a user admin menu that plugins can add menu items to
git-svn-id: http://code.elgg.org/elgg/trunk@7678 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/users.php30
-rw-r--r--mod/logbrowser/start.php19
-rw-r--r--mod/logbrowser/views/default/logbrowser/adminlinks.php10
-rwxr-xr-xmod/profile/views/default/profile/admin_menu.php42
-rw-r--r--mod/profile/views/default/profile/hoverover.php16
-rw-r--r--mod/profile/views/default/profile/icon.php111
-rwxr-xr-xmod/profile/views/default/profile/ownerblock.php15
-rwxr-xr-xmod/tabbed_profile/views/default/profile/admin_menu.php42
-rw-r--r--mod/tabbed_profile/views/default/profile/hoverover.php16
-rwxr-xr-xmod/tabbed_profile/views/default/profile/ownerblock.php15
-rw-r--r--views/default/navigation/menu/user_admin.php30
-rw-r--r--views/default/profile/icon.php (renamed from mod/tabbed_profile/views/default/profile/icon.php)17
12 files changed, 104 insertions, 259 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 0482fd034..d95f32475 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -1478,6 +1478,34 @@ function user_avatar_hook($hook, $entity_type, $returnvalue, $params){
}
/**
+ * Setup the user admin menu
+ */
+function elgg_user_admin_menu($hook, $type, $return, $params) {
+ $user = $params['user'];
+
+ $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);
+ elgg_register_menu_item('user_admin', $item);
+ }
+}
+
+/**
* This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit
* add and delete fields.
*
@@ -1656,6 +1684,8 @@ function users_init() {
elgg_register_menu_item('page', $params);
}
+ elgg_register_plugin_hook_handler('register', 'menu:user_admin', 'elgg_user_admin_menu');
+
elgg_register_action("register", '', 'public');
elgg_register_action("useradd", '', 'public');
elgg_register_action("friends/add");
diff --git a/mod/logbrowser/start.php b/mod/logbrowser/start.php
index 4236ce64e..1eda00732 100644
--- a/mod/logbrowser/start.php
+++ b/mod/logbrowser/start.php
@@ -12,13 +12,20 @@ elgg_register_event_handler('init', 'system', 'logbrowser_init');
*/
function logbrowser_init() {
- // Extend CSS
elgg_extend_view('css/admin', 'logbrowser/css');
-
- // Extend context menu with admin logbrowser link
- if (isadminloggedin()) {
- elgg_extend_view('profile/menu/adminlinks', 'logbrowser/adminlinks', 10000);
- }
+
+ elgg_register_plugin_hook_handler('register', 'menu:user_admin', 'logbrowser_user_admin_menu');
elgg_add_admin_submenu_item('logbrowser', elgg_echo('logbrowser'), 'overview');
}
+
+/**
+ * Add to the user admin menu
+ */
+function logbrowser_user_admin_menu($hook, $type, $return, $params) {
+ $user = $params['user'];
+
+ $url = "pg/admin/overview/logbrowser/?user_guid={$user->guid}";
+ $item = new ElggMenuItem('logbrowser', elgg_echo('logbrowser:explore'), $url);
+ elgg_register_menu_item('user_admin', $item);
+} \ No newline at end of file
diff --git a/mod/logbrowser/views/default/logbrowser/adminlinks.php b/mod/logbrowser/views/default/logbrowser/adminlinks.php
deleted file mode 100644
index 03e42fbb8..000000000
--- a/mod/logbrowser/views/default/logbrowser/adminlinks.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-/**
- * The dropdown link for exploring a user's log
- *
- * @package ElggLogBrowser
- */
-?>
-<a href="<?php echo elgg_get_site_url(); ?>pg/admin/overview/logbrowser/?user_guid=<?php echo $vars['entity']->guid; ?>">
- <?php echo elgg_echo("logbrowser:explore"); ?>
-</a> \ No newline at end of file
diff --git a/mod/profile/views/default/profile/admin_menu.php b/mod/profile/views/default/profile/admin_menu.php
deleted file mode 100755
index 99ed3a4f5..000000000
--- a/mod/profile/views/default/profile/admin_menu.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * This is the admin menu that appears on a user's profile page
- **/
-global $CONFIG;
-
-if (isadminloggedin()){
- if (get_loggedin_userid()!=elgg_get_page_owner_guid()){
- $user = get_user(elgg_get_page_owner_guid());
- $url = elgg_get_site_url();
- $ts = time();
- $token = generate_action_token($ts);
-
-?>
-<div class="owner_block_links clearfix">
-<ul class="admin_menu">
-<li><a href="#" onclick="elgg_slide_toggle(this,'.owner_block_links','.admin_menu_options');">Admin options&hellip;</a>
-
- <ul class="admin_menu_options">
- <li><a href="<?php echo $url; ?>pg/settings/user/<?php echo $user->username; ?>/"><?php echo elgg_echo('profile:editdetails'); ?></a></li>
- <?php
- if (!$user->isBanned()) {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("ban"), 'href' => "action/admin/user/ban?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- } else {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("unban"), 'href' => "action/admin/user/unban?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- }
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("delete"), 'href' => "action/admin/user/delete?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("resetpassword"), 'href' => "action/admin/user/resetpassword?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- if (!$vars['entity']->admin) {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("makeadmin"), 'href' => "action/admin/user/makeadmin?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- } else {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("removeadmin"), 'href' => "action/admin/user/removeadmin?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- }
- ?>
- </ul>
-</li>
-</ul>
-</div>
-<?php
- }
-}
-?>
diff --git a/mod/profile/views/default/profile/hoverover.php b/mod/profile/views/default/profile/hoverover.php
deleted file mode 100644
index 172ef5d3d..000000000
--- a/mod/profile/views/default/profile/hoverover.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Elgg profile icon hover over
- *
- * @package ElggProfile
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-?>
-<li class="user_menu_name">
- <?php echo $vars['entity']->name; ?>
-</li>
-<?php
- echo elgg_view('profile/hoverover/actions', $vars);
- echo elgg_view('profile/hoverover/links', $vars);
-?> \ No newline at end of file
diff --git a/mod/profile/views/default/profile/icon.php b/mod/profile/views/default/profile/icon.php
deleted file mode 100644
index 71b25fe6c..000000000
--- a/mod/profile/views/default/profile/icon.php
+++ /dev/null
@@ -1,111 +0,0 @@
-<?php
-
-/**
- * Elgg profile icon
- *
- * @package ElggProfile
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- * @uses $vars['size'] The size - small, medium or large. If none specified, medium is assumed.
- */
-
-// Get entity
-if (empty($vars['entity'])) {
- $vars['entity'] = get_loggedin_user();
-}
-
-if ($vars['entity'] instanceof ElggUser) {
- $name = htmlentities($vars['entity']->name, ENT_QUOTES, 'UTF-8');
- $username = $vars['entity']->username;
-
- if ($icontime = $vars['entity']->icontime) {
- $icontime = "{$icontime}";
- } else {
- $icontime = "default";
- }
-
- // Get size
- if (!in_array($vars['size'],array('small','medium','large','tiny','master','topbar'))) {
- $vars['size'] = 'medium';
- }
-
- // Get any align and js
- if (!empty($vars['align'])) {
- $align = " align=\"{$vars['align']}\" ";
- } else {
- $align = '';
- }
-
- // Override
- if (isset($vars['override']) && $vars['override'] == true) {
- $override = true;
- } else {
- $override = false;
- }
- // profile avatar drop-down menu
- if (!$override) {
- ?>
- <div class="usericon <?php echo $vars['size']; ?>">
- <div class="avatar_menu_button"><img src="<?php echo elgg_get_site_url(); ?>_graphics/spacer.gif" border="0" width="15" height="15" /></div>
- <div class="sub_menu">
- <h3 class="displayname"><a href="<?php echo $vars['entity']->getURL(); ?>"><?php echo $vars['entity']->name; ?>
- <span class="username"><?php echo "&#64;" . $vars['entity']->username; ?></span></a></h3>
- <?php
- echo "<ul class='sub_menu_list'>";
- if (isloggedin()) {
- // if not looking at your own avatar menu
- if ($vars['entity']->getGUID() != get_loggedin_userid()) {
-
- // Add / Remove friend link
- $friendlinks = elgg_view('profile/menu/friendlinks',$vars);
- if (!empty($friendlinks)) {
- echo "<li class='user_menu_profile'>{$friendlinks}</li>";
- }
- // view for plugins to extend
- echo elgg_view('profile/menu/links',$vars);
- } else {
- // if looking at your own avatar menu - provide a couple of handy links
- ?>
- <li class="user_menu_profile">
- <a class="edit_profile" href="<?php echo elgg_get_site_url()?>pg/profile/<?php echo $vars['entity']->username; ?>/edit/details"><?php echo elgg_echo("profile:edit"); ?></a>
- </li>
- <li class="user_menu_profile">
- <a class="edit_avatar" href="<?php echo elgg_get_site_url()?>pg/profile/<?php echo $vars['entity']->username; ?>/edit/icon"><?php echo elgg_echo("profile:editicon"); ?></a>
- </li>
- <?php
- }
-
- // if Admin is logged in, and not looking at admins own avatar menu
- if (isadminloggedin() && (get_loggedin_userid()!=$vars['entity']->guid) ){
- $adminlinks = elgg_view('profile/menu/adminlinks', $vars);
- if (!empty($adminlinks)) {
- echo "<li class='user_menu_admin'>{$adminlinks}</li>";
- }
- }
-
- }
- echo "</ul>";
- ?>
- </div>
- <?php
- if ((isadminloggedin()) || (!$vars['entity']->isBanned())) {
- ?><a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><?php
- }
-
- }
-
- // Rounded avatar corners - CSS3 method - users avatar as background image so we can clip it with border-radius in supported browsers
- ?>
- <img src="<?php echo elgg_get_site_url(); ?>_graphics/spacer.gif" border="0" <?php echo $align; ?> alt="<?php echo htmlentities($vars['entity']->name, ENT_QUOTES, 'UTF-8'); ?>" title="<?php echo htmlentities($vars['entity']->name, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $vars['js']; ?> style="background: url(<?php echo $vars['entity']->getIcon($vars['size']); ?>) no-repeat;" class="<?php echo $vars['size']; ?>" />
- <?php
- /*
- original avatar method
- <img src="<?php echo elgg_format_url($vars['entity']->getIcon($vars['size'])); ?>" border="0" <?php echo $align; ?> alt="<?php echo htmlentities($vars['entity']->name, ENT_QUOTES, 'UTF-8'); ?>" title="<?php echo htmlentities($vars['entity']->name, ENT_QUOTES, 'UTF-8'); ?>" <?php echo $vars['js']; ?> />
- */
-
- if (!$override) {
- ?>
- </a></div>
- <?php
- }
-} \ No newline at end of file
diff --git a/mod/profile/views/default/profile/ownerblock.php b/mod/profile/views/default/profile/ownerblock.php
index c0b5fd898..684209569 100755
--- a/mod/profile/views/default/profile/ownerblock.php
+++ b/mod/profile/views/default/profile/ownerblock.php
@@ -67,11 +67,16 @@ $email = $user->email;
$phone = $user->phone;
-//if admin display admin links
-if (isadminloggedin()) {
- $admin_links = elgg_view('profile/admin_menu');
-} else {
- $admin_links = '';
+// if admin, display admin links
+$admin_links = '';
+if (isadminloggedin() && get_loggedin_userid() != elgg_get_page_owner_guid()) {
+ $params = array(
+ 'user' => elgg_get_page_owner(),
+ 'toggle' => true,
+ 'sort_by' => 'order',
+ );
+ $admin_links = elgg_view_menu('user_admin', $params);
+ $admin_links = "<div class=\"owner_block_links\">$admin_links</div>";
}
$menu = elgg_view_menu('user_ownerblock', array('user' => elgg_get_page_owner()));
diff --git a/mod/tabbed_profile/views/default/profile/admin_menu.php b/mod/tabbed_profile/views/default/profile/admin_menu.php
deleted file mode 100755
index 99ed3a4f5..000000000
--- a/mod/tabbed_profile/views/default/profile/admin_menu.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * This is the admin menu that appears on a user's profile page
- **/
-global $CONFIG;
-
-if (isadminloggedin()){
- if (get_loggedin_userid()!=elgg_get_page_owner_guid()){
- $user = get_user(elgg_get_page_owner_guid());
- $url = elgg_get_site_url();
- $ts = time();
- $token = generate_action_token($ts);
-
-?>
-<div class="owner_block_links clearfix">
-<ul class="admin_menu">
-<li><a href="#" onclick="elgg_slide_toggle(this,'.owner_block_links','.admin_menu_options');">Admin options&hellip;</a>
-
- <ul class="admin_menu_options">
- <li><a href="<?php echo $url; ?>pg/settings/user/<?php echo $user->username; ?>/"><?php echo elgg_echo('profile:editdetails'); ?></a></li>
- <?php
- if (!$user->isBanned()) {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("ban"), 'href' => "action/admin/user/ban?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- } else {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("unban"), 'href' => "action/admin/user/unban?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- }
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("delete"), 'href' => "action/admin/user/delete?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("resetpassword"), 'href' => "action/admin/user/resetpassword?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- if (!$vars['entity']->admin) {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("makeadmin"), 'href' => "action/admin/user/makeadmin?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- } else {
- echo "<li>".elgg_view('output/confirmlink', array('text' => elgg_echo("removeadmin"), 'href' => "action/admin/user/removeadmin?guid={$user->guid}&__elgg_token=$token&__elgg_ts=$ts")) . "</li>";
- }
- ?>
- </ul>
-</li>
-</ul>
-</div>
-<?php
- }
-}
-?>
diff --git a/mod/tabbed_profile/views/default/profile/hoverover.php b/mod/tabbed_profile/views/default/profile/hoverover.php
deleted file mode 100644
index 172ef5d3d..000000000
--- a/mod/tabbed_profile/views/default/profile/hoverover.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-/**
- * Elgg profile icon hover over
- *
- * @package ElggProfile
- *
- * @uses $vars['entity'] The user entity. If none specified, the current user is assumed.
- */
-?>
-<li class="user_menu_name">
- <?php echo $vars['entity']->name; ?>
-</li>
-<?php
- echo elgg_view('profile/hoverover/actions', $vars);
- echo elgg_view('profile/hoverover/links', $vars);
-?> \ No newline at end of file
diff --git a/mod/tabbed_profile/views/default/profile/ownerblock.php b/mod/tabbed_profile/views/default/profile/ownerblock.php
index 3fb5f509e..85c930678 100755
--- a/mod/tabbed_profile/views/default/profile/ownerblock.php
+++ b/mod/tabbed_profile/views/default/profile/ownerblock.php
@@ -67,11 +67,16 @@ $email = $user->email;
$phone = $user->phone;
-//if admin display admin links
-if (isadminloggedin()) {
- $admin_links = elgg_view('profile/admin_menu');
-} else {
- $admin_links = '';
+// if admin display admin links
+$admin_links = '';
+if (isadminloggedin() && get_loggedin_userid() != elgg_get_page_owner_guid()) {
+ $params = array(
+ 'user' => elgg_get_page_owner(),
+ 'toggle' => true,
+ 'sort_by' => 'order',
+ );
+ $admin_links = elgg_view_menu('user_admin', $params);
+ $admin_links = "<div class=\"owner_block_links\">$admin_links</div>";
}
diff --git a/views/default/navigation/menu/user_admin.php b/views/default/navigation/menu/user_admin.php
new file mode 100644
index 000000000..1972d7916
--- /dev/null
+++ b/views/default/navigation/menu/user_admin.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * User admin menu
+ *
+ * @todo css/html clean up needed as this was pulled from early 1.8 profile code
+ *
+ * @uses vars['menu']
+ * @uses vars['toggle']
+ */
+
+$toggle = elgg_get_array_value('toggle', $vars, false);
+
+$id = '';
+
+if ($toggle) {
+ echo '<ul class="admin_menu">';
+ echo '<li><a class="elgg-toggle" id="elgg-toggler-admin-menu">Admin options&hellip;</a>';
+ $id = 'id="elgg-togglee-admin-menu"';
+}
+foreach ($vars['menu'] as $section => $menu_items) {
+ echo "<ul class=\"admin_menu_options\" $id>";
+ foreach ($menu_items as $menu_item) {
+ echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item));
+ }
+ echo '</ul>';
+}
+if ($toggle) {
+ echo '<li>';
+ echo '<ul>';
+} \ No newline at end of file
diff --git a/mod/tabbed_profile/views/default/profile/icon.php b/views/default/profile/icon.php
index 71b25fe6c..f58fbf10d 100644
--- a/mod/tabbed_profile/views/default/profile/icon.php
+++ b/views/default/profile/icon.php
@@ -76,10 +76,14 @@ if ($vars['entity'] instanceof ElggUser) {
}
// if Admin is logged in, and not looking at admins own avatar menu
- if (isadminloggedin() && (get_loggedin_userid()!=$vars['entity']->guid) ){
- $adminlinks = elgg_view('profile/menu/adminlinks', $vars);
- if (!empty($adminlinks)) {
- echo "<li class='user_menu_admin'>{$adminlinks}</li>";
+ if (isadminloggedin() && get_loggedin_userid() != $vars['entity']->guid) {
+ $params = array(
+ 'user' => $vars['entity'],
+ 'sort_by' => 'order',
+ );
+ $admin_links = elgg_view_menu('user_admin', $params);
+ if (!empty($admin_links)) {
+ echo "<li class='user_menu_admin'>{$admin_links}</li>";
}
}
@@ -89,9 +93,10 @@ if ($vars['entity'] instanceof ElggUser) {
</div>
<?php
if ((isadminloggedin()) || (!$vars['entity']->isBanned())) {
- ?><a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" ><?php
+ ?>
+ <a href="<?php echo $vars['entity']->getURL(); ?>" class="icon" >
+ <?php
}
-
}
// Rounded avatar corners - CSS3 method - users avatar as background image so we can clip it with border-radius in supported browsers