Пример #1
0
 public function delete($userId = null, $providerId = null, $providerUserId = null)
 {
     MDataType::mustBeNullableInt($userId);
     MDataType::mustBeNullableInt($providerId);
     MDataType::mustBeNullableString($providerUserId);
     $sql = "CALL mt_provider_user_delete(?,?, ?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $query->bindValue($providerId);
     $query->bindValue($providerUserId);
     $queryResult = $query->exec();
     if ($queryResult == false) {
         throw new DeleteProviderException($query->getLastError());
     }
 }
Пример #2
0
 /**
  * @param int $providerId
  * @return ProviderInfo[]
  * @throws \Exception
  */
 public function get($providerId = null)
 {
     MDataType::mustBe(array(MDataType::INT));
     $toReturn = array();
     $sql = "CALL mt_provider_get(?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($providerId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $userLogins = new ProviderInfo();
         $userLogins->setName($row['name'])->setAppKey($row['app_key'])->setSecretKey($row['secret_key'])->setId((int) $row['id']);
         $toReturn[] = $userLogins;
     }
     return $toReturn;
 }
Пример #3
0
 /**
  * @param $userId
  * @param \PDO|null $connection
  * @return array
  * @throws \Exception
  */
 public static function getList($userId, \PDO $connection = null)
 {
     $toReturn = array();
     $sql = "CALL mentity_role_get_list(?);";
     $query = new MPDOQuery($sql, $connection);
     $query->bindValue($userId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $role = new Role();
         $role->setId($row['id'])->setName($row['name']);
         $toReturn[] = $role;
     }
     return $toReturn;
 }
Пример #4
0
 /**
  * @param int|null $userId
  * @return array
  * @throws \Exception
  */
 public function get($userId = null)
 {
     MDataType::mustBeNullableInt($userId);
     $toReturn = array();
     $sql = "CALL mt_role_get(?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $role = new Role();
         $role->setId($row['id'])->setName($row['name']);
         $toReturn[] = $role;
     }
     return $toReturn;
 }
Пример #5
0
 /**
  * @param int|null $userId
  * @param string|null $username
  * @param string|null $email
  * @return User[]
  * @throws \Exception
  */
 public function get($userId = null, $username = null, $email = null)
 {
     MDataType::mustBeNullableInt($userId);
     MDataType::mustBeNullableString($username);
     MDataType::mustBeNullableString($email);
     $userList = array();
     $sql = "CALL mt_user_get(?, ?, ?);";
     $query = new MPDOQuery($sql, $this->connection);
     $query->bindValue($userId);
     $query->bindValue($username);
     $query->bindValue($email);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $userList;
     }
     foreach ($query->getResult() as $row) {
         $user = new User();
         $enabledDate = \DateTime::createFromFormat('Y-m-d H:i:s', $row['enabled_date']);
         $user->setId((int) $row['id'])->setEmail($row['email'])->setPassword($row['password'])->setPhoneNumber($row['phone_number'])->setTwoFactorEnabled($row['two_factor_enabled'] == 1 ? true : false)->setEnabledDate($enabledDate)->setEnabled($row['enabled'] == 1 ? true : false)->setAccessFailedCount((int) $row['access_failed_count'])->setUserName($row['username'])->setRoleList($this->roleBook->get((int) $row['id']))->setProviderUserList($this->providerUserBook->get((int) $row['id']));
         $userList[] = $user;
     }
     return $userList;
 }
Пример #6
0
 /**
  * @param $userLoginsId
  * @param \PDO|null $connection
  * @return array
  * @throws \Exception
  */
 public static function getList($userLoginsId, \PDO $connection = null)
 {
     $toReturn = array();
     $sql = "CALL mentity_provider_get_list(?);";
     $query = new MPDOQuery($sql, $connection);
     $query->bindValue($userLoginsId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $userLogins = new Provider();
         $userLogins->setLoginProvider($row['login_provider'])->setProviderKey($row['providers_key'])->setUserId($row['user_id'])->setId($userLoginsId);
         $toReturn[] = $userLogins;
     }
     return $toReturn;
 }
Пример #7
0
 /**
  * @param $userId
  * @param \PDO|null $connection
  * @return array
  * @throws \Exception
  */
 public function getList($userId, \PDO $connection = null)
 {
     $toReturn = array();
     $sql = "CALL mentity_user_get_list(?);";
     $query = new MPDOQuery($sql, $connection);
     $query->bindValue($userId);
     $queryResult = $query->exec();
     if ($queryResult == false || $query->getResult()->rowCount() <= 0) {
         return $toReturn;
     }
     foreach ($query->getResult() as $row) {
         $user = new User();
         $user->setId($row['id'])->setEmail($row['email'])->setPassword($row['password'])->setPhoneNumber($row['phone_numer'])->setTwoFactorEnabled($row['two_factory_enabled'])->setLockoutEndDateUtc($row['lockout_end'])->setLockoutEnabled($row['lockount_enabled'])->setAccessFailedCount($row['access_failed_count'])->setUserName($row['user_name'])->setRoleList(RoleBook::getList($row['id']))->setUserLoginsList(UserLoginsBook::getList($row['id']));
         $toReturn[] = $user;
     }
     return $toReturn;
 }