mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 17:25:26 +02:00
2011-06-06 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_tags.php: Added new parameters to function tags_search_tag(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4404 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
c755e03c55
commit
c4a067a340
@ -1,3 +1,8 @@
|
|||||||
|
2011-06-06 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
|
* include/functions_tags.php: Added new parameters to function
|
||||||
|
tags_search_tag().
|
||||||
|
|
||||||
2011-06-06 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2011-06-06 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* include/ajax/alert_list.ajax.php: Added new callback function
|
* include/ajax/alert_list.ajax.php: Added new callback function
|
||||||
|
@ -24,10 +24,11 @@
|
|||||||
*
|
*
|
||||||
* @param string $tag_name_description Name or description of the tag that it's currently searched.
|
* @param string $tag_name_description Name or description of the tag that it's currently searched.
|
||||||
* @param array $filter Array with pagination parameters.
|
* @param array $filter Array with pagination parameters.
|
||||||
|
* @param bool $only_names Whether to return only names or all fields.
|
||||||
*
|
*
|
||||||
* @return mixed Returns an array with the tag selected by name or false.
|
* @return mixed Returns an array with the tag selected by name or false.
|
||||||
*/
|
*/
|
||||||
function tags_search_tag ($tag_name_description = false, $filter = false) {
|
function tags_search_tag ($tag_name_description = false, $filter = false, $only_names = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($tag_name_description){
|
if ($tag_name_description){
|
||||||
@ -49,6 +50,7 @@ function tags_search_tag ($tag_name_description = false, $filter = false) {
|
|||||||
else{
|
else{
|
||||||
$sql = 'SELECT * FROM ttag';
|
$sql = 'SELECT * FROM ttag';
|
||||||
}
|
}
|
||||||
|
if ($filter !== false){
|
||||||
switch ($config["dbtype"]) {
|
switch ($config["dbtype"]) {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
case "postgresql":
|
case "postgresql":
|
||||||
@ -63,6 +65,17 @@ function tags_search_tag ($tag_name_description = false, $filter = false) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$result = db_get_all_rows_sql ($sql);
|
||||||
|
}
|
||||||
|
$result_tags = array();
|
||||||
|
if ($only_names) {
|
||||||
|
foreach ($result as $tag){
|
||||||
|
$result_tags [$tag['id_tag']] = $tag['name'];
|
||||||
|
}
|
||||||
|
$result = $result_tags;
|
||||||
|
}
|
||||||
if ($result === false)
|
if ($result === false)
|
||||||
return array (); //Return an empty array
|
return array (); //Return an empty array
|
||||||
else
|
else
|
||||||
@ -103,7 +116,7 @@ function tags_search_tag_id($id){
|
|||||||
* @return mixed String with tag name or false.
|
* @return mixed String with tag name or false.
|
||||||
*/
|
*/
|
||||||
function tags_get_name($id){
|
function tags_get_name($id){
|
||||||
return db_get_value_filter ('name', 'ttag', 'id_tag', $id);
|
return db_get_value_filter ('name', 'ttag', array('id_tag' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,7 +127,7 @@ function tags_get_name($id){
|
|||||||
* @return mixed String with tag description or false.
|
* @return mixed String with tag description or false.
|
||||||
*/
|
*/
|
||||||
function tags_get_description($id){
|
function tags_get_description($id){
|
||||||
return db_get_value_filter('description', 'ttag', 'id_tag', $id);
|
return db_get_value_filter('description', 'ttag', array('id_tag' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,7 +138,7 @@ function tags_get_description($id){
|
|||||||
* @return mixed String with tag url or false.
|
* @return mixed String with tag url or false.
|
||||||
*/
|
*/
|
||||||
function tags_get_url($id){
|
function tags_get_url($id){
|
||||||
return db_get_value_filter('description', 'ttag', 'id_tag', $id);
|
return db_get_value_filter('description', 'ttag', array('id_tag' => $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,17 +276,25 @@ function tags_insert_module_tag ($id_agent_module, $tags){
|
|||||||
*
|
*
|
||||||
* @param int $id_agent_module Module's id.
|
* @param int $id_agent_module Module's id.
|
||||||
* @param array $tags Array with tags to associate to the module.
|
* @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.
|
* @return bool True or false if something goes wrong.
|
||||||
*/
|
*/
|
||||||
function tags_update_module_tag ($id_agent_module, $tags){
|
function tags_update_module_tag ($id_agent_module, $tags, $autocommit = false){
|
||||||
$errn = 0;
|
$errn = 0;
|
||||||
|
|
||||||
|
if (empty($tags))
|
||||||
|
$tags = array();
|
||||||
|
|
||||||
/* First delete module tag entries */
|
/* First delete module tag entries */
|
||||||
$result_tag = db_process_sql_delete ('ttag_module', 'id_agente_modulo', $id_agent_module);
|
$result_tag = db_process_sql_delete ('ttag_module', 'id_agente_modulo', $id_agent_module);
|
||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($tags as $tag){
|
foreach ($tags as $tag){
|
||||||
|
//Protect against default insert
|
||||||
|
if (empty($tag))
|
||||||
|
continue;
|
||||||
|
|
||||||
$values['id_tag'] = $tag;
|
$values['id_tag'] = $tag;
|
||||||
$values['id_agente_modulo'] = $id_agent_module;
|
$values['id_agente_modulo'] = $id_agent_module;
|
||||||
$result_tag = db_process_sql_insert('ttag_module', $values, false);
|
$result_tag = db_process_sql_insert('ttag_module', $values, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user