2012-12-07 Sergio Martin <sergio.martin@artica.es>
* 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
This commit is contained in:
parent
1bb1011868
commit
eb8f66da1e
|
@ -1,3 +1,8 @@
|
|||
2012-12-07 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/functions_categories.php: Add categories
|
||||
library of functions
|
||||
|
||||
2012-12-07 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/javascript/pandora_modules.js
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
||||
// Please see http://pandorafms.org for full contribution list
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License
|
||||
// as published by the Free Software Foundation; version 2
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
/**
|
||||
* @package Include
|
||||
* @subpackage TAGS
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Delete a category by id.
|
||||
*
|
||||
* @param array $id Int with category id info.
|
||||
*
|
||||
* @return bool True or false if something goes wrong.
|
||||
*/
|
||||
function categories_delete_category ($id_category){
|
||||
// Change the elements of this category to "without category"
|
||||
db_process_sql_update('tagente_modulo', array('id_category' => 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;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue