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"); } }
public function actionRefreshFileData($id) { $record = $this->model->get($id); if ($record) { $this->model->refreshData($id); $this->flashMessage("Data souboru byla aktualizována.", "success"); } else { $this->flashMessage("Neexistuje záznam o takovém souboru.", "danger"); } $this->redirect("id", $id); }