[ Index ]

PHP Cross Reference of phpBB-3.2.11-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 = array(
  64          'id'    => 'notification.type.report',
  65          'lang'    => 'NOTIFICATION_TYPE_REPORT',
  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          $m_approve = $this->auth->acl_getf($this->permission, true);
  88  
  89          return (!empty($m_approve));
  90      }
  91  
  92  
  93      /**
  94      * Find the users who want to receive notifications
  95      *  (copied from post_in_queue)
  96      *
  97      * @param array $post Data from the post
  98      * @param array $options Options for finding users for notification
  99      *
 100      * @return array
 101      */
 102  	public function find_users_for_notification($post, $options = array())
 103      {
 104          $options = array_merge(array(
 105              'ignore_users'        => array(),
 106          ), $options);
 107  
 108          // Global
 109          $post['forum_id'] = 0;
 110  
 111          $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
 112  
 113          if (empty($auth_approve))
 114          {
 115              return array();
 116          }
 117  
 118          if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
 119          {
 120              unset($auth_approve[$post['forum_id']][$this->permission][$key]);
 121          }
 122  
 123          return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array(
 124              'item_type'        => static::$notification_option['id'],
 125          )));
 126      }
 127  
 128      /**
 129      * Get email template
 130      *
 131      * @return string|bool
 132      */
 133  	public function get_email_template()
 134      {
 135          return 'report_pm';
 136      }
 137  
 138      /**
 139      * Get email template variables
 140      *
 141      * @return array
 142      */
 143  	public function get_email_template_variables()
 144      {
 145          $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
 146  
 147          return array(
 148              'AUTHOR_NAME'    => htmlspecialchars_decode($user_data['username']),
 149              'SUBJECT'        => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
 150  
 151              /** @deprecated    3.2.6-RC1    (to be removed in 4.0.0) use {SUBJECT} instead in report_pm.txt */
 152              'TOPIC_TITLE'    => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
 153  
 154              'U_VIEW_REPORT'    => generate_board_url() . "/mcp.{$this->php_ext}?r={$this->item_parent_id}&i=pm_reports&mode=pm_report_details",
 155          );
 156      }
 157  
 158      /**
 159      * Get the url to this item
 160      *
 161      * @return string URL
 162      */
 163  	public function get_url()
 164      {
 165          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");
 166      }
 167  
 168      /**
 169      * Get the HTML formatted title of this notification
 170      *
 171      * @return string
 172      */
 173  	public function get_title()
 174      {
 175          $this->language->add_lang('mcp');
 176  
 177          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
 178  
 179          return $this->language->lang(
 180              $this->language_key,
 181              $username
 182          );
 183      }
 184  
 185      /**
 186      * Get the HTML formatted reference of the notification
 187      *
 188      * @return string
 189      */
 190  	public function get_reference()
 191      {
 192          return $this->language->lang(
 193              'NOTIFICATION_REFERENCE',
 194              censor_text($this->get_data('message_subject'))
 195          );
 196      }
 197  
 198      /**
 199      * Get the reason for the notification
 200      *
 201      * @return string
 202      */
 203  	public function get_reason()
 204      {
 205          if ($this->get_data('report_text'))
 206          {
 207              return $this->language->lang(
 208                  'NOTIFICATION_REASON',
 209                  $this->get_data('report_text')
 210              );
 211          }
 212  
 213          if ($this->language->is_set($this->get_data('reason_title')))
 214          {
 215              return $this->language->lang(
 216                  'NOTIFICATION_REASON',
 217                  $this->language->lang($this->get_data('reason_title'))
 218              );
 219          }
 220  
 221          return $this->language->lang(
 222              'NOTIFICATION_REASON',
 223              $this->get_data('reason_description')
 224          );
 225      }
 226  
 227      /**
 228      * Get the user's avatar
 229      */
 230  	public function get_avatar()
 231      {
 232          return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
 233      }
 234  
 235      /**
 236      * Users needed to query before this notification can be displayed
 237      *
 238      * @return array Array of user_ids
 239      */
 240  	public function users_to_query()
 241      {
 242          return array(
 243              $this->get_data('from_user_id'),
 244              $this->get_data('reporter_id'),
 245          );    }
 246  
 247      /**
 248      * {@inheritdoc}
 249      */
 250  	public function create_insert_array($post, $pre_create_data = array())
 251      {
 252          $this->set_data('reporter_id', $this->user->data['user_id']);
 253          $this->set_data('reason_title', strtoupper($post['reason_title']));
 254          $this->set_data('reason_description', $post['reason_description']);
 255          $this->set_data('report_text', $post['report_text']);
 256  
 257          parent::create_insert_array($post, $pre_create_data);
 258      }
 259  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1