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.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FusionForge; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
24 require_once $gfcommon.'include/Error.class.php';
25 require_once $gfcommon.'include/Group.class.php';
26 require_once $gfcommon.'include/FusionForge.class.php';
28 // Add The definition of a group object
29 $server->wsdl->addComplexType(
36 'group_id' => array('name'=>'group_id', 'type' => 'xsd:int'),
37 'group_name' => array('name'=>'group_name', 'type' => 'xsd:string'),
38 'homepage' => array('name'=>'homepage', 'type' => 'xsd:string'),
39 'is_public' => array('name'=>'is_public', 'type' => 'xsd:int'),
40 'status' => array('name'=>'status', 'type' => 'xsd:string'),
41 'unix_group_name' => array('name'=>'unix_group_name', 'type' => 'xsd:string'),
42 'short_description' => array('name'=>'short_description', 'type' => 'xsd:string'),
43 'scm_box' => array('name'=>'scm_box', 'type' => 'xsd:string'),
44 'register_time' => array('name'=>'register_time', 'type' => 'xsd:int') ) );
47 $server->wsdl->addComplexType(
54 array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Group[]')),
57 //getGroups (id array)
60 array('session_ser'=>'xsd:string','group_ids'=>'tns:ArrayOfint'),
61 array('return'=>'tns:ArrayOfGroup'),
63 $uri.'#getGroups','rpc','encoded'
66 //getGroupsByName (unix_name array)
69 array('session_ser'=>'xsd:string','group_names'=>'tns:ArrayOfstring'),
70 array('return'=>'tns:ArrayOfGroup'),
72 $uri.'#getGroupsByName','rpc','encoded'
75 //getPublicProjectNames ()
77 'getPublicProjectNames',
78 array('session_ser'=>'xsd:string'),
79 array('return'=>'tns:ArrayOfstring'),
81 $uri.'#getPublicProjectNames','rpc','encoded'
84 function &getGroups($session_ser,$group_ids) {
86 continue_session($session_ser);
88 $inputArgs = $session_ser;
89 for ($i=0; $i<count($group_ids); $i++) {
90 $inputArgs = $inputArgs.':'.$group_ids[i];
93 $grps = group_get_objects($group_ids);
95 return new soap_fault ('2001','group','Could Not Get Projects by Id'.$inputArgs,$feedback);
98 return groups_to_soap($grps);
101 function &getGroupsByName($session_ser,$group_names) {
102 session_continue($session_ser);
103 $grps = group_get_objects_by_name($group_names);
105 return new soap_fault ('2002','group','Could Not Get Projects by Name','Could Not Get Projects by Name');
108 return groups_to_soap($grps);
112 // use as a way to get group names for use in getGroupsByName
113 function &getPublicProjectNames($session_ser) {
114 continue_session($session_ser);
115 $forge = new FusionForge();
116 $result = $forge->getPublicProjectNames();
117 if ($forge->isError()) {
118 $errMsg = 'Could Not Get Public Projects Names: '.$forge->getErrorMessage();
119 return new soap_fault ('2003','group',$errMsg,$errMsg);
125 Converts an array of Group objects to soap data
127 function &groups_to_soap($grps) {
129 $ra = RoleAnonymous::getInstance() ;
131 for ($i=0; $i<count($grps); $i++) {
132 if ($grps[$i]->isError()) {
133 //skip it if it had an error
135 $gid = $grps[$i]->data_array['group_id'];
136 if ($ra->hasPermission('project_read', $gid)) {
141 //build an array of just the fields we want
142 $return[] = array('group_id'=>$grps[$i]->data_array['group_id'],
143 'group_name'=>$grps[$i]->data_array['group_name'],
144 'homepage'=>$grps[$i]->data_array['homepage'],
145 'is_public'=>$is_public,
146 'status'=>$grps[$i]->data_array['status'],
147 'unix_group_name'=>$grps[$i]->data_array['unix_group_name'],
148 'short_description'=>$grps[$i]->data_array['short_description'],
149 'scm_box'=>$grps[$i]->data_array['scm_box'],
150 'register_time'=>$grps[$i]->data_array['register_time']);
153 // changed to not return soapval which is not necessary
154 // since we have wsdl to describe return value