Esempio n. 1
0
 /**
  * @return string
  */
 public function getLocale()
 {
     if ($this->locale === '') {
         $locale = $this->user->getLanguage();
         $this->locale = $this->languagePackExists($locale) === true ? $locale : $this->config->getSettings(Schema::MODULE_NAME)['lang'];
     }
     return $this->locale;
 }
 /**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     if ($this->acl->hasPermission('frontend/captcha/index/image') === true && $this->user->isAuthenticated() === false) {
         return $this->checkCaptcha($data, isset($extra['path']) ? $extra['path'] : '');
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Erzeugt das Captchafeld für das Template
  *
  * @param integer $captchaLength
  * @param string  $formFieldId
  * @param bool    $inputOnly
  * @param string  $path
  *
  * @return string
  */
 public function captcha($captchaLength = self::CAPTCHA_DEFAULT_LENGTH, $formFieldId = self::CAPTCHA_DEFAULT_INPUT_ID, $inputOnly = false, $path = '')
 {
     if ($this->user->isAuthenticated() === false) {
         $path = sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path));
         $this->sessionHandler->set('captcha_' . $path, $this->secureHelper->salt($captchaLength));
         $this->view->assign('captcha', ['width' => $captchaLength * 25, 'id' => $formFieldId, 'height' => 30, 'input_only' => $inputOnly, 'path' => $path]);
         return $this->view->fetchTemplate('Captcha/Partials/captcha.tpl');
     }
     return '';
 }
 /**
  * @param int $pollId
  * @param string $ipAddress
  * @return mixed
  */
 protected function getVotes($pollId, $ipAddress)
 {
     // Check, whether the logged user has already voted
     if ($this->userModel->isAuthenticated() === true) {
         $votes = $this->voteRepository->getVotesByUserId($pollId, $this->userModel->getUserId(), $ipAddress);
     } else {
         // For guest users check against the ip address
         $votes = $this->voteRepository->getVotesByIpAddress($pollId, $ipAddress);
     }
     return $votes;
 }
 /**
  * @param ModelSaveEvent $event
  * @throws SuperUserNotDeletableException
  */
 public function forbidSuperUserDelete(ModelSaveEvent $event)
 {
     if (!$event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $item) {
         $user = $this->userModel->getUserInfo($item);
         if ($user['super_user'] == 1) {
             throw new SuperUserNotDeletableException();
         }
     }
 }
Esempio n. 6
0
 /**
  * @param array $formData
  * @param int $pollId
  * @param string $ipAddress
  * @param string $time
  * @return bool|int
  * @throws Core\Validation\Exceptions\ValidationRuleNotFoundException
  */
 public function vote(array $formData, $pollId, $ipAddress, $time)
 {
     $answers = $formData['answer'];
     $bool = false;
     $userId = $this->userModel->isAuthenticated() ? $this->userModel->getUserId() : null;
     // Multiple Answers
     if (is_array($answers) === false) {
         $answers = [$answers];
     }
     foreach ($answers as $answer) {
         if ($this->validator->is(IntegerValidationRule::class, $answer) === true) {
             $insertValues = ['poll_id' => $pollId, 'answer_id' => $answer, 'user_id' => $userId, 'ip' => $ipAddress, 'time' => $time];
             $bool = $this->voteRepository->insert($insertValues);
         }
     }
     return $bool;
 }
Esempio n. 7
0
File: ACL.php Progetto: acp3/core
 /**
  * @param string $resource
  *
  * @return boolean
  */
 protected function canAccessResource($resource)
 {
     $resourceParts = $this->convertResourcePathToArray($resource);
     $area = $resourceParts[0];
     $resource = $resourceParts[1] . '/' . $resourceParts[2] . '/' . $resourceParts[3] . '/';
     // At least allow users to access the login page
     if (isset($this->getResources()[$area][$resource])) {
         $module = $resourceParts[1];
         $privilegeKey = $this->getResources()[$area][$resource]['key'];
         return $this->userHasPrivilege($module, $privilegeKey) === true || $this->user->isSuperUser() === true;
     }
     return false;
 }
Esempio n. 8
0
File: Date.php Progetto: acp3/core
 /**
  * Date constructor.
  * @param UserModel $user
  * @param DateTranslator $dateTranslator
  * @param SettingsInterface $config
  */
 public function __construct(UserModel $user, DateTranslator $dateTranslator, SettingsInterface $config)
 {
     $this->dateTranslator = $dateTranslator;
     $this->config = $config;
     $this->setFormatAndTimeZone($user->getUserInfo());
 }
Esempio n. 9
0
 private function setSessionValues()
 {
     $this->sessionHandler->set(self::AUTH_NAME, ['id' => $this->userModel->getUserId(), 'super_user' => $this->userModel->isSuperUser(), 'language' => $this->userModel->getLanguage()]);
 }