diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-01 03:09:12 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-01 03:09:12 +0000 |
commit | 7cd7febec888d56225fb43dc9ac7a96f95eee154 (patch) | |
tree | 87f83d25d2c123105dfab8b5437cfd28c7bd8a4e | |
parent | 051e6113a19fac3b5da24eabede5768e1a040518 (diff) | |
download | elgg-7cd7febec888d56225fb43dc9ac7a96f95eee154.tar.gz elgg-7cd7febec888d56225fb43dc9ac7a96f95eee154.tar.bz2 |
blog plugin uses on_activate to set its class or the upgrade event
git-svn-id: http://code.elgg.org/elgg/trunk@8526 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | mod/blog/manifest.xml | 1 | ||||
-rw-r--r-- | mod/blog/start.php | 29 |
2 files changed, 19 insertions, 11 deletions
diff --git a/mod/blog/manifest.xml b/mod/blog/manifest.xml index 6bc570449..b241d2651 100644 --- a/mod/blog/manifest.xml +++ b/mod/blog/manifest.xml @@ -14,4 +14,5 @@ </requires> <admin_interface>simple</admin_interface> <activate_on_install>true</activate_on_install> + <on_activate>blog_on_activate</on_activate> </plugin_manifest> diff --git a/mod/blog/start.php b/mod/blog/start.php index 04197aa4e..437970de4 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -25,8 +25,7 @@ function blog_init() { $item = new ElggMenuItem('blog', elgg_echo('blog:blogs'), 'pg/blog/all'); elgg_register_menu_item('site', $item); - // run the setup upon activations or to upgrade old installations. - run_function_once('blog_runonce', '1269370108'); + elgg_register_event_handler('upgrade', 'upgrade', 'blog_run_upgrades'); // add to the main css elgg_extend_view('css/screen', 'blog/css'); @@ -69,15 +68,6 @@ function blog_init() { } /** - * Register entity class for object:blog -> ElggBlog - */ -function blog_runonce() { - if (!update_subtype('object', 'blog', 'ElggBlog')) { - add_subtype('object', 'blog', 'ElggBlog'); - } -} - -/** * Dispatches blog pages. * URLs take the form of * All blogs: pg/blog/all @@ -198,3 +188,20 @@ function blog_ecml_views_hook($hook, $entity_type, $return_value, $params) { return $return_value; } + +/** + * Runs when blog plugin is activated. See manifest file. + */ +function blog_on_activate() { + add_subtype('object', 'blog', 'ElggBlog'); +} + +/** + * When upgrading, check if the ElggBlog class has been registered as this + * was added in Elgg 1.8 + */ +function blog_run_upgrades() { + if (!update_subtype('object', 'blog', 'ElggBlog')) { + add_subtype('object', 'blog', 'ElggBlog'); + } +} |