summaryrefslogtreecommitdiff
path: root/public/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/models')
-rw-r--r--public/app/models/Access_model.php54
-rw-r--r--public/app/models/Content_model.php30
2 files changed, 83 insertions, 1 deletions
diff --git a/public/app/models/Access_model.php b/public/app/models/Access_model.php
index 844ff6b..5c9f991 100644
--- a/public/app/models/Access_model.php
+++ b/public/app/models/Access_model.php
@@ -41,7 +41,7 @@ class Access_model
{
return Registry::use('database')->query(
"SELECT * FROM user WHERE invitation = :invitation",
- ['invitation' => $invitation]
+ [ 'invitation' => $invitation ]
)->getFirst();
}
@@ -166,6 +166,58 @@ class Access_model
+ /** update_user
+ *
+ * activate user and set password
+ *
+ * @param array $post;
+ * @param int $id: user id
+ */
+ public static function update_user($post, $id)
+ {
+ // Update and set activate = true
+ $rowCount = Registry::use('database')->query(
+ "UPDATE user
+ SET first_name = :first_name,
+ last_name = :last_name,
+ email = :email,
+ father_name = :father_name,
+ registration_number = :registration_number,
+ sector = :sector,
+ belonging_school = :belonging_school,
+ position = :position,
+ phone = :phone,
+ invitation = NULL,
+ active = :active
+ WHERE id = :id",
+ [
+ ':first_name' => $post['first_name'],
+ ':last_name' => $post['last_name'],
+ ':email' => $post['email'],
+ ':father_name' => $post['father_name'],
+ ':registration_number' => $post['registration_number'],
+ ':sector' => $post['sector'],
+ ':belonging_school' => $post['belonging_school'],
+ ':position' => $post['position'],
+ ':phone' => $post['phone'],
+ ':active' => 1,
+ ':id' => $id
+ ]
+ )->rowCount();
+
+ // update history
+ if ($rowCount != 0) {
+ History_model::trackUserAccess(
+ $id, TRACK_ACCOUNT, 'User properties changed'
+ );
+ }
+
+ return $rowCount;
+
+ }
+
+
+
## Set permission methods
## -------------------------------------------------------------------------
diff --git a/public/app/models/Content_model.php b/public/app/models/Content_model.php
index 2a79159..1f145a0 100644
--- a/public/app/models/Content_model.php
+++ b/public/app/models/Content_model.php
@@ -73,6 +73,7 @@ class Content_model {
'subject' => $rec['subject'],
'signature' => $rec['signature'],
'protocol' => $rec['protocol'] ?? '',
+ 'creation_date' => date("Y-m-d", strtotime($rec['creation_date'])),
'form_structure' => unserialize($rec['form_structure'])
];
}
@@ -96,6 +97,35 @@ class Content_model {
}
+ public static function get_petition($filters)
+ {
+ $where = [];
+ $binds = [];
+ foreach($filters as $key => $val) {
+ $where[] = $key ." = :". $key;
+ $binds[':'.$key] = $val;
+ }
+
+ $rec = Registry::use('database')->query(
+ "SELECT * FROM petition WHERE ". implode(" AND ", $where),
+ $filters
+ )->getFirst();
+
+ if ($rec === false) return false;
+ else {
+ return [
+ 'id' => $rec['id'],
+ 'type' => (($rec['type_id'] == 1) ? 'application' : 'penalty'),
+ 'subject' => $rec['subject'],
+ 'signature' => $rec['signature'],
+ 'protocol' => $rec['protocol'] ?? false,
+ 'creation_date' => date("Y-m-d", strtotime($rec['creation_date'])),
+ 'form_structure' => unserialize($rec['form_structure'])
+ ];
+ }
+ }
+
+
## F I L E S
## -------------------------------------------------------------------------