Example #1
0
 public function &getUserById($id)
 {
     if (!isset($this->ids[$id])) {
         $temp = new User($this->System);
         $temp->loadFromId($id);
         $this->ids[$temp->id] =& $temp;
         $this->hashes[$temp->hash] =& $this->ids[$temp->id];
         return $this->ids[$temp->id];
     } else {
         return $this->ids[$id];
     }
 }
 /**
  * Return a user object that corresponds to the current SAML assertion.
  * If no SAML assertion is set, the function returns null.
  * If the user doesn't exist, and auto create has been turned on in the config,
  * the user is created.
  *
  * If realnameAttr and/or mailAttr and/or groupMap are set in the config,
  * these attributes are synchronised to the MediaWiki user.
  * This also happens if the user already exists.
  *
  * @param $user MediaWiki user that will be made to correspond to the SAML assertion
  * @param $attr string[][] SAML attributes
  *
  * @return void $user is modified upon return
  */
 protected static function loadUser(User $user, $attr)
 {
     global $wgSamlCreateUser;
     global $wgSamlUsernameAttr;
     global $wgContLang;
     $username = $wgContLang->ucfirst(reset($attr[$wgSamlUsernameAttr]));
     $id = User::idFromName($username);
     if ($id || $wgSamlCreateUser) {
         if ($id) {
             $user->setId($id);
             $user->loadFromId();
         } else {
             $user->setName($username);
         }
         self::updateUser($user, $attr);
         self::setGroups($user);
     } else {
         return 'User "' . htmlentities(reset($attr[$wgSamlUsernameAttr])) . "\" does not exist and \"\$wgSamlCreateUser\" flag is false.\n";
     }
 }