Пример #1
0
 /**
  * Edit the user's role
  *
  * @param integer $userId
  * @param integer $roleId
  * @param string $roleName
  * @param array $userInfo
  *      string language
  *      string email
  *      string nick_name
  *      integer user_id
  * @param boolean $isSystem
  * @return boolean|string
  */
 public function editUserRole($userId, $roleId, $roleName, array $userInfo, $isSystem = false)
 {
     try {
         $this->adapter->getDriver()->getConnection()->beginTransaction();
         $update = $this->update()->table('user_list')->set(['role' => $roleId, 'date_edited' => date('Y-m-d')])->where(['user_id' => $userId])->where([new NotInPredicate('user_id', [self::DEFAULT_USER_ID])]);
         $statement = $this->prepareStatementForSqlObject($update);
         $statement->execute();
         // clear a cache
         $this->removeUserCache($userId);
         $this->adapter->getDriver()->getConnection()->commit();
     } catch (Exception $e) {
         $this->adapter->getDriver()->getConnection()->rollback();
         ApplicationErrorLogger::log($e);
         return $e->getMessage();
     }
     // fire the edit user role event
     UserEvent::fireEditRoleEvent($userInfo, $roleName, $isSystem);
     return true;
 }