summaryrefslogtreecommitdiff
path: root/html/app/models
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-17 03:13:28 +0200
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-17 03:13:28 +0200
commitd90b51ce89bcc693e3014b313fe8e3b975031adf (patch)
tree782cb2203e813ade37fe20ebf5dfcabe0d83d7d0 /html/app/models
parent26229c110fb92646b36c7b2f48ac7518fd3810a5 (diff)
downloadclassroom-tests.tar.gz
classroom-tests.tar.bz2
classroom-tests.zip
introduced history; will track user accesstests
Diffstat (limited to 'html/app/models')
-rw-r--r--html/app/models/admin/History_model.php9
-rw-r--r--html/app/models/admin/User_model.php23
2 files changed, 20 insertions, 12 deletions
diff --git a/html/app/models/admin/History_model.php b/html/app/models/admin/History_model.php
index 63086e3..638ac62 100644
--- a/html/app/models/admin/History_model.php
+++ b/html/app/models/admin/History_model.php
@@ -3,7 +3,7 @@
namespace app\models\admin;
use \Registry;
-use app\models\admin\history;
+
class User_model
{
@@ -21,6 +21,13 @@ class User_model
'ip' => Registry::get('REQUEST')->IP
];
+ Registry::use('database')->query(
+ "INSERT INTO history
+ (user_id, `type`, `message`, note, ip)
+ VALUES (:user_id, :type, :message, note, :ip)",
+ [ $access ]
+ )->lastInsertID();
+
}
diff --git a/html/app/models/admin/User_model.php b/html/app/models/admin/User_model.php
index 63d826f..80ce113 100644
--- a/html/app/models/admin/User_model.php
+++ b/html/app/models/admin/User_model.php
@@ -3,7 +3,7 @@
namespace app\models\admin;
use \Registry;
-use app\models\admin\history;
+use app\models\admin\History_model as History;
class User_model
{
@@ -128,26 +128,27 @@ class User_model
'active' => 0 // needs email confirmation
];
- $sql = "INSERT INTO user (`prefix`, `name`, `surname`, email, `password`, user_id)
- VALUES (:prrfic, :name, :surname, :email, :password, :userid)";
- $stmt = $this->pdo->prepare($sql);
- $stmt->execute($user);
-
- $inserted_id = $this->pdo->lastInsertId();
+ // insert new user record
+ $new_user_id = Registry::use('database')->query(
+ "INSERT INTO user
+ (`prefix`, `name`, `surname`, email, `password`, user_id)
+ VALUES
+ (:prefic, :name, :surname, :email, :password, :userid)"
+ [ $user ]
+ )->lastInsertID();
// set default privileges
self::set_user_privileges($privileges);
// update history
+ History::trackUserAccess($new_user_id, TRACK_ACCOUNT, 'Create User Account');
-
-
- return [ "success" => true, 'id' => $inserted_id ];
+ // return success and user id
+ return [ "success" => true, 'id' => $new_user_id ];
}
-
/** inherited privileges
*
* list of all inhereted (sub-)privileges