[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/notification/type/ -> bookmark.php (source)

   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      static public $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          $notified_users = $this->notification_manager->get_notified_users($this->get_type(), array(
  95              'item_parent_id'    => static::get_item_parent_id($post),
  96              'read'                => 0,
  97          ));
  98  
  99          foreach ($notified_users as $user => $notification_data)
 100          {
 101              unset($notify_users[$user]);
 102  
 103              /** @var bookmark $notification */
 104              $notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
 105              $update_responders = $notification->add_responders($post);
 106              if (!empty($update_responders))
 107              {
 108                  $this->notification_manager->update_notification($notification, $update_responders, array(
 109                      'item_parent_id'    => self::get_item_parent_id($post),
 110                      'read'                => 0,
 111                      'user_id'            => $user,
 112                  ));
 113              }
 114          }
 115  
 116          return $notify_users;
 117      }
 118  
 119      /**
 120      * Get email template
 121      *
 122      * @return string|bool
 123      */
 124  	public function get_email_template()
 125      {
 126          return 'bookmark';
 127      }
 128  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1