[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/notification/type/ -> 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 notifications class
  18  * This class handles notifications for private messages
  19  */
  20  
  21  class pm extends \phpbb\notification\type\base
  22  {
  23      /**
  24      * Get notification type name
  25      *
  26      * @return string
  27      */
  28  	public function get_type()
  29      {
  30          return 'notification.type.pm';
  31      }
  32  
  33      /**
  34      * Notification option data (for outputting to the user)
  35      *
  36      * @var bool|array False if the service should use it's default data
  37      *                     Array of data (including keys 'id', 'lang', and 'group')
  38      */
  39      public static $notification_option = array(
  40          'lang'    => 'NOTIFICATION_TYPE_PM',
  41      );
  42  
  43      /**
  44      * Is available
  45      */
  46  	public function is_available()
  47      {
  48          return ($this->config['allow_privmsg'] && $this->auth->acl_get('u_readpm'));
  49      }
  50  
  51      /**
  52      * Get the id of the
  53      *
  54      * @param array $pm The data from the private message
  55      */
  56  	public static function get_item_id($pm)
  57      {
  58          return (int) $pm['msg_id'];
  59      }
  60  
  61      /**
  62      * Get the id of the parent
  63      *
  64      * @param array $pm The data from the pm
  65      */
  66  	public static function get_item_parent_id($pm)
  67      {
  68          // No parent
  69          return 0;
  70      }
  71  
  72      /**
  73      * Find the users who want to receive notifications
  74      *
  75      * @param array $pm Data from submit_pm
  76      * @param array $options Options for finding users for notification
  77      *
  78      * @return array
  79      */
  80  	public function find_users_for_notification($pm, $options = array())
  81      {
  82          $options = array_merge(array(
  83              'ignore_users'        => array(),
  84          ), $options);
  85  
  86          if (!sizeof($pm['recipients']))
  87          {
  88              return array();
  89          }
  90  
  91          unset($pm['recipients'][$pm['from_user_id']]);
  92  
  93          $this->user_loader->load_users(array_keys($pm['recipients']));
  94  
  95          return $this->check_user_notification_options(array_keys($pm['recipients']), $options);
  96      }
  97  
  98      /**
  99      * Get the user's avatar
 100      */
 101  	public function get_avatar()
 102      {
 103          return $this->user_loader->get_avatar($this->get_data('from_user_id'), false, true);
 104      }
 105  
 106      /**
 107      * Get the HTML formatted title of this notification
 108      *
 109      * @return string
 110      */
 111  	public function get_title()
 112      {
 113          $username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile');
 114  
 115          return $this->user->lang('NOTIFICATION_PM', $username);
 116      }
 117  
 118      /**
 119      * Get the HTML formatted reference of the notification
 120      *
 121      * @return string
 122      */
 123  	public function get_reference()
 124      {
 125          return $this->user->lang(
 126              'NOTIFICATION_REFERENCE',
 127              $this->get_data('message_subject')
 128          );
 129      }
 130  
 131      /**
 132      * Get email template
 133      *
 134      * @return string|bool
 135      */
 136  	public function get_email_template()
 137      {
 138          return 'privmsg_notify';
 139      }
 140  
 141      /**
 142      * Get email template variables
 143      *
 144      * @return array
 145      */
 146  	public function get_email_template_variables()
 147      {
 148          $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
 149  
 150          return array(
 151              'AUTHOR_NAME'                => htmlspecialchars_decode($user_data['username']),
 152              'SUBJECT'                    => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
 153  
 154              'U_VIEW_MESSAGE'            => generate_board_url() . '/ucp.' . $this->php_ext . "?i=pm&mode=view&p={$this->item_id}",
 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 . 'ucp.' . $this->php_ext, "i=pm&amp;mode=view&amp;p={$this->item_id}");
 166      }
 167  
 168      /**
 169      * Users needed to query before this notification can be displayed
 170      *
 171      * @return array Array of user_ids
 172      */
 173  	public function users_to_query()
 174      {
 175          return array($this->get_data('from_user_id'));
 176      }
 177  
 178      /**
 179      * Function for preparing the data for insertion in an SQL query
 180      * (The service handles insertion)
 181      *
 182      * @param array $pm Data from submit_post
 183      * @param array $pre_create_data Data from pre_create_insert_array()
 184      *
 185      * @return array Array of data ready to be inserted into the database
 186      */
 187  	public function create_insert_array($pm, $pre_create_data = array())
 188      {
 189          $this->set_data('from_user_id', $pm['from_user_id']);
 190  
 191          $this->set_data('message_subject', $pm['message_subject']);
 192  
 193          return parent::create_insert_array($pm, $pre_create_data);
 194      }
 195  }


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