Example #1
0
 function Lookup($uid_idx)
 {
     global $user_cache;
     # Look in cache first
     if (array_key_exists("{$uid_idx}", $user_cache)) {
         return $user_cache["{$uid_idx}"];
     }
     $foo = new User($uid_idx);
     if (!$foo->IsValid()) {
         # Try lookup by plain uid.
         $foo = User::LookupByUid($uid_idx);
         if (!$foo || !$foo->IsValid()) {
             return null;
         }
         # Already in the cache from LookupByUid() so just return it.
         return $foo;
     }
     # Insert into cache.
     $user_cache["{$uid_idx}"] =& $foo;
     return $foo;
 }