Exemplo n.º 1
0
 public function save(Nette\Application\UI\Form $form)
 {
     $flag = $this->context->createServiceFlags();
     try {
         $vars = $form->getValues();
         if ($vars['www'] !== '') {
             $form->addError('Are you a spam robot, right?');
             throw new AuthorizationException('Are you a spam robot, right?');
         }
         unset($vars['www']);
         $flag->flag = $vars;
         $flag->save();
         $cache = new Nette\Caching\Cache($this->context->cacheStorage);
         $cache->clean(array('flags', 'flag'));
         $this->flashMessage('Děkujeme! Váš podnět k aktualizaci zpracujeme. Peknyden.cz.', 'success');
         $this->hide = true;
     } catch (AuthorizationException $e) {
         $this->flashMessage($e->getMessage(), 'error');
     } catch (Exception $e) {
         $this->flashMessage('There is error during saving flag! We know about this. Try it later, please.', 'error');
     }
     if ($this->parent->isAjax()) {
         $this->redrawControl('form');
     }
 }
Exemplo n.º 2
0
 public function commandFormSubmitted(Nette\Application\UI\Form $form)
 {
     $command = $form->getValues()->command;
     $this->serverCmd->issueCommand($command, $this->runtimeHash);
     //TODO make it less ugly and more reliable
     usleep(500000);
     if ($this->isAjax()) {
         $this->redrawControl();
     } else {
         $this->redirect('this');
     }
 }
Exemplo n.º 3
0
 public function login(Nette\Application\UI\Form $form)
 {
     $values = $form->getValues();
     try {
         //$this->context->user->setExpiration('+ 14 days', FALSE);
         $this->context->user->login($values->username, $values->password);
         if ($this->parent->isAjax()) {
             $this->invalidateControl('body');
             $this->invalidateControl('login');
         } else {
             $this->parent->redirect("this");
         }
     } catch (Nette\Security\AuthenticationException $e) {
         $this->flashMessage("Špatné jméno nebo heslo. Zkus to znovu.", "error");
         if ($this->parent->isAjax()) {
             $this->invalidateControl('loginForm');
         }
     }
 }