Ejemplo n.º 1
0
 public function beforeRender()
 {
     $serversIds = array_keys($this->permRepo->getPermissions($this->user->id));
     if ($this->selectedServerId != 0) {
         $srvname = $this->serverRepo->findBy(array('id' => $this->selectedServerId))->fetch();
         $this->template->activeServer = $srvname->name;
     } else {
         $this->template->activeServer = NULL;
     }
     $this->template->userServers = $this->serverRepo->findBy(array('id' => $serversIds));
     $this->template->running = $this->runtimeHash != NULL ? TRUE : FALSE;
 }
Ejemplo n.º 2
0
 /**
  * @param \Nette\Application\UI\Form $form
  */
 public function newServerFormSubmitted($form)
 {
     $values = $form->getValues();
     $servers = $this->serverRepo->findBy(array('user_id' => $this->user->id))->fetchPairs('id', 'name');
     if (!in_array($values->name, $servers)) {
         $port = $this->serverRepo->findFreePort();
         try {
             if ($values->storage == "0") {
                 $id = $this->serverRepo->addServer($this->user->id, $values->name, $values->path, 'placeholder', $port);
             } else {
                 $id = $this->serverRepo->addServer($this->user->id, $values->name, $values->path, 'placeholder', $port, $values->name);
             }
             $this->redirect('download', array('newServerId' => $id));
         } catch (Nette\InvalidArgumentException $e) {
             $this->flashMessage($e->getMessage(), "error");
             $this->redirect('this');
         }
     } else {
         $this->flashMessage("Server s tímto jménem už jste vytvořili", "error");
         $this->redirect('this');
     }
 }