3 * SOAP User Include - this file contains wrapper functions for the SOAP interface
5 * Copyright 2004 (c) GForge, LLC
8 * This file is part of GForge.
10 * GForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * GForge 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
21 * along with GForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
25 require_once $gfcommon.'include/Error.class.php';
26 require_once $gfcommon.'include/User.class.php';
28 // Add The definition of a user object
29 $server->wsdl->addComplexType(
36 'user_id' => array('name'=>'user_id', 'type' => 'xsd:int'),
37 'user_name' => array('name'=>'user_name', 'type' => 'xsd:string'),
38 'title' => array('name'=>'title', 'type' => 'xsd:string'),
39 'firstname' => array('name'=>'firstname', 'type' => 'xsd:string'),
40 'lastname' => array('name'=>'lastname', 'type' => 'xsd:string'),
41 'address' => array('name'=>'address', 'type' => 'xsd:string'),
42 'address2' => array('name'=>'address2', 'type' => 'xsd:string'),
43 'phone' => array('name'=>'phone', 'type' => 'xsd:string'),
44 'fax' => array('name'=>'fax', 'type' => 'xsd:string'),
45 'status' => array('name'=>'status', 'type' => 'xsd:string'),
46 'timezone' => array('name'=>'timezone', 'type' => 'xsd:string'),
47 'country_code' => array('name'=>'country_code', 'type' => 'xsd:string'),
48 'add_date' => array('name'=>'add_date', 'type' => 'xsd:int'),
49 'language_id' => array('name'=>'language_id', 'type' => 'xsd:int')
53 $server->wsdl->addComplexType(
60 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:User[]')),
66 array('session_ser'=>'string','user_ids'=>'tns:ArrayOfint'),
67 array('userResponse'=>'tns:ArrayOfUser'),
69 $uri.'#getUsers','rpc','encoded'
72 //getUsersByName (unix_name array)
75 array('session_ser'=>'string','user_ids'=>'tns:ArrayOfstring'),
76 array('userResponse'=>'tns:ArrayOfUser'),
78 $uri.'#getUsersByName','rpc','encoded'
81 //getGroups (id array)
84 array('session_ser'=>'string','user_id'=>'xsd:int'),
85 array('groupResponse'=>'tns:ArrayOfGroup'),
87 $uri.'#userGetGroups','rpc','encoded'
91 //get user objects for array of user_ids
92 function &getUsers($session_ser,$user_ids) {
93 continue_session($session_ser);
94 $usrs =& user_get_objects($user_ids);
96 return new soap_fault ('3001','user','Could Not Get Users By Id','Could Not Get Users By Id');
99 return users_to_soap($usrs);
102 //get user objects for array of unix_names
103 function getUsersByName($session_ser,$user_names) {
104 continue_session($session_ser);
105 $usrs =& user_get_objects_by_name($user_names);
107 return new soap_fault ('3002','user','Could Not Get Users By Name','Could Not Get Users By Name');
110 return users_to_soap($usrs);
113 //get groups for user_id
114 function &userGetGroups($session_ser,$user_id) {
115 continue_session($session_ser);
116 $user =& user_get_object($user_id);
118 return new soap_fault ('3003','user','Could Not Get Users Groups','Could Not Get Users Groups');
120 return groups_to_soap($user->getGroups());
124 Converts an array of User objects to soap data
126 function &users_to_soap($usrs) {
128 for ($i=0; $i<count($usrs); $i++) {
129 if ($usrs[$i]->isError()) {
130 return new soap_fault ('','User to soap',$usrs[$i]->getErrorMessage(),$usrs[$i]->getErrorMessage());
131 //skip it if it had an error
133 //build an array of just the fields we want
135 'user_id'=>$usrs[$i]->data_array['user_id'],
136 'user_name'=>$usrs[$i]->data_array['user_name'],
137 'title'=>$usrs[$i]->data_array['title'],
138 'firstname'=>$usrs[$i]->data_array['firstname'],
139 'lastname'=>$usrs[$i]->data_array['lastname'],
140 'address'=>$usrs[$i]->data_array['address'],
141 'address2'=>$usrs[$i]->data_array['address2'],
142 'phone'=>$usrs[$i]->data_array['phone'],
143 'fax'=>$usrs[$i]->data_array['fax'],
144 'status'=>$usrs[$i]->data_array['status'],
145 'timezone'=>$usrs[$i]->data_array['timezone'],
146 'country_code'=>$usrs[$i]->data_array['country_code'],
147 'add_date'=>$usrs[$i]->data_array['add_date'],
148 'language_id'=>$usrs[$i]->data_array['language_id']