aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-10-05 00:07:48 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2012-10-05 00:07:48 -0500
commit3f2e3ad633930744e1ed92cc529ca473ccfa09e0 (patch)
treedd66211547856d3e484aa52fefbb2f6352ee9205 /phpBB/includes
parentceb56da965f12245bca6b735cb71f3bbaf505307 (diff)
downloadforums-3f2e3ad633930744e1ed92cc529ca473ccfa09e0.tar
forums-3f2e3ad633930744e1ed92cc529ca473ccfa09e0.tar.gz
forums-3f2e3ad633930744e1ed92cc529ca473ccfa09e0.tar.bz2
forums-3f2e3ad633930744e1ed92cc529ca473ccfa09e0.tar.xz
forums-3f2e3ad633930744e1ed92cc529ca473ccfa09e0.zip
[ticket/11103] Working on test case
Fixing extension type/method naming scheme so they can be autoloaded. Other bugs PHPBB3-11103
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/notification/manager.php39
-rw-r--r--phpBB/includes/notification/method/base.php2
-rw-r--r--phpBB/includes/notification/type/base.php7
-rw-r--r--phpBB/includes/notification/type/interface.php2
4 files changed, 31 insertions, 19 deletions
diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php
index 854d72009e..c1ae61e08a 100644
--- a/phpBB/includes/notification/manager.php
+++ b/phpBB/includes/notification/manager.php
@@ -466,11 +466,6 @@ class phpbb_notification_manager
{
$class_name = $this->get_item_type_class_name($class_name);
- if (!class_exists($class_name))
- {
- include($file);
- }
-
$class = $this->get_item_type_class($class_name);
if ($class->is_available() && method_exists($class_name, 'get_item_type'))
@@ -502,11 +497,6 @@ class phpbb_notification_manager
{
$class_name = 'phpbb_notification_method_' . $method_name;
- if (!class_exists($class_name))
- {
- include($file);
- }
-
$method = $this->get_method_class($class_name);
if ($method->is_available())
@@ -652,7 +642,14 @@ class phpbb_notification_manager
{
if (!$safe)
{
- $item_type = preg_replace('#[^a-z_]#', '', $item_type);
+ $item_type = preg_replace('#[^a-z_-]#', '', $item_type);
+ }
+
+ if (strpos($item_type, 'ext_') === 0)
+ {
+ $item_type_ary = explode('-', substr($item_type, 4), 2);
+
+ return 'phpbb_ext_' . $item_type_ary[0] . '_notification_type_' . $item_type_ary[1];
}
return 'phpbb_notification_type_' . $item_type;
@@ -661,7 +658,7 @@ class phpbb_notification_manager
/**
* Helper to get the notifications item type class and set it up
*/
- private 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);
@@ -673,7 +670,7 @@ class phpbb_notification_manager
/**
* Helper to get the notifications method class and set it up
*/
- private 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);
}
@@ -693,15 +690,23 @@ class phpbb_notification_manager
->get_files();
foreach ($files as $file)
{
- $class = substr($file, strrpos($file, '/'));
- $class = substr($class, 1, (strpos($class, '.' . $this->php_ext) - 1));
+ $name = substr($file, strrpos($file, '/'));
+ $name = substr($name, 1, (strpos($name, '.' . $this->php_ext) - 1));
- if ($class == 'interface' || $class == 'base')
+ if ($name == 'interface' || $name == 'base')
{
continue;
}
- $subscription_files[$class] = $file;
+ if (!strpos($file, 'includes/')) // is an extension
+ {
+ $ext_name = substr($file, (strpos($file, 'ext/') + 4));
+ $ext_name = substr($ext_name, 0, strpos($ext_name, '/'));
+
+ $name = 'ext_' . $ext_name . '-' . $name;
+ }
+
+ $subscription_files[$name] = $file;
}
return $subscription_files;
diff --git a/phpBB/includes/notification/method/base.php b/phpBB/includes/notification/method/base.php
index 9f1db6d9f5..6410b1f519 100644
--- a/phpBB/includes/notification/method/base.php
+++ b/phpBB/includes/notification/method/base.php
@@ -50,7 +50,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth
*/
protected $queue = array();
- public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, phpbb_user $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
+ public function __construct(phpbb_notification_manager $notification_manager, 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->notification_manager = $notification_manager;
$this->db = $db;
diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php
index 31150477bb..9e31d57108 100644
--- a/phpBB/includes/notification/type/base.php
+++ b/phpBB/includes/notification/type/base.php
@@ -55,7 +55,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
*/
private $data = array();
- public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, phpbb_user $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
+ public function __construct(phpbb_notification_manager $notification_manager, 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->notification_manager = $notification_manager;
$this->db = $db;
@@ -91,6 +91,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
$this->data[$name] = $value;
}
+ public function __toString()
+ {
+ return (!empty($this->data)) ? var_export($this->data, true) : static::get_item_type();
+ }
+
/**
* Get special data (only important for the classes that extend this)
*
diff --git a/phpBB/includes/notification/type/interface.php b/phpBB/includes/notification/type/interface.php
index c17f248080..56fad9fd80 100644
--- a/phpBB/includes/notification/type/interface.php
+++ b/phpBB/includes/notification/type/interface.php
@@ -43,6 +43,8 @@ interface phpbb_notification_type_interface
public function create_insert_array($type_data);
+ public function users_to_query();
+
public function get_load_special();
public function load_special($data, $notifications);