/** * Identical portrayal of markread() function to handle the custom notification for mark reads. * Most code is copy'n'pasted. * * @param string $mode (all, topics, topic, post) * @param int|bool $forum_id Used in all, topics, and topic mode * @param int|bool $topic_id Used in topic and post mode * @param int $post_time 0 means current time(), otherwise to set a specific mark time * @param int $user_id can only be used with $mode == 'post' */ public function markread_notifications($mode, $forum_id = false, $topic_id = false, $post_time = 0, $user_id = 0) { $post_time = $post_time === 0 || $post_time > time() ? time() : (int) $post_time; if ($mode == 'all') { if ($forum_id === false || !sizeof($forum_id)) { // Mark all forums read (index page) // Mark all topic notifications read for this user $this->notification_manager->mark_notifications_read(array('wolfsblvt.mentions.notification.type.mention'), false, $this->user->data['user_id'], $post_time); } else { if ($mode == 'topics') { // Mark all topics in forums read if (!is_array($forum_id)) { $forum_id = array($forum_id); } // Mark all mention notifications read for this user in this forum $topic_ids = array(); $sql = 'SELECT topic_id FROM ' . TOPICS_TABLE . ' WHERE ' . $this->db->sql_in_set('forum_id', $forum_id); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $topic_ids[] = $row['topic_id']; } $this->db->sql_freeresult($result); $this->notification_manager->mark_notifications_read_by_parent(array('wolfsblvt.mentions.notification.type.mention'), $topic_ids, $this->user->data['user_id'], $post_time); } else { if ($mode == 'topic') { if ($topic_id === false || $forum_id === false) { return; } $this->notification_manager->mark_notifications_read_by_parent(array('wolfsblvt.mentions.notification.type.mention'), $topic_id, $this->user->data['user_id'], $post_time); } } } } }