Пример #1
0
 public function editFormSucceeded($form, $values)
 {
     $id = $values->id;
     $record = $this->model->get($id);
     if ($record) {
         if ($record->locked && !$this->user->isInRole("administrator")) {
             $this->flashMessage("Soubor je uzamčen.", "danger");
             $this->redirect("id", $id);
         } elseif (!($this->user->isInRole("administrator") || $this->user->id == $record->user_id)) {
             $this->flashMessage("Nemáte oprávnění měnit vlastnosti tohoto souboru.", "danger");
             $this->redirect("id", $id);
         } else {
             unset($values->id);
             try {
                 $this->model->update($id, $values);
                 $this->flashMessage("Vlastnosti souboru byly uloženy.", "success");
             } catch (Exception $e) {
                 $this->flashMessage("Během ukládání vlastností souboru došlo k chybě.", "danger");
             }
             $this->redirect("id", $id);
         }
     } else {
         $this->flashMessage("Takový soubor neexistuje.", "danger");
         $this->redirect("default");
     }
 }
Пример #2
0
 public function actionApplication($id)
 {
     $record = $this->model->get($id);
     if ($record) {
         if ($record->user_id == $this->user->id || $this->user->isInRole("teacher")) {
             if ($record->application) {
                 $downloadFileId = $record->application;
             } else {
                 $targetFile = $this->fileModel->reserveStorage($record->user_id, "Přihláška k DP: " . $record->name . " ({$record->lastname}, {$record->firstname}, {$record->class})" . ".pdf");
                 $this->flashMessage("Byl vytvořen nový soubor s přihláškou. " . $targetFile->filename, "info");
                 $this->buildPDFApplication($id, $targetFile->filename);
                 $this->model->update($id, array("application" => $targetFile->id));
                 $this->fileModel->update($targetFile->id, array("locked" => 1));
                 $this->fileModel->refreshData($targetFile->id);
                 $downloadFileId = $targetFile->id;
             }
             if (!$this->downloadFile($downloadFileId)) {
                 $this->flashMessage("Soubor není možné uložit.", "danger");
             }
             $this->redirect("default");
         } else {
             $this->flashMessage('Nemáte oprávnění k prohlížení této přihlášky', 'error');
             $this->redirect("default");
         }
     } else {
         $this->flashMessage("Takové zadání práce neexistuje.", "danger");
         $this->redirect("default");
     }
 }