summaryrefslogtreecommitdiff
path: root/public/app/controllers
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 20:18:01 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-04-27 20:18:01 +0300
commita2e68fce808dbe6fba320a6232a15380b63157f6 (patch)
treeb6ceaf603b2237c328707c152233304b9a511b9e /public/app/controllers
parent059e0d95d0c28bc5060e87e146eaf7411f51bf90 (diff)
downloadgyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.tar.gz
gyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.tar.bz2
gyraf1gov-a2e68fce808dbe6fba320a6232a15380b63157f6.zip
structure simplified
Diffstat (limited to 'public/app/controllers')
-rw-r--r--public/app/controllers/Admin.php58
-rw-r--r--public/app/controllers/Auth.php15
-rw-r--r--public/app/controllers/Cms.php (renamed from public/app/controllers/cms/Course.php)49
-rw-r--r--public/app/controllers/CmsAdmin.php (renamed from public/app/controllers/admin/Course_admin.php)6
-rw-r--r--public/app/controllers/admin/.gitkeep0
-rw-r--r--public/app/controllers/admin/Users_admin.php42
-rw-r--r--public/app/controllers/cli/CliContoller.php4
7 files changed, 40 insertions, 134 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
);