summaryrefslogtreecommitdiff
path: root/public/app/controllers/Office.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-06-12 01:12:30 +0300
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-06-12 01:12:30 +0300
commit5375e22de976b74f5f04d800014c30d9c66f0fe5 (patch)
tree3f9d79b898c4bbb392c2a4ec5ec65c0fde5c6f01 /public/app/controllers/Office.php
parent0b0076b2ece062f248b7c048d6bb28abbe9174a5 (diff)
downloadgyraf1gov-5375e22de976b74f5f04d800014c30d9c66f0fe5.tar.gz
gyraf1gov-5375e22de976b74f5f04d800014c30d9c66f0fe5.tar.bz2
gyraf1gov-5375e22de976b74f5f04d800014c30d9c66f0fe5.zip
official Reliese Candidate; themes added; routes organized; fine tuning
Diffstat (limited to 'public/app/controllers/Office.php')
-rw-r--r--public/app/controllers/Office.php51
1 files changed, 21 insertions, 30 deletions
diff --git a/public/app/controllers/Office.php b/public/app/controllers/Office.php
index 79f76d8..4161efc 100644
--- a/public/app/controllers/Office.php
+++ b/public/app/controllers/Office.php
@@ -7,6 +7,7 @@ use Render;
use app\controllers\Auth;
use app\extends\App_manager;
use app\models\Content_model;
+use app\models\Access_model;
use app\extends\SendMail_service;
use app\extends\Cache_service;
@@ -225,7 +226,7 @@ class Office {
// #3.1: get all teachers
$teachers_array = Registry::use('database')->runQuery(
"SELECT concat(last_name, ' ', first_name) as TeacherName
- FROM user ORDER BY TeacherName", []
+ FROM user WHERE deprecated IS NULL ORDER BY last_name, first_name", []
);
$teachers = []; // constuct teacher names as a simple array
foreach($teachers_array as $key => $person) {
@@ -323,18 +324,9 @@ class Office {
}
- public static function all_petitions()
- {
- if (Auth::in_admin_group()) {
- Render::json([
- 'success' => true,
- 'data' => Content_model::all_petitions()
- ]);
- }
- }
- ## SEND INVITATION
+ ## SEND INVITATION(s)
## -------------------------------------------------------------------------
public static function send_invitation()
@@ -359,11 +351,12 @@ class Office {
"SELECT * FROM user
WHERE id IN ( $all_handlers ) AND (
otp_expiration < :now OR otp_expiration IS NULL
- )",
+ ) AND deprecated IS NULL",
$binds
);
$sent = [];
+ $failed = [];
foreach($recipients as $key => $rec) {
$invitation = md5(
@@ -373,36 +366,34 @@ class Office {
. rand(0, 999999)
);
- /*
$gone = SendMail_service::send_invitation([
'email' => $rec['email'],
- 'name' => $rec['last_name'] .' '. $rec['fisrt_name'],
+ 'name' => $rec['last_name'] .' '. $rec['first_name'],
'code' => $invitation
- ])
+ ]);
- if ($gone) {
- // update user record with invitation
- Registry::use('database')->runQuery(
- "UPDATE user SET invitatopm = :inv WHERE id = :id",
- [ ':inv' => $invitation, ':id' => $rec['id'] ]
- );
+ if ($gone === true) {
+ // update user record with invitation;
+ Access_model::invite_user($rec['id'], $invitation, $expiration);
- $sent[] = $rec['first_name']
- ." ". $rec['last_name']
+ $sent[] = $rec['last_name'] // keep data for echoing
+ ." ". $rec['first_name']
." (". $rec['id'] .")"
.": ". $invitation;
- }
- */
- $sent[] = $rec['first_name']
- ." ". $rec['last_name']
- ." (". $rec['id'] .")"
- .": ". $invitation;
+ } else {
+ $failed[] = [
+ 'rec' => $rec['last_name'] ." ". $rec['first_name']
+ ." (". $rec['id'] .")",
+ 'mdg' => $gone
+ ];
+ }
}
return Render::json([
- 'success' => true,
+ 'success' => (empty($failed)),
'sent' => implode(",\n\n", $sent),
+ 'failed' => $failed
]);
}