/**
  * Try and load a UserAuthentication account from the gicen provider and provder user id.
  * @param $provider the provider
  * @param $userproviderid the user provider id
  * returns an UserAuthentication instance else return Error;
  */
 function loadByProvider($provider, $userproviderid)
 {
     global $DB, $HUB_SQL;
     $params = array();
     $params[0] = $provider;
     $params[1] = $userproviderid;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_AUTH_LOAD_BY_PROVIDER, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUserNotFoundError($this->authid);
             return $ERROR;
         } else {
             //Should only every be one
             $authentication = new UserAuthentication($resArray[0]['AuthID']);
             $authentication->load();
             return $authentication;
         }
     } else {
         return database_error();
     }
 }
Exemplo n.º 2
0
 /**
  * Load user based on their email address
  *
  * @return User object (this) (or Error object)
  */
 function getByEmail()
 {
     global $DB, $CFG, $ERROR, $HUB_SQL;
     $params = array();
     $params[0] = $this->email;
     $resArray = $DB->select($HUB_SQL->DATAMODEL_USER_BY_EMAIL_SELECT, $params);
     if ($resArray !== false) {
         $count = count($resArray);
         if ($count == 0) {
             $ERROR = new error();
             $ERROR->createUserNotFoundError($this->userid);
             return $ERROR;
         } else {
             for ($i = 0; $i < $count; $i++) {
                 $array = $resArray[$i];
                 $this->userid = trim($array['UserID']);
             }
         }
     } else {
         return database_error();
     }
     return $this->load();
 }
Exemplo n.º 3
0
 /**
  * Mark that this user was removed from the group by marking thier requested record as reported
  * Only group admins can run this function.
  *
  * @param string $userid of the user to mark as reported
  * @return Group object (this)
  */
 function reportpendingmember($userid)
 {
     global $DB, $CFG, $USER, $HUB_SQL, $LNG;
     //check user can edit the group
     if (!$this->isgroupadmin($USER->userid)) {
         return access_denied_error();
     }
     // check user exists
     $user = new User($userid);
     if ($user->load() instanceof Error) {
         global $ERROR;
         $ERROR = new error();
         return $ERROR->createUserNotFoundError($userid);
     }
     // now add the user
     $params = array();
     $params[0] = $USER->userid;
     $params[1] = time();
     $params[2] = $this->groupid;
     $params[3] = $userid;
     $res = $DB->insert($HUB_SQL->DATAMODEL_GROUP_JOIN_REPORT, $params);
     if (!$res) {
         return database_error();
     }
     return $this;
 }