Example #1
0
 public static function Get($uname)
 {
     $data = self::$userDAL->getUserData($uname);
     if ($data == null) {
         return null;
     }
     $user = new User($data['username']);
     $user->setPasswordHash($data['password']);
     return $user;
 }
Example #2
0
 /** Search for Users Similar to the Query
  *
  * @param string $search
  *
  * @return array $ret
  */
 public function getLikeUsers($search)
 {
     $ret = [];
     $query = null;
     $id = null;
     $res_username = null;
     $description = null;
     if (sizeof($search) > 4) {
         $query = substr($search, 0, 4) . "%";
         $this->getLikeUsers->bind_param("s", $query);
     } else {
         $query = $search . "%";
         $this->getLikeUsers->bind_param("s", $query);
     }
     $this->getLikeUsers->execute();
     $this->getLikeUsers->bind_result($id, $res_username, $description);
     while ($this->getLikeUsers->fetch()) {
         $user = new User($res_username, null, $description);
         $user->setPasswordHash(null);
         $user->setId($id);
         array_push($ret, $user);
     }
     return $ret;
 }
Example #3
0
                 $response['tempCode'] = $object->getTempCode();
                 $response['deleted'] = $object->getDeleted();
                 $response['hash'] = $object->getHash();
             }
         }
     } else {
         $response = errorResponse(RESPONSE_BAD_REQUEST, 'Need hash');
     }
 } else {
     if (isPutMethod()) {
         $data = getPostData();
         if (isset($data['userId']) && $data['userId'] !== '') {
             $userId = $data['userId'];
             $object = new User($userId);
             if (isset($data['passwordHash'])) {
                 $object->setPasswordHash($data['passwordHash']);
             }
             if (isset($data['created'])) {
                 $object->setCreated($data['created']);
             }
             if (isset($data['updated'])) {
                 $object->setUpdated($data['updated']);
             }
             if (isset($data['name'])) {
                 $object->setName($data['name']);
             }
             if (isset($data['externalType'])) {
                 $object->setExternalType($data['externalType']);
             }
             if (isset($data['externalId'])) {
                 $object->setExternalId($data['externalId']);
Example #4
0
 public function getUserByUserName($user_name)
 {
     $ret = null;
     $id = null;
     $res_user_name = null;
     $password_hash = null;
     $email_address = null;
     $description = null;
     $this->getUserByUserNameStatement->bind_param("s", $user_name);
     $this->getUserByUserNameStatement->execute();
     $this->getUserByUserNameStatement->bind_result($id, $res_user_name, $password_hash, $email_address, $description);
     // Expecting only 1 result
     if ($this->getUserByUserNameStatement->fetch()) {
         $ret = new User($res_user_name, $email_address, $description);
         $ret->setPasswordHash($password_hash);
         $ret->setId($id);
         // Another fetch to not leave query in progress
         $this->getUserByUserNameStatement->fetch();
     }
     return $ret;
 }