From 7bee460df28bcd956206c3719e091fb500e3045d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 4 Oct 2012 23:05:45 -0700 Subject: provide auto admin registration as before, but allow the current admin to create other admins --- include/account.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include/account.php') diff --git a/include/account.php b/include/account.php index fa56afe7d..b850fcffd 100644 --- a/include/account.php +++ b/include/account.php @@ -77,6 +77,15 @@ function check_account_invite($invite_code) { } +function check_account_admin($arr) { + if(is_site_admin()) + return true; + $admin_mail = trim(get_config('system','admin_email')); + if(strlen($admin_email) && $admin_email === trim($arr['email'])) + return true; + return false; +} + function create_account($arr) { @@ -90,6 +99,7 @@ function create_account($arr) { $password2 = ((x($arr,'password2')) ? trim($arr['password2']) : ''); $parent = ((x($arr,'parent')) ? intval($arr['parent']) : 0 ); $flags = ((x($arr,'account_flags')) ? intval($arr['account_flags']) : ACCOUNT_OK); + $roles = ((x($arr,'account_roles')) ? intval($arr['account_roles']) : 0 ); $default_service_class = get_config('system','default_service_class'); if($default_service_class === false) @@ -100,6 +110,13 @@ function create_account($arr) { return $result; } + if($roles & ACCOUNT_ROLE_ADMIN) { + $admin_result = check_account_admin($arr); + if(! $admin_result) { + $roles = 0; + } + } + $invite_result = check_account_invite($invite_code); if($invite_result['error']) { $result['message'] = $invite_result['message']; @@ -134,7 +151,7 @@ function create_account($arr) { dbesc(get_best_language()), dbesc(datetime_convert()), dbesc($flags), - dbesc(0), + dbesc($roles), dbesc($expires), dbesc($default_service_class) -- cgit v1.2.3