diff options
| author | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 20:18:01 +0300 |
|---|---|---|
| committer | George Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2023-04-27 20:18:01 +0300 |
| commit | a2e68fce808dbe6fba320a6232a15380b63157f6 (patch) | |
| tree | b6ceaf603b2237c328707c152233304b9a511b9e /public/app | |
| parent | 059e0d95d0c28bc5060e87e146eaf7411f51bf90 (diff) | |
| download | gyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.tar.gz gyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.tar.bz2 gyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.zip | |
structure simplified
Diffstat (limited to 'public/app')
20 files changed, 174 insertions, 385 deletions
diff --git a/public/app/controllers/Admin.php b/public/app/controllers/Admin.php deleted file mode 100644 index 6f6858c..0000000 --- a/public/app/controllers/Admin.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -namespace app\controllers; - -use Registry; -use Render; - -// user classes and models -use app\extends\Classroom_user; -use app\extends\Classroom_manager; -use app\models\admin\User_model; - -use app\extends\Send_mail; -use app\extends\Mail_jet; - - -/** class Auth - * - * handles user's Authentication and Authorizarion - * - */ -class Admin { - - /** admin cateogories - * - */ - public static function categories() - { - Render::view('admin/categories'); - } - - - /** admin lessons - * - */ - public static function lessons() - { - - } - - - /** admin pages - * - */ - public static function pages() - { - - } - - /** admin users - * - */ - public static function users() - { - - } - - -}
\ No newline at end of file diff --git a/public/app/controllers/Auth.php b/public/app/controllers/Auth.php index 4a6b9ed..4b3dcfb 100644 --- a/public/app/controllers/Auth.php +++ b/public/app/controllers/Auth.php @@ -7,10 +7,9 @@ use Render; // user classes and models use app\extends\Classroom_user; use app\extends\Classroom_manager; -use app\models\admin\User_model; +use app\models\Access_model; +use app\extends\SendMail_service; -use app\extends\Send_mail; -use app\extends\Mail_jet; /** class Auth @@ -31,7 +30,7 @@ class Auth { $req = Registry::get('REQUEST'); // get the record of the target user - $record = User_model::checkUser($req->POST['email']); + $record = Access_model::checkUser($req->POST['email']); // if no user exists, return false if ($record === false) return false; @@ -51,7 +50,7 @@ class Auth { if ($userManager->isPasswordValid($user, $req->POST['password'])) { // get user's security attributes - $attributes = User_Model::getUser($record['id']); + $attributes = Access_model::getUser($record['id']); $roles = json_decode($attributes['Roles_json']); $user ->setRoles($roles) @@ -111,7 +110,7 @@ class Auth { $req = Registry::get('REQUEST'); // get the record of the target user - $check = User_model::activate($req->GET['ticket']); + $check = Access_model::activate($req->GET['ticket']); if ($check == true) { Render::view('/error/general', [ @@ -151,7 +150,7 @@ class Auth { ->setPrivileges([]); // none privilege until acount confirmation // create user record - $activation_code = User_model::registerUser($req->POST, $password); + $activation_code = Access_model::registerUser($req->POST, $password); // TODO: // handle error on user registration @@ -164,7 +163,7 @@ class Auth { // ]; // } - $send_mail = Send_mail::send_activation_code([ + $send_mail = SendMail_service::send_activation_code([ 'email' => $req->POST['email'], 'name' => $req->POST['name'] .' '. $req->POST['surname'], 'code' => $activation_code['activation'] diff --git a/public/app/controllers/cms/Course.php b/public/app/controllers/Cms.php index 47eac5f..306bc88 100644 --- a/public/app/controllers/cms/Course.php +++ b/public/app/controllers/Cms.php @@ -1,19 +1,25 @@ <?php -namespace app\controllers\cms; +namespace app\controllers; use Registry; use Render; use app\controllers\Auth; -use app\models\cms\Course_model; +use app\models\Cms_model; use app\extends\Cache_service; -class Course { +/** CMS class + * (Content Management System) + * + * Serves the content; + * Reponds to all front-end front-office requests + * + */ +class Cms { - /** PERMITION - * ------------------------------------------------------------------------- - */ + ## PERMITION + ## ------------------------------------------------------------------------- /** is admin or permited @@ -41,9 +47,9 @@ class Course { - /** FILES - * ------------------------------------------------------------------------- - */ + ## FILES + ## ------------------------------------------------------------------------- + /** serve file by file_path * (request is valid only for admin users) @@ -103,9 +109,9 @@ class Course { - /** COURSES - * ------------------------------------------------------------------------- - */ + ## COURSES + ## ------------------------------------------------------------------------- + /** course * prepare and render the course view @@ -121,7 +127,7 @@ class Course { $cache = Cache_service::courses_struct(); $tree = $cache['tree']; $breadcrumbs = $cache['breadcrumbs']; - $lessons = Course_model::lessons_of_course(intval($id)); + $lessons = Cms_model::lessons_of_course(intval($id)); // find parent_ids of current category (to open the menu tree) // --- @@ -147,9 +153,9 @@ class Course { - /** LESSONS - * ------------------------------------------------------------------------ - */ + ## LESSONS + ## ------------------------------------------------------------------------- + /** lesson @@ -163,7 +169,7 @@ class Course { { $id = intval($id); // lesson id - $lesson = Course_model::lesson($id); // get lesson + $lesson = Cms_model::lesson($id); // get lesson $course_id = $lesson['course_id']; // get course id $pri_id = $lesson['privilege_id']; // privilege needed @@ -220,6 +226,10 @@ class Course { } + ## PAGES + ## ------------------------------------------------------------------------- + + /** lesson * * check if user is authorized to view the content; @@ -246,7 +256,4 @@ class Course { } - - - -}
\ No newline at end of file +} diff --git a/public/app/controllers/admin/Course_admin.php b/public/app/controllers/CmsAdmin.php index fcf38c9..9629741 100644 --- a/public/app/controllers/admin/Course_admin.php +++ b/public/app/controllers/CmsAdmin.php @@ -1,13 +1,13 @@ <?php -namespace app\controllers\admin; +namespace app\controllers; use Registry; use Render; -use app\models\cms\Course_model; +use app\models\Cms_model; use app\extends\Cache_service; -class Course_admin { +class CmsAdmin { ## ------------------------------------------------------------------------- diff --git a/public/app/controllers/admin/.gitkeep b/public/app/controllers/admin/.gitkeep deleted file mode 100644 index e69de29..0000000 --- a/public/app/controllers/admin/.gitkeep +++ /dev/null diff --git a/public/app/controllers/admin/Users_admin.php b/public/app/controllers/admin/Users_admin.php deleted file mode 100644 index 4e335c1..0000000 --- a/public/app/controllers/admin/Users_admin.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace app\controllers\admin; - -use Registry; -use Render; - - -class Users_admin { - - /** privileges - * --- - * get all privileges - * - * @param void - * @return privileges (array) - */ - public static function privileges() - { - return Registry::use('database')->runQuery( - "SELECT * FROM privilege",[] - ); - } - - /** edit privileges - * --- - */ - public static function edit_privileges() - { - // TODO: ... - } - - - /** update course - * --- - */ - public static function update_course() - { - // TODO: ... - } - -}
\ No newline at end of file diff --git a/public/app/controllers/cli/CliContoller.php b/public/app/controllers/cli/CliContoller.php index 4549b50..949985d 100644 --- a/public/app/controllers/cli/CliContoller.php +++ b/public/app/controllers/cli/CliContoller.php @@ -39,12 +39,12 @@ class CliContoller if (php_sapi_name() != 'cli') return false; # PROXY call: - # CMS \ Course_model::courses_struct(): + # CMS \ Cms_model::courses_struct(): # + Refresh Cache # -------------------------------------- echo textColor("Creating category_products tree Cache ... ", \NORMAL); $reply = proxy( - [\app\models\cms\Course_model::class, 'courses_struct'], + [\app\models\Cms_model::class, 'courses_struct'], [], \CACHE_ROOT_TTL, \PROXY_IGNORE_CACHE ); diff --git a/public/app/extends/Cache_service.php b/public/app/extends/Cache_service.php index 52311f3..c435b75 100644 --- a/public/app/extends/Cache_service.php +++ b/public/app/extends/Cache_service.php @@ -1,8 +1,8 @@ <?php namespace app\extends; -use app\models\cms\Course_model; -use app\models\admin\Privilege_model; +use app\models\Cms_model; +use app\models\Access_model; /** Cache service * ----------------------------------------------------------------------------- @@ -20,7 +20,7 @@ class Cache_service public static function courses_struct( $options = 0 ) { return proxy( // cache-get courses - [\app\models\cms\Course_model::class, 'courses_struct'], + [\app\models\Cms_model::class, 'courses_struct'], [], CACHE_ROOT_TTL, $options ); @@ -29,7 +29,7 @@ class Cache_service public static function files_attributes( $options = 0 ) { return proxy( - [\app\models\cms\Course_model::class, 'files'], + [\app\models\Cms_model::class, 'files'], [], CACHE_ROOT_TTL, $options ); @@ -39,7 +39,7 @@ class Cache_service public static function privileges_hierarchy( $options = 0 ) { return proxy( - [\app\models\admin\Privilege_model::class, 'privileges'], + [\app\models\Access_model::class, 'privileges'], [], CACHE_ROOT_TTL, $options ); @@ -48,7 +48,7 @@ class Cache_service public static function pages_list( $options = 0 ) { return proxy( - [\app\models\cms\Course_model::class, 'pages'], + [\app\models\Cms_model::class, 'pages'], [], CACHE_ROOT_TTL, $options ); @@ -72,7 +72,7 @@ class Cache_service // TODO: needs testing before release // return proxy( - // [\app\models\admin\Course_model::class, $entity], + // [\app\models\Cms_model::class, $entity], // [], CACHE_ROOT_TTL, // $options // ); diff --git a/public/app/extends/Classroom_manager.php b/public/app/extends/Classroom_manager.php index 4d38ba3..ea2e891 100644 --- a/public/app/extends/Classroom_manager.php +++ b/public/app/extends/Classroom_manager.php @@ -37,7 +37,7 @@ class Classroom_manager extends UserManager public function register_user() { $req = Registry::get('REQUEST'); - $register = User_model::registerUser($req->POST); + $register = Access_model::registerUser($req->POST); if ($register['success']) { @@ -83,7 +83,7 @@ class Classroom_manager extends UserManager public function create_OTP($id) { $otp = rand(100000,999999); - User_model::set_OTP($id, $otp); + Access_model::set_OTP($id, $otp); return true; } diff --git a/public/app/extends/Send_mail.php b/public/app/extends/SendMail_service.php index 52eab53..c717e61 100644 --- a/public/app/extends/Send_mail.php +++ b/public/app/extends/SendMail_service.php @@ -6,7 +6,7 @@ use PHPMailer\PHPMailer\SMTP; use PHPMailer\PHPMailer\Exception; -class Send_mail +class SendMail_service { /** send_activation_code * diff --git a/public/app/models/admin/User_model.php b/public/app/models/Access_model.php index 2885dc1..d5ae19e 100644 --- a/public/app/models/admin/User_model.php +++ b/public/app/models/Access_model.php @@ -1,13 +1,16 @@ <?php -namespace app\models\admin; +namespace app\models; use \Registry; -use app\models\admin\History_model as History; +use app\models\History_model; -class User_model +class Access_model { + ## User methods + ## ------------------------------------------------------------------------- + /** check user (by index key) * * @param $indexKey (string) : key for user identification @@ -133,11 +136,6 @@ class User_model return [ "success" => false, 'error' => EMPTY_REQUIRED_FIELDS ]; } - - // TODO: - // check if email exists - // ... - // create an activation code $activation_code = md5($data['email'].time().rand(0, 10000)); @@ -165,7 +163,7 @@ class User_model self::set_user_role($new_user_id, 5); // update history - History::trackUserAccess($new_user_id, TRACK_ACCOUNT, 'Create User Account'); + History_model::trackUserAccess($new_user_id, TRACK_ACCOUNT, 'Create User Account'); // return success and user id return [ @@ -176,6 +174,45 @@ class User_model } + /** activate + * + * check if activation code is valid; + * if valid, set account active; + * + * @param $ticket (hex/MD5): activation code; + * + */ + public static function activate($ticket) + { + $user = Registry::use('database')->query( + "SELECT * FROM user WHERE activation = :ticket", + [ 'ticket' => $ticket ] + )->getFirst(); + + // if no user with this activation code, return false + if ($user === false) return false; + + // remove activation code from user record + Registry::use('database')->runQuery( + "UPDATE user + SET active = 1, `activation` = NULL + WHERE activation = :ticket", + [ 'ticket' => $ticket ] + ); + + // update history + History_model::trackUserAccess($user['id'], TRACK_ACCOUNT, 'User Account Activated'); + + return true; + + } + + + + ## Set permission methods + ## ------------------------------------------------------------------------- + + /** set_user_privileges * * @param $privileges (array) @@ -209,91 +246,24 @@ class User_model } - /** activate - * - * check if activation code is valid; - * if valid, set account active; - * - * @param $ticket (hex/MD5): activation code; + ## List methods + ## ------------------------------------------------------------------------- + + + /** privileges + * --- + * get all privileges (as a list) + * used by cacher; speeds up seveal things * + * @param void + * @return privileges (array) */ - public static function activate($ticket) + public static function privileges() { - $user = Registry::use('database')->query( - "SELECT * FROM user WHERE activation = :ticket", - [ 'ticket' => $ticket ] - )->getFirst(); - - // if no user with this activation code, return false - if ($user === false) return false; - - // remove activation code from user record - Registry::use('database')->runQuery( - "UPDATE user - SET active = 1, `activation` = NULL - WHERE activation = :ticket", - [ 'ticket' => $ticket ] + return Registry::use('database')->runQuery( + "SELECT * FROM privilege",[] ); - - // update history - History::trackUserAccess($user['id'], TRACK_ACCOUNT, 'User Account Activated'); - - return true; - } } - -/* example query getUser (super-array) ---- -- -- - - - - -SELECT user.*, -( -- array (json) of roles granted to user - SELECT CONCAT('[', GROUP_CONCAT(role.id), ']') - FROM `role` - WHERE role.id IN ( - SELECT user_role.role_id - FROM user_role - WHERE user_role.user_id = 1 - ) -) AS Roles_json, -( - SELECT CONCAT( - '[', - GROUP_CONCAT(privilege.id), - ']' - ) - FROM privilege - WHERE privilege.id IN ( - SELECT user_privilege.privilege_id - FROM user_privilege - WHERE user_privilege.user_id = 1 - ) -) AS RootPrivileges_json, -( - SELECT CONCAT( -- array of array of sub-privileges - '[', - GROUP_CONCAT( -- array (json) of subprivileges - ( - SELECT CONCAT( - '[', - GROUP_CONCAT(included_id), - ']' - ) - FROM privilege_includes - WHERE privilege_id = privilege.id - ) - ), - ']' - ) - FROM privilege - WHERE privilege.id IN ( - SELECT user_privilege.privilege_id - FROM user_privilege - WHERE user_id = 1 - ) -) AS SubPrivileges_json -FROM user -WHERE id = 1 ---- */
\ No newline at end of file diff --git a/public/app/models/cms/Course_model.php b/public/app/models/Cms_model.php index 6614993..fad11b8 100644 --- a/public/app/models/cms/Course_model.php +++ b/public/app/models/Cms_model.php @@ -1,10 +1,10 @@ <?php -namespace app\models\cms; +namespace app\models; use \Registry; -class Course_model { +class Cms_model { /** COURSES * ------------------------------------------------------------------------- @@ -143,7 +143,7 @@ class Course_model { * * NOTE: * --- - * Course_model::all_breadcrumbs returns an indexed super-array; + * Cms_model::all_breadcrumbs returns an indexed super-array; * each array item includes a banch of information: [ * breadcrumb, * rec: [ id , title ], diff --git a/public/app/models/admin/History_model.php b/public/app/models/History_model.php index 04ce630..f50539f 100644 --- a/public/app/models/admin/History_model.php +++ b/public/app/models/History_model.php @@ -1,5 +1,5 @@ <?php -namespace app\models\admin; +namespace app\models; use \Registry; diff --git a/public/app/models/admin/Privilege_model.php b/public/app/models/admin/Privilege_model.php deleted file mode 100644 index c385484..0000000 --- a/public/app/models/admin/Privilege_model.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace app\models\admin; - -use Registry; -use Render; - - -class Privilege_model { - - /** privileges - * --- - * get all privileges - * - * @param void - * @return privileges (array) - */ - public static function privileges() - { - return Registry::use('database')->runQuery( - "SELECT * FROM privilege",[] - ); - } - - /** edit privileges - * --- - */ - public static function edit_privileges() - { - // TODO: ... - } - - - /** update course - * --- - */ - public static function update_course() - { - // TODO: ... - } - -}
\ No newline at end of file diff --git a/public/app/models/cms/Media_model.php b/public/app/models/cms/Media_model.php deleted file mode 100644 index 6a4a681..0000000 --- a/public/app/models/cms/Media_model.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace app\models\cms; - -use \Registry; - - -class Media_model -{ - public static function serve($type, $id, $ticket) - { - - // get media data - // [ type =>, rights =>, path => ] - - // validate ticket - // ValidateAccess::for($ticket) - - // serve - // header("Content-type: type"); - // passthru('cat $media_path'); - - - return Registry::use('database')->query( - "SELECT * FROM pages - WHERE FullFriendlyUrl = :url AND IsActive = 1", - [ ':url' => $url ] - )->getFirst(); - } - -} - - - -// check: -// https://stackoverflow.com/questions/1353850/serve-image-with-php-script-vs-direct-loading-an-image
\ No newline at end of file diff --git a/public/app/models/cms/Page_model.php b/public/app/models/cms/Page_model.php deleted file mode 100644 index fda5fb1..0000000 --- a/public/app/models/cms/Page_model.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -namespace app\models\cms; - -use \Registry; - -class Page_model -{ - public static function fromUrl($url) - { - return Registry::use('database')->query( - "SELECT * FROM pages - WHERE FullFriendlyUrl = :url AND IsActive = 1", - [ ':url' => $url ] - )->getFirst(); - } - -}
\ No newline at end of file diff --git a/public/app/models/ideas.md b/public/app/models/ideas.md new file mode 100644 index 0000000..300612d --- /dev/null +++ b/public/app/models/ideas.md @@ -0,0 +1,24 @@ +# interesting projects + +projects for brainstorming + +## php ORM projects + +* [riverside\php-orm](https://github.com/riverside/php-orm) seems the lightest and most promissing + +* https://github.com/mareimorsy/DB + +* https://propelorm.org/ + +* https://redbeanphp.com/index.php?p=/download + +* you can find more in a [related github topic](https://github.com/topics/php-orm) + + +Thoughts: +create a DatabaseModel class (??) based on the riverside\php-orm then use it in anom framerok + + +## php micro-framework + +* [riverside\php-express](https://github.com/riverside/php-express) seems quite interesting diff --git a/public/app/models/todo.md b/public/app/models/todo.md index defd21e..ec027a6 100644 --- a/public/app/models/todo.md +++ b/public/app/models/todo.md @@ -1,55 +1,41 @@ - - -Privilege ---- - -Privilege::list_of_privileges( privilege_id ) - -Privilege::privileges_tree() - - - - - -User +Rearange --- -User::get_privileges +-- #1 -- +[ok] app\controllers\cms\Course -> [*] app\controllers\Course -User::has_privilege( privilege_id ) +[ok] app\controllers\admin\Users_admin -> [delete] +[ok] app\controllers\Admin -> [delete] -User::reset_password() - -> create otp - -> send email +[ok] app\controllers\admin\Course_admin -> [*] app\controllers\Course_admin +[ok] app\models\admin\User_model -> [*] app\models\User_model -User::set_privilege( privilege_id ) +[ok] app\models\admin\Privilege_model -> [merge_to] -> [**] app\models\User_model +[ok] app\models\admin\History_model -> [*] app\models\History_model -User::track_action() - -> user_id - -> action : Contoller::method(args) - -> timestamp +[ok] app\models\cms\Page_model -> [delete] +[ok] app\models\cms\Media_model -> [delete] +[ok] app\models\cms\Course_model -> [*] app\models\Course_model -Lesson: ---- -Lesson::create_lesson( POST ) +[*] = move -Lesson::get_lesson( lesson_id ) +-- #2 -- +[ok] app\controllers\Course -> [rename] app\controllers\Cms -Course ---- +[ok] app\controllers\Course_admin -> [rename] app\controllers\CmsAdmin -Course::create_course( POST ) +[ok] app\models\Course_model -> [rename] app\models\Cms_model -Course::courses_tree() +[ok] app\extends\Send_mail -> [rename] SendMail_service diff --git a/public/app/routes/backend.php b/public/app/routes/backend.php index 2bbd056..027c50a 100644 --- a/public/app/routes/backend.php +++ b/public/app/routes/backend.php @@ -1,7 +1,7 @@ <?php use app\controllers\Auth; -use app\controllers\admin\Course_admin; +use app\controllers\CmsAdmin; use app\models\admin\Privilege_model; use app\extends\Cache_service; @@ -45,17 +45,17 @@ Route::add('/admin/categories', function () { // manage categories page Route::add('/admin/api/categories', function () { // ajax: get all courses; with breadcrumbs Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::breadcrumbs(); + CmsAdmin::breadcrumbs(); }); Route::add('/admin/api/categories/add', function () { // ajax: add new category (course) Auth::allowRoles([1, 2, 3]); - Course_admin::add_course(); + CmsAdmin::add_course(); }, 'post'); Route::add('/admin/api/categories/update', function () { // ajax: edit category (course) Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::update_course(); + CmsAdmin::update_course(); }, 'post'); @@ -116,25 +116,25 @@ Route::add('/admin/edit_lesson/([0-9]*)', function ($id) { // edit lesson f Route::add('/admin/api/lesson/([0-9]*)', function ($id) { // ajax: get lesson Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::get_lesson($id); + CmsAdmin::get_lesson($id); }); Route::add('/admin/api/lesson/add', function () { // ajax: add lesson Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json(['success' => Course_admin::add_lesson()]); + Render::json(['success' => CmsAdmin::add_lesson()]); }, 'post'); Route::add('/admin/api/lesson/update', function () { // ajax: update lesson Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json(['success' => Course_admin::update_lesson()]); + Render::json(['success' => CmsAdmin::update_lesson()]); }, 'post'); Route::add('/admin/api/lessons', function () { // ajax: get all lessons Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::all_lessons(); + CmsAdmin::all_lessons(); }); @@ -153,14 +153,14 @@ Route::add('/admin/files', function () { // admin-files panel Route::add('/admin/api/files', function () { // ajax: get lesson Auth::allowRoles([1, 2, 3]); - Render::json(Course_admin::files()); + Render::json(CmsAdmin::files()); }); // ajax: file-upload // --- Route::add('/admin/api/file_upload', function () { Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json(Course_admin::upload_file()); + Render::json(CmsAdmin::upload_file()); }, 'post'); @@ -198,24 +198,24 @@ Route::add('/admin/edit_page/([0-9]*)', function ($id) { // edit page form Route::add('/admin/api/page/([0-9]*)', function ($id) { // ajax: get page Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::get_page($id); + CmsAdmin::get_page($id); }); Route::add('/admin/api/page/add', function () { // ajax: add page Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json(['success' => Course_admin::add_page()]); + Render::json(['success' => CmsAdmin::add_page()]); }, 'post'); Route::add('/admin/api/page/update', function () { // ajax: update page Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Render::json(['success' => Course_admin::update_page()]); + Render::json(['success' => CmsAdmin::update_page()]); }, 'post'); Route::add('/admin/api/pages', function () { // ajax: get all pages Auth::allowRoles([1, 2, 3]); // allow few admin-panel roles - Course_admin::all_pages(); + CmsAdmin::all_pages(); }); diff --git a/public/app/routes/frontend.php b/public/app/routes/frontend.php index be06b1c..96e9786 100644 --- a/public/app/routes/frontend.php +++ b/public/app/routes/frontend.php @@ -2,8 +2,7 @@ use app\controllers\Auth; use app\controllers\Classroom_user; -use app\controllers\cms\Course; -use app\models\cms\Course_model; +use app\controllers\Cms; use app\extends\Cache_service; @@ -34,19 +33,19 @@ Route::notFound( function() { // 404 error page Route::add('/course/([0-9]*)', // request course by course-id - function($id) { Course::course($id); } + function($id) { Cms::course($id); } ); Route::add('/lesson/([0-9]*)', // request lesson by lesson-id - function($id) { Course::lesson($id); } + function($id) { Cms::lesson($id); } ); Route::add('/page/([0-9]*)', // request lesson by lesson-id - function($id) { Course::page($id); } + function($id) { Cms::page($id); } ); Route::add('/serve/file/([0-9a-zA-Z-_\.\/]*)', // serve file by path - function ($path) { Course::serve_file($path); } // (also ?type= is sent) + function ($path) { Cms::serve_file($path); } // (also ?type= is sent) ); |
