[ Index ] |
PHP Cross Reference of phpBB-3.1.12-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\method; 15 16 /** 17 * Abstract notification method handling email and jabber notifications 18 * using the phpBB messenger. 19 */ 20 abstract class messenger_base extends \phpbb\notification\method\base 21 { 22 /** 23 * Notify using phpBB messenger 24 * 25 * @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM) 26 * @param string $template_dir_prefix Base directory to prepend to the email template name 27 * 28 * @return null 29 */ 30 protected function notify_using_messenger($notify_method, $template_dir_prefix = '') 31 { 32 if (empty($this->queue)) 33 { 34 return; 35 } 36 37 // Load all users we want to notify (we need their email address) 38 $user_ids = $users = array(); 39 foreach ($this->queue as $notification) 40 { 41 $user_ids[] = $notification->user_id; 42 } 43 44 // We do not send emails to banned users 45 if (!function_exists('phpbb_get_banned_user_ids')) 46 { 47 include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext); 48 } 49 $banned_users = phpbb_get_banned_user_ids($user_ids); 50 51 // Load all the users we need 52 $this->user_loader->load_users($user_ids); 53 54 // Load the messenger 55 if (!class_exists('messenger')) 56 { 57 include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); 58 } 59 $messenger = new \messenger(); 60 $board_url = generate_board_url(); 61 62 // Time to go through the queue and send emails 63 foreach ($this->queue as $notification) 64 { 65 if ($notification->get_email_template() === false) 66 { 67 continue; 68 } 69 70 $user = $this->user_loader->get_user($notification->user_id); 71 72 if ($user['user_type'] == USER_IGNORE || ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL) || in_array($notification->user_id, $banned_users)) 73 { 74 continue; 75 } 76 77 $messenger->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix); 78 79 $messenger->set_addresses($user); 80 81 $messenger->assign_vars(array_merge(array( 82 'USERNAME' => $user['username'], 83 84 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options', 85 ), $notification->get_email_template_variables())); 86 87 $messenger->send($notify_method); 88 } 89 90 // Save the queue in the messenger class (has to be called or these emails could be lost?) 91 $messenger->save_queue(); 92 93 // We're done, empty the queue 94 $this->empty_queue(); 95 } 96 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |