[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gforge-commits] gforge/www/soap/common group.php, NONE, 1.1 user.php, N
From: |
tperdue |
Subject: |
[Gforge-commits] gforge/www/soap/common group.php, NONE, 1.1 user.php, NONE, 1.1 |
Date: |
Sat, 28 Feb 2004 15:43:55 -0600 |
Update of /cvsroot/gforge/gforge/www/soap/common
In directory db.perdue.net:/home/tperdue/share/dev.gforge.org/www/soap/common
Added Files:
group.php user.php
Log Message:
first pass (UNTESTED) of SOAP structure
--- NEW FILE: group.php ---
<?php
/**
* SOAP Group Include - this file contains wrapper functions for the SOAP
interface
*
* Copyright 2004 (c) GForge, LLC
* http://gforge.org
*
* @version $Id: group.php,v 1.1 2004/02/28 21:43:53 tperdue Exp $
*
* This file is part of GForge.
*
* GForge 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.
*
* GForge 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 GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
*/
require_once('common/include/Error.class');
require_once('common/include/Group.class');
// Add The definition of a group object
$server->wsdl->addComplexType(
'Group',
'complexType',
'struct',
'sequence',
'',
array(
'group_id' => array('name'=>'group_id', 'type' => 'xsd:integer'),
'group_name' => array('name'=>'group_name', 'type' => 'xsd:string'),
'homepage' => array('name'=>'homepage', 'type' => 'xsd:string'),
'is_public' => array('name'=>'is_public', 'type' => 'xsd:integer'),
'status' => array('name'=>'status', 'type' => 'xsd:string'),
'unix_group_name' => array('name'=>'unix_group_name', 'type' =>
'xsd:string'),
'short_description' => array('name'=>'short_description', 'type' =>
'xsd:string'),
'register_time' => array('name'=>'register_time', 'type' =>
'xsd:integer') ) );
// Array of groups
$server->wsdl->addComplexType(
'ArrayOfGroup',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Group[]')),
'tns:Group');
//getGroups (id array)
$server->register(
'getGroups',
array('session_ser'=>'string','group_ids'=>'xsd:integer[]'),
array('groupResponse'=>'tns:ArrayOfGroup'),
$uri);
//getGroupsByName (unix_name array)
$server->register(
'getGroupsByName',
array('session_ser'=>'string','group_ids'=>'xsd:string[]'),
array('groupResponse'=>'tns:ArrayOfGroup'),
$uri);
function &getGroups($session_ser,$group_ids) {
continue_session($session_ser);
$grps =& group_get_objects($group_ids);
if (!$grps) {
return new soap_fault ('','','','Could Not Get Groups');
}
return groups_to_soap($grps);
}
function &getGroupsByName($session_ser,$group_names) {
continue_session($session_ser);
$grps =& group_get_objects_by_name($group_names);
if (!$grps) {
return new soap_fault ('','','','Could Not Get Groups');
}
return groups_to_soap($grps);
}
/*
Converts an array of Group objects to soap data
*/
function &groups_to_soap($grps) {
for ($i=0; $i<count($grps); $i++) {
if ($grps[$i]->isError()) {
//skip it if it had an error
} else {
//build an array of just the fields we want
$return[] =
array('group_id'=>$grps[$i]->data_array['group_id'],
'group_name'=>$grps[$i]->data_array['group_name'],
'homepage'=>$grps[$i]->data_array['homepage'],
'is_public'=>$grps[$i]->data_array['is_public'],
'status'=>$grps[$i]->data_array['status'],
'unix_group_name'=>$grps[$i]->data_array['unix_group_name'],
'short_description'=>$grps[$i]->data_array['short_description'],
'register_time'=>$grps[$i]->data_array['register_time']);
}
}
return new soapval('tns:ArrayOfGroup', 'ArrayOfGroup', $return);
}
?>
--- NEW FILE: user.php ---
<?php
/**
* SOAP User Include - this file contains wrapper functions for the SOAP
interface
*
* Copyright 2004 (c) GForge, LLC
* http://gforge.org
*
* @version $Id: user.php,v 1.1 2004/02/28 21:43:53 tperdue Exp $
*
* This file is part of GForge.
*
* GForge 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.
*
* GForge 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 GForge; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
*/
require_once('common/include/Error.class');
require_once('common/include/User.class');
// Add The definition of a user object
$server->wsdl->addComplexType(
'User',
'complexType',
'struct',
'sequence',
'',
array(
'user_id' => array('name'=>'user_id', 'type' => 'xsd:integer'),
'user_name' => array('name'=>'user_name', 'type' => 'xsd:string'),
'realname' => array('name'=>'realname', 'type' => 'xsd:string'),
'status' => array('name'=>'status', 'type' => 'xsd:string'),
'timezone' => array('name'=>'timezone', 'type' => 'xsd:string'),
'country_code' => array('name'=>'country_code', 'type' => 'xsd:string'),
'add_date' => array('name'=>'add_date', 'type' => 'xsd:integer'),
'language_id' => array('name'=>'language_id', 'type' => 'xsd:integer')
) );
// Array of users
$server->wsdl->addComplexType(
'ArrayOfUser',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:User[]')),
'tns:User');
//getUsers (id array)
$server->register(
'getUsers',
array('session_ser'=>'string','user_ids'=>'xsd:integer[]'),
array('userResponse'=>'tns:ArrayOfUser'),
$uri);
//getUsersByName (unix_name array)
$server->register(
'getUsersByName',
array('session_ser'=>'string','user_ids'=>'xsd:string[]'),
array('userResponse'=>'tns:ArrayOfUser'),
$uri);
//getGroups (id array)
$server->register(
'userGetGroups',
array('session_ser'=>'string','user_id'=>'xsd:integer'),
array('groupResponse'=>'tns:ArrayOfGroup'),
$uri);
//get user objects for array of user_ids
function &getUsers($session_ser,$user_ids) {
continue_session($session_ser);
$usrs =& user_get_objects($user_ids);
if (!$usrs) {
return new soap_fault ('','','','Could Not Get Users');
}
return users_to_soap($usrs);
}
//get user objects for array of unix_names
function &getUsersByName($session_ser,$user_names) {
continue_session($session_ser);
$usrs =& user_get_objects_by_name($user_names);
if (!$usrs) {
return new soap_fault ('','','','Could Not Get Users');
}
return users_to_soap($usrs);
}
//get groups for user_id
function &userGetGroups($session_ser,$user_id) {
continue_session($session_ser);
$user =& user_get_object($user_id);
if (!$user) {
return new soap_fault ('','','','Could Not Get User');
}
return groups_to_soap($user->getGroups());
}
/*
Converts an array of User objects to soap data
*/
function &users_to_soap($usrs) {
for ($i=0; $i<count($usrs); $i++) {
if ($usrs[$i]->isError()) {
//skip it if it had an error
} else {
//build an array of just the fields we want
$return[] =
array('user_id'=>$usrs[$i]->data_array['user_id'],
'user_name'=>$usrs[$i]->data_array['user_name'],
'realname'=>$usrs[$i]->data_array['realname'],
'status'=>$usrs[$i]->data_array['status'],
'timezone'=>$usrs[$i]->data_array['timezone'],
'country_code'=>$usrs[$i]->data_array['country_code'],
'add_date'=>$usrs[$i]->data_array['add_date']),
'language_id'=>$usrs[$i]->data_array['language_id']);
}
}
return new soapval('tns:ArrayOfUser', 'ArrayOfUser', $return);
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gforge-commits] gforge/www/soap/common group.php, NONE, 1.1 user.php, NONE, 1.1,
tperdue <=