From 695908c7ab2a5d5f011f616d2af3368da7131a6f Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Tue, 22 Jan 2019 02:04:53 +0100 Subject: home columns and download function added --- app/class/controllerart.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'app/class/controllerart.php') diff --git a/app/class/controllerart.php b/app/class/controllerart.php index 20ef634..ace7e82 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -201,6 +201,28 @@ class Controllerart extends Controller } } + public function download($id) + { + if($this->user->isadmin()) { + + $file = Model::DATABASE_DIR . Config::arttable() . DIRECTORY_SEPARATOR . $id . '.json'; + + if (file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/json; charset=utf-8'); + header('Content-Disposition: attachment; filename="'.basename($file).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + readfile($file); + exit; + } + } else { + $this->routedirect('artread/', ['art' => $id]); + } + } + public function delete($id) { $this->setart($id, 'artdelete'); -- cgit v1.2.3