From 7aed9239088b582a065da3fb63796ff66cd357c8 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 26 May 2009 05:28:59 +0000 Subject: Restructure the module lifecycle. Install: _installer::install() is called, any necessary tables are created. Activate: _installer::activate() is called. Module controllers are routable, helpers are accessible, etc. The module is in use. Deactivate: _installer::deactivate() is called. Module code is not accessible or routable. Module is *not* in use, but its tables are still around. Uninstall: _installer::uninstall() is called. Module is completely removed from the database. Admin > Modules will install and activate modules, but will only deactivate (will NOT uninstall modules). --- modules/search/helpers/search_installer.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'modules/search/helpers/search_installer.php') diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php index a3d0f79e..5fc9b37b 100644 --- a/modules/search/helpers/search_installer.php +++ b/modules/search/helpers/search_installer.php @@ -31,18 +31,23 @@ class search_installer { KEY(`item_id`), FULLTEXT INDEX (`data`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;"); - - // populate the index with dirty records - $db->query("INSERT INTO {search_records} (`item_id`) SELECT `id` FROM {items}"); module::set_version("search", 1); + } + } + + static function activate() { + // Update the root item. This is a quick hack because the search module is activated as part + // of the official install, so this way we don't start off with a "your index is out of date" + // banner. + search::update(model_cache::get("item", 1)); search::check_index(); } + + static function deactivate() { + site_status::clear("search_index_out_of_date"); } static function uninstall() { - $db = Database::instance(); - $db->query("DROP TABLE {search_records}"); - site_status::clear("search_index_out_of_date"); - module::delete("search"); + Database::instance()->query("DROP TABLE {search_records}"); } } -- cgit v1.2.3