5 * Previous Copyright FusionForge Team
6 * Copyright 2016, Franck Villaume - TrivialDev
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 // 0. Include FusionForge files for access to FusionForge system
28 require_once '../env.inc.php';
29 require_once $gfcommon.'include/pre.php';
30 require_once $gfcommon.'include/gettext.php';
31 require_once $gfcommon.'include/FusionForge.class.php';
35 // Disable error_reporting as it breaks XML generated output.
38 $uri = util_make_url();
39 // 1. include client and server
40 require_once 'nusoap/nusoap.php';
42 // 2. instantiate server object
43 $server = new soap_server();
44 $server->setDebugLevel(0);
45 $server->soap_defencoding = 'UTF-8';
46 $server->encode_utf8 = true;
47 $server->configureWSDL('FusionForgeAPI',$uri,$uri.'/soap/index.php','rpc','http://schemas.xmlsoap.org/soap/http',$uri);
50 $server->wsdl->addComplexType(
57 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')),
61 $server->wsdl->addComplexType(
68 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:integer[]')),
72 $server->wsdl->addComplexType(
79 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:long[]')),
83 $server->wsdl->addComplexType(
90 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:int[]')),
94 // session/authentication
97 array('username'=>'xsd:string','passwd'=>'xsd:string'),
98 array('loginResponse'=>'xsd:string'),
104 array('session_ser'=>'xsd:string'),
105 array('logoutResponse'=>'xsd:string'),
112 array('versionResponse'=>'xsd:string'),
116 // Include Project Functions
118 require_once $gfwww.'soap/common/group.php';
121 // Include User Functions
123 require_once $gfwww.'soap/common/user.php';
126 // Include tracker & tracker query Functions
128 require_once $gfwww.'soap/tracker/tracker.php';
129 require_once $gfwww.'soap/tracker/query.php';
132 // Include Docman Functions
134 require_once $gfwww.'soap/docman/docman.php';
137 // Include tasks Functions
139 require_once $gfwww.'soap/pm/pm.php';
140 require_once $gfwww.'soap/reporting/timeentry.php';
143 // Include frs Functions
145 require_once $gfwww.'soap/frs/frs.php';
148 // Include SCM Functions
150 require_once $gfwww.'soap/scm/scm.php';
152 // Include methods defined by plugins
154 $params['server'] = &$server;
155 plugin_hook('register_soap',$params);
157 $wsdl_data = $server->wsdl->serialize();
165 * continueSession - A utility method to carry on with an already established session
167 * @param string $sessionKey The session key
169 function continue_session($sessionKey) {
170 session_continue($sessionKey);
173 // session/authentication
175 * login - Logs in a SOAP client
177 * @param string $username username The user's unix id
178 * @param string $passwd passwd The user's passwd in clear text
180 * @return string the session key
182 function login($username, $passwd) {
183 global $feedback, $session_ser;
185 setlocale (LC_TIME, _('en_US'));
187 $res = session_login_valid($username, $passwd);
190 return new soap_fault('1001', 'user', 'Unable to log in with username of '.$username, $feedback);
193 return session_build_session_token(user_getid());
197 * logout - Logs out a SOAP client
199 * @param string $session_ser sessionkey The session key
202 function logout($session_ser) {
203 continue_session($session_ser);
209 * version - get the running version of FusionForge
211 * @return string the version of FusionForge running on the server
214 $ff = new FusionForge();
215 return $ff->software_version;
218 // 4. call the service method to initiate the transaction and send the response
219 $postdata = file_get_contents("php://input");
220 $server->service($postdata);
222 if(isset($log) and $log != ''){
223 harness('nusoap_r2_base_server',$server->headers['User-Agent'],$server->methodname,$server->request,$server->response,$server->result);