From 3f2e3ad633930744e1ed92cc529ca473ccfa09e0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Oct 2012 00:07:48 -0500 Subject: [ticket/11103] Working on test case Fixing extension type/method naming scheme so they can be autoloaded. Other bugs PHPBB3-11103 --- phpBB/includes/notification/manager.php | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'phpBB/includes/notification/manager.php') 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; -- cgit v1.2.1