mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
Merge branch '3.2.x' into 3.3.x
This commit is contained in:
commit
ddc8e5c712
2 changed files with 72 additions and 12 deletions
|
@ -25,7 +25,7 @@ class ucp_notifications
|
||||||
|
|
||||||
public function main($id, $mode)
|
public function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $config, $template, $user, $request, $phpbb_container;
|
global $config, $template, $user, $request, $phpbb_container, $phpbb_dispatcher;
|
||||||
global $phpbb_root_path, $phpEx;
|
global $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
add_form_key('ucp_notification');
|
add_form_key('ucp_notification');
|
||||||
|
@ -57,15 +57,34 @@ class ucp_notifications
|
||||||
|
|
||||||
foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
|
||||||
{
|
{
|
||||||
foreach ($subscription_types as $type => $data)
|
foreach ($subscription_types as $type => $type_data)
|
||||||
{
|
{
|
||||||
foreach ($notification_methods as $method => $method_data)
|
foreach ($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
|
$is_set_notify = $request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id']));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to perform additional actions before ucp_notifications is submitted
|
||||||
|
*
|
||||||
|
* @event core.ucp_notifications_submit_notification_is_set
|
||||||
|
* @var array type_data The notification type data
|
||||||
|
* @var array method_data The notification method data
|
||||||
|
* @var bool is_set_notify The notification is set or not
|
||||||
|
*
|
||||||
|
* @since 3.2.10-RC1
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'type_data',
|
||||||
|
'method_data',
|
||||||
|
'is_set_notify',
|
||||||
|
];
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.ucp_notifications_submit_notification_is_set', compact($vars)));
|
||||||
|
|
||||||
|
if ($is_set_notify && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
|
||||||
{
|
{
|
||||||
$phpbb_notifications->add_subscription($type, 0, $method_data['id']);
|
$phpbb_notifications->add_subscription($type, 0, $method_data['id']);
|
||||||
}
|
}
|
||||||
else if (!$request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
|
else if (!$is_set_notify && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
|
||||||
{
|
{
|
||||||
$phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
|
$phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +99,7 @@ class ucp_notifications
|
||||||
|
|
||||||
$this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
|
$this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
|
||||||
|
|
||||||
$this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, 'notification_types');
|
$this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, $phpbb_dispatcher, 'notification_types');
|
||||||
|
|
||||||
$this->tpl_name = 'ucp_notifications';
|
$this->tpl_name = 'ucp_notifications';
|
||||||
$this->page_title = 'UCP_NOTIFICATION_OPTIONS';
|
$this->page_title = 'UCP_NOTIFICATION_OPTIONS';
|
||||||
|
@ -168,9 +187,10 @@ class ucp_notifications
|
||||||
* @param \phpbb\notification\manager $phpbb_notifications
|
* @param \phpbb\notification\manager $phpbb_notifications
|
||||||
* @param \phpbb\template\template $template
|
* @param \phpbb\template\template $template
|
||||||
* @param \phpbb\user $user
|
* @param \phpbb\user $user
|
||||||
|
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher
|
||||||
* @param string $block
|
* @param string $block
|
||||||
*/
|
*/
|
||||||
public function output_notification_types($subscriptions, \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_types')
|
public function output_notification_types($subscriptions, \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, \phpbb\event\dispatcher_interface $phpbb_dispatcher, $block = 'notification_types')
|
||||||
{
|
{
|
||||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||||
|
|
||||||
|
@ -191,15 +211,31 @@ class ucp_notifications
|
||||||
|
|
||||||
foreach ($notification_methods as $method => $method_data)
|
foreach ($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block . '.notification_methods', array(
|
$tpl_ary = [
|
||||||
'METHOD' => $method_data['id'],
|
'METHOD' => $method_data['id'],
|
||||||
|
|
||||||
'NAME' => $user->lang($method_data['lang']),
|
'NAME' => $user->lang($method_data['lang']),
|
||||||
|
|
||||||
'AVAILABLE' => $method_data['method']->is_available($type_data['type']),
|
'AVAILABLE' => $method_data['method']->is_available($type_data['type']),
|
||||||
|
|
||||||
'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
|
'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
|
||||||
));
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to perform additional actions before ucp_notifications is displayed
|
||||||
|
*
|
||||||
|
* @event core.ucp_notifications_output_notification_types_modify_template_vars
|
||||||
|
* @var array type_data The notification type data
|
||||||
|
* @var array method_data The notification method data
|
||||||
|
* @var array tpl_ary The template variables
|
||||||
|
*
|
||||||
|
* @since 3.2.10-RC1
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'type_data',
|
||||||
|
'method_data',
|
||||||
|
'tpl_ary',
|
||||||
|
];
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.ucp_notifications_output_notification_types_modify_template_vars', compact($vars)));
|
||||||
|
|
||||||
|
$template->assign_block_vars($block . '.notification_methods', $tpl_ary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -277,7 +277,7 @@ class manager
|
||||||
* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
|
* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
|
||||||
*
|
*
|
||||||
* @event core.notification_manager_add_notifications
|
* @event core.notification_manager_add_notifications
|
||||||
* @var string notification_type_name The forum id from where the topic belongs
|
* @var string notification_type_name The notification type identifier
|
||||||
* @var array data Data specific for the notification_type_name used will be inserted
|
* @var array data Data specific for the notification_type_name used will be inserted
|
||||||
* @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel.
|
* @var array notify_users The array of userid that are going to be notified for this notification. Set to array() to cancel.
|
||||||
* @var array options The options that were used when this method was called (read only)
|
* @var array options The options that were used when this method was called (read only)
|
||||||
|
@ -333,10 +333,34 @@ class manager
|
||||||
foreach ($this->get_subscription_methods_instances() as $method)
|
foreach ($this->get_subscription_methods_instances() as $method)
|
||||||
{
|
{
|
||||||
$notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id));
|
$notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id));
|
||||||
|
$notification_method_name = $method->get_type();
|
||||||
|
|
||||||
foreach ($notified_users as $user => $notifications)
|
foreach ($notified_users as $user => $notifications)
|
||||||
{
|
{
|
||||||
unset($notify_users[$user]);
|
unset($notify_users[$user]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow filtering the $notify_users array by $notification_type_name & $notification_method_name for a notification that is about to be sent.
|
||||||
|
* Here, $notify_users is already filtered from users who've already been notified.
|
||||||
|
*
|
||||||
|
* @event core.notification_manager_add_notifications_for_users_modify_data
|
||||||
|
* @var string notification_type_name The notification type identifier
|
||||||
|
* @var string notification_method_name The notification method identifier (read only)
|
||||||
|
* @var array data Data specific for this type that will be inserted
|
||||||
|
* @var array notify_users User list to notify
|
||||||
|
* @var array notified_users The list of the users already notified (read only)
|
||||||
|
*
|
||||||
|
* @since 3.2.10-RC1
|
||||||
|
*/
|
||||||
|
$vars = [
|
||||||
|
'notification_type_name',
|
||||||
|
'notification_method_name',
|
||||||
|
'data',
|
||||||
|
'notify_users',
|
||||||
|
'notified_users',
|
||||||
|
];
|
||||||
|
extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications_for_users_modify_data', compact($vars)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($notify_users))
|
if (!count($notify_users))
|
||||||
|
|
Loading…
Add table
Reference in a new issue