aboutsummaryrefslogtreecommitdiff
path: root/mod/categories/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/categories/start.php')
-rw-r--r--mod/categories/start.php59
1 files changed, 33 insertions, 26 deletions
diff --git a/mod/categories/start.php b/mod/categories/start.php
index 2dedb3dc3..0aacf11e7 100644
--- a/mod/categories/start.php
+++ b/mod/categories/start.php
@@ -1,40 +1,42 @@
<?php
-
/**
* Elgg categories plugin
*
* @package ElggCategories
*/
+elgg_register_event_handler('init', 'system', 'categories_init');
+
/**
* Initialise categories plugin
*
*/
function categories_init() {
- global $CONFIG;
- elgg_extend_view('css', 'categories/css');
+ elgg_extend_view('css/elgg', 'categories/css');
- register_action('settings/categories/save', FALSE, $CONFIG->pluginspath . 'categories/actions/save.php', TRUE);
+ elgg_register_page_handler('categories', 'categories_page_handler');
- register_page_handler('categories', 'categories_page_handler');
+ elgg_register_event_handler('update', 'all', 'categories_save');
+ elgg_register_event_handler('create', 'all', 'categories_save');
- register_elgg_event_handler('update','all','categories_save');
- register_elgg_event_handler('create','all','categories_save');
+ // To keep the category plugins in the settings area and because we have to do special stuff,
+ // handle saving ourself.
+ elgg_register_plugin_hook_handler('action', 'plugins/settings/save', 'categories_save_site_categories');
}
/**
- * Page handler
- *
+ * Category page handler
+ * @return bool
*/
function categories_page_handler() {
- include(dirname(__FILE__) . "/listing.php");
- return TRUE;
+ include(dirname(__FILE__) . "/pages/categories/listing.php");
+ return true;
}
/**
- * Save site categories to and object upon save / edit
+ * Save categories to object upon save / edit
*
*/
function categories_save($event, $object_type, $object) {
@@ -55,22 +57,27 @@ function categories_save($event, $object_type, $object) {
}
/**
- * Add a reminder to set default categories.
+ * Saves the site categories.
+ *
+ * @param type $hook
+ * @param type $type
+ * @param type $value
+ * @param type $params
*/
-function categories_on_enable() {
- if (!$site->categories) {
- global $CONFIG;
- $message = sprintf(elgg_echo('categories:on_enable_reminder'), "{$CONFIG->url}pg/admin/plugin_settings/categories");
- elgg_add_admin_notice('categories_admin_notice_no_categories', $message);
+function categories_save_site_categories($hook, $type, $value, $params) {
+ $plugin_id = get_input('plugin_id');
+ if ($plugin_id != 'categories') {
+ return $value;
}
- return TRUE;
-}
-/**
- * Clean up admin notices on disable.
- */
-function categories_on_disable() {
+ $categories = get_input('categories');
+ $categories = string_to_tag_array($categories);
+
+ $site = elgg_get_site_entity();
+ $site->categories = $categories;
+ system_message(elgg_echo("categories:save:success"));
+
elgg_delete_admin_notice('categories_admin_notice_no_categories');
-}
-register_elgg_event_handler('init','system','categories_init'); \ No newline at end of file
+ forward(REFERER);
+} \ No newline at end of file