diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-24 04:36:57 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-24 04:36:57 +0300 |
| commit | 17d243371c43847e9dbdeb21395afc0e8f5437ae (patch) | |
| tree | 7dfe75fe664826f2b1575d13f09e75a500b605fb /public/app/controllers/cms/Course.php | |
| parent | 74f1c04022328280b996dde0b7089e13d96acf70 (diff) | |
| download | classroom-17d243371c43847e9dbdeb21395afc0e8f5437ae.tar.gz classroom-17d243371c43847e9dbdeb21395afc0e8f5437ae.tar.bz2 classroom-17d243371c43847e9dbdeb21395afc0e8f5437ae.zip | |
edit lesson: putting all together; media with privile level
Diffstat (limited to 'public/app/controllers/cms/Course.php')
| -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 |
