Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
pm.php
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 public static $notification_option = array(
040 'lang' => 'NOTIFICATION_TYPE_PM',
041 );
042
043 /**
044 * Is available
045 */
046 public function is_available()
047 {
048 return ($this->config['allow_privmsg'] && $this->auth->acl_get('u_readpm'));
049 }
050
051 /**
052 * Get the id of the
053 *
054 * @param array $pm The data from the private message
055 */
056 public static function get_item_id($pm)
057 {
058 return (int) $pm['msg_id'];
059 }
060
061 /**
062 * Get the id of the parent
063 *
064 * @param array $pm The data from the pm
065 */
066 public static function get_item_parent_id($pm)
067 {
068 // No parent
069 return 0;
070 }
071
072 /**
073 * Find the users who want to receive notifications
074 *
075 * @param array $pm Data from submit_pm
076 * @param array $options Options for finding users for notification
077 *
078 * @return array
079 */
080 public function find_users_for_notification($pm, $options = array())
081 {
082 $options = array_merge(array(
083 'ignore_users' => array(),
084 ), $options);
085
086 if (!sizeof($pm['recipients']))
087 {
088 return array();
089 }
090
091 unset($pm['recipients'][$pm['from_user_id']]);
092
093 $this->user_loader->load_users(array_keys($pm['recipients']));
094
095 return $this->check_user_notification_options(array_keys($pm['recipients']), $options);
096 }
097
098 /**
099 * 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'));
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&mode=view&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 }
196