[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/notification/type/ -> report_post_closed.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  * Post report closed notifications class
  18  * This class handles notifications for when reports are closed on posts (for the one who reported the post)
  19  */
  20  
  21  class report_post_closed 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.report_post_closed';
  31      }
  32  
  33      /**
  34      * Email template to use to send notifications
  35      *
  36      * @var string
  37      */
  38      public $email_template = 'report_closed';
  39  
  40      /**
  41      * Language key used to output the text
  42      *
  43      * @var string
  44      */
  45      protected $language_key = 'NOTIFICATION_REPORT_CLOSED';
  46  
  47      /**
  48      * Notification option data (for outputting to the user)
  49      *
  50      * @var bool|array False if the service should use it's default data
  51      *                     Array of data (including keys 'id', 'lang', and 'group')
  52      */
  53      static public $notification_option = [
  54          'id'    => 'notification.type.report_post_closed',
  55          'lang'    => 'NOTIFICATION_TYPE_REPORT_CLOSED',
  56          'group'    => 'NOTIFICATION_GROUP_MISCELLANEOUS',
  57      ];
  58  
  59      /**
  60      * Inherit notification read status from post.
  61      *
  62      * @var bool
  63      */
  64      protected $inherit_read_status = false;
  65  
  66  	public function is_available()
  67      {
  68          return $this->auth->acl_getf_global('f_report');
  69      }
  70  
  71      /**
  72      * Find the users who want to receive notifications
  73      *
  74      * @param array $post Data from submit_post
  75      * @param array $options Options for finding users for notification
  76      *
  77      * @return array
  78      */
  79  	public function find_users_for_notification($post, $options = [])
  80      {
  81          $options = array_merge([
  82              'ignore_users'        => [],
  83          ], $options);
  84  
  85          if ($post['reporter'] == $this->user->data['user_id'])
  86          {
  87              return [];
  88          }
  89  
  90          return $this->check_user_notification_options([$post['reporter']], $options);
  91      }
  92  
  93      /**
  94      * Get email template
  95      *
  96      * @return string|bool
  97      */
  98  	public function get_email_template()
  99      {
 100          return $this->email_template;
 101      }
 102  
 103      /**
 104      * Get email template variables
 105      *
 106      * @return array
 107      */
 108  	public function get_email_template_variables()
 109      {
 110          $post_username = $this->get_data('post_username') ?: $this->user_loader->get_username($this->get_data('poster_id'), 'username');
 111          $closer_username = $this->user_loader->get_username($this->get_data('closer_id'), 'username');
 112  
 113          return [
 114              'AUTHOR_NAME'    => html_entity_decode($post_username, ENT_COMPAT),
 115              'CLOSER_NAME'    => html_entity_decode($closer_username, ENT_COMPAT),
 116              'POST_SUBJECT'    => html_entity_decode(censor_text($this->get_data('post_subject')), ENT_COMPAT),
 117              'TOPIC_TITLE'    => html_entity_decode(censor_text($this->get_data('topic_title')), ENT_COMPAT),
 118  
 119              'U_VIEW_POST'    => generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
 120          ];
 121      }
 122  
 123      /**
 124      * Get the url to this item
 125      *
 126      * @return string URL
 127      */
 128  	public function get_url()
 129      {
 130          return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}");
 131      }
 132  
 133      /**
 134      * {inheritDoc}
 135      */
 136  	public function get_redirect_url()
 137      {
 138          return $this->get_url();
 139      }
 140  
 141      /**
 142      * Get the HTML formatted title of this notification
 143      *
 144      * @return string
 145      */
 146  	public function get_title()
 147      {
 148          $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile');
 149  
 150          return $this->language->lang(
 151              $this->language_key,
 152              $username
 153          );
 154      }
 155  
 156      /**
 157      * Get the HTML formatted reference of the notification
 158      *
 159      * @return string
 160      */
 161  	public function get_reference()
 162      {
 163          return $this->language->lang(
 164              'NOTIFICATION_REFERENCE',
 165              censor_text($this->get_data('post_subject'))
 166          );
 167      }
 168  
 169      /**
 170      * Get the user's avatar
 171      */
 172  	public function get_avatar()
 173      {
 174          return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true);
 175      }
 176  
 177      /**
 178      * Users needed to query before this notification can be displayed
 179      *
 180      * @return array Array of user_ids
 181      */
 182  	public function users_to_query()
 183      {
 184          return [$this->get_data('closer_id')];
 185      }
 186  
 187      /**
 188      * {@inheritdoc}
 189      */
 190  	public function create_insert_array($post, $pre_create_data = [])
 191      {
 192          $this->set_data('closer_id', $post['closer_id']);
 193  
 194          parent::create_insert_array($post, $pre_create_data);
 195  
 196          $this->notification_time = time();
 197      }
 198  
 199      /**
 200      * {@inheritdoc}
 201      */
 202  	public function get_insert_array()
 203      {
 204          $data = parent::get_insert_array();
 205          $data['notification_time'] = $this->notification_time;
 206  
 207          return $data;
 208      }
 209  }


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