Commit c7280fc2 authored by Guillaume Lucas's avatar Guillaume Lucas

[Plugins_GLPI] webservices - Passage à la version 1.4.2

Note : la methode methodListObjects() a été patchée en upstream. Le
pseudo-patch du commit be8ce666 est
donc inutile.
parent 870e0cd2
<?php
/*
* @version $Id: methodcommon.class.php 351 2013-05-22 14:41:59Z yllen $
* @version $Id: methodcommon.class.php 379 2014-04-06 15:49:28Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
......@@ -248,23 +248,6 @@ class PluginWebservicesMethodCommon {
if (($ok_master || $ok_slave)
&& DBConnection::establishDBConnection(false, false, false)) {
// Check OCS connections
$query = "SELECT `id`, `name`
FROM `glpi_ocsservers` WHERE `is_active`='1'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
if (OcsServer::checkOCSconnection($data['id'])) {
$resp['OCS_' . $data['name']] = "ok";
} else {
$resp['OCS_' . $data['name']] = "offline";
$ok = false;
}
}
}
}
// Check Auth connections
$auth = new Auth();
$auth->getAuthMethods();
......@@ -501,7 +484,8 @@ class PluginWebservicesMethodCommon {
if (isset($option['itemlink_type'])) {
$obj = new $option['itemlink_type']();
} else {
$obj = new $option['itemlink_link']();
$itemtype = getItemTypeForTable($option['table']);
$obj = new $itemtype();
}
$obj->getFromDB($p['data'][$linkfield]);
$tmp[$linkfield] = $p['data'][$linkfield];
......
<?php
/*
* @version $Id: methodhelpdesk.class.php 365 2014-02-09 16:48:19Z yllen $
* @version $Id: methodhelpdesk.class.php 379 2014-04-06 15:49:28Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
......@@ -851,9 +851,6 @@ class PluginWebservicesMethodHelpdesk extends PluginWebservicesMethodCommon {
= Html::clean(getUserName($ticket->fields['users_id_recipient']));
$resp['users_name_lastupdater']
= Html::clean(getUserName($ticket->fields['users_id_lastupdater']));
$resp['suppliers_name_assign']
= Html::clean(Dropdown::getDropdownName('glpi_manufacturers',
$ticket->fields['suppliers_id_assign']));
$resp['ticketcategories_name']
= Html::clean(Dropdown::getDropdownName('glpi_itilcategories',
$ticket->fields['itilcategories_id']));
......@@ -884,6 +881,8 @@ class PluginWebservicesMethodHelpdesk extends PluginWebservicesMethodCommon {
= Ticket::getTicketTypeName($resp['type']);
$resp['global_validation_name']
= TicketValidation::getStatus($resp['global_validation']);
$resp['locations_name']
= Html::clean(Dropdown::getDropdownName('glpi_locations', $resp['locations_id']));
if ($item && $item->getFromDB($resp['items_id'])) {
$resp['items_name'] = Html::clean($item->getNameID());
......@@ -1006,6 +1005,19 @@ class PluginWebservicesMethodHelpdesk extends PluginWebservicesMethodCommon {
$resp['groups'][$name][] = $group;
}
}
// Suppliers
$resp['suppliers']['assign'] = array();
foreach ($ticket->getSuppliers(CommonITILActor::ASSIGN) as $supplier) {
if (isset($params['id2name'])) {
$supplier['suppliers_name']
= Html::clean(Dropdown::getDropdownName('glpi_suppliers',
$supplier['suppliers_id']));
}
unset($supplier['tickets_id']);
unset($supplier['type']);
$resp['suppliers'][$name][] = $supplier;
}
// Satisfaction
$satisfaction = new TicketSatisfaction();
......@@ -1101,10 +1113,15 @@ class PluginWebservicesMethodHelpdesk extends PluginWebservicesMethodCommon {
$private = (isset($params['private']) && $params['private'] ? 1 : 0);
$followup = new TicketFollowup();
$user = 0;
if (isset($users_id)) {
$user = $users_id;
}
$data = array('tickets_id' => $params['ticket'],
'requesttypes_id'
=> $source,
'is_private' => $private,
'users_id' => $user,
'content' => addslashes(Toolbox::clean_cross_side_scripting_deep($params["content"])));
if (isset($params['close'])) {
......@@ -2016,19 +2033,24 @@ class PluginWebservicesMethodHelpdesk extends PluginWebservicesMethodCommon {
}
// supplier to assign : optionnal, default = none
$supplier_ticket = new Supplier();
$supplier = array('id' => $params['ticket']);
$supplier_ticket = new Supplier_Ticket();
$supplier = array('tickets_id' => $params['ticket'],
'type' => CommonITILActor::ASSIGN);
if (isset($params['supplier'])) {
if (!is_numeric($params['supplier'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'supplier');
}
$supplier['suppliers_id_assign'] = $params['supplier'];
$supplier['suppliers_id'] = $params['supplier'];
if (!$supplier_ticket->can(-1, 'w', $supplier)) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if ($ticket->isSupplier(CommonITILActor::ASSIGN, $params['supplier'])) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '',
'Supplier already assign for this ticket');
}
if (!$ticket->update($supplier)) {
if (!$supplier_ticket->add($supplier)) {
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '',
'supplier not assign');
}
......
<?php
/*
* @version $Id: methodinventaire.class.php 350 2013-05-22 13:38:57Z yllen $
* @version $Id: methodinventaire.class.php 374 2014-03-25 18:37:03Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
......@@ -119,27 +119,21 @@ class PluginWebservicesMethodInventaire extends PluginWebservicesMethodCommon {
if ($item->getField('entities_id') != NOT_AVAILABLE) {
$left_join = " LEFT JOIN `glpi_entities`
ON (`$table`.`entities_id` = `glpi_entities`.`id`) ";
}
$already_joined = array();
/* Aucune jointure n'est effectuée. Donc listInventoryObjectsRequestLeftJoins()
* ne retourne rien. Donc getEntitiesRestrictRequest(), en ajoutant un « AND ... »,
* rend la requête SQL invalide.
$left_join.= self::listInventoryObjectsRequestLeftJoins($params, $item, $table, $already_joined).
getEntitiesRestrictRequest(" AND ", $table); */
$already_joined = array();
$left_join.= self::listInventoryObjectsRequestLeftJoins($params, $item, $table, $already_joined).
getEntitiesRestrictRequest(" AND ", $table);
$where = self::listInventoryObjectsRequestParameters($params, $item, $table, $where);
$where = self::listInventoryObjectsRequestParameters($params, $item, $table, $where);
}
$query = "SELECT `$table`.* FROM `$table`
$left_join
$left_join
$where
ORDER BY `id`";
//LIMIT $start,$limit"; // C'est à Centreon-glpi de fixer sa limite (voir début).
// Comme il ne le fait pas, la limite par défaut, 20, s'applique.
// Cela nuit à mes tests actuels. À coder proprement du côté de Centreon-glpi.
foreach ($DB->request($query) as $data) {
$tmp = array();
$toformat = array('table' => $table, 'data' => $data,
......@@ -1611,7 +1605,7 @@ class PluginWebservicesMethodInventaire extends PluginWebservicesMethodCommon {
$item = new $params['itemtype']();
if (!$item->getFromDB($params['id'])
|| !Session::haveRight('contract','r')
|| $item->can($params['id'], 'r')) {
|| !$item->can($params['id'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
......
<?php
/*
* @version $Id: methodtools.class.php 365 2014-02-09 16:48:19Z yllen $
* @version $Id: methodtools.class.php 363 2014-02-09 16:45:11Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
......
<?php
/*
* @version $Id: setup.php 365 2014-02-09 16:48:19Z yllen $
* @version $Id: setup.php 367 2014-03-04 11:04:23Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
......@@ -90,12 +90,12 @@ function plugin_init_webservices() {
'class' => 'PluginWebservicesMethodHelpdesk'),
'with_ticketfollowup'
=> array('help' => 'bool', 'optional (Ticket only)',
=> array('help' => 'bool', 'optional (Ticket only)',
'itemtype' => 'TicketFollowup',
'allowed_types' => array('Ticket'),
'class' => 'PluginWebservicesMethodHelpdesk'),
'with_ticketvalidation'
=> array('help' => 'bool', 'optional (Ticket only)',
=> array('help' => 'bool', 'optional (Ticket only)',
'itemtype' => 'TicketValidation',
'allowed_types' => array('Ticket'),
'class' => 'PluginWebservicesMethodHelpdesk'),
......@@ -130,15 +130,14 @@ function plugin_init_webservices() {
}
// Get the name and the version of the plugin - Needed
function plugin_version_webservices() {
return array('name' => __('Web Services', 'webservices'),
'version' => '1.4.1',
'version' => '1.4.2',
'author' => 'Remi Collet, Nelly Mahu-Lasson, Walid Nouh',
'license' => 'GPLv2+',
'homepage' => 'https://forge.indepnet.net/projects/show/webservices',
'minGlpiVersion' => '0.84');
'minGlpiVersion' => '0.84.5');
}
......
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