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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
messenger_base.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\method;
015
016 /**
017 * Abstract notification method handling email and jabber notifications
018 * using the phpBB messenger.
019 */
020 abstract class messenger_base extends \phpbb\notification\method\base
021 {
022 /** @var \phpbb\user_loader */
023 protected $user_loader;
024
025 /** @var string */
026 protected $phpbb_root_path;
027
028 /** @var string */
029 protected $php_ext;
030
031 /**
032 * Notification Method Board Constructor
033 *
034 * @param \phpbb\user_loader $user_loader
035 * @param string $phpbb_root_path
036 * @param string $php_ext
037 */
038 public function __construct(\phpbb\user_loader $user_loader, $phpbb_root_path, $php_ext)
039 {
040 $this->user_loader = $user_loader;
041 $this->phpbb_root_path = $phpbb_root_path;
042 $this->php_ext = $php_ext;
043 }
044
045 /**
046 * Notify using phpBB messenger
047 *
048 * @param int $notify_method Notify method for messenger (e.g. NOTIFY_IM)
049 * @param string $template_dir_prefix Base directory to prepend to the email template name
050 *
051 * @return null
052 */
053 protected function notify_using_messenger($notify_method, $template_dir_prefix = '')
054 {
055 if (empty($this->queue))
056 {
057 return;
058 }
059
060 // Load all users we want to notify (we need their email address)
061 $user_ids = $users = array();
062 foreach ($this->queue as $notification)
063 {
064 $user_ids[] = $notification->user_id;
065 }
066
067 // We do not send emails to banned users
068 if (!function_exists('phpbb_get_banned_user_ids'))
069 {
070 include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
071 }
072 $banned_users = phpbb_get_banned_user_ids($user_ids);
073
074 // Load all the users we need
075 $this->user_loader->load_users($user_ids);
076
077 // Load the messenger
078 if (!class_exists('messenger'))
079 {
080 include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
081 }
082 $messenger = new \messenger();
083
084 // Time to go through the queue and send emails
085 /** @var \phpbb\notification\type\type_interface $notification */
086 foreach ($this->queue as $notification)
087 {
088 if ($notification->get_email_template() === false)
089 {
090 continue;
091 }
092
093 $user = $this->user_loader->get_user($notification->user_id);
094
095 if ($user['user_type'] == USER_IGNORE || ($user['user_type'] == USER_INACTIVE && $user['user_inactive_reason'] == INACTIVE_MANUAL) || in_array($notification->user_id, $banned_users))
096 {
097 continue;
098 }
099
100 $messenger->template($notification->get_email_template(), $user['user_lang'], '', $template_dir_prefix);
101
102 $messenger->set_addresses($user);
103
104 $messenger->assign_vars(array_merge(array(
105 'USERNAME' => $user['username'],
106
107 'U_NOTIFICATION_SETTINGS' => generate_board_url() . '/ucp.' . $this->php_ext . '?i=ucp_notifications&mode=notification_options',
108 ), $notification->get_email_template_variables()));
109
110 $messenger->send($notify_method);
111 }
112
113 // Save the queue in the messenger class (has to be called or these emails could be lost?)
114 $messenger->save_queue();
115
116 // We're done, empty the queue
117 $this->empty_queue();
118 }
119 }
120