Exemplo n.º 1
0
 /**
  * Validates user credentials
  *
  * @return TRUE - if validation passed, and FALSE - otherwise
  */
 public function validate()
 {
     if (AdminManager::getInstance()->validate($this->getId(), $this->getUniqueId())) {
         return true;
     }
     throw new \ngs\framework\exceptions\InvalidUserException("wrong user");
 }
Exemplo n.º 2
0
 public function load()
 {
     $moderatorId = NGS()->getSessionManager()->getUserId();
     $limit = 20;
     $page = 1;
     if (isset(NGS()->args()->page)) {
         $page = intval(NGS()->args()->page);
     }
     if (isset(NGS()->args()->limit)) {
         $limit = intval(NGS()->args()->limit);
     }
     $this->addParam('page', $page);
     $this->addParam('limit', $limit);
     $offset = ($page - 1) * $limit;
     $duplicatedRealVoters = AnalyzeManager::getInstance()->getDuplicatedNumberRealVoters($offset, $limit);
     $this->addParam('duplicatedRealVoters', $duplicatedRealVoters);
     $voterIdsArray = $this->getVoterIdsArray($duplicatedRealVoters);
     $voters = [];
     $preVoteData = [];
     if (!empty($voterIdsArray)) {
         $voters = VoterManager::getInstance()->selectByPKs($voterIdsArray, true);
         $voterIdsSqlString = "(" . implode(',', $voterIdsArray) . ")";
         $preVoteData = VoterDataManager::getInstance()->selectAdvance('*', ['voter_id', 'in', $voterIdsSqlString]);
         $preVoteData = $this->MapByVoterId($preVoteData);
     }
     $count = AnalyzeManager::getInstance()->getDuplicatedNumberRealVotersCount();
     $pageCount = ceil($count / $limit);
     if ($count == 0) {
         $pageCount = 1;
     }
     $this->addParam('pageCount', $pageCount);
     $this->addParam('rows', $duplicatedRealVoters);
     $this->addParam('voters', $voters);
     $admins = AdminManager::getInstance()->selectAllMappedByIds();
     $this->addParam('moderators', $admins);
     $this->addParam('preVoteData', $preVoteData);
 }
Exemplo n.º 3
-17
 public function service()
 {
     $adminDto = AdminManager::getInstance()->getByUsernamePassword(NGS()->args()->getUsername(), NGS()->args()->getPassword());
     if (!$adminDto) {
         $this->redirect('login');
     }
     if ($adminDto->getType() == 'admin') {
         NGS()->getSessionManager()->login(UserGroups::$ADMIN, $adminDto->getId());
     } elseif ($adminDto->getType() == 'moderator') {
         NGS()->getSessionManager()->login(UserGroups::$MODERATOR, $adminDto->getId());
     }
     $this->redirect('');
 }