diff options
Diffstat (limited to 'public/app/controllers/cms')
| -rw-r--r-- | public/app/controllers/cms/Course.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/public/app/controllers/cms/Course.php b/public/app/controllers/cms/Course.php new file mode 100644 index 0000000..b671a5f --- /dev/null +++ b/public/app/controllers/cms/Course.php @@ -0,0 +1,36 @@ +<?php + +namespace app\controllers\cms; + +use Registry; +use Render; +use app\controllers\Auth; +use app\models\cms\Course_model; + +class Course { + + /** serve file by file_path + * (request is valid only for admin users) + * + * @param $file_path (string): relative file path + * GET @param type (string) : media-type of file + */ + public static function serve_file($file_path) + { + // check privileges + if (Auth::is_admin()) { // TODO: -OR- has prvivilege + + $media_type = Registry::get('REQUEST')->GET['type']; // get media-type + $real_path = MEDIA_STORAGE_ROOT . $file_path; // construct real path + + if (!file_exists($real_path)) { + Render::view('error/404'); + + } else { + Render::file($real_path, $media_type); + } + + } + } + +}
\ No newline at end of file |
