Skip to content
Browse files

datalib MDL-18470 Implemented more readable version of get_admin()

  • Loading branch information...
1 parent f7e5d92 commit de7092fe1f45f01004342d079d6bb4144be4e8ce Andrew Davis committed Nov 20, 2009
Showing with 5 additions and 12 deletions.
  1. +5 −12 lib/datalib.php
View
17 lib/datalib.php
@@ -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;
}
/**

0 comments on commit de7092f

Please sign in to comment.
Something went wrong with that request. Please try again.