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