[ Index ]

PHP Cross Reference of phpBB-3.3.0-deutsch

title

Body

[close]

/phpbb/notification/type/ -> report_post.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  * Reported post notifications class
  18  * This class handles notifications for reported posts
  19  */
  20  class report_post extends \phpbb\notification\type\post_in_queue
  21  {
  22      /**
  23      * Get notification type name
  24      *
  25      * @return string
  26      */
  27  	public function get_type()
  28      {
  29          return 'notification.type.report_post';
  30      }
  31  
  32      /**
  33      * Get the CSS style class of the notification
  34      *
  35      * @return string
  36      */
  37  	public function get_style_class()
  38      {
  39          return 'notification-reported';
  40      }
  41  
  42      /**
  43      * Language key used to output the text
  44      *
  45      * @var string
  46      */
  47      protected $language_key = 'NOTIFICATION_REPORT_POST';
  48  
  49      /**
  50      * Inherit notification read status from post.
  51      *
  52      * @var bool
  53      */
  54      protected $inherit_read_status = false;
  55  
  56      /**
  57      * Permission to check for (in find_users_for_notification)
  58      *
  59      * @var string Permission name
  60      */
  61      protected $permission = 'm_report';
  62  
  63      /**
  64      * Notification option data (for outputting to the user)
  65      *
  66      * @var bool|array False if the service should use it's default data
  67      *                     Array of data (including keys 'id' and 'lang')
  68      */
  69      static public $notification_option = array(
  70          'id'    => 'notification.type.report',
  71          'lang'    => 'NOTIFICATION_TYPE_REPORT',
  72          'group'    => 'NOTIFICATION_GROUP_MODERATION',
  73      );
  74  
  75      /**
  76      * Find the users who want to receive notifications
  77      *
  78      * @param array $post Data from the post
  79      * @param array $options Options for finding users for notification
  80      *
  81      * @return array
  82      */
  83  	public function find_users_for_notification($post, $options = array())
  84      {
  85          $notify_users = parent::find_users_for_notification($post, $options);
  86  
  87          // never notify reporter
  88          unset($notify_users[$this->user->data['user_id']]);
  89  
  90          return $notify_users;
  91      }
  92  
  93      /**
  94      * Get email template
  95      *
  96      * @return string|bool
  97      */
  98  	public function get_email_template()
  99      {
 100          return 'report_post';
 101      }
 102  
 103      /**
 104      * Get email template variables
 105      *
 106      * @return array
 107      */
 108  	public function get_email_template_variables()
 109      {
 110          $board_url = generate_board_url();
 111  
 112          return array(
 113              'POST_SUBJECT'                => htmlspecialchars_decode(censor_text($this->get_data('post_subject'))),
 114              'TOPIC_TITLE'                => htmlspecialchars_decode(censor_text($this->get_data('topic_title'))),
 115  
 116              'U_VIEW_REPORT'                => "{$board_url}/mcp.{$this->php_ext}?f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports",
 117              'U_VIEW_POST'                => "{$board_url}/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}",
 118              'U_NEWEST_POST'                => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}&view=unread#unread",
 119              'U_TOPIC'                    => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 120              'U_VIEW_TOPIC'                => "{$board_url}/viewtopic.{$this->php_ext}?f={$this->get_data('forum_id')}&t={$this->item_parent_id}",
 121              'U_FORUM'                    => "{$board_url}/viewforum.{$this->php_ext}?f={$this->get_data('forum_id')}",
 122          );
 123      }
 124  
 125      /**
 126      * Get the url to this item
 127      *
 128      * @return string URL
 129      */
 130  	public function get_url()
 131      {
 132          return append_sid($this->phpbb_root_path . 'mcp.' . $this->php_ext, "f={$this->get_data('forum_id')}&amp;p={$this->item_id}&amp;i=reports&amp;mode=report_details#reports");
 133      }
 134  
 135      /**
 136      * Get the HTML formatted title of this notification
 137      *
 138      * @return string
 139      */
 140  	public function get_title()
 141      {
 142          $this->language->add_lang('mcp');
 143  
 144          $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
 145  
 146          return $this->language->lang(
 147              $this->language_key,
 148              $username
 149          );
 150      }
 151  
 152      /**
 153      * Get the HTML formatted reference of the notification
 154      *
 155      * @return string
 156      */
 157  	public function get_reference()
 158      {
 159          return $this->language->lang(
 160              'NOTIFICATION_REFERENCE',
 161              censor_text($this->get_data('post_subject'))
 162          );
 163      }
 164  
 165      /**
 166      * Get the reason for the notification
 167      *
 168      * @return string
 169      */
 170  	public function get_reason()
 171      {
 172          if ($this->get_data('report_text'))
 173          {
 174              return $this->language->lang(
 175                  'NOTIFICATION_REASON',
 176                  $this->get_data('report_text')
 177              );
 178          }
 179  
 180          if ($this->language->is_set($this->get_data('reason_title')))
 181          {
 182              return $this->language->lang(
 183                  'NOTIFICATION_REASON',
 184                  $this->language->lang($this->get_data('reason_title'))
 185              );
 186          }
 187  
 188          return $this->language->lang(
 189              'NOTIFICATION_REASON',
 190              $this->get_data('reason_description')
 191          );
 192      }
 193  
 194      /**
 195      * Get the user's avatar
 196      */
 197  	public function get_avatar()
 198      {
 199          return $this->user_loader->get_avatar($this->get_data('reporter_id'), false, true);
 200      }
 201  
 202      /**
 203      * Users needed to query before this notification can be displayed
 204      *
 205      * @return array Array of user_ids
 206      */
 207  	public function users_to_query()
 208      {
 209          return array($this->get_data('reporter_id'));
 210      }
 211  
 212      /**
 213      * {@inheritdoc}
 214      */
 215  	public function create_insert_array($post, $pre_create_data = array())
 216      {
 217          $this->set_data('reporter_id', $this->user->data['user_id']);
 218          $this->set_data('reason_title', strtoupper($post['reason_title']));
 219          $this->set_data('reason_description', $post['reason_description']);
 220          $this->set_data('report_text', $post['report_text']);
 221  
 222          parent::create_insert_array($post, $pre_create_data);
 223      }
 224  }


Generated: Tue Apr 7 19:44:41 2020 Cross-referenced by PHPXref 0.7.1