3 * SOAP Group Include - this file contains wrapper functions for the SOAP interface
5 * Copyright 2004 (c) GForge, LLC
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once $gfcommon.'include/Error.class.php';
24 require_once $gfcommon.'include/Group.class.php';
25 require_once $gfcommon.'include/FusionForge.class.php';
27 // Add The definition of a group object
28 $server->wsdl->addComplexType(
35 'group_id' => array('name'=>'group_id', 'type' => 'xsd:int'),
36 'group_name' => array('name'=>'group_name', 'type' => 'xsd:string'),
37 'homepage' => array('name'=>'homepage', 'type' => 'xsd:string'),
38 'is_public' => array('name'=>'is_public', 'type' => 'xsd:int'),
39 'status' => array('name'=>'status', 'type' => 'xsd:string'),
40 'unix_group_name' => array('name'=>'unix_group_name', 'type' => 'xsd:string'),
41 'short_description' => array('name'=>'short_description', 'type' => 'xsd:string'),
42 'scm_box' => array('name'=>'scm_box', 'type' => 'xsd:string'),
43 'register_time' => array('name'=>'register_time', 'type' => 'xsd:int') ) );
46 $server->wsdl->addComplexType(
53 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Group[]')),
56 //getGroups (id array)
59 array('session_ser'=>'xsd:string','group_ids'=>'tns:ArrayOfint'),
60 array('return'=>'tns:ArrayOfGroup'),
62 $uri.'#getGroups','rpc','encoded'
65 //getGroupsByName (unix_name array)
68 array('session_ser'=>'xsd:string','group_names'=>'tns:ArrayOfstring'),
69 array('return'=>'tns:ArrayOfGroup'),
71 $uri.'#getGroupsByName','rpc','encoded'
74 //getPublicProjectNames ()
76 'getPublicProjectNames',
77 array('session_ser'=>'xsd:string'),
78 array('return'=>'tns:ArrayOfstring'),
80 $uri.'#getPublicProjectNames','rpc','encoded'
83 function &getGroups($session_ser,$group_ids) {
85 continue_session($session_ser);
87 $inputArgs = $session_ser;
88 for ($i=0; $i<count($group_ids); $i++) {
89 $inputArgs = $inputArgs.':'.$group_ids[i];
92 $grps = group_get_objects($group_ids);
94 return new soap_fault ('2001','group','Could Not Get Projects by Id'.$inputArgs,$feedback);
97 return groups_to_soap($grps);
100 function &getGroupsByName($session_ser,$group_names) {
101 session_continue($session_ser);
102 $grps = group_get_objects_by_name($group_names);
104 return new soap_fault ('2002','group','Could Not Get Projects by Name','Could Not Get Projects by Name');
107 return groups_to_soap($grps);
111 // use as a way to get group names for use in getGroupsByName
112 function &getPublicProjectNames($session_ser) {
113 continue_session($session_ser);
114 $forge = new FusionForge();
115 $result = $forge->getPublicProjectNames();
116 if ($forge->isError()) {
117 $errMsg = 'Could Not Get Public Projects Names: '.$forge->getErrorMessage();
118 return new soap_fault ('2003','group',$errMsg,$errMsg);
124 Converts an array of Group objects to soap data
126 function &groups_to_soap($grps) {
128 $ra = RoleAnonymous::getInstance() ;
130 for ($i=0; $i<count($grps); $i++) {
131 if ($grps[$i]->isError()) {
132 //skip it if it had an error
134 $gid = $grps[$i]->data_array['group_id'];
135 if ($ra->hasPermission('project_read', $gid)) {
140 //build an array of just the fields we want
141 $return[] = array('group_id'=>$grps[$i]->data_array['group_id'],
142 'group_name'=>$grps[$i]->data_array['group_name'],
143 'homepage'=>$grps[$i]->data_array['homepage'],
144 'is_public'=>$is_public,
145 'status'=>$grps[$i]->data_array['status'],
146 'unix_group_name'=>$grps[$i]->data_array['unix_group_name'],
147 'short_description'=>$grps[$i]->data_array['short_description'],
148 'scm_box'=>$grps[$i]->data_array['scm_box'],
149 'register_time'=>$grps[$i]->data_array['register_time']);
152 // changed to not return soapval which is not necessary
153 // since we have wsdl to describe return value