2011-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* include/functions_modules.php
	include/functions_tags.php: Support for policy's tag functionality.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4418 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-06-08 14:11:12 +00:00
parent 0035e2937e
commit 39828a68c4
3 changed files with 100 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2011-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_modules.php
include/functions_tags.php: Support for policy's tag functionality.
2011-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2011-06-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* godmode/massive/massive_edit_modules.php: Tags editor inside massive * godmode/massive/massive_edit_modules.php: Tags editor inside massive

View File

@ -164,6 +164,7 @@ function modules_delete_agent_module ($id_agent_module) {
db_process_sql_update ('tagente_modulo', db_process_sql_update ('tagente_modulo',
array ('nombre' => 'delete_pending', 'delete_pending' => 1, 'disabled' => 1), array ('nombre' => 'delete_pending', 'delete_pending' => 1, 'disabled' => 1),
$where); $where);
db_process_sql_delete('ttag_module', $where);
return true; return true;
} }
@ -234,6 +235,7 @@ function modules_create_agent_module ($id_agent, $name, $values = false, $disabl
if ($id_agent_module === false) if ($id_agent_module === false)
return false; return false;
if ($tags !== false)
$return_tag = tags_insert_module_tag ($id_agent_module, $tags); $return_tag = tags_insert_module_tag ($id_agent_module, $tags);
if ($return_tag === false){ if ($return_tag === false){

View File

@ -273,6 +273,40 @@ function tags_insert_module_tag ($id_agent_module, $tags){
} }
} }
/**
* Inserts tag's array of a policy module.
*
* @param int $id_agent_module Policy module's id.
* @param array $tags Array with tags to associate to the module.
*
* @return bool True or false if something goes wrong.
*/
function tags_insert_policy_module_tag ($id_agent_module, $tags){
$errn = 0;
$values = array();
foreach ($tags as $tag){
//Protect against default insert
if (empty($tag))
continue;
$values['id_tag'] = $tag;
$values['id_policy_module'] = $id_agent_module;
$result_tag = db_process_sql_insert('ttag_policy_module', $values, false);
if ($result_tag === false)
$errn++;
}
if ($errn > 0){
db_process_sql_rollback();
return false;
}
else{
db_process_sql_commit();
return true;
}
}
/** /**
* Updates tag's array of a module. * Updates tag's array of a module.
* *
@ -306,6 +340,39 @@ function tags_update_module_tag ($id_agent_module, $tags, $autocommit = false){
} }
/**
* Updates tag's array of a policy module.
*
* @param int $id_policy_module Policy module's id.
* @param array $tags Array with tags to associate to the module.
* @param bool $autocommit Whether to do automatical commit or not.
*
* @return bool True or false if something goes wrong.
*/
function tags_update_policy_module_tag ($id_policy_module, $tags, $autocommit = false){
$errn = 0;
if (empty($tags))
$tags = array();
/* First delete module tag entries */
$result_tag = db_process_sql_delete ('ttag_policy_module', array('id_policy_module' => $id_policy_module));
$values = array();
foreach ($tags as $tag){
//Protect against default insert
if (empty($tag))
continue;
$values['id_tag'] = $tag;
$values['id_policy_module'] = $id_policy_module;
$result_tag = db_process_sql_insert('ttag_policy_module', $values, false);
if ($result_tag === false)
$errn++;
}
}
/** /**
* Select all tags of a module. * Select all tags of a module.
* *
@ -330,4 +397,29 @@ function tags_get_module_tags ($id_agent_module){
return $return; return $return;
} }
/**
* Select all tags of a policy module.
*
* @param int $id_policy_module Policy module's id.
*
* @return mixed Array with module tags or false if something goes wrong.
*/
function tags_get_policy_module_tags ($id_policy_module){
if (empty($id_policy_module))
return false;
$tags = db_get_all_rows_filter('ttag_policy_module', array('id_policy_module' => $id_policy_module), false);
if ($tags === false)
return false;
$return = array();
foreach ($tags as $tag){
$return[] = $tag['id_tag'];
}
return $return;
}
?> ?>