phpBB

Code Changes

File: phpbb/notification/manager.php

  Unmodified   Added   Modified   Removed
Line 277Line 277
		* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
*
* @event core.notification_manager_add_notifications

		* Here, $notify_users is already filtered by f_read and the ignored list included in the options variable
*
* @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 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 	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 options The options that were used when this method was called (read only)

Line 333Line 333
		foreach ($this->get_subscription_methods_instances() as $method)
{
$notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id));

		foreach ($this->get_subscription_methods_instances() as $method)
{
$notified_users = $method->get_notified_users($notification_type_id, array('item_id' => $item_id));

 


			foreach ($notified_users as $user => $notifications)
{
unset($notify_users[$user]);
}
}


			foreach ($notified_users as $user => $notifications)
{
unset($notify_users[$user]);
}
}


		if (!sizeof($notify_users))




















		/**
* Allow filtering the $notify_users array by $notification_type_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 array data Data specific for this type that will be inserted
* @var array notify_users User list to notify
*
* @since 3.2.10-RC1
* @since 3.3.1-RC1
*/
$vars = [
'notification_type_name',
'data',
'notify_users',
];
extract($this->phpbb_dispatcher->trigger_event('core.notification_manager_add_notifications_for_users_modify_data', compact($vars)));

if (!count($notify_users))

		{
return;
}

		{
return;
}

Line 475Line 495
				if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())
{
$options = array_merge(array(

				if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())
{
$options = array_merge(array(

						'id' => $type->get_type(),
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',


						'type'	=> $type,
'id' => $type->get_type(),
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',

					), (($type::$notification_option !== false) ? $type::$notification_option : array()));

$this->subscription_types[$options['group']][$options['id']] = $options;

					), (($type::$notification_option !== false) ? $type::$notification_option : array()));

$this->subscription_types[$options['group']][$options['id']] = $options;

Line 509Line 530
		foreach ($this->get_available_subscription_methods() as $method_name => $method)
{
$subscription_methods[$method_name] = array(

		foreach ($this->get_available_subscription_methods() as $method_name => $method)
{
$subscription_methods[$method_name] = array(

 
				'method'	=> $method,

				'id'		=> $method->get_type(),
'lang' => str_replace('.', '_', strtoupper($method->get_type())),
);

				'id'		=> $method->get_type(),
'lang' => str_replace('.', '_', strtoupper($method->get_type())),
);

Line 897Line 919
	*/
public function get_notification_type_id($notification_type_name)
{

	*/
public function get_notification_type_id($notification_type_name)
{

		$notification_type_ids = $this->cache->get('notification_type_ids');

$this->db->sql_transaction('begin');

if ($notification_type_ids === false)
{
$notification_type_ids = array();


 
			$sql = 'SELECT notification_type_id, notification_type_name
FROM ' . $this->notification_types_table;

			$sql = 'SELECT notification_type_id, notification_type_name
FROM ' . $this->notification_types_table;

			$result = $this->db->sql_query($sql);

		$result = $this->db->sql_query($sql, 604800); // cache for one week

			while ($row = $this->db->sql_fetchrow($result))
{
$notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
}
$this->db->sql_freeresult($result);

			while ($row = $this->db->sql_fetchrow($result))
{
$notification_type_ids[$row['notification_type_name']] = (int) $row['notification_type_id'];
}
$this->db->sql_freeresult($result);


$this->cache->put('notification_type_ids', $notification_type_ids);
}

 

if (!isset($notification_type_ids[$notification_type_name]))
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{


if (!isset($notification_type_ids[$notification_type_name]))
{
if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))
{

				$this->db->sql_transaction('rollback');


 
				throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}


				throw new \phpbb\notification\exception('NOTIFICATION_TYPE_NOT_EXIST', array($notification_type_name));
}


Line 932Line 941
			));
$this->db->sql_query($sql);


			));
$this->db->sql_query($sql);


 
			// expose new notification type ID for this request

			$notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();


			$notification_type_ids[$notification_type_name] = (int) $this->db->sql_nextid();


			$this->cache->put('notification_type_ids', $notification_type_ids);


			// destroy cache, we have a new addition which we have to to load next time
$this->cache->destroy('sql', $this->notification_types_table);

		}

		}


$this->db->sql_transaction('commit');

 

return $notification_type_ids[$notification_type_name];
}


return $notification_type_ids[$notification_type_name];
}