Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

pm.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 4.17 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  namespace phpbb\notification\type;
 015   
 016  /**
 017  * Private message notifications class
 018  * This class handles notifications for private messages
 019  */
 020   
 021  class pm extends \phpbb\notification\type\base
 022  {
 023      /**
 024      * Get notification type name
 025      *
 026      * @return string
 027      */
 028      public function get_type()
 029      {
 030          return 'notification.type.pm';
 031      }
 032   
 033      /**
 034      * Notification option data (for outputting to the user)
 035      *
 036      * @var bool|array False if the service should use it's default data
 037      *                     Array of data (including keys 'id', 'lang', and 'group')
 038      */
 039      static public $notification_option = array(
 040          'lang'    => 'NOTIFICATION_TYPE_PM',
 041      );
 042   
 043      /** @var \phpbb\user_loader */
 044      protected $user_loader;
 045   
 046      /** @var \phpbb\config\config */
 047      protected $config;
 048   
 049      public function set_config(\phpbb\config\config $config)
 050      {
 051          $this->config = $config;
 052      }
 053   
 054      public function set_user_loader(\phpbb\user_loader $user_loader)
 055      {
 056          $this->user_loader = $user_loader;
 057      }
 058   
 059      /**
 060      * Is available
 061      */
 062      public function is_available()
 063      {
 064          return ($this->config['allow_privmsg'] && $this->auth->acl_get('u_readpm'));
 065      }
 066   
 067      /**
 068      * Get the id of the
 069      *
 070      * @param array $pm The data from the private message
 071      */
 072      static public function get_item_id($pm)
 073      {
 074          return (int) $pm['msg_id'];
 075      }
 076   
 077      /**
 078      * Get the id of the parent
 079      *
 080      * @param array $pm The data from the pm
 081      */
 082      static public function get_item_parent_id($pm)
 083      {
 084          // No parent
 085          return 0;
 086      }
 087   
 088      /**
 089      * Find the users who want to receive notifications
 090      *
 091      * @param array $pm Data from submit_pm
 092      * @param array $options Options for finding users for notification
 093      *
 094      * @return array
 095      */
 096      public function find_users_for_notification($pm, $options = array())
 097      {
 098          $options = array_merge(array(
 099              'ignore_users'        => array(),
 100          ), $options);
 101   
 102          if (!sizeof($pm['recipients']))
 103          {
 104              return array();
 105          }
 106   
 107          unset($pm['recipients'][$pm['from_user_id']]);
 108   
 109          $this->user_loader->load_users(array_keys($pm['recipients']));
 110   
 111          return $this->check_user_notification_options(array_keys($pm['recipients']), $options);
 112      }
 113   
 114      /**
 115      * Get the user's avatar
 116      */
 117      public function get_avatar()
 118      {
 119          return $this->user_loader->get_avatar($this->get_data('from_user_id'), false, true);
 120      }
 121   
 122      /**
 123      * Get the HTML formatted title of this notification
 124      *
 125      * @return string
 126      */
 127      public function get_title()
 128      {
 129          $username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile');
 130   
 131          return $this->language->lang('NOTIFICATION_PM', $username);
 132      }
 133   
 134      /**
 135      * Get the HTML formatted reference of the notification
 136      *
 137      * @return string
 138      */
 139      public function get_reference()
 140      {
 141          return $this->language->lang(
 142              'NOTIFICATION_REFERENCE',
 143              $this->get_data('message_subject')
 144          );
 145      }
 146   
 147      /**
 148      * Get email template
 149      *
 150      * @return string|bool
 151      */
 152      public function get_email_template()
 153      {
 154          return 'privmsg_notify';
 155      }
 156   
 157      /**
 158      * Get email template variables
 159      *
 160      * @return array
 161      */
 162      public function get_email_template_variables()
 163      {
 164          $user_data = $this->user_loader->get_user($this->get_data('from_user_id'));
 165   
 166          return array(
 167              'AUTHOR_NAME'                => htmlspecialchars_decode($user_data['username']),
 168              'SUBJECT'                    => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),
 169   
 170              'U_VIEW_MESSAGE'            => generate_board_url() . '/ucp.' . $this->php_ext . "?i=pm&mode=view&p={$this->item_id}",
 171          );
 172      }
 173   
 174      /**
 175      * Get the url to this item
 176      *
 177      * @return string URL
 178      */
 179      public function get_url()
 180      {
 181          return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&amp;mode=view&amp;p={$this->item_id}");
 182      }
 183   
 184      /**
 185      * Users needed to query before this notification can be displayed
 186      *
 187      * @return array Array of user_ids
 188      */
 189      public function users_to_query()
 190      {
 191          return array($this->get_data('from_user_id'));
 192      }
 193   
 194      /**
 195      * {@inheritdoc}
 196      */
 197      public function create_insert_array($pm, $pre_create_data = array())
 198      {
 199          $this->set_data('from_user_id', $pm['from_user_id']);
 200   
 201          $this->set_data('message_subject', $pm['message_subject']);
 202   
 203          parent::create_insert_array($pm, $pre_create_data);
 204      }
 205  }
 206