[ Index ]

PHP Cross Reference of phpBB-3.3.2-deutsch

title

Body

[close]

/phpbb/notification/type/ -> forum.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   * Forum notifications class
  18   * This class handles notifications for replies to a topic in a forum user subscribed to
  19   */
  20  
  21  class forum 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.forum';
  31      }
  32  
  33      /**
  34       * Notification option data (for outputting to the user)
  35       *
  36       * @var bool|array False if the service should use its default data
  37       *                     Array of data (including keys 'id', 'lang', and 'group')
  38       */
  39      static public $notification_option = [
  40          'lang'    => 'NOTIFICATION_TYPE_FORUM',
  41          'group'    => 'NOTIFICATION_GROUP_POSTING',
  42      ];
  43  
  44      /**
  45       * Find the users who want to receive notifications
  46       *
  47       * @param array $post Data from submit_post
  48       * @param array $options Options for finding users for notification
  49       *
  50       * @return array
  51       */
  52  	public function find_users_for_notification($post, $options = [])
  53      {
  54          $options = array_merge([
  55              'ignore_users'        => [],
  56          ], $options);
  57  
  58          $users = [];
  59  
  60          $sql = 'SELECT user_id
  61              FROM ' . FORUMS_WATCH_TABLE . '
  62              WHERE forum_id = ' . (int) $post['forum_id'] . '
  63                  AND notify_status = ' . NOTIFY_YES . '
  64                  AND user_id <> ' . (int) $post['poster_id'];
  65          $result = $this->db->sql_query($sql);
  66          while ($row = $this->db->sql_fetchrow($result))
  67          {
  68              $users[] = (int) $row['user_id'];
  69          }
  70          $this->db->sql_freeresult($result);
  71  
  72          $notify_users = $this->get_authorised_recipients($users, $post['forum_id'], $options, true);
  73  
  74          if (empty($notify_users))
  75          {
  76              return [];
  77          }
  78  
  79          // Try to find the users who already have been notified about replies and have not read them
  80          // Just update their notifications
  81          $notified_users = $this->notification_manager->get_notified_users($this->get_type(), [
  82              'item_parent_id'    => static::get_item_parent_id($post),
  83              'read'                => 0,
  84          ]);
  85  
  86          foreach ($notified_users as $user => $notification_data)
  87          {
  88              unset($notify_users[$user]);
  89  
  90              /** @var post $notification */
  91              $notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
  92              $update_responders = $notification->add_responders($post);
  93              if (!empty($update_responders))
  94              {
  95                  $this->notification_manager->update_notification($notification, $update_responders, [
  96                      'item_parent_id'    => self::get_item_parent_id($post),
  97                      'read'                => 0,
  98                      'user_id'            => $user,
  99                  ]);
 100              }
 101          }
 102  
 103          return $notify_users;
 104      }
 105  
 106      /**
 107       * Get email template
 108       *
 109       * @return string|bool
 110       */
 111  	public function get_email_template()
 112      {
 113          return 'forum_notify';
 114      }
 115  
 116      /**
 117       * Get email template variables
 118       *
 119       * @return array
 120       */
 121  	public function get_email_template_variables()
 122      {
 123          if ($this->get_data('post_username'))
 124          {
 125              $username = $this->get_data('post_username');
 126          }
 127          else
 128          {
 129              $username = $this->user_loader->get_username($this->get_data('poster_id'), 'username');
 130          }
 131  
 132          return [
 133              'AUTHOR_NAME'                => htmlspecialchars_decode($username),
 134              'FORUM_NAME'                => htmlspecialchars_decode(censor_text($this->get_data('forum_name'))),
 135              'POST_SUBJECT'                => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
 136              'TOPIC_TITLE'                => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
 137  
 138              'U_VIEW_POST'                => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
 139              'U_NEWEST_POST'                => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&e=1&view=unread#unread",
 140              'U_TOPIC'                    => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 141              'U_VIEW_TOPIC'                => generate_board_url() . "/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 142              'U_FORUM'                    => generate_board_url() . "/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}",
 143              'U_STOP_WATCHING_FORUM'        => generate_board_url() . "/viewtopic.{$this->php_ext}?uid={$this->user_id}&f={$this->get_data('forum_id')}&t={$this->item_parent_id}&unwatch=forum",
 144          ];
 145      }
 146  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1