[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/notification/type/ -> report_pm_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  * PM report closed notifications class
  18  * This class handles notifications for when reports are closed on PMs (for the one who reported the PM)
  19  */
  20  
  21  class report_pm_closed extends \phpbb\notification\type\pm
  22  {
  23      /**
  24      * Get notification type name
  25      *
  26      * @return string
  27      */
  28  	public function get_type()
  29      {
  30          return 'notification.type.report_pm_closed';
  31      }
  32  
  33      /**
  34      * Email template to use to send notifications
  35      *
  36      * @var string
  37      */
  38      public $email_template = 'report_pm_closed';
  39  
  40      /**
  41      * Language key used to output the text
  42      *
  43      * @var string
  44      */
  45      protected $language_key = 'NOTIFICATION_REPORT_PM_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_pm_closed',
  55          'lang'    => 'NOTIFICATION_TYPE_REPORT_PM_CLOSED',
  56          'group'    => 'NOTIFICATION_GROUP_MISCELLANEOUS',
  57      ];
  58  
  59  	public function is_available()
  60      {
  61          return (bool) $this->config['allow_pm_report'];
  62      }
  63  
  64      /**
  65      * Find the users who want to receive notifications
  66      *
  67      * @param array $pm Data from submit_pm
  68      * @param array $options Options for finding users for notification
  69      *
  70      * @return array
  71      */
  72  	public function find_users_for_notification($pm, $options = [])
  73      {
  74          $options = array_merge([
  75              'ignore_users'        => [],
  76          ], $options);
  77  
  78          if ($pm['reporter'] == $this->user->data['user_id'])
  79          {
  80              return [];
  81          }
  82  
  83          return $this->check_user_notification_options([$pm['reporter']], $options);
  84      }
  85  
  86      /**
  87      * Get email template
  88      *
  89      * @return string|bool
  90      */
  91  	public function get_email_template()
  92      {
  93          return $this->email_template;
  94      }
  95  
  96      /**
  97      * Get email template variables
  98      *
  99      * @return array
 100      */
 101  	public function get_email_template_variables()
 102      {
 103          $sender_username = $this->user_loader->get_username($this->get_data('from_user_id'), 'username');
 104          $closer_username = $this->user_loader->get_username($this->get_data('closer_id'), 'username');
 105  
 106          return [
 107              'AUTHOR_NAME'    => html_entity_decode($sender_username, ENT_COMPAT),
 108              'CLOSER_NAME'    => html_entity_decode($closer_username, ENT_COMPAT),
 109              'SUBJECT'        => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
 110  
 111              'U_VIEW_MESSAGE'=> generate_board_url() . "/ucp.{$this->php_ext}?i=pm&amp;mode=view&amp;p={$this->item_id}",
 112          ];
 113      }
 114  
 115      /**
 116      * Get the HTML formatted title of this notification
 117      *
 118      * @return string
 119      */
 120  	public function get_title()
 121      {
 122          $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile');
 123  
 124          return $this->language->lang(
 125              $this->language_key,
 126              $username
 127          );
 128      }
 129  
 130      /**
 131      * Get the HTML formatted reference of the notification
 132      *
 133      * @return string
 134      */
 135  	public function get_reference()
 136      {
 137          return $this->language->lang(
 138              'NOTIFICATION_REFERENCE',
 139              censor_text($this->get_data('message_subject'))
 140          );
 141      }
 142  
 143      /**
 144      * Get the user's avatar
 145      */
 146  	public function get_avatar()
 147      {
 148          return $this->user_loader->get_avatar($this->get_data('closer_id'), false, true);
 149      }
 150  
 151      /**
 152      * Users needed to query before this notification can be displayed
 153      *
 154      * @return array Array of user_ids
 155      */
 156  	public function users_to_query()
 157      {
 158          return [$this->get_data('closer_id')];
 159      }
 160  
 161      /**
 162      * {@inheritdoc}
 163      */
 164  	public function create_insert_array($pm, $pre_create_data = [])
 165      {
 166          $this->set_data('closer_id', $pm['closer_id']);
 167  
 168          parent::create_insert_array($pm, $pre_create_data);
 169  
 170          $this->notification_time = time();
 171      }
 172  
 173      /**
 174      * {@inheritdoc}
 175      */
 176  	public function get_insert_array()
 177      {
 178          $data = parent::get_insert_array();
 179          $data['notification_time'] = $this->notification_time;
 180  
 181          return $data;
 182      }
 183  }


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