aboutsummaryrefslogtreecommitdiff
path: root/actions/admin/user/makeadmin.php
blob: 54b0b7070c51e7390a618bab6dcfa414529b5067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/**
 * Grants admin privileges to a user.
 *
 * 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
 */

$guid = get_input('guid');
$user = get_entity($guid);

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'));
	}
} else {
	register_error(elgg_echo('admin:user:makeadmin:no'));
}

forward(REFERER);