datalib MDL-18470 Implemented more readable version of get_admin()
This commit is contained in:
+5
-12
@@ -42,22 +42,15 @@ function addslashes_object( $dataobject ) {
|
||||
* @return object(admin) An associative array representing the admin user.
|
||||
*/
|
||||
function get_admin () {
|
||||
|
||||
global $CFG;
|
||||
static $myadmin;
|
||||
|
||||
if (isset($myadmin)) {
|
||||
return $myadmin;
|
||||
}
|
||||
|
||||
if ( $admins = get_admins() ) {
|
||||
foreach ($admins as $admin) {
|
||||
$myadmin = $admin;
|
||||
return $admin; // ie the first one
|
||||
if (! isset($admin)) {
|
||||
if (! $admins = get_admins()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
$admin = reset($admins);//reset returns first element
|
||||
}
|
||||
return $admin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user