mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11103] Use phpBB Container to load types/methods
PHPBB3-11103
This commit is contained in:
parent
03e348cf58
commit
f09ee16252
25 changed files with 505 additions and 75 deletions
272
phpBB/config/notifications.yml
Normal file
272
phpBB/config/notifications.yml
Normal file
|
@ -0,0 +1,272 @@
|
||||||
|
services:
|
||||||
|
notification.type.approve_post:
|
||||||
|
class: phpbb_notification_type_approve_post
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.approve_topic:
|
||||||
|
class: phpbb_notification_type_approve_topic
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.bookmark:
|
||||||
|
class: phpbb_notification_type_bookmark
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.disapprove_post:
|
||||||
|
class: phpbb_notification_type_disapprove_post
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.disapprove_topic:
|
||||||
|
class: phpbb_notification_type_disapprove_topic
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.pm:
|
||||||
|
class: phpbb_notification_type_pm
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.post:
|
||||||
|
class: phpbb_notification_type_post
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.post_in_queue:
|
||||||
|
class: phpbb_notification_type_post_in_queue
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.quote:
|
||||||
|
class: phpbb_notification_type_quote
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.report_pm:
|
||||||
|
class: phpbb_notification_type_report_pm
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.report_pm_closed:
|
||||||
|
class: phpbb_notification_type_report_pm_closed
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.report_post:
|
||||||
|
class: phpbb_notification_type_report_post
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.report_post_closed:
|
||||||
|
class: phpbb_notification_type_report_post
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.topic:
|
||||||
|
class: phpbb_notification_type_topic
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.type.topic_in_queue:
|
||||||
|
class: phpbb_notification_type_topic_in_queue
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.type }
|
||||||
|
|
||||||
|
notification.method.email:
|
||||||
|
class: phpbb_notification_method_email
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.method }
|
||||||
|
|
||||||
|
notification.method.jabber:
|
||||||
|
class: phpbb_notification_method_jabber
|
||||||
|
arguments:
|
||||||
|
- @notification_manager
|
||||||
|
- @dbal.conn
|
||||||
|
- @cache.driver
|
||||||
|
- @template
|
||||||
|
- @ext.manager
|
||||||
|
- @user
|
||||||
|
- @auth
|
||||||
|
- @config
|
||||||
|
- %core.root_path%
|
||||||
|
- %core.php_ext%
|
||||||
|
tags:
|
||||||
|
- { name: notification.method }
|
|
@ -1,6 +1,7 @@
|
||||||
imports:
|
imports:
|
||||||
- { resource: tables.yml }
|
- { resource: tables.yml }
|
||||||
- { resource: cron_tasks.yml }
|
- { resource: cron_tasks.yml }
|
||||||
|
- { resource: notifications.yml }
|
||||||
|
|
||||||
services:
|
services:
|
||||||
auth:
|
auth:
|
||||||
|
@ -92,6 +93,7 @@ services:
|
||||||
notification_manager:
|
notification_manager:
|
||||||
class: phpbb_notification_manager
|
class: phpbb_notification_manager
|
||||||
arguments:
|
arguments:
|
||||||
|
- @container
|
||||||
- @dbal.conn
|
- @dbal.conn
|
||||||
- @cache.driver
|
- @cache.driver
|
||||||
- @template
|
- @template
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +23,9 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_manager
|
class phpbb_notification_manager
|
||||||
{
|
{
|
||||||
|
/** @var ContainerBuilder */
|
||||||
|
protected $phpbb_container = null;
|
||||||
|
|
||||||
/** @var dbal */
|
/** @var dbal */
|
||||||
protected $db = null;
|
protected $db = null;
|
||||||
|
|
||||||
|
@ -55,8 +60,9 @@ class phpbb_notification_manager
|
||||||
*/
|
*/
|
||||||
protected $users = array();
|
protected $users = array();
|
||||||
|
|
||||||
public function __construct(dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
public function __construct(ContainerBuilder $phpbb_container, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
|
$this->phpbb_container = $phpbb_container;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
|
@ -495,17 +501,17 @@ class phpbb_notification_manager
|
||||||
{
|
{
|
||||||
$subscription_types = array();
|
$subscription_types = array();
|
||||||
|
|
||||||
foreach ($this->get_subscription_files('notification/type/') as $class_name)
|
foreach ($this->phpbb_container->findTaggedServiceIds('notification.type') as $type_name => $data)
|
||||||
{
|
{
|
||||||
$class = $this->get_item_type_class($class_name);
|
$type = $this->get_item_type_class($type_name);
|
||||||
|
|
||||||
if ($class instanceof phpbb_notification_type_interface && $class->is_available())
|
if ($type instanceof phpbb_notification_type_interface && $type->is_available())
|
||||||
{
|
{
|
||||||
$options = array_merge(array(
|
$options = array_merge(array(
|
||||||
'id' => $class_name,
|
'id' => $type->get_type(),
|
||||||
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($class_name),
|
'lang' => 'NOTIFICATION_TYPE_' . strtoupper($type->get_type()),
|
||||||
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
|
'group' => 'NOTIFICATION_GROUP_MISCELLANEOUS',
|
||||||
), (($class_name::$notification_option !== false) ? $class_name::$notification_option : array()));
|
), (($type::$notification_option !== false) ? $type::$notification_option : array()));
|
||||||
|
|
||||||
$subscription_types[$options['group']][$options['id']] = $options;
|
$subscription_types[$options['group']][$options['id']] = $options;
|
||||||
}
|
}
|
||||||
|
@ -531,13 +537,16 @@ class phpbb_notification_manager
|
||||||
{
|
{
|
||||||
$subscription_methods = array();
|
$subscription_methods = array();
|
||||||
|
|
||||||
foreach ($this->get_subscription_files('notification/method/') as $class_name)
|
foreach ($this->phpbb_container->findTaggedServiceIds('notification.method') as $method_name => $data)
|
||||||
{
|
{
|
||||||
$method = $this->get_method_class($class_name);
|
$method = $this->get_method_class($method_name);
|
||||||
|
|
||||||
if ($method instanceof phpbb_notification_method_interface && $method->is_available())
|
if ($method instanceof phpbb_notification_method_interface && $method->is_available())
|
||||||
{
|
{
|
||||||
$subscription_methods[] = $class_name;
|
$subscription_methods[$method_name] = array(
|
||||||
|
'id' => $method->get_type(),
|
||||||
|
'lang' => 'NOTIFICATION_METHOD_' . strtoupper($method->get_type()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -783,7 +792,7 @@ class phpbb_notification_manager
|
||||||
*/
|
*/
|
||||||
public function get_item_type_class($item_type, $data = array())
|
public function get_item_type_class($item_type, $data = array())
|
||||||
{
|
{
|
||||||
$item = new $item_type($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
|
$item = $this->phpbb_container->get($item_type);
|
||||||
|
|
||||||
$item->set_initial_data($data);
|
$item->set_initial_data($data);
|
||||||
|
|
||||||
|
@ -795,43 +804,6 @@ class phpbb_notification_manager
|
||||||
*/
|
*/
|
||||||
public function get_method_class($method_name)
|
public function get_method_class($method_name)
|
||||||
{
|
{
|
||||||
return new $method_name($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
|
return $this->phpbb_container->get($method_name);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to get subscription related files with the finder
|
|
||||||
*/
|
|
||||||
private function get_subscription_files($path)
|
|
||||||
{
|
|
||||||
$finder = $this->extension_manager->get_finder();
|
|
||||||
|
|
||||||
$subscription_files = array();
|
|
||||||
|
|
||||||
$classes = $finder
|
|
||||||
->core_path('includes/' . $path)
|
|
||||||
->extension_directory($path)
|
|
||||||
->get_classes();
|
|
||||||
|
|
||||||
if (array_search('phpbb_notification_type_interface', $classes) !== false)
|
|
||||||
{
|
|
||||||
unset($classes[array_search('phpbb_notification_type_interface', $classes)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_search('phpbb_notification_type_base', $classes) !== false)
|
|
||||||
{
|
|
||||||
unset($classes[array_search('phpbb_notification_type_base', $classes)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_search('phpbb_notification_method_interface', $classes) !== false)
|
|
||||||
{
|
|
||||||
unset($classes[array_search('phpbb_notification_method_interface', $classes)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_search('phpbb_notification_method_base', $classes) !== false)
|
|
||||||
{
|
|
||||||
unset($classes[array_search('phpbb_notification_method_base', $classes)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $classes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_method_email extends phpbb_notification_method_base
|
class phpbb_notification_method_email extends phpbb_notification_method_base
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification method name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'email';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
|
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,13 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
interface phpbb_notification_method_interface
|
interface phpbb_notification_method_interface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification method name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this method available for the user?
|
* Is this method available for the user?
|
||||||
* This is checked on the notifications options
|
* This is checked on the notifications options
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_method_jabber extends phpbb_notification_method_email
|
class phpbb_notification_method_jabber extends phpbb_notification_method_email
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification method name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'jabber';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
|
* Notify method (since jabber gets sent through the same messenger, we let the jabber class inherit from this to reduce code duplication)
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_approve_post extends phpbb_notification_type_post
|
class phpbb_notification_type_approve_post extends phpbb_notification_type_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'approve_post';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic
|
class phpbb_notification_type_approve_topic extends phpbb_notification_type_topic
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'approve_topic';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -116,7 +116,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return (!empty($this->data)) ? var_export($this->data, true) : get_class($this);
|
return (!empty($this->data)) ? var_export($this->data, true) : $this->get_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +156,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||||
// Defaults
|
// Defaults
|
||||||
$this->data = array_merge(array(
|
$this->data = array_merge(array(
|
||||||
'item_id' => static::get_item_id($type_data),
|
'item_id' => static::get_item_id($type_data),
|
||||||
'item_type' => get_class($this),
|
'item_type' => $this->get_type(),
|
||||||
'item_parent_id' => static::get_item_parent_id($type_data),
|
'item_parent_id' => static::get_item_parent_id($type_data),
|
||||||
|
|
||||||
'time' => time(),
|
'time' => time(),
|
||||||
|
@ -319,7 +319,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||||
{
|
{
|
||||||
$options = array_merge(array(
|
$options = array_merge(array(
|
||||||
'ignore_users' => array(),
|
'ignore_users' => array(),
|
||||||
'item_type' => get_class($this),
|
'item_type' => $this->get_type(),
|
||||||
'item_id' => 0, // Global by default
|
'item_id' => 0, // Global by default
|
||||||
), $options);
|
), $options);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_bookmark extends phpbb_notification_type_post
|
class phpbb_notification_type_bookmark extends phpbb_notification_type_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'bookmark';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
@ -93,7 +103,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
|
||||||
$update_notifications = array();
|
$update_notifications = array();
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . NOTIFICATIONS_TABLE . "
|
FROM ' . NOTIFICATIONS_TABLE . "
|
||||||
WHERE item_type = '" . get_class($this) . "'
|
WHERE item_type = '" . $this->get_type() . "'
|
||||||
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
||||||
AND unread = 1
|
AND unread = 1
|
||||||
AND is_enabled = 1';
|
AND is_enabled = 1';
|
||||||
|
@ -103,7 +113,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post
|
||||||
// Do not create a new notification
|
// Do not create a new notification
|
||||||
unset($notify_users[$row['user_id']]);
|
unset($notify_users[$row['user_id']]);
|
||||||
|
|
||||||
$notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
|
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
||||||
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
||||||
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
||||||
WHERE notification_id = ' . $row['notification_id'];
|
WHERE notification_id = ' . $row['notification_id'];
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post
|
class phpbb_notification_type_disapprove_post extends phpbb_notification_type_approve_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'disapprove_post';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic
|
class phpbb_notification_type_disapprove_topic extends phpbb_notification_type_approve_topic
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'disapprove_topic';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,13 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
interface phpbb_notification_type_interface
|
interface phpbb_notification_type_interface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set initial data from the database
|
* Set initial data from the database
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_pm extends phpbb_notification_type_base
|
class phpbb_notification_type_pm extends phpbb_notification_type_base
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'pm';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification option data (for outputting to the user)
|
* Notification option data (for outputting to the user)
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_post extends phpbb_notification_type_base
|
class phpbb_notification_type_post extends phpbb_notification_type_base
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'post';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
@ -114,7 +124,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
|
||||||
$update_notifications = array();
|
$update_notifications = array();
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . NOTIFICATIONS_TABLE . "
|
FROM ' . NOTIFICATIONS_TABLE . "
|
||||||
WHERE item_type = '" . get_class($this) . "'
|
WHERE item_type = '" . $this->get_type() . "'
|
||||||
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
||||||
AND unread = 1
|
AND unread = 1
|
||||||
AND is_enabled = 1';
|
AND is_enabled = 1';
|
||||||
|
@ -124,7 +134,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base
|
||||||
// Do not create a new notification
|
// Do not create a new notification
|
||||||
unset($notify_users[$row['user_id']]);
|
unset($notify_users[$row['user_id']]);
|
||||||
|
|
||||||
$notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
|
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
||||||
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
||||||
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
||||||
WHERE notification_id = ' . $row['notification_id'];
|
WHERE notification_id = ' . $row['notification_id'];
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
|
class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'post_in_queue';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_quote extends phpbb_notification_type_post
|
class phpbb_notification_type_quote extends phpbb_notification_type_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'quote';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* regular expression to match to find usernames
|
* regular expression to match to find usernames
|
||||||
*
|
*
|
||||||
|
@ -112,7 +122,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
|
||||||
$update_notifications = array();
|
$update_notifications = array();
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . NOTIFICATIONS_TABLE . "
|
FROM ' . NOTIFICATIONS_TABLE . "
|
||||||
WHERE item_type = '" . get_class($this) . "'
|
WHERE item_type = '" . $this->get_type() . "'
|
||||||
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
AND item_parent_id = " . (int) self::get_item_parent_id($post) . '
|
||||||
AND unread = 1
|
AND unread = 1
|
||||||
AND is_enabled = 1';
|
AND is_enabled = 1';
|
||||||
|
@ -122,7 +132,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
|
||||||
// Do not create a new notification
|
// Do not create a new notification
|
||||||
unset($notify_users[$row['user_id']]);
|
unset($notify_users[$row['user_id']]);
|
||||||
|
|
||||||
$notification = $this->notification_manager->get_item_type_class(get_class($this), $row);
|
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $row);
|
||||||
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
$sql = 'UPDATE ' . NOTIFICATIONS_TABLE . '
|
||||||
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . '
|
||||||
WHERE notification_id = ' . $row['notification_id'];
|
WHERE notification_id = ' . $row['notification_id'];
|
||||||
|
@ -143,7 +153,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
|
||||||
$old_notifications = array();
|
$old_notifications = array();
|
||||||
$sql = 'SELECT user_id
|
$sql = 'SELECT user_id
|
||||||
FROM ' . NOTIFICATIONS_TABLE . "
|
FROM ' . NOTIFICATIONS_TABLE . "
|
||||||
WHERE item_type = '" . get_class($this) . "'
|
WHERE item_type = '" . $this->get_type() . "'
|
||||||
AND item_id = " . self::get_item_id($post) . '
|
AND item_id = " . self::get_item_id($post) . '
|
||||||
AND is_enabled = 1';
|
AND is_enabled = 1';
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
|
@ -167,13 +177,13 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the necessary notifications
|
// Add the necessary notifications
|
||||||
$this->notification_manager->add_notifications_for_users(get_class($this), $post, $add_notifications);
|
$this->notification_manager->add_notifications_for_users($this->get_type(), $post, $add_notifications);
|
||||||
|
|
||||||
// Remove the necessary notifications
|
// Remove the necessary notifications
|
||||||
if (!empty($remove_notifications))
|
if (!empty($remove_notifications))
|
||||||
{
|
{
|
||||||
$sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . "
|
$sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . "
|
||||||
WHERE item_type = '" . get_class($this) . "'
|
WHERE item_type = '" . $this->get_type() . "'
|
||||||
AND item_id = " . self::get_item_id($post) . '
|
AND item_id = " . self::get_item_id($post) . '
|
||||||
AND ' . $this->db->sql_in_set('user_id', $remove_notifications);
|
AND ' . $this->db->sql_in_set('user_id', $remove_notifications);
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
|
class phpbb_notification_type_report_pm extends phpbb_notification_type_pm
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'report_pm';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_pm
|
class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_pm
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'report_pm_closed';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email template to use to send notifications
|
* Email template to use to send notifications
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue
|
class phpbb_notification_type_report_post extends phpbb_notification_type_post_in_queue
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'report_post';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_report_post_closed extends phpbb_notification_type_post
|
class phpbb_notification_type_report_post_closed extends phpbb_notification_type_post
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'report_post_closed';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Email template to use to send notifications
|
* Email template to use to send notifications
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_topic extends phpbb_notification_type_base
|
class phpbb_notification_type_topic extends phpbb_notification_type_base
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'topic';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -23,6 +23,16 @@ if (!defined('IN_PHPBB'))
|
||||||
*/
|
*/
|
||||||
class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic
|
class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_topic
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Get notification type name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_type()
|
||||||
|
{
|
||||||
|
return 'topic_in_queue';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language key used to output the text
|
* Language key used to output the text
|
||||||
*
|
*
|
||||||
|
|
|
@ -48,15 +48,15 @@ class ucp_notifications
|
||||||
{
|
{
|
||||||
foreach($subscription_types as $type => $data)
|
foreach($subscription_types as $type => $data)
|
||||||
{
|
{
|
||||||
foreach($notification_methods as $method)
|
foreach($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
if ($request->is_set_post($type . '_' . $method) && (!isset($subscriptions[$type]) || !in_array($method, $subscriptions[$type])))
|
if ($request->is_set_post($type . '_' . $method_data['id']) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
|
||||||
{
|
{
|
||||||
$phpbb_notifications->add_subscription($type, 0, $method);
|
$phpbb_notifications->add_subscription($type, 0, $method_data['id']);
|
||||||
}
|
}
|
||||||
else if (!$request->is_set_post($type . '_' . $method) && isset($subscriptions[$type]) && in_array($method, $subscriptions[$type]))
|
else if (!$request->is_set_post($type . '_' . $method_data['id']) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
|
||||||
{
|
{
|
||||||
$phpbb_notifications->delete_subscription($type, 0, $method);
|
$phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,14 +186,14 @@ class ucp_notifications
|
||||||
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
|
'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
|
||||||
));
|
));
|
||||||
|
|
||||||
foreach($notification_methods as $method)
|
foreach($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block . '.notification_methods', array(
|
$template->assign_block_vars($block . '.notification_methods', array(
|
||||||
'METHOD' => $method,
|
'METHOD' => $method_data['id'],
|
||||||
|
|
||||||
'NAME' => $user->lang(strtoupper($method)),
|
'NAME' => $user->lang($method_data['lang']),
|
||||||
|
|
||||||
'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method, $subscriptions[$type])) ? true : false,
|
'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,12 +212,12 @@ class ucp_notifications
|
||||||
{
|
{
|
||||||
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
$notification_methods = $phpbb_notifications->get_subscription_methods();
|
||||||
|
|
||||||
foreach($notification_methods as $method)
|
foreach($notification_methods as $method => $method_data)
|
||||||
{
|
{
|
||||||
$template->assign_block_vars($block, array(
|
$template->assign_block_vars($block, array(
|
||||||
'METHOD' => $method,
|
'METHOD' => $method_data['id'],
|
||||||
|
|
||||||
'NAME' => $user->lang(strtoupper($method)),
|
'NAME' => $user->lang($method_data['lang']),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,6 +295,8 @@ $lang = array_merge($lang, array(
|
||||||
'NOTIFICATION_GROUP_MISCELLANEOUS' => 'Miscellaneous Notifications',
|
'NOTIFICATION_GROUP_MISCELLANEOUS' => 'Miscellaneous Notifications',
|
||||||
'NOTIFICATION_GROUP_MODERATION' => 'Moderation Notifications',
|
'NOTIFICATION_GROUP_MODERATION' => 'Moderation Notifications',
|
||||||
'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications',
|
'NOTIFICATION_GROUP_POSTING' => 'Posting Notifications',
|
||||||
|
'NOTIFICATION_METHOD_EMAIL' => 'Email',
|
||||||
|
'NOTIFICATION_METHOD_JABBER' => 'Jabber',
|
||||||
'NOTIFICATION_TYPE' => 'Notification type',
|
'NOTIFICATION_TYPE' => 'Notification type',
|
||||||
'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked',
|
'NOTIFICATION_TYPE_BOOKMARK' => 'Someone replies to a topic you have bookmarked',
|
||||||
'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval',
|
'NOTIFICATION_TYPE_IN_MODERATION_QUEUE' => 'A post or topic needs approval',
|
||||||
|
@ -374,8 +376,6 @@ $lang = array_merge($lang, array(
|
||||||
'PASSWORD_UPDATED' => 'A new password was sent to your registered email address.',
|
'PASSWORD_UPDATED' => 'A new password was sent to your registered email address.',
|
||||||
'PERMISSIONS_RESTORED' => 'Successfully restored original permissions.',
|
'PERMISSIONS_RESTORED' => 'Successfully restored original permissions.',
|
||||||
'PERMISSIONS_TRANSFERRED' => 'Successfully transferred permissions from <strong>%s</strong>, you are now able to browse the board with this user’s permissions.<br />Please note that admin permissions were not transferred. You are able to revert to your permission set at any time.',
|
'PERMISSIONS_TRANSFERRED' => 'Successfully transferred permissions from <strong>%s</strong>, you are now able to browse the board with this user’s permissions.<br />Please note that admin permissions were not transferred. You are able to revert to your permission set at any time.',
|
||||||
'PHPBB_NOTIFICATION_METHOD_EMAIL' => 'Email',
|
|
||||||
'PHPBB_NOTIFICATION_METHOD_JABBER' => 'Jabber',
|
|
||||||
'PM_DISABLED' => 'Private messaging has been disabled on this board.',
|
'PM_DISABLED' => 'Private messaging has been disabled on this board.',
|
||||||
'PM_FROM' => 'From',
|
'PM_FROM' => 'From',
|
||||||
'PM_FROM_REMOVED_AUTHOR' => 'This message was sent by a user no longer registered.',
|
'PM_FROM_REMOVED_AUTHOR' => 'This message was sent by a user no longer registered.',
|
||||||
|
|
Loading…
Add table
Reference in a new issue