[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\notification\type; 15 16 /** 17 * Bookmark updating notifications class 18 * This class handles notifications for replies to a bookmarked topic 19 */ 20 21 class bookmark extends \phpbb\notification\type\post 22 { 23 /** 24 * Get notification type name 25 * 26 * @return string 27 */ 28 public function get_type() 29 { 30 return 'notification.type.bookmark'; 31 } 32 33 /** 34 * Language key used to output the text 35 * 36 * @var string 37 */ 38 protected $language_key = 'NOTIFICATION_BOOKMARK'; 39 40 /** 41 * Notification option data (for outputting to the user) 42 * 43 * @var bool|array False if the service should use it's default data 44 * Array of data (including keys 'id', 'lang', and 'group') 45 */ 46 public static $notification_option = array( 47 'lang' => 'NOTIFICATION_TYPE_BOOKMARK', 48 'group' => 'NOTIFICATION_GROUP_POSTING', 49 ); 50 51 /** 52 * Is available 53 */ 54 public function is_available() 55 { 56 return $this->config['allow_bookmarks']; 57 } 58 59 /** 60 * Find the users who want to receive notifications 61 * 62 * @param array $post Data from submit_post 63 * @param array $options Options for finding users for notification 64 * 65 * @return array 66 */ 67 public function find_users_for_notification($post, $options = array()) 68 { 69 $options = array_merge(array( 70 'ignore_users' => array(), 71 ), $options); 72 73 $users = array(); 74 75 $sql = 'SELECT user_id 76 FROM ' . BOOKMARKS_TABLE . ' 77 WHERE ' . $this->db->sql_in_set('topic_id', $post['topic_id']) . ' 78 AND user_id <> ' . (int) $post['poster_id']; 79 $result = $this->db->sql_query($sql); 80 while ($row = $this->db->sql_fetchrow($result)) 81 { 82 $users[] = (int) $row['user_id']; 83 } 84 $this->db->sql_freeresult($result); 85 86 $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true); 87 88 if (empty($notify_users)) 89 { 90 return array(); 91 } 92 93 // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications 94 $update_notifications = array(); 95 $sql = 'SELECT n.* 96 FROM ' . $this->notifications_table . ' n, ' . $this->notification_types_table . ' nt 97 WHERE n.notification_type_id = ' . (int) $this->notification_type_id . ' 98 AND n.item_parent_id = ' . (int) static::get_item_parent_id($post) . ' 99 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |