diff options
Diffstat (limited to 'phpBB/phpbb/notification')
26 files changed, 436 insertions, 100 deletions
| diff --git a/phpBB/phpbb/notification/exception.php b/phpBB/phpbb/notification/exception.php index a52d6fdc57..275fb3b542 100644 --- a/phpBB/phpbb/notification/exception.php +++ b/phpBB/phpbb/notification/exception.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification; +  /**  * @ignore  */ @@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_exception extends \Exception +class exception extends \Exception  {  	public function __toString()  	{ diff --git a/phpBB/phpbb/notification/manager.php b/phpBB/phpbb/notification/manager.php index 97833710c0..c42c84fb1f 100644 --- a/phpBB/phpbb/notification/manager.php +++ b/phpBB/phpbb/notification/manager.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification; +  /**  * @ignore  */ @@ -19,7 +21,7 @@ if (!defined('IN_PHPBB'))  * Notifications service class  * @package notifications  */ -class phpbb_notification_manager +class manager  {  	/** @var array */  	protected $notification_types; @@ -30,16 +32,16 @@ class phpbb_notification_manager  	/** @var ContainerBuilder */  	protected $phpbb_container; -	/** @var phpbb_user_loader */ +	/** @var \phpbb\user_loader */  	protected $user_loader; -	/** @var phpbb_db_driver */ +	/** @var \phpbb\db\driver\driver */  	protected $db; -	/** @var phpbb_cache_service */ +	/** @var \phpbb\cache\service */  	protected $cache; -	/** @var phpbb_user */ +	/** @var \phpbb\user */  	protected $user;  	/** @var string */ @@ -59,21 +61,21 @@ class phpbb_notification_manager  	/**  	* Notification Constructor -	*  +	*  	* @param array $notification_types  	* @param array $notification_methods  	* @param ContainerBuilder $phpbb_container -	* @param phpbb_user_loader $user_loader -	* @param phpbb_db_driver $db -	* @param phpbb_user $user +	* @param \phpbb\user_loader $user_loader +	* @param \phpbb\db\driver\driver $db +	* @param \phpbb\user $user  	* @param string $phpbb_root_path  	* @param string $php_ext  	* @param string $notification_types_table  	* @param string $notifications_table  	* @param string $user_notifications_table -	* @return phpbb_notification_manager +	* @return \phpbb\notification\manager  	*/ -	public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) +	public function __construct($notification_types, $notification_methods, $phpbb_container, \phpbb\user_loader $user_loader, \phpbb\db\driver\driver $db, \phpbb\cache\service $cache, $user, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)  	{  		$this->notification_types = $notification_types;  		$this->notification_methods = $notification_methods; @@ -402,7 +404,7 @@ class phpbb_notification_manager  		$pre_create_data = $notification->pre_create_insert_array($data, $notify_users);  		unset($notification); -		$insert_buffer = new phpbb_db_sql_insert_buffer($this->db, $this->notifications_table); +		$insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->notifications_table);  		// Go through each user so we can insert a row in the DB and then notify them by their desired means  		foreach ($notify_users as $user => $methods) @@ -490,15 +492,15 @@ class phpbb_notification_manager  	*  	* @param string|array $notification_type_name Type identifier or array of item types (only acceptable if the $item_id is identical for the specified types)  	* @param int|array $item_id Identifier within the type (or array of ids) -	* @param array $data Data specific for this type that will be updated +	* @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)  	*/ -	public function delete_notifications($notification_type_name, $item_id) +	public function delete_notifications($notification_type_name, $item_id, $parent_id = false)  	{  		if (is_array($notification_type_name))  		{  			foreach ($notification_type_name as $type)  			{ -				$this->delete_notifications($type, $item_id); +				$this->delete_notifications($type, $item_id, $parent_id);  			}  			return; @@ -508,7 +510,8 @@ class phpbb_notification_manager  		$sql = 'DELETE FROM ' . $this->notifications_table . '  			WHERE notification_type_id = ' . (int) $notification_type_id . ' -				AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id); +				AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) . +				(($parent_id !== false) ? ' AND ' . ((is_array($parent_id) ? $this->db->sql_in_set('item_parent_id', $parent_id) : 'item_parent_id = ' . (int) $parent_id)) : '');  		$this->db->sql_query($sql);  	} @@ -525,7 +528,7 @@ class phpbb_notification_manager  		{  			$type = $this->get_item_type_class($type_name); -			if ($type instanceof phpbb_notification_type_interface && $type->is_available()) +			if ($type instanceof \phpbb\notification\type\type_interface && $type->is_available())  			{  				$options = array_merge(array(  					'id'		=> $type->get_type(), @@ -561,7 +564,7 @@ class phpbb_notification_manager  		{  			$method = $this->get_method_class($method_name); -			if ($method instanceof phpbb_notification_method_interface && $method->is_available()) +			if ($method instanceof \phpbb\notification\method\method_interface && $method->is_available())  			{  				$subscription_methods[$method_name] = array(  					'id'		=> $method->get_type(), @@ -796,11 +799,13 @@ class phpbb_notification_manager  	* Delete all notifications older than a certain time  	*  	* @param int $timestamp Unix timestamp to delete all notifications that were created before +	* @param bool $only_unread True (default) to only prune read notifications  	*/ -	public function prune_notifications($timestamp) +	public function prune_notifications($timestamp, $only_read = true)  	{  		$sql = 'DELETE FROM ' . $this->notifications_table . ' -			WHERE notification_time < ' . (int) $timestamp; +			WHERE notification_time < ' . (int) $timestamp . +				(($only_read) ? ' AND notification_read = 1' : '');  		$this->db->sql_query($sql);  	} @@ -834,12 +839,12 @@ class phpbb_notification_manager  	protected function load_object($object_name)  	{  		$object = $this->phpbb_container->get($object_name); -		 +  		if (method_exists($object, 'set_notification_manager'))  		{  			$object->set_notification_manager($this);  		} -		 +  		return $object;  	} @@ -873,7 +878,7 @@ class phpbb_notification_manager  		{  			if (!isset($this->notification_types[$notification_type_name]) && !isset($this->notification_types['notification.type.' . $notification_type_name]))  			{ -				throw new phpbb_notification_exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name)); +				throw new \phpbb\notification\exception($this->user->lang('NOTIFICATION_TYPE_NOT_EXIST', $notification_type_name));  			}  			$sql = 'INSERT INTO ' . $this->notification_types_table . ' ' . $this->db->sql_build_array('INSERT', array( diff --git a/phpBB/phpbb/notification/method/base.php b/phpBB/phpbb/notification/method/base.php index b633956d01..327f964424 100644 --- a/phpBB/phpbb/notification/method/base.php +++ b/phpBB/phpbb/notification/method/base.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\method; +  /**  * @ignore  */ @@ -19,33 +21,33 @@ if (!defined('IN_PHPBB'))  * Base notifications method class  * @package notifications  */ -abstract class phpbb_notification_method_base implements phpbb_notification_method_interface +abstract class base implements \phpbb\notification\method\method_interface  { -	/** @var phpbb_notification_manager */ +	/** @var \phpbb\notification\manager */  	protected $notification_manager; -	/** @var phpbb_user_loader */ +	/** @var \phpbb\user_loader */  	protected $user_loader; -	/** @var phpbb_db_driver */ +	/** @var \phpbb\db\driver\driver */  	protected $db; -	/** @var phpbb_cache_driver_interface */ +	/** @var \phpbb\cache\driver\driver_interface */  	protected $cache; -	/** @var phpbb_template */ +	/** @var \phpbb\template\template */  	protected $template; -	/** @var phpbb_extension_manager */ +	/** @var \phpbb\extension\manager */  	protected $extension_manager; -	/** @var phpbb_user */ +	/** @var \phpbb\user */  	protected $user; -	/** @var phpbb_auth */ +	/** @var \phpbb\auth\auth */  	protected $auth; -	/** @var phpbb_config */ +	/** @var \phpbb\config\config */  	protected $config;  	/** @var string */ @@ -64,17 +66,17 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth  	/**  	* Notification Method Base Constructor  	*  -	* @param phpbb_user_loader $user_loader -	* @param phpbb_db_driver $db -	* @param phpbb_cache_driver_interface $cache -	* @param phpbb_user $user -	* @param phpbb_auth $auth -	* @param phpbb_config $config +	* @param \phpbb\user_loader $user_loader +	* @param \phpbb\db\driver\driver $db +	* @param \phpbb\cache\driver\driver_interface $cache +	* @param \phpbb\user $user +	* @param \phpbb\auth\auth $auth +	* @param \phpbb\config\config $config  	* @param string $phpbb_root_path  	* @param string $php_ext -	* @return phpbb_notification_method_base +	* @return \phpbb\notification\method\base  	*/ -	public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) +	public function __construct(\phpbb\user_loader $user_loader, \phpbb\db\driver\driver $db, \phpbb\cache\driver\driver_interface $cache, $user, \phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path, $php_ext)  	{  		$this->user_loader = $user_loader;  		$this->db = $db; @@ -89,9 +91,9 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth  	/**  	* Set notification manager (required)  	*  -	* @param phpbb_notification_manager $notification_manager +	* @param \phpbb\notification\manager $notification_manager  	*/ -	public function set_notification_manager(phpbb_notification_manager $notification_manager) +	public function set_notification_manager(\phpbb\notification\manager $notification_manager)  	{  		$this->notification_manager = $notification_manager;  	} @@ -99,9 +101,9 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth  	/**  	* Add a notification to the queue  	* -	* @param phpbb_notification_type_interface $notification +	* @param \phpbb\notification\type\type_interface $notification  	*/ -	public function add_to_queue(phpbb_notification_type_interface $notification) +	public function add_to_queue(\phpbb\notification\type\type_interface $notification)  	{  		$this->queue[] = $notification;  	} diff --git a/phpBB/phpbb/notification/method/email.php b/phpBB/phpbb/notification/method/email.php index 571b0ec656..b761eb5a28 100644 --- a/phpBB/phpbb/notification/method/email.php +++ b/phpBB/phpbb/notification/method/email.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\method; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_method_email extends phpbb_notification_method_messenger_base +class email extends \phpbb\notification\method\messenger_base  {  	/**  	* Get notification method name diff --git a/phpBB/phpbb/notification/method/jabber.php b/phpBB/phpbb/notification/method/jabber.php index d3b756d020..6ec21bb735 100644 --- a/phpBB/phpbb/notification/method/jabber.php +++ b/phpBB/phpbb/notification/method/jabber.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\method; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_method_jabber extends phpbb_notification_method_messenger_base +class jabber extends \phpbb\notification\method\messenger_base  {  	/**  	* Get notification method name diff --git a/phpBB/phpbb/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php index 4966aa94bc..b1b30f29b7 100644 --- a/phpBB/phpbb/notification/method/messenger_base.php +++ b/phpBB/phpbb/notification/method/messenger_base.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\method; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -abstract class phpbb_notification_method_messenger_base extends phpbb_notification_method_base +abstract class messenger_base extends \phpbb\notification\method\base  {  	/**  	* Notify using phpBB messenger @@ -60,7 +62,7 @@ abstract class phpbb_notification_method_messenger_base extends phpbb_notificati  		{  			include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);  		} -		$messenger = new messenger(); +		$messenger = new \messenger();  		$board_url = generate_board_url();  		// Time to go through the queue and send emails diff --git a/phpBB/phpbb/notification/method/interface.php b/phpBB/phpbb/notification/method/method_interface.php index ef875942cc..0131a8bde0 100644 --- a/phpBB/phpbb/notification/method/interface.php +++ b/phpBB/phpbb/notification/method/method_interface.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\method; +  /**  * @ignore  */ @@ -19,7 +21,7 @@ if (!defined('IN_PHPBB'))  * Base notifications method interface  * @package notifications  */ -interface phpbb_notification_method_interface +interface method_interface  {  	/**  	* Get notification method name @@ -37,9 +39,9 @@ interface phpbb_notification_method_interface  	/**  	* Add a notification to the queue  	* -	* @param phpbb_notification_type_interface $notification +	* @param \phpbb\notification\type\type_interface $notification  	*/ -	public function add_to_queue(phpbb_notification_type_interface $notification); +	public function add_to_queue(\phpbb\notification\type\type_interface $notification);  	/**  	* Parse the queue and notify the users diff --git a/phpBB/phpbb/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php index 1a30781c35..cf4ec57989 100644 --- a/phpBB/phpbb/notification/type/approve_post.php +++ b/phpBB/phpbb/notification/type/approve_post.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_approve_post extends phpbb_notification_type_post +class approve_post extends \phpbb\notification\type\post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php index e728e9ac30..ca5bb67754 100644 --- a/phpBB/phpbb/notification/type/approve_topic.php +++ b/phpBB/phpbb/notification/type/approve_topic.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic +class approve_topic extends \phpbb\notification\type\topic  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 46517f1c9b..3c44468bb8 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -19,30 +21,30 @@ if (!defined('IN_PHPBB'))  * Base notifications class  * @package notifications  */ -abstract class phpbb_notification_type_base implements phpbb_notification_type_interface +abstract class base implements \phpbb\notification\type\type_interface  { -	/** @var phpbb_notification_manager */ +	/** @var \phpbb\notification\manager */  	protected $notification_manager; -	/** @var phpbb_user_loader */ +	/** @var \phpbb\user_loader */  	protected $user_loader; -	/** @var phpbb_db_driver */ +	/** @var \phpbb\db\driver\driver */  	protected $db; -	/** @var phpbb_cache_driver_interface */ +	/** @var \phpbb\cache\driver\driver_interface */  	protected $cache; -	/** @var phpbb_template */ +	/** @var \phpbb\template\template */  	protected $template; -	/** @var phpbb_user */ +	/** @var \phpbb\user */  	protected $user; -	/** @var phpbb_auth */ +	/** @var \phpbb\auth\auth */  	protected $auth; -	/** @var phpbb_config */ +	/** @var \phpbb\config\config */  	protected $config;  	/** @var string */ @@ -93,21 +95,21 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Notification Type Base Constructor -	*  -	* @param phpbb_user_loader $user_loader -	* @param phpbb_db_driver $db -	* @param phpbb_cache_driver_interface $cache -	* @param phpbb_user $user -	* @param phpbb_auth $auth -	* @param phpbb_config $config +	* +	* @param \phpbb\user_loader $user_loader +	* @param \phpbb\db\driver\driver $db +	* @param \phpbb\cache\driver\driver_interface $cache +	* @param \phpbb\user $user +	* @param \phpbb\auth\auth $auth +	* @param \phpbb\config\config $config  	* @param string $phpbb_root_path  	* @param string $php_ext  	* @param string $notification_types_table  	* @param string $notifications_table  	* @param string $user_notifications_table -	* @return phpbb_notification_type_base +	* @return \phpbb\notification\type\base  	*/ -	public function __construct(phpbb_user_loader $user_loader, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table) +	public function __construct(\phpbb\user_loader $user_loader, \phpbb\db\driver\driver $db, \phpbb\cache\driver\driver_interface $cache, $user, \phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path, $php_ext, $notification_types_table, $notifications_table, $user_notifications_table)  	{  		$this->user_loader = $user_loader;  		$this->db = $db; @@ -126,10 +128,10 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Set notification manager (required) -	*  -	* @param phpbb_notification_manager $notification_manager +	* +	* @param \phpbb\notification\manager $notification_manager  	*/ -	public function set_notification_manager(phpbb_notification_manager $notification_manager) +	public function set_notification_manager(\phpbb\notification\manager $notification_manager)  	{  		$this->notification_manager = $notification_manager; @@ -150,7 +152,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Magic method to get data from this notification -	*  +	*  	* @param mixed $name  	* @return mixed  	*/ @@ -162,7 +164,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Magic method to set data on this notification -	*  +	*  	* @param mixed $name  	* @return null  	*/ @@ -174,9 +176,9 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Magic method to get a string of this notification -	*  +	*  	* Primarily for testing -	*  +	*  	* @param string $name  	* @return mixed  	*/ @@ -283,7 +285,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Prepare to output the notification to the template -	*  +	*  	* @return array Template variables  	*/  	public function prepare_for_display() @@ -331,7 +333,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Get the user's avatar (fall back) -	*  +	*  	* @return string  	*/  	public function get_avatar() @@ -341,7 +343,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Get the special items to load (fall back) -	*  +	*  	* @return array  	*/  	public function get_load_special() @@ -359,7 +361,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Is available (fall back) -	*  +	*  	* @return bool  	*/  	public function is_available() @@ -369,7 +371,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i  	/**  	* Pre create insert array function (fall back) -	*  +	*  	* @return array  	*/  	public function pre_create_insert_array($type_data, $notify_users) diff --git a/phpBB/phpbb/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php index ae2e75d3eb..50ea7380af 100644 --- a/phpBB/phpbb/notification/type/bookmark.php +++ b/phpBB/phpbb/notification/type/bookmark.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_bookmark extends phpbb_notification_type_post +class bookmark extends \phpbb\notification\type\post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php index 951c7e0254..0c9162ec5c 100644 --- a/phpBB/phpbb/notification/type/disapprove_post.php +++ b/phpBB/phpbb/notification/type/disapprove_post.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post +class disapprove_post extends \phpbb\notification\type\approve_post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php index 038e528797..dde6f83ec4 100644 --- a/phpBB/phpbb/notification/type/disapprove_topic.php +++ b/phpBB/phpbb/notification/type/disapprove_topic.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic +class disapprove_topic extends \phpbb\notification\type\approve_topic  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/group_request.php b/phpBB/phpbb/notification/type/group_request.php new file mode 100644 index 0000000000..1768a8fffa --- /dev/null +++ b/phpBB/phpbb/notification/type/group_request.php @@ -0,0 +1,165 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\notification\type; + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ +	exit; +} + +class group_request extends \phpbb\notification\type\base +{ +	/** +	* {@inheritdoc} +	*/ +	public function get_type() +	{ +		return 'group_request'; +	} + +	/** +	* {@inheritdoc} +	*/ +	public static $notification_option = array( +		'lang'	=> 'NOTIFICATION_TYPE_GROUP_REQUEST', +	); + +	/** +	* {@inheritdoc} +	*/ +	public function is_available() +	{ +		// Leader of any groups? +		$sql = 'SELECT group_id +			FROM ' . USER_GROUP_TABLE . ' +			WHERE user_id = ' . (int) $this->user->data['user_id'] . ' +				AND group_leader = 1'; +		$result = $this->db->sql_query_limit($sql, 1); +		$row = $this->db->sql_fetchrow($result); +		$this->db->sql_freeresult($result); + +		return (!empty($row)) ? true : false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public static function get_item_id($group) +	{ +		return (int) $group['user_id']; +	} + +	/** +	* {@inheritdoc} +	*/ +	public static function get_item_parent_id($group) +	{ +		// Group id is the parent +		return (int) $group['group_id']; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function find_users_for_notification($group, $options = array()) +	{ +		$options = array_merge(array( +			'ignore_users'		=> array(), +		), $options); + +		$sql = 'SELECT user_id +			FROM ' . USER_GROUP_TABLE . ' +			WHERE group_leader = 1 +				AND group_id = ' . (int) $group['group_id']; +		$result = $this->db->sql_query($sql); + +		$user_ids = array(); +		while ($row = $this->db->sql_fetchrow($result)) +		{ +			$user_ids[] = (int) $row['user_id']; +		} +		$this->db->sql_freeresult($result); + +		$this->user_loader->load_users($user_ids); + +		return $this->check_user_notification_options($user_ids, $options); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_avatar() +	{ +		return $this->user_loader->get_avatar($this->item_id); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_title() +	{ +		$username = $this->user_loader->get_username($this->item_id, 'no_profile'); + +		return $this->user->lang('NOTIFICATION_GROUP_REQUEST', $username, $this->get_data('group_name')); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_email_template() +	{ +		return 'group_request'; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_email_template_variables() +	{ +		$user_data = $this->user_loader->get_user($this->item_id); + +		return array( +			'GROUP_NAME'		   		=> htmlspecialchars_decode($this->get_data('group_name')), +			'REQUEST_USERNAME' 	   		=> htmlspecialchars_decode($user_data['username']), + +			'U_PENDING'			  		=> generate_board_url() . "/ucp.{$this->php_ext}?i=groups&mode=manage&action=list&g={$this->item_parent_id}", +			'U_GROUP'					=> generate_board_url() . "/memberlist.{$this->php_ext}?mode=group&g={$this->item_parent_id}", +		); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_url() +	{ +		return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=groups&mode=manage&action=list&g={$this->item_parent_id}"); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function users_to_query() +	{ +		return array($this->item_id); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function create_insert_array($group, $pre_create_data = array()) +	{ +		$this->set_data('group_name', $group['group_name']); + +		return parent::create_insert_array($group, $pre_create_data); +	} +} diff --git a/phpBB/phpbb/notification/type/group_request_approved.php b/phpBB/phpbb/notification/type/group_request_approved.php new file mode 100644 index 0000000000..be4a902acd --- /dev/null +++ b/phpBB/phpbb/notification/type/group_request_approved.php @@ -0,0 +1,120 @@ +<?php +/** +* +* @package notifications +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb\notification\type; + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ +	exit; +} + +class group_request_approved extends \phpbb\notification\type\base +{ +	/** +	* {@inheritdoc} +	*/ +	public function get_type() +	{ +		return 'group_request_approved'; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function is_available() +	{ +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public static function get_item_id($group) +	{ +		return (int) $group['group_id']; +	} + +	/** +	* {@inheritdoc} +	*/ +	public static function get_item_parent_id($group) +	{ +		return 0; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function find_users_for_notification($group, $options = array()) +	{ +		$users = array(); + +		$group['user_ids'] = (!is_array($group['user_ids'])) ? array($group['user_ids']) : $group['user_ids']; + +		foreach ($group['user_ids'] as $user_id) +		{ +			$users[$user_id] = array(''); +		} + +		return $users; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_title() +	{ +		return $this->user->lang('NOTIFICATION_GROUP_REQUEST_APPROVED', $this->get_data('group_name')); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_url() +	{ +		return append_sid($this->phpbb_root_path . 'memberlist.' . $this->php_ext, "mode=group&g={$this->item_id}"); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function create_insert_array($group, $pre_create_data = array()) +	{ +		$this->set_data('group_name', $group['group_name']); + +		return parent::create_insert_array($group, $pre_create_data); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function users_to_query() +	{ +		return array(); +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_email_template() +	{ +		return false; +	} + +	/** +	* {@inheritdoc} +	*/ +	public function get_email_template_variables() +	{ +		return array(); +	} +} diff --git a/phpBB/phpbb/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php index b3db7ad5ad..bed0807b0f 100644 --- a/phpBB/phpbb/notification/type/pm.php +++ b/phpBB/phpbb/notification/type/pm.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_pm extends phpbb_notification_type_base +class pm extends \phpbb\notification\type\base  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 9207fd866e..fe50e7f172 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_post extends phpbb_notification_type_base +class post extends \phpbb\notification\type\base  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php index bc4b15cdc3..f05ed1ce9a 100644 --- a/phpBB/phpbb/notification/type/post_in_queue.php +++ b/phpBB/phpbb/notification/type/post_in_queue.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post +class post_in_queue extends \phpbb\notification\type\post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php index 0ed13f36fb..56cfbc9364 100644 --- a/phpBB/phpbb/notification/type/quote.php +++ b/phpBB/phpbb/notification/type/quote.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_quote extends phpbb_notification_type_post +class quote extends \phpbb\notification\type\post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php index 3fa73bab41..fd3f754f8a 100644 --- a/phpBB/phpbb/notification/type/report_pm.php +++ b/phpBB/phpbb/notification/type/report_pm.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_report_pm extends phpbb_notification_type_pm +class report_pm extends \phpbb\notification\type\pm  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php index 63dfa92064..2e4a1ceb30 100644 --- a/phpBB/phpbb/notification/type/report_pm_closed.php +++ b/phpBB/phpbb/notification/type/report_pm_closed.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_pm +class report_pm_closed extends \phpbb\notification\type\pm  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php index de5c54a291..c2dad6f1bb 100644 --- a/phpBB/phpbb/notification/type/report_post.php +++ b/phpBB/phpbb/notification/type/report_post.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue +class report_post extends \phpbb\notification\type\post_in_queue  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php index 3916cd8db7..270ccf0a1a 100644 --- a/phpBB/phpbb/notification/type/report_post_closed.php +++ b/phpBB/phpbb/notification/type/report_post_closed.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_report_post_closed extends phpbb_notification_type_post +class report_post_closed extends \phpbb\notification\type\post  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php index 22436d3fb1..8db02f610b 100644 --- a/phpBB/phpbb/notification/type/topic.php +++ b/phpBB/phpbb/notification/type/topic.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_topic extends phpbb_notification_type_base +class topic extends \phpbb\notification\type\base  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php index f735e10c00..056651bc53 100644 --- a/phpBB/phpbb/notification/type/topic_in_queue.php +++ b/phpBB/phpbb/notification/type/topic_in_queue.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))  *  * @package notifications  */ -class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic +class topic_in_queue extends \phpbb\notification\type\topic  {  	/**  	* Get notification type name diff --git a/phpBB/phpbb/notification/type/interface.php b/phpBB/phpbb/notification/type/type_interface.php index a40fdafd09..cfc6cd461e 100644 --- a/phpBB/phpbb/notification/type/interface.php +++ b/phpBB/phpbb/notification/type/type_interface.php @@ -7,6 +7,8 @@  *  */ +namespace phpbb\notification\type; +  /**  * @ignore  */ @@ -19,7 +21,7 @@ if (!defined('IN_PHPBB'))  * Base notifications interface  * @package notifications  */ -interface phpbb_notification_type_interface +interface type_interface  {  	/**  	* Get notification type name @@ -27,7 +29,7 @@ interface phpbb_notification_type_interface  	* @return string  	*/  	public function get_type(); -	 +  	/**  	* Set initial data from the database  	* | 
