[ Index ]

PHP Cross Reference of phpBB-3.1.12-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      public static $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      */
  74  	public static function get_item_parent_id($pm)
  75      {
  76          return (int) $pm['report_id'];
  77      }
  78  
  79      /**
  80      * Is this type available to the current user (defines whether or not it will be shown in the UCP Edit notification options)
  81      *
  82      * @return bool True/False whether or not this is available to the user
  83      */
  84  	public function is_available()
  85      {
  86          $m_approve = $this->auth->acl_getf($this->permission, true);
  87  
  88          return (!empty($m_approve));
  89      }
  90  
  91  
  92      /**
  93      * Find the users who want to receive notifications
  94      *  (copied from post_in_queue)
  95      *
  96      * @param array $post Data from the post
  97      * @param array $options Options for finding users for notification
  98      *
  99      * @return array
 100      */
 101  	public function find_users_for_notification($post, $options = array())
 102      {
 103          $options = array_merge(array(
 104              'ignore_users'        => array(),
 105          ), $options);
 106  
 107          // Global
 108          $post['forum_id'] = 0;
 109  
 110          $auth_approve = $this->auth->acl_get_list(false, $this->permission, $post['forum_id']);
 111  
 112          if (empty($auth_approve))
 113          {
 114              return array();
 115          }
 116  
 117          if (($key = array_search($this->user->data['user_id'], $auth_approve[$post['forum_id']][$this->permission])))
 118          {
 119              unset($auth_approve[$post['forum_id']][$this->permission][$key]);
 120          }
 121  
 122          return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array(
 123              'item_type'        => static::$notification_option['id'],
 124          )));
 125      }
 126  
 127      /**
 128      * Get email template
 129      *
 130      * @return string|bool
 131      */
 132  	public function get_email_template()
 133      {
 134          return 'report_pm';
 135      }
 136  
 137      /**
 138      * Get email template variables
 139      *
 140      * @return array
 141      */
 142  	public function get_email_template_variables()
 143      {
 144          $user_data = $this->user_loader->get_user($this->get_data('reporter_id'));
 145  
 146          return array(
 147              'AUTHOR_NAME'                => htmlspecialchars_decode($user_data['username']),
 148              'SUBJECT'                    => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
 149  
 150              'U_VIEW_REPORT'                => generate_board_url() . "mcp.{$this->php_ext}?r={$this->item_parent_id}&amp;i=pm_reports&amp;mode=pm_report_details",
 151          );
 152      }
 153  
 154      /**
 155      * Get the url to this item
 156      *
 157      * @return string URL
 158      */
 159  	public function get_url()
 160      {
 161          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");
 162      }
 163  
 164      /**
 165      * Get the HTML formatted title of this notification
 166      *
 167      * @return string
 168      */
 169  	public function get_title()
 170      {
 171          $this->user->add_lang('mcp');
 172  
 173          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
 174  
 175          return $this->user->lang(
 176              $this->language_key,
 177              $username
 178          );
 179      }
 180  
 181      /**
 182      * Get the HTML formatted reference of the notification
 183      *
 184      * @return string
 185      */
 186  	public function get_reference()
 187      {
 188          return $this->user->lang(
 189              'NOTIFICATION_REFERENCE',
 190              censor_text($this->get_data('message_subject'))
 191          );
 192      }
 193  
 194      /**
 195      * Get the reason for the notification
 196      *
 197      * @return string
 198      */
 199  	public function get_reason()
 200      {
 201          if ($this->get_data('report_text'))
 202          {
 203              return $this->user->lang(
 204                  'NOTIFICATION_REASON',
 205                  $this->get_data('report_text')
 206              );
 207          }
 208  
 209          if (isset($this->user->lang[$this->get_data('reason_title')]))
 210          {
 211              return $this->user->lang(
 212                  'NOTIFICATION_REASON',
 213                  $this->user->lang[$this->get_data('reason_title')]
 214              );
 215          }
 216  
 217          return $this->user->lang(
 218              'NOTIFICATION_REASON',
 219              $this->get_data('reason_description')
 220          );
 221      }
 222  
 223      /**
 224      * Get the user's avatar
 225      */
 226  	public function get_avatar()
 227      {
 228          return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
 229      }
 230  
 231      /**
 232      * Users needed to query before this notification can be displayed
 233      *
 234      * @return array Array of user_ids
 235      */
 236  	public function users_to_query()
 237      {
 238          return array($this->get_data('reporter_id'));
 239      }
 240  
 241      /**
 242      * Function for preparing the data for insertion in an SQL query
 243      * (The service handles insertion)
 244      *
 245      * @param array $post Data from submit_post
 246      * @param array $pre_create_data Data from pre_create_insert_array()
 247      *
 248      * @return array Array of data ready to be inserted into the database
 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          return parent::create_insert_array($post, $pre_create_data);
 258      }
 259  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1