Filestore Beta
This commit is contained in:
@@ -19,26 +19,20 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$this->layout()->setTemplate("Filestore/Index");
|
||||
$files = FilestoreModel::getAll();
|
||||
$networkaddress = NetworkAddressModel::getAll();
|
||||
|
||||
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 25;
|
||||
$pagination['maxItems'] = 0;
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
$pagination['maxItems'] = FilestoreModel::count();
|
||||
$this->layout()->set("files", $files);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
$this->layout()->set("networkaddresses", $networkaddress);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$this->layout()->set("networks", NetworkModel::getAll());
|
||||
$this->layout()->set("networkaddresses", NetworkAddressModel::getAll());
|
||||
$this->layout()->setTemplate("Filestore/Form");
|
||||
}
|
||||
|
||||
@@ -46,9 +40,12 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$editmode=$r->mode;
|
||||
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
|
||||
$filestore = new Filestore($id);
|
||||
if (!$filestore->id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
@@ -59,17 +56,23 @@ class FilestoreController extends mfBaseController
|
||||
$dataHistory['name'] = $filestore->name;
|
||||
$dataHistory['description'] = $filestore->description;
|
||||
$dataHistory['file_id'] = $filestore->file_id;
|
||||
$dataHistory['network_id'] = $filestore->network_id;
|
||||
$dataHistory['filestore_id'] = $filestore->id;
|
||||
$dataHistory['create'] = $filestore->create;
|
||||
$dataHistory['create_by'] = $filestore->create_by;
|
||||
$dataHistory['edit'] = date("U");
|
||||
$dataHistory['edit_by'] = $filestore->edit_by;
|
||||
// $dataHistory['edit'] = date("U");
|
||||
$dataHistory['edit'] = $filestore->edit;
|
||||
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['name'] = trim($r->name);
|
||||
$data['network_id'] = trim($r->network_id);
|
||||
$data['description'] = trim($r->description);
|
||||
$data['edit_by'] = trim($this->me->id);
|
||||
|
||||
if (!$data['name']) {
|
||||
$this->layout()->setFlash("Name darf nicht leer sein", "error");
|
||||
@@ -114,7 +117,6 @@ class FilestoreController extends mfBaseController
|
||||
$data['file_id'] = $file_id;
|
||||
|
||||
if ($mode == "edit") {
|
||||
|
||||
$fsh = FilestoreHistoryModel::create($dataHistory);
|
||||
}
|
||||
} else {
|
||||
@@ -141,7 +143,7 @@ class FilestoreController extends mfBaseController
|
||||
$id = $filestore->save();
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen33", "error");
|
||||
$this->layout()->setFlash("Dateiupload fehlgeschlagen", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
if ($fsh) {
|
||||
@@ -155,19 +157,28 @@ class FilestoreController extends mfBaseController
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if ($r->mode) {
|
||||
$mode = $r->mode;
|
||||
} else {
|
||||
$mode = "";
|
||||
}
|
||||
if (!is_numeric($id) && $id < 1) {
|
||||
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
$this->redirect("Filestore");
|
||||
|
||||
}
|
||||
$filestore = new Filestore($id);
|
||||
|
||||
$filestore = new Filestore($id);
|
||||
$filestorehistory = new FilestoreHistory($id);
|
||||
if (!$filestore->id) {
|
||||
$this->layout()->setFlash("Datei nicht gefunden", "error");
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
if ($mode) {
|
||||
$this->layout()->set("mode", $mode);
|
||||
}
|
||||
$this->layout()->set("filestorehistory", $filestorehistory);
|
||||
$this->layout()->set("file", $filestore);
|
||||
|
||||
return $this->addAction();
|
||||
@@ -194,4 +205,35 @@ class FilestoreController extends mfBaseController
|
||||
$filstore->delete();
|
||||
$this->redirect("Filestore");
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
if (!$this->me->is(["Admin", "netowner", "pipeplanner", "lineplanner", "pipeworker", "netoperator", "lineworker"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
$id = $this->request->id;
|
||||
|
||||
$filestorehistory = FilestoreHistoryModel::getAllhistory($id);
|
||||
$counter = 0;
|
||||
foreach ($filestorehistory as $history) {
|
||||
$data[$counter]['id'] = $history->id;
|
||||
$data[$counter]['file_id'] = $history->data->file_id;
|
||||
$data[$counter]['name'] = $history->data->name;
|
||||
$data[$counter]['description'] = $history->data->description;
|
||||
$data[$counter]['workername'] = $history->data->workername;
|
||||
$data[$counter]['workerid'] = $history->data->workerid;
|
||||
$data[$counter]['edit'] = $history->edit;
|
||||
if (trim($this->me->id) == $history->data->workerid) {
|
||||
$data[$counter]['is_delete'] = 1;
|
||||
} else {
|
||||
$data[$counter]['is_delete'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$counter++;
|
||||
}
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user