diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 19:48:22 -0400 |
commit | 14713b0ec7ed93ca45578da069ad4e19a7d8addf (patch) | |
tree | 79972d53f6091a1ddb17f64a6a05a5523f5d5168 /app/Model/UserUnreadNotification.php | |
parent | 936376ffe74c583d3cb819e98f53a85137fdf8bc (diff) |
Rename all models
Diffstat (limited to 'app/Model/UserUnreadNotification.php')
-rw-r--r-- | app/Model/UserUnreadNotification.php | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/app/Model/UserUnreadNotification.php b/app/Model/UserUnreadNotification.php deleted file mode 100644 index f3fcd601..00000000 --- a/app/Model/UserUnreadNotification.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -namespace Kanboard\Model; - -use Kanboard\Core\Base; - -/** - * User Unread Notification - * - * @package model - * @author Frederic Guillot - */ -class UserUnreadNotification extends Base -{ - /** - * SQL table name - * - * @var string - */ - const TABLE = 'user_has_unread_notifications'; - - /** - * Add unread notification to someone - * - * @access public - * @param integer $user_id - * @param string $event_name - * @param array $event_data - */ - public function create($user_id, $event_name, array $event_data) - { - $this->db->table(self::TABLE)->insert(array( - 'user_id' => $user_id, - 'date_creation' => time(), - 'event_name' => $event_name, - 'event_data' => json_encode($event_data), - )); - } - - /** - * Get one notification - * - * @param integer $notification_id - * @return array|null - */ - public function getById($notification_id) - { - $notification = $this->db->table(self::TABLE)->eq('id', $notification_id)->findOne(); - - if (! empty($notification)) { - $this->unserialize($notification); - } - - return $notification; - } - - /** - * Get all notifications for a user - * - * @access public - * @param integer $user_id - * @return array - */ - public function getAll($user_id) - { - $events = $this->db->table(self::TABLE)->eq('user_id', $user_id)->asc('date_creation')->findAll(); - - foreach ($events as &$event) { - $this->unserialize($event); - } - - return $events; - } - - /** - * Mark a notification as read - * - * @access public - * @param integer $user_id - * @param integer $notification_id - * @return boolean - */ - public function markAsRead($user_id, $notification_id) - { - return $this->db->table(self::TABLE)->eq('id', $notification_id)->eq('user_id', $user_id)->remove(); - } - - /** - * Mark all notifications as read for a user - * - * @access public - * @param integer $user_id - * @return boolean - */ - public function markAllAsRead($user_id) - { - return $this->db->table(self::TABLE)->eq('user_id', $user_id)->remove(); - } - - /** - * Return true if the user as unread notifications - * - * @access public - * @param integer $user_id - * @return boolean - */ - public function hasNotifications($user_id) - { - return $this->db->table(self::TABLE)->eq('user_id', $user_id)->exists(); - } - - private function unserialize(&$event) - { - $event['event_data'] = json_decode($event['event_data'], true); - $event['title'] = $this->notification->getTitleWithoutAuthor($event['event_name'], $event['event_data']); - } -} |