From eb8f66da1ea4de0a2d1d8d921260a807d51a7232 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 7 Dec 2012 14:30:16 +0000 Subject: [PATCH] 2012-12-07 Sergio Martin * include/functions_categories.php: Add categories library of functions git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7239 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++ .../include/functions_categories.php | 74 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 pandora_console/include/functions_categories.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9a3c61707a..1d96b2a282 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-12-07 Sergio Martin + + * include/functions_categories.php: Add categories + library of functions + 2012-12-07 Sergio Martin * include/javascript/pandora_modules.js diff --git a/pandora_console/include/functions_categories.php b/pandora_console/include/functions_categories.php new file mode 100644 index 0000000000..18b68f730b --- /dev/null +++ b/pandora_console/include/functions_categories.php @@ -0,0 +1,74 @@ + 0), array('id_category' => $id_category)); + db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category)); + if(enterprise_installed()) { + db_process_sql_update('tlocal_component', array('id_category' => 0), array('id_category' => $id_category)); + db_process_sql_update('tpolicy_modules', array('id_category' => 0), array('id_category' => $id_category)); + } + + return db_process_sql_delete('tcategory', array('id' => $id_category)); +} + +/** + * Get tag's total count. + * + * @return mixed Int with the tag's count. + */ +function categories_get_category_count(){ + return (int)db_get_value('count(*)', 'tcategory'); +} + +/** + * Select all categories. + * + * @return mixed Array with categories. + */ +function categories_get_all_categories ($mode = 'all') { + $categories = db_get_all_fields_in_table('tcategory'); + + if ($categories === false) + $categories = array(); + + switch($mode) { + case 'all': + return $categories; + break; + case 'forselect': + $categories_select = array(); + foreach($categories as $cat) { + $categories_select[$cat['id']] = $cat['name']; + } + return $categories_select; + } +} +?>