Commit 3fad3427 authored by Guillaume Lucas's avatar Guillaume Lucas

[Plugins_GLPI] webservices - Ajout methodGetTags()

parent aa21a464
......@@ -126,6 +126,9 @@ function plugin_webservices_registerMethods() {
= array('PluginWebservicesMethodHelpdesk','methodsetTicketSolution');
$WEBSERVICES_METHOD['glpi.setTicketAssign']
= array('PluginWebservicesMethodHelpdesk','methodsetTicketAssign');
// Remonter les tags dans Centreon
$WEBSERVICES_METHOD['glpi.getTags'] = array('PluginWebservicesMethodInventaire','methodGetTags');
}
......@@ -234,4 +237,4 @@ function cron_plugin_webservices() {
return 1;
}
?>
\ No newline at end of file
?>
......@@ -1718,5 +1718,73 @@ class PluginWebservicesMethodInventaire extends PluginWebservicesMethodCommon {
}
return $resp;
}
/**
* Get tags for an object for an authenticated user
*
* @param $params array of options (computer)
* @param protocol the commonication protocol used
*/
static function methodGetTags($params, $protocol)
{
global $DB;
$check = self::checkStandardParameters($params,$protocol);
if ($check != 1)
{
return array();
}
if (!Session::haveRight("networking", "r")
|| !Session::haveRight("computer", "r"))
{
return array();
}
$item = new $params['itemtype']();
$resp = array();
$output = array();
if ($item->can($params['data']['id'], 'r'))
{
$tags = array();
$query = "SELECT *
FROM `glpi_plugin_tags_tags` tags
WHERE tags.itemtype = '".Toolbox::addslashes_deep($params['itemtype'])."'
AND tags.items_id = '".Toolbox::addslashes_deep($params['id'])."'";
if ($result = $DB->query($query))
{
if ($ligne = $DB->fetch_assoc($result))
{
$tags[$ligne['id']] = $ligne;
$resp = array();
$toformat = array('data' => $tags[$ligne['id']],
'searchOptions' => array('1' =>
array('table' => 'glpi_plugin_tags_tags',
'field' => 'tags',
'linkfield' => 'tags'
)
),
'options' => $params['options']);
parent::formatDataForOutput($toformat, $resp);
$output[$ligne['id']] = $resp;
}
}
}
return $output;
}
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment