aboutsummaryrefslogtreecommitdiff
path: root/actions/admin/user/makeadmin.php
diff options
context:
space:
mode:
Diffstat (limited to 'actions/admin/user/makeadmin.php')
-rw-r--r--actions/admin/user/makeadmin.php28
1 files changed, 12 insertions, 16 deletions
diff --git a/actions/admin/user/makeadmin.php b/actions/admin/user/makeadmin.php
index 580e7df05..54b0b7070 100644
--- a/actions/admin/user/makeadmin.php
+++ b/actions/admin/user/makeadmin.php
@@ -1,25 +1,21 @@
<?php
/**
- * Make another user an admin.
+ * Grants admin privileges to a user.
*
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
+ * In >=1.7.1, admin is flagged by setting the admin
+ * column in the users_entity table.
+ *
+ * In <1.7.1, admin is a piece of metadata on the user object.
+ *
+ * @package Elgg.Core
+ * @subpackage Administration.User
*/
-global $CONFIG;
-
-// block non-admin users
-admin_gatekeeper();
-
-// Get the user
$guid = get_input('guid');
-$obj = get_entity($guid);
+$user = get_entity($guid);
-if (($obj instanceof ElggUser) && ($obj->canEdit())) {
- $obj->admin = 'yes';
- if ($obj->admin) {
+if (($user instanceof ElggUser) && ($user->canEdit())) {
+ if ($user->makeAdmin()) {
system_message(elgg_echo('admin:user:makeadmin:yes'));
} else {
register_error(elgg_echo('admin:user:makeadmin:no'));
@@ -28,4 +24,4 @@ if (($obj instanceof ElggUser) && ($obj->canEdit())) {
register_error(elgg_echo('admin:user:makeadmin:no'));
}
-forward($_SERVER['HTTP_REFERER']);
+forward(REFERER);