โดย Ittichai_chupol » 25/02/2019 11:43 am
โค้ด: เลือกทั้งหมด
public function find_users_for_notification($data, $options = array()) {
// $this->notifications_table $this->notification_types_table
// print_r($data);
$update_notifications = array();
$sql = 'SELECT n.*
FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
AND n.item_parent_id = ' . (int) self::get_item_parent_id($data) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
//echo $sql;
$result = $this->db->sql_query($sql);
$nofify_user = $this->db->sql_fetchrow($result);
if ($nofify_user) {
// print_r($nofify_user); exit;
foreach ($nofify_user as $row) {
// Do not create a new notification
//unset($notify_users[$row['user_id']]);
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $nofify_user);
$update_responders = $notification->add_responders($data);
if (!empty($update_responders)) {
$sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
WHERE notification_id = ' . $nofify_user['notification_id'];
$this->db->sql_query($sql);
}
}
} else {
$users = array();
$users[$data['user_id']] = array('');
$this->user_loader->load_users(array_keys($users));
return $this->check_user_notification_options(array_keys($users), $options);
}
}
ส่วนการทำงาน นี้เป็นส่วนสุดท้ายที่ บางครั่ง หลังจากมาถึง ส่วนนี้ก็ไม่มีการส่งค่าไปต่อที่อื่น ทำให้ไม่สามรถที่จะบันทึก ผล ไปยังตาราง notification ได้
[code]
public function find_users_for_notification($data, $options = array()) {
// $this->notifications_table $this->notification_types_table
// print_r($data);
$update_notifications = array();
$sql = 'SELECT n.*
FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . ' nt
WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
AND n.item_parent_id = ' . (int) self::get_item_parent_id($data) . '
AND n.notification_read = 0
AND nt.notification_type_id = n.notification_type_id
AND nt.notification_type_enabled = 1';
//echo $sql;
$result = $this->db->sql_query($sql);
$nofify_user = $this->db->sql_fetchrow($result);
if ($nofify_user) {
// print_r($nofify_user); exit;
foreach ($nofify_user as $row) {
// Do not create a new notification
//unset($notify_users[$row['user_id']]);
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $nofify_user);
$update_responders = $notification->add_responders($data);
if (!empty($update_responders)) {
$sql = 'UPDATE ' . $this->notifications_table . '
SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
WHERE notification_id = ' . $nofify_user['notification_id'];
$this->db->sql_query($sql);
}
}
} else {
$users = array();
$users[$data['user_id']] = array('');
$this->user_loader->load_users(array_keys($users));
return $this->check_user_notification_options(array_keys($users), $options);
}
}
[/code]
ส่วนการทำงาน นี้เป็นส่วนสุดท้ายที่ บางครั่ง หลังจากมาถึง ส่วนนี้ก็ไม่มีการส่งค่าไปต่อที่อื่น ทำให้ไม่สามรถที่จะบันทึก ผล ไปยังตาราง notification ได้