2013-04-02 Dario Rodriguez <dario@artica.es>

* include/functions_api.php: New function to create a tag
        via API.
        * include/functions_tags.php: Create tag only if not exists.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7916 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
darode 2013-04-02 16:49:43 +00:00
parent 38576c4470
commit 1706c1f9fd
3 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2013-04-02 Dario Rodriguez <dario@artica.es>
* include/functions_api.php: New function to create a tag
via API.
* include/functions_tags.php: Create tag only if not exists.
2013-04-02 Mario Pulido <mario.pulido@artica.es>
* include/help/en/help_inventory_tab.php,

View File

@ -5698,6 +5698,40 @@ function api_get_event_info($id_event, $trash1, $trash, $returnType) {
return;
}
//http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_tag&other=tag_name|tag_description|tag_url|tag_email&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
function api_set_create_tag ($id, $trash1, $other, $returnType) {
$data = array();
if ($other['type'] == 'string') {
$data["name"] = $other["data"];
} else if ($other['type'] == 'array') {
$data['name'] = $other["data"][0];
if ($other["data"][1] != '') {
$data['description'] = $other["data"][1];
} else {
$data['description'] = "";
}
if ($other["data"][1] != '') {
$data['url'] = $other["data"][2];
} else {
$data['url'] = "";
}
if ($other["data"][1] != '') {
$data['email'] = $other["data"][3];
} else {
$data['email'] = '';
}
}
tags_create_tag ($data);
}
//http://127.0.0.1/pandora_console/include/api.php?op=set&op2=create_event&id=name_event&other=2|system|3|admin|2|1|10|0|comments||Pandora||critical_inst|warning_inst|unknown_inst|other&other_mode=url_encode_separator_|&apipass=1234&user=admin&pass=pandora
function api_set_create_event($id, $trash1, $other, $returnType) {

View File

@ -198,6 +198,11 @@ function tags_create_tag($values) {
return false;
}
//No create tag if the tag exists
if (tags_get_id($values["name"])) {
return false;
}
return db_process_sql_insert('ttag',$values);
}