| Server IP : 188.114.96.2 / Your IP : 104.23.197.231 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/sms.formationlangues.be/application/models/ |
Upload File : |
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Notification_model extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->model('crud_model');
$this->load->model('profile_model');
$this->load->model('email_model');
$this->load->model('mbox_model');
}
public function is_new_mail($user_id, $mail_id, $current_snapshot)
{
$last_snapshot = $this->get_mail_snapshot($user_id, $mail_id);
if ($current_snapshot == $last_snapshot) {
return true;
} else {
return false;
}
}
public function store_mail_snapshot($user_id, $mail_id, $snapshot)
{
$sql = array(
'Mail_ID' => $mail_id,
'User_ID' => $user_id,
'Snapshot' => $snapshot
);
$q = $this->db->get_where('notification_mail', array('Mail_ID' => $mail_id,'User_ID' => $user_id));
// $q = $this->db->get('notification_mail');
if ($q->num_rows() > 0) {
$this->db->where(array('Mail_ID' => $mail_id,'User_ID' => $user_id));
$this->db->update('notification_mail', $sql);
return "update";
} else {
var_dump($sql);
$this->db->insert('notification_mail', $this->crud_model->cleanArray($sql));
return $this->db->insert_id();
}
}
public function get_mail_snapshot($user_id, $mail_id)
{
$query = $this->db->get_where('notification_mail', array('Mail_ID' => $mail_id,'User_ID' => $user_id));
$query = $query->result_array();
return $query[0]['Snapshot'];
}
public function get_notification_type()
{
$this->db->order_by('ID', 'ASC');
$query = $this->db->get('notification_type');
$query = $query->result_array();
return $query;
}
public function get_notification_senders()
{
$this->db->order_by('ID', 'ASC');
$query = $this->db->get('notification_senders');
$query = $query->result_array();
return $query;
}
public function get_notification_type_name($id)
{
$query = $this->db->get_where('notification_type', array('ID' => $id));
$query = $query->result_array();
return $query[0]['Name'];
}
public function get_notification_sender_mail($id, $course = "#")
{
$query = $this->db->get_where('notification_senders', array('ID' => $id));
$query = $query->result_array();
return $query[0]['Mail'];
}
public function notify_presence($lesson, $mail_type, $mail_sender)
{
//$this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
if (!isset($lesson)) {
$lesson = $this->input->post('lesson');
}
$query = $this->db->get_where('course_student_new', array('lesson_id' => $lesson));
$query = $query->result_array();
$data = array();
//var_dump($query);
foreach ($query as $key => $row) {
if ($row['status_id'] != "0") {
$lang = $this->profile_model->get_user_master_lang($row['student_id']);
array_push($data, $this->email_model->presence_notification_email($row['student_id'], $row['lesson_id'], $row['course_id'], $row['status_id'], $lang, $mail_sender, $mail_type));
}
}
$this->db->set(array("LessonLocked" => "1"));
$this->db->where('ID', $lesson);
$this->db->update('course_scheduled_new');
//echo "ok";
return $data;
}
public function notify_course_start($lesson, $mail_type, $mail_sender)
{
//$this->continueIfAllowed(array('allowed'=>array('admin','teacher')));
$query = $this->db->get_where('course_student_new', array('lesson_id' => $lesson));
$query = $query->result_array();
$data = array();
//var_dump($query);
foreach ($query as $key => $row) {
$lang = $this->profile_model->get_user_master_lang($row['student_id']);
array_push($data, $this->email_model->course_start_notification_email($row['student_id'], $row['lesson_id'], $row['course_id'], $lang, $mail_sender, $mail_type));
}
$this->db->set(array("LessonNotified" => '1'));
$this->db->where('ID', $lesson);
$this->db->update('course_scheduled_new');
//echo "ok";
return $data;
}
public function get_user_notifications($u)
{
$q = $this->db->get_where('notification_history',array('User_ID' => $u))->result_array();
return $q;
}
}