Files
thetool/application/TerminationFile/TerminationFileController.php
2021-09-09 22:09:07 +02:00

42 lines
1.0 KiB
PHP

<?php
class TerminationFileController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->isAdmin()) {
$this->redirect("Dashboard");
}
}
protected function editAction() {
// internal redirect to File::editAction
}
protected function deleteAction() {
$id = $this->request->id;
$termfile = new TerminationFile($id);
if(!$termfile->id || $termfile->id != $id) {
$this->layout()->setFlash("Datei nicht gefunden.", "error");
$this->redirect("Termination");
}
$term_id = $termfile->termination_id;
$building_id = $termfile->termination->building_id;
$termfile->file->delete();
$termfile->delete();
if($this->request->from == "linework") {
$this->redirect("Linework", "Index", false, "object=".$termination_id);
}
$this->redirect("building", "edit", ["id" => $building_id]);
}
}