示例#1
0
 /**
  * Zpracovani formulare s anketou
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     $result = TRUE;
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success');
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger');
     }
 }
示例#2
0
 /**
  * Zpracovani formulare s rubrikou
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     //nova rubrika nebo jeji editace
     $result = empty($values->id) ? $this->newTag($values) : $this->editTag($values);
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'));
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'));
     }
 }
示例#3
0
 protected function error(Form $form, \Exception $e)
 {
     if ($e instanceof \Kdyby\Doctrine\DuplicateEntryException) {
         $form['name']->addError($form->getTranslator()->translate('Name must be unique.'));
         return;
     }
     if ($e instanceof CreateDirectoryException) {
         $form['name']->addError($form->getTranslator()->translate('Failed to create directory.'));
         return;
     }
     if ($e instanceof RenameDirectoryException) {
         $form['name']->addError($form->getTranslator()->translate('Failed to rename directory.'));
         return;
     }
     parent::error($form, $e);
 }
示例#4
0
 /**
  * Nahled prispevku pro odeslani
  * @param Form $form
  * @param ArrayHash $values
  */
 public function formPreview(Form $form, $values)
 {
     //ulozeni do session
     $this->commentSession->content = (array) $values;
     $this->template->modal = TRUE;
     $this->template->modalContent = $values->content;
     $this->template->modalTitle = $form->getTranslator()->translate('system.commentPreview');
     $this->redrawControl('modal');
 }
示例#5
0
 /**
  * Prihlaseni uzivatele
  * @param Form $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if ($values->remember) {
         $this->user->setExpiration('14 days', FALSE);
     } else {
         $this->user->setExpiration('20 minutes', TRUE);
     }
     try {
         $this->user->login($values->username, $values->password);
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($form->getTranslator()->translate('system.credentialsLogError'));
     }
 }
示例#6
0
 /**
  * @param \Nette\Application\UI\Form $form
  * @param callable $resetLinkCallback
  */
 protected function save(Form $form, $resetLinkCallback)
 {
     /** @var \Venne\Security\User $user */
     $user = $this->userRepository->findOneBy(array('email' => $form['email']->value));
     if (!$user) {
         $form->addError($form->getTranslator()->translate('User with email %email% does not exist.', null, array('email' => $form['email']->value)));
         return;
     }
     $key = $user->resetPassword();
     $url = Callback::invoke($resetLinkCallback, $key);
     $this->entityManager->persist($user);
     $this->entityManager->flush($user);
     $this->securityManager->sendRecoveryUrl($user, $url);
 }
示例#7
0
 /**
  * Zpracovani formulare s anketou
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     $requestInfo = $this->getRequestInfo($this->request);
     $result = $this->processPoll($this->vote, $requestInfo, $values);
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success');
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger');
     }
 }
示例#8
0
 protected function error(Form $form, \Exception $e)
 {
     Debugger::log($e);
     $form->addError($form->getTranslator()->translate('Something went wrong'));
 }
示例#9
0
 /**
  * Zpracovani formulare s clankem
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     //nastaveni datumu zverejneni
     if (empty($values->publishDate)) {
         $date = new DateTime();
     } else {
         $date = DateTime::createFromFormat('d. m. Y, H:i', $values->publishDate);
     }
     $values->offsetSet('publishDate', $date);
     //novy clanek nebo jeho editace
     $result = empty($values->id) ? $this->newArticle($values) : $this->editArticle($values);
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success');
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger');
     }
 }
示例#10
0
 /**
  * Zpracovani formulare s clankem
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     //nastaveni hodnot
     if (empty($values->person->surname)) {
         $values->person->surname = NULL;
     }
     //novy uzivatel nebo jeho editace
     $result = empty($values->id) ? $this->newUser($values) : $this->editUser($values);
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success');
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger');
     }
 }
示例#11
0
 /**
  * Zpracovani formulare s anketou
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if (!empty($values->expiration)) {
         $expiration = DateTime::createFromFormat(self::$dateMask, $values->expiration);
         $values->expiration = $expiration;
     } else {
         $values->expiration = NULL;
     }
     if (empty($values->id)) {
         //novy
         $result = $this->newVote($values);
     } else {
         //editace
         $result = $this->editVote($values);
     }
     if ($result) {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestS'), 'success');
     } else {
         $form->getPresenter()->flashMessage($form->getTranslator()->translate('system.requestN'), 'danger');
     }
 }