Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
bookmark.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\notification\type;
015
016 /**
017 * Bookmark updating notifications class
018 * This class handles notifications for replies to a bookmarked topic
019 */
020
021 class bookmark extends \phpbb\notification\type\post
022 {
023 /**
024 * Get notification type name
025 *
026 * @return string
027 */
028 public function get_type()
029 {
030 return 'notification.type.bookmark';
031 }
032
033 /**
034 * Language key used to output the text
035 *
036 * @var string
037 */
038 protected $language_key = 'NOTIFICATION_BOOKMARK';
039
040 /**
041 * Notification option data (for outputting to the user)
042 *
043 * @var bool|array False if the service should use it's default data
044 * Array of data (including keys 'id', 'lang', and 'group')
045 */
046 public static $notification_option = array(
047 'lang' => 'NOTIFICATION_TYPE_BOOKMARK',
048 'group' => 'NOTIFICATION_GROUP_POSTING',
049 );
050
051 /**
052 * Is available
053 */
054 public function is_available()
055 {
056 return $this->config['allow_bookmarks'];
057 }
058
059 /**
060 * Find the users who want to receive notifications
061 *
062 * @param array $post Data from submit_post
063 * @param array $options Options for finding users for notification
064 *
065 * @return array
066 */
067 public function find_users_for_notification($post, $options = array())
068 {
069 $options = array_merge(array(
070 'ignore_users' => array(),
071 ), $options);
072
073 $users = array();
074
075 $sql = 'SELECT user_id
076 FROM ' . BOOKMARKS_TABLE . '
077 WHERE ' . $this->db->sql_in_set('topic_id', $post['topic_id']) . '
078 AND user_id <> ' . (int) $post['poster_id'];
079 $result = $this->db->sql_query($sql);
080 while ($row = $this->db->sql_fetchrow($result))
081 {
082 $users[] = (int) $row['user_id'];
083 }
084 $this->db->sql_freeresult($result);
085
086 $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
087
088 if (empty($notify_users))
089 {
090 return array();
091 }
092
093 // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications
094 $update_notifications = array();
095 $sql = 'SELECT n.*
096 FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt
097 WHERE n.notification_type_id = ' . (int) $this->notification_type_id . '
098 AND n.item_parent_id = ' . (int) self::get_item_parent_id($post) . '
099 AND n.notification_read = 0
100 AND nt.notification_type_id = n.notification_type_id
101 AND nt.notification_type_enabled = 1';
102 $result = $this->db->sql_query($sql);
103 while ($row = $this->db->sql_fetchrow($result))
104 {
105 // Do not create a new notification
106 unset($notify_users[$row['user_id']]);
107
108 $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
109 $update_responders = $notification->add_responders($post);
110 if (!empty($update_responders))
111 {
112 $sql = 'UPDATE ' . $this->notifications_table . '
113 SET ' . $this->db->sql_build_array('UPDATE', $update_responders) . '
114 WHERE notification_id = ' . $row['notification_id'];
115 $this->db->sql_query($sql);
116 }
117 }
118 $this->db->sql_freeresult($result);
119
120 return $notify_users;
121 }
122
123 /**
124 * Get email template
125 *
126 * @return string|bool
127 */
128 public function get_email_template()
129 {
130 return 'bookmark';
131 }
132 }
133