From 6b51de49c5c6a4030505ff1f979e3e14da06c457 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 22 Oct 2009 13:28:23 -0700 Subject: Change the modifier on activate and deactivate methods to static as they are in a helper class. --- modules/gallery/tests/No_Direct_Access_Test.php | 77 ---------------------- .../gallery/tests/No_Direct_ORM_Access_Test.php | 77 ++++++++++++++++++++++ modules/user/helpers/user.php | 4 +- 3 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 modules/gallery/tests/No_Direct_Access_Test.php create mode 100644 modules/gallery/tests/No_Direct_ORM_Access_Test.php diff --git a/modules/gallery/tests/No_Direct_Access_Test.php b/modules/gallery/tests/No_Direct_Access_Test.php deleted file mode 100644 index c6d8df95..00000000 --- a/modules/gallery/tests/No_Direct_Access_Test.php +++ /dev/null @@ -1,77 +0,0 @@ - $line) { - if (preg_match('/ORM::factory\\(\"user\"/', $line)) { - $errors[] = "$file($l) => $line"; - } - } - } - $file_as_string = null; - } - if ($errors) { - $this->assert_false(true, "Direct access to the users table found:\n" . join("\n", $errors)); - } - } - - public function no_access_to_groups_table_test() { - $dir = new UserModuleFilterIterator( - new PhpCodeFilterIterator( - new GalleryCodeFilterIterator( - new RecursiveIteratorIterator( - new RecursiveDirectoryIterator(DOCROOT))))); - $errors = array(); - foreach ($dir as $file) { - $file_as_string = file_get_contents($file); - if (preg_match("/ORM::factory\\(\"group\"/", $file_as_string)) { - foreach (split("\n", $file_as_string) as $l => $line) { - if (preg_match('/ORM::factory\\(\"group\"/', $line)) { - $errors[] = "$file($l) => $line"; - } - } - } - $file_as_string = null; - } - if ($errors) { - $this->assert_false(true, "Direct access to the groups table found:\n" . join("\n", $errors)); - } - } - -} - -class UserModuleFilterIterator extends FilterIterator { - public function accept() { - $path_name = $this->getInnerIterator()->getPathName(); - return strpos($path_name, "/modules/user") === false; - } -} diff --git a/modules/gallery/tests/No_Direct_ORM_Access_Test.php b/modules/gallery/tests/No_Direct_ORM_Access_Test.php new file mode 100644 index 00000000..c6d8df95 --- /dev/null +++ b/modules/gallery/tests/No_Direct_ORM_Access_Test.php @@ -0,0 +1,77 @@ + $line) { + if (preg_match('/ORM::factory\\(\"user\"/', $line)) { + $errors[] = "$file($l) => $line"; + } + } + } + $file_as_string = null; + } + if ($errors) { + $this->assert_false(true, "Direct access to the users table found:\n" . join("\n", $errors)); + } + } + + public function no_access_to_groups_table_test() { + $dir = new UserModuleFilterIterator( + new PhpCodeFilterIterator( + new GalleryCodeFilterIterator( + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator(DOCROOT))))); + $errors = array(); + foreach ($dir as $file) { + $file_as_string = file_get_contents($file); + if (preg_match("/ORM::factory\\(\"group\"/", $file_as_string)) { + foreach (split("\n", $file_as_string) as $l => $line) { + if (preg_match('/ORM::factory\\(\"group\"/', $line)) { + $errors[] = "$file($l) => $line"; + } + } + } + $file_as_string = null; + } + if ($errors) { + $this->assert_false(true, "Direct access to the groups table found:\n" . join("\n", $errors)); + } + } + +} + +class UserModuleFilterIterator extends FilterIterator { + public function accept() { + $path_name = $this->getInnerIterator()->getPathName(); + return strpos($path_name, "/modules/user") === false; + } +} diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index ec4f56ae..5f154313 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -27,7 +27,7 @@ class user_Core { /** * Initialize the provider so it is ready to use */ - public function activate() { + static function activate() { $db = Database::instance(); $db->query("CREATE TABLE IF NOT EXISTS {users} ( `id` int(9) NOT NULL auto_increment, @@ -93,7 +93,7 @@ class user_Core { /** * Cleanup up this provider so it is unavailable for use and won't conflict with the current driver */ - public function deactivate() { + static function deactivate() { // Delete all users and groups so that we give other modules an opportunity to clean up foreach (ORM::factory("user")->find_all() as $user) { $user->delete(); -- cgit v1.2.3