[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
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 static public $notification_option = array( 40 'lang' => 'NOTIFICATION_TYPE_PM', 41 ); 42 43 /** @var \phpbb\user_loader */ 44 protected $user_loader; 45 46 /** @var \phpbb\config\config */ 47 protected $config; 48 49 public function set_config(\phpbb\config\config $config) 50 { 51 $this->config = $config; 52 } 53 54 public function set_user_loader(\phpbb\user_loader $user_loader) 55 { 56 $this->user_loader = $user_loader; 57 } 58 59 /** 60 * Is available 61 */ 62 public function is_available() 63 { 64 return ($this->config['allow_privmsg'] && $this->auth->acl_get('u_readpm')); 65 } 66 67 /** 68 * Get the id of the 69 * 70 * @param array $pm The data from the private message 71 */ 72 static public function get_item_id($pm) 73 { 74 return (int) $pm['msg_id']; 75 } 76 77 /** 78 * Get the id of the parent 79 * 80 * @param array $pm The data from the pm 81 */ 82 static public function get_item_parent_id($pm) 83 { 84 // No parent 85 return 0; 86 } 87 88 /** 89 * Find the users who want to receive notifications 90 * 91 * @param array $pm Data from submit_pm 92 * @param array $options Options for finding users for notification 93 * 94 * @return array 95 */ 96 public function find_users_for_notification($pm, $options = array()) 97 { 98 $options = array_merge(array( 99 'ignore_users' => array(), 100 ), $options); 101 102 if (!count($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' => html_entity_decode($user_data['username'], ENT_COMPAT), 168 'SUBJECT' => html_entity_decode(censor_text($this->get_data('message_subject')), ENT_COMPAT), 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&mode=view&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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |