[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/phpbb/notification/type/ -> report_pm.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  * Private message reported notifications class
  18  * This class handles notifications for private messages when they are reported
  19  */
  20  
  21  class report_pm 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';
  31      }
  32  
  33      /**
  34      * Get the CSS style class of the notification
  35      *
  36      * @return string
  37      */
  38  	public function get_style_class()
  39      {
  40          return 'notification-reported';
  41      }
  42  
  43      /**
  44      * Language key used to output the text
  45      *
  46      * @var string
  47      */
  48      protected $language_key = 'NOTIFICATION_REPORT_PM';
  49  
  50      /**
  51      * Permission to check for (in find_users_for_notification)
  52      *
  53      * @var string Permission name
  54      */
  55      protected $permission = 'm_pm_report';
  56  
  57      /**
  58      * Notification option data (for outputting to the user)
  59      *
  60      * @var bool|array False if the service should use it's default data
  61      *                     Array of data (including keys 'id', 'lang', and 'group')
  62      */
  63      static public $notification_option = [
  64          'id'    => 'notification.type.report_pm',
  65          'lang'    => 'NOTIFICATION_TYPE_REPORT_PM',
  66          'group'    => 'NOTIFICATION_GROUP_MODERATION',
  67      ];
  68  
  69      /**
  70      * Get the id of the parent
  71      *
  72      * @param array $pm The data from the pm
  73      * @return int The report id
  74      */
  75  	static public function get_item_parent_id($pm)
  76      {
  77          return (int) $pm['report_id'];
  78      }
  79  
  80      /**
  81      * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options)
  82      *
  83      * @return bool True/False whether or not this is available to the user
  84      */
  85  	public function is_available()
  86      {
  87          return $this->config['allow_pm_report'] &&
  88              !empty($this->auth->acl_get($this->permission));
  89      }
  90  
  91      /**
  92      * Find the users who want to receive notifications
  93      *  (copied from post_in_queue)
  94      *
  95      * @param array $post Data from the post
  96      * @param array $options Options for finding users for notification
  97      *
  98      * @return array
  99      */
 100  	public function find_users_for_notification($post, $options = [])
 101      {
 102          $options = array_merge([
 103              'ignore_users'        => [],
 104          ], $options);
 105  
 106          // Global
 107          $post['forum_id'] = 0;
 108  
 109          $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
 110  
 111          if (empty($auth_approve))
 112          {
 113              return [];
 114          }
 115  
 116          if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
 117          {
 118              unset($auth_approve[$post['forum_id']][$this->permission][$key]);
 119          }
 120  
 121          return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, [
 122              'item_type'        => static::$notification_option['id'],
 123          ]));
 124      }
 125  
 126      /**
 127      * Get email template
 128      *
 129      * @return string|bool
 130      */
 131  	public function get_email_template()
 132      {
 133          return 'report_pm';
 134      }
 135  
 136      /**
 137      * Get email template variables
 138      *
 139      * @return array
 140      */
 141  	public function get_email_template_variables()
 142      {
 143          $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
 144  
 145          return [
 146              'AUTHOR_NAME'    => html_entity_decode($user_data['username'], ENT_COMPAT),
 147              'SUBJECT'        => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
 148  
 149              /** @deprecated    3.2.6-RC1    (to be removed in 4.0.0) use {SUBJECT} instead in report_pm.txt */
 150              'TOPIC_TITLE'    => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT),
 151  
 152              'U_VIEW_REPORT'    => generate_board_url() . "/mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details",
 153          ];
 154      }
 155  
 156      /**
 157      * Get the url to this item
 158      *
 159      * @return string URL
 160      */
 161  	public function get_url()
 162      {
 163          return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details");
 164      }
 165  
 166      /**
 167      * Get the HTML formatted title of this notification
 168      *
 169      * @return string
 170      */
 171  	public function get_title()
 172      {
 173          $this->language->add_lang('mcp');
 174  
 175          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
 176  
 177          return $this->language->lang(
 178              $this->language_key,
 179              $username
 180          );
 181      }
 182  
 183      /**
 184      * Get the HTML formatted reference of the notification
 185      *
 186      * @return string
 187      */
 188  	public function get_reference()
 189      {
 190          return $this->language->lang(
 191              'NOTIFICATION_REFERENCE',
 192              censor_text($this->get_data('message_subject'))
 193          );
 194      }
 195  
 196      /**
 197      * Get the reason for the notification
 198      *
 199      * @return string
 200      */
 201  	public function get_reason()
 202      {
 203          if ($this->get_data('report_text'))
 204          {
 205              return $this->language->lang(
 206                  'NOTIFICATION_REASON',
 207                  $this->get_data('report_text')
 208              );
 209          }
 210  
 211          if ($this->language->is_set($this->get_data('reason_title')))
 212          {
 213              return $this->language->lang(
 214                  'NOTIFICATION_REASON',
 215                  $this->language->lang($this->get_data('reason_title'))
 216              );
 217          }
 218  
 219          return $this->language->lang(
 220              'NOTIFICATION_REASON',
 221              $this->get_data('reason_description')
 222          );
 223      }
 224  
 225      /**
 226      * Get the user's avatar
 227      */
 228  	public function get_avatar()
 229      {
 230          return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
 231      }
 232  
 233      /**
 234      * Users needed to query before this notification can be displayed
 235      *
 236      * @return array Array of user_ids
 237      */
 238  	public function users_to_query()
 239      {
 240          return [
 241              $this->get_data('from_user_id'),
 242              $this->get_data('reporter_id'),
 243          ];
 244      }
 245  
 246      /**
 247      * {@inheritdoc}
 248      */
 249  	public function create_insert_array($post, $pre_create_data = [])
 250      {
 251          $this->set_data('reporter_id', $this->user->data['user_id']);
 252          $this->set_data('reason_title', strtoupper($post['reason_title']));
 253          $this->set_data('reason_description', $post['reason_description']);
 254          $this->set_data('report_text', $post['report_text']);
 255  
 256          parent::create_insert_array($post, $pre_create_data);
 257      }
 258  }


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