Commit 4dc32722 authored by Guillaume Lucas's avatar Guillaume Lucas

[Plugins_GLPI] webservices - commit initial. Version 1.4.1 en l'état.

parent 283d3a12
<Files xmlrpc.php>
# Uncomment next line to enable compression and reduce network load
# If this is globally enabled, it should NOT be enable for a client from GUI
#php_value zlib.output_compression 4096
</Files>
Plugin Webservices developers :
Xavier Caillaud
Remi Collet
Jean Marc Grisard
François Legastelois
Nelly Mahu-Lasson
Walid Nouh
Traductors
Remi Collet (en_GB, fr_FR)
Nelly Mahu-Lasson -en_GB, fr_FR)
This diff is collapsed.
GLPI webservices
======================
Code original encore maintenu : https://forge.indepnet.net/projects/webservices/
Ce plugin existant rencontre actuellement deux problèmes :
* getnetworkports() ne retourne plus les adresses IP d'un port.
* La recherche par nom est cassée.
L'objectif est de corriger ces problèmes.
<?php
/*
* @version $Id: client.form.php 351 2013-05-22 14:41:59Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
https://forge.indepnet.net/projects/webservices
-------------------------------------------------------------------------
LICENSE
This file is part of webservices.
webservices is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
webservices is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with webservices. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
Plugin::load('webservices', true);
if (!isset($_GET["id"])) {
$_GET["id"] = "";
}
$webservices = new PluginWebservicesClient();
if (isset($_POST["add"])) {
$webservices->check(-1,'w',$_POST);
$webservices->add($_POST);
Html::back();
} else if (isset($_POST["update"])) {
$webservices->check($_POST["id"],'w');
$webservices->update($_POST);
Html::back();
} else if (isset($_POST["delete"])) {
$webservices->check($_POST["id"],'w');
$webservices->delete($_POST);
Html::redirect($CFG_GLPI["root_doc"]."/plugins/webservices/front/client.php");
} else {
Html::header(__('Web Services', 'webservices'), $_SERVER['PHP_SELF'], "plugins", "webservices");
$webservices->showForm($_GET["id"]);
Html::footer();
}
?>
\ No newline at end of file
<?php
/*
* @version $Id: client.php 349 2013-05-21 15:16:15Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
https://forge.indepnet.net/projects/webservices
-------------------------------------------------------------------------
LICENSE
This file is part of webservices.
webservices is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
webservices is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with webservices. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include ("../../../inc/includes.php");
Plugin::load('webservices');
Session::checkRight("config","w");
Html::header(__('Web Services', 'webservices'), $_SERVER['PHP_SELF'], "plugins", "webservices");
Search::show('PluginWebservicesClient');
Html::footer();
?>
\ No newline at end of file
<?php
/*
* @version $Id: hook.php 353 2013-09-18 14:00:53Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
https://forge.indepnet.net/projects/webservices
-------------------------------------------------------------------------
LICENSE
This file is part of webservices.
webservices is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
webservices is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with webservices. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
function plugin_webservices_registerMethods() {
global $WEBSERVICES_METHOD;
// Not authenticated method
$WEBSERVICES_METHOD['glpi.test']
= array('PluginWebservicesMethodCommon','methodTest');
$WEBSERVICES_METHOD['glpi.status']
= array('PluginWebservicesMethodCommon','methodStatus');
$WEBSERVICES_METHOD['glpi.listAllMethods']
= array('PluginWebservicesMethodCommon','methodList');
$WEBSERVICES_METHOD['glpi.listEntities']
= array('PluginWebservicesMethodCommon','methodListEntities');
$WEBSERVICES_METHOD['glpi.doLogin']
= array('PluginWebservicesMethodSession','methodLogin');
$WEBSERVICES_METHOD['glpi.listKnowBaseItems']
= array('PluginWebservicesMethodTools','methodListKnowBaseItems');
$WEBSERVICES_METHOD['glpi.getKnowBaseItem']
= array('PluginWebservicesMethodTools','methodGetKnowBaseItem');
$WEBSERVICES_METHOD['glpi.getDocument']
= array('PluginWebservicesMethodInventaire','methodGetDocument');
// Authenticated method - Session
$WEBSERVICES_METHOD['glpi.doLogout']
= array('PluginWebservicesMethodSession','methodLogout');
$WEBSERVICES_METHOD['glpi.getMyInfo']
= array('PluginWebservicesMethodSession','methodGetMyInfo');
$WEBSERVICES_METHOD['glpi.listMyProfiles']
= array('PluginWebservicesMethodSession','methodListMyProfiles');
$WEBSERVICES_METHOD['glpi.setMyProfile']
= array('PluginWebservicesMethodSession','methodSetMyProfile');
$WEBSERVICES_METHOD['glpi.listMyEntities']
= array('PluginWebservicesMethodSession','methodListMyEntities');
$WEBSERVICES_METHOD['glpi.setMyEntity']
= array('PluginWebservicesMethodSession','methodSetMyEntity');
// Authenticated method - Others
$WEBSERVICES_METHOD['glpi.listDropdownValues']
= array('PluginWebservicesMethodCommon','methodListDropdownValues');
$WEBSERVICES_METHOD['glpi.listHelpdeskTypes']
= array('PluginWebservicesMethodHelpdesk','methodListHelpdeskTypes');
$WEBSERVICES_METHOD['glpi.listHelpdeskItems']
= array('PluginWebservicesMethodHelpdesk','methodListHelpdeskItems');
$WEBSERVICES_METHOD['glpi.listTickets']
= array('PluginWebservicesMethodHelpdesk','methodListTickets');
$WEBSERVICES_METHOD['glpi.listGroups']
= array('PluginWebservicesMethodInventaire','methodListGroups');
$WEBSERVICES_METHOD['glpi.listUsers']
= array('PluginWebservicesMethodInventaire','methodListUsers');
//Inventory
$WEBSERVICES_METHOD['glpi.listInventoryObjects']
= array('PluginWebservicesMethodInventaire','methodListInventoryObjects');
$WEBSERVICES_METHOD['glpi.listObjects']
= array('PluginWebservicesMethodInventaire','methodListObjects');
$WEBSERVICES_METHOD['glpi.getObject']
= array('PluginWebservicesMethodInventaire','methodGetObject');
// Inventory : write methods
$WEBSERVICES_METHOD['glpi.createObjects']
= array('PluginWebservicesMethodInventaire','methodCreateObjects');
$WEBSERVICES_METHOD['glpi.deleteObjects']
= array('PluginWebservicesMethodInventaire','methodDeleteObjects');
$WEBSERVICES_METHOD['glpi.updateObjects']
= array('PluginWebservicesMethodInventaire','methodUpdateObjects');
$WEBSERVICES_METHOD['glpi.linkObjects']
= array('PluginWebservicesMethodInventaire','methodLinkObjects');
//Inventor : generic methods
$WEBSERVICES_METHOD['glpi.getInfocoms']
= array('PluginWebservicesMethodInventaire','methodGetItemInfocoms');
$WEBSERVICES_METHOD['glpi.getContracts']
= array('PluginWebservicesMethodInventaire','methodGetItemContracts');
//Inventory : computer
$WEBSERVICES_METHOD['glpi.getNetworkports']
= array('PluginWebservicesMethodInventaire','methodGetNetworkports');
$WEBSERVICES_METHOD['glpi.getPhones']
= array('PluginWebservicesMethodInventaire','methodGetPhones');
//Helpdesk
$WEBSERVICES_METHOD['glpi.getTicket']
= array('PluginWebservicesMethodHelpdesk','methodGetTicket');
$WEBSERVICES_METHOD['glpi.createTicket']
= array('PluginWebservicesMethodHelpdesk','methodCreateTicket');
$WEBSERVICES_METHOD['glpi.addTicketFollowup']
= array('PluginWebservicesMethodHelpdesk','methodAddTicketFollowup');
$WEBSERVICES_METHOD['glpi.addTicketDocument']
= array('PluginWebservicesMethodHelpdesk','methodAddTicketDocument');
$WEBSERVICES_METHOD['glpi.addTicketObserver']
= array('PluginWebservicesMethodHelpdesk','methodAddTicketObserver');
$WEBSERVICES_METHOD['glpi.setTicketSatisfaction']
= array('PluginWebservicesMethodHelpdesk','methodsetTicketSatisfaction');
$WEBSERVICES_METHOD['glpi.setTicketValidation']
= array('PluginWebservicesMethodHelpdesk','methodsetTicketValidation');
$WEBSERVICES_METHOD['glpi.setTicketSolution']
= array('PluginWebservicesMethodHelpdesk','methodsetTicketSolution');
$WEBSERVICES_METHOD['glpi.setTicketAssign']
= array('PluginWebservicesMethodHelpdesk','methodsetTicketAssign');
}
// Install process for plugin : need to return true if succeeded
function plugin_webservices_install() {
$migration = new Migration(130);
// No autoload when plugin is not activated
require_once 'inc/client.class.php';
PluginWebservicesClient::install($migration);
$migration->executeMigration();
return true;
}
// Uninstall process for plugin : need to return true if succeeded
function plugin_webservices_uninstall() {
// No autoload when plugin is not activated
require_once 'inc/client.class.php';
PluginWebservicesClient::uninstall();
return true;
}
function plugin_webservices_giveItem($type,$ID,$data,$num) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
switch ($table.'.'.$field) {
case "glpi_plugin_webservices_clients.do_log" :
switch ($data["ITEM_$num"]) {
case 2 :
return _n('Log', 'Logs', 2);
case 1:
return __('Historical');
default:
return __('No');
}
break;
}
}
function plugin_webservices_addSelect($type,$ID,$num) {
$searchopt = &Search::getOptions($type);
$table=$searchopt[$ID]["table"];
$field=$searchopt[$ID]["field"];
switch ($table.'.'.$field) {
case 'glpi_plugin_webservices_clients.ip' :
return " CONCAT(INET_NTOA(ip_start), ' - ', INET_NTOA(ip_end)) AS ITEM_$num, ";
}
return '';
}
function plugin_webservices_addWhere($link,$nott,$type,$ID,$val) {
$NOT = ($nott ? " NOT" : "");
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
switch ($table.'.'.$field) {
case 'glpi_plugin_webservices_clients.ip' :
return " $link $NOT (INET_ATON('$val') >= ip_start
AND INET_ATON('$val') <= ip_end) ";
case 'pattern' :
return " $link '$val' $NOT REGEXP pattern ";
}
return '';
}
function plugin_webservices_addOrderBy($type,$ID,$order,$key=0) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
switch ($table.'.'.$field) {
case 'glpi_plugin_webservices_clients.ip' :
return " ORDER BY INET_NTOA(`ip_start`) $order,
INET_NTOA(`ip_end`) $order ";
}
return '';
}
function cron_plugin_webservices() {
Toolbox::logInFile('webservices', "cron called\n");
plugin_webservices_soap_create_wdsl();
return 1;
}
?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
/*
* @version $Id: methodtools.class.php 365 2014-02-09 16:48:19Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
https://forge.indepnet.net/projects/webservices
-------------------------------------------------------------------------
LICENSE
This file is part of webservices.
webservices is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
webservices is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with webservices. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}
class PluginWebservicesMethodTools extends PluginWebservicesMethodCommon {
/**
* Get a list of KB/FAQ articles
* for an authenticated user (or anonymous if allowed from config)
*
* @param $params array of options
* @param $protocol the commonication protocol used
**/
static function methodListKnowBaseItems($params, $protocol) {
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('start' => 'integer,optional',
'limit' => 'integer,optional',
'contains' => 'string,optional',
'category' => 'string,optional',
'faq' => 'bool,optional',
'type' => 'string,optionnal',
'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
$params['faq'] = 1;
} else if (!(isset($params['faq']))) {
$params['faq'] = 0;
}
$kb = new KnowbaseItem();
if (!$kb->canView()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if (!(isset($params['category']))) {
$params['category'] = 0;
} else if (!is_numeric($params['category'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'category');
}
if (!(isset($params['contains']))) {
$params['contains'] = '';
}
if (!isset($params['type'])) {
$params['type'] == 'search';
}
$query = KnowbaseItem::getListRequest(array('faq' => $params['faq'],
'contains' => addslashes($params['contains']),
'knowbaseitemcategories_id'
=> $params['category']),
$params['type']);
$resp = array ();
if (isset($params['count'])) {
$resp['count'] = $DB->numrows($DB->query($query));
} else {
$start = 0;
$limit = $CFG_GLPI["list_limit_max"];
if (isset($params['limit']) && is_numeric($params['limit'])) {
$limit = $params['limit'];
}
if (isset($params['start']) && is_numeric($params['start'])) {
$start = $params['start'];
}
$query .= " LIMIT $start, $limit";
foreach ($DB->request($query) as $data) {
$data['resume'] = Toolbox::unclean_cross_side_scripting_deep($data['answer']);
$data['resume'] = Html::clean(Html::resume_text(Html::clean($data['resume']), 200));
$data['resume'] = html_entity_decode($data['resume'], 0, 'UTF-8');
unset($data['answer']);
$resp[] = $data;
}
}
return $resp;
}
/**
* Get list of documents attached to an item
*
* @param $item Object
* @param $id2name Boolean
*
* @return Array of documents
*/
static function getDocForItem($item, $id2name=false) {
global $DB;
if (Session::getLoginUserID()) {
$query = "SELECT * ";
} else {
$query = "SELECT `id`, `name`, `filename`, `mime` ";
$id2name = false;
}
$query .= "FROM `glpi_documents`
WHERE `id` IN (SELECT `documents_id`
FROM `glpi_documents_items`
WHERE `itemtype` = '".$item->getType()."'
AND `items_id` = '".$item->getID()."')";
$resp = array();
foreach ($DB->request($query) as $data) {
if ($id2name) {
$data['users_name']
= Html::clean(getUserName($data['users_id']));
$data['documentcategories_name']
= Html::clean(Dropdown::getDropdownName('glpi_documentcategories',
$data['documentcategories_id']));
}
$resp[] = $data;
}
return $resp;
}
/**
* Get a KB/FAQ article
* for an authenticated user (or anonymous if allowed from config)
*
* @param $params array of options
* @param $protocol the commonication protocol used
**/
static function methodGetKnowBaseItem($params, $protocol) {
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('id' => 'integer,mandatory',
'help' => 'bool,optional');
}
$kb = new KnowbaseItem();
if (!isset($params['id'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'id');
}
if (!is_numeric($params['id'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'id');
}
if (!$kb->can($params['id'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
$answer = Toolbox::unclean_cross_side_scripting_deep($kb->getField('answer'));
$resp = $kb->fields;
$resp['answer'] = $answer;
$resp['answer_text'] = html_entity_decode(Html::clean($answer), 0, 'UTF-8');
$resp['documents'] = self::getDocForItem($kb);
$kb->updateCounter();
return $resp;
}
}
\ No newline at end of file
<?php
/*
* @version $Id: soap.class.php 350 2013-05-22 13:38:57Z yllen $
-------------------------------------------------------------------------
webservices - WebServices plugin for GLPI
Copyright (C) 2003-2013 by the webservices Development Team.
https://forge.indepnet.net/projects/webservices
-------------------------------------------------------------------------
LICENSE
This file is part of webservices.
webservices is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
webservices is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with webservices. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
if (!defined('GLPI_ROOT')) {
die("Sorry. You can't access directly to this file");
}
class PluginWebservicesSoap {
function genericExecute($params) {
$method = $params['method'];
unset($params['method']);
$session = new PluginWebservicesMethodSession();
return $session->execute($method, $params, WEBSERVICE_PROTOCOL_SOAP);
}
}
?>
\ No newline at end of file
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-05-22 16:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#: setup.php:136 front/client.form.php:55 front/client.php:36
#: inc/client.class.php:254
msgid "Web Services"
msgstr "Webdienste"
#: setup.php:149
msgid "Incompatible GLPI version. Requires 0.84"
msgstr ""
#: setup.php:151
msgid "Incompatible PHP Installation. Requires module soap"
msgstr ""
#: setup.php:153
msgid "Incompatible PHP Installation. Requires module xmlrpc"
msgstr ""
#: setup.php:155
msgid "Incompatible PHP Installation. Requires module json"
msgstr ""
#: inc/client.class.php:42 inc/client.class.php:44
msgid "Client"
msgid_plural "Clients"
msgstr[0] "Client"
msgstr[1] "Clients"
#: inc/client.class.php:71
msgid "Methods"
msgstr "Methoden"
#: inc/client.class.php:147 inc/client.class.php:268
msgid "Enabled services"
msgstr "Eingetragene Webdienste"
#: inc/client.class.php:152 inc/client.class.php:277
msgid "Compression enabled"
msgstr "Kompression aktiviert"
#: inc/client.class.php:160 inc/client.class.php:273
msgid "Log connections"
msgstr "Verbindungen loggen"
#: inc/client.class.php:173 inc/client.class.php:291
msgid "SQL pattern for services"
msgstr "SQL-Pattern für den Dienst"
#: inc/client.class.php:178
msgid "IPv4 address range"
msgstr "IPv4-Adressbereich"
#: inc/client.class.php:187 inc/client.class.php:287
msgid "IPv6 address"
msgstr "IPv6-Adresse"
#: inc/client.class.php:192
msgid "User name"
msgstr "Benutzername"
#: inc/client.class.php:212
msgid "Method list - defined and allowed by this rule"
msgstr "Durch diese Regel definierte und erlaubte Methoden"
#: inc/client.class.php:214
msgid "Method name"
msgstr "Methodenname"
#: inc/client.class.php:215
msgid "Provider plugin"
msgstr "Provider-Plugin"
#: inc/client.class.php:216
msgid "Internal function name"
msgstr "Interner Methodenname"