Example #1
0
 public function handleAddNewAjaxSection($name = '', $underSection = '', $underSubSection = '')
 {
     if (!$name || !$underSection || !$underSubSection) {
         throw new Nette\Application\BadRequestException();
     }
     if (!$this->user->isAllowed('Section', 'moderate')) {
         throw new \Nette\Application\ForbiddenRequestException();
     }
     $form = $this->presenter->action;
     $id = $this->articleManager->addSerial(ArrayHash::from(['name' => $name, 'underSection' => $underSection, 'underSubSection' => $underSubSection, 'byUser' => $this->user->id, 'articleId' => $this->updateId]));
     if ($this->user->isAllowed(self::RES, 'moderate')) {
         $items = $this->articleManager->getSerialList($underSubSection);
     } else {
         $items = $this->articleManager->getSerialList($underSubSection, $this->user->getId());
     }
     $this[$form]['underSerial']->setItems($items + [0 => 'Žádná'])->setValue($id);
     $this->redrawAjax(['underSerialSnippet', 'jsUpdate']);
 }
Example #2
0
 private function create()
 {
     $form = new Form();
     $form->addText('title', 'Titulek')->setRequired('Zadejte titulek')->setAttribute('placeholder', 'Zadejte titulek');
     if ($this->user->isAllowed(self::RES, 'moderate')) {
         $users = $this->userManager->getUserList();
         $form->addSelect('byUser', 'Za uživatele', ['0' => 'Neregistrovaný'] + $users['deleted'] + $users['allowed'])->setValue($this->user->id);
         $form->addText('byUnregUser', 'Za neregistrovaného uživatele');
     }
     $form->addTextArea('description', 'Popis')->setRequired('Zadejte popis');
     $form->addTextArea('text', 'Článek')->setRequired('Zadejte článek');
     $form->addText('keyWords', 'Klíčová slova');
     $form->addCheckbox('commentsAllow', 'Povolit komentáře');
     $form->addCheckbox('voteAllow', 'Povolit hlasování');
     $form->addUpload('photo', 'Náhledová fotka');
     if ($this->setSection) {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setValue($this->setSection);
         if ($this->setSubsection) {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setValue($this->setSubsection);
             if ($this->setSerial) {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setValue($this->setSerial);
             } else {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setPrompt('Vyberte');
             }
         } else {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setPrompt('Vyberte podsekci');
             $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte podsekci');
         }
     } else {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSubSection', 'Podsekce')->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte hlavní sekci');
     }
     if ($this->user->isAllowed('Section', 'moderate')) {
     }
     if ($this->user->isAllowed(self::RES, 'publish')) {
         $form->addCheckbox('published', 'Publikovaný ihned');
     }
     $form->addSubmit('submitArticle', 'Odeslat')->setValidationScope(false);
     return $form;
 }