Skip to content

Commit

Permalink
datalib MDL-18470 Implemented more readable version of get_admin()
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Davis committed Nov 20, 2009
1 parent f7e5d92 commit de7092f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/datalib.php
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit de7092f

Please sign in to comment.