Merge branch 'BT9431' of https://github.com/ilosada/chamilo-lms into ilosada-BT9431

1.10.x
Yannick Warnier 11 years ago
commit 6913882e09
  1. 26
      main/admin/group_list.php
  2. 330
      main/webservices/registration.soap.php

@ -102,9 +102,33 @@ function get_group_data($from, $number_of_items, $column, $direction) {
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
$result = Database::select(
'tGroupRelGroup.group_id, tGroup.id, tGroup.name',
Database::get_main_table(TABLE_MAIN_GROUP_REL_GROUP).
" AS tGroupRelGroup RIGHT JOIN ".Database::get_main_table(TABLE_MAIN_GROUP).
" AS tGroup ON tGroupRelGroup.subgroup_id = tGroup.id"
);
$groupRelations = array();
foreach ($result as $row) {
$groupRelations[$row['id']] = $row;
}
while ($group = Database::fetch_row($res)) {
$name = null;
$id = $group[0];
// Loops while the current group is a subgroup
while (isset($groupRelations[$id]['group_id'])) {
$name = $name ?
$groupRelations[$id]['name'] . " > " . $name :
$groupRelations[$id]['name'];
$id = $groupRelations[$id]['group_id'];
}
// The base group
$name = $name ?
$groupRelations[$id]['name'] . " > " . $name :
$groupRelations[$id]['name'];
$group[3] = $status[$group[3]];
$group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group['0'].'">'.$group['1'].'</a>';
$group['1'] = '<a href="'.api_get_path(WEB_CODE_PATH).'social/groups.php?id='.$group['0'].'">'.$name.'</a>';
$groups[] = $group;
}
return $groups;

@ -5744,6 +5744,336 @@ function WSFetchSession($params)
/* Fetch session Web Service end */
/* Create group Web Service start */
// Register the data structures used by the service
// Input params for WSCreateGroup
$server->wsdl->addComplexType(
'createGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'name' => array('name' => 'name', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSCreateGroup', // method name
array('createGroup' => 'tns:createGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSCreateGroup', // soapaction
'rpc', // style
'encoded', // use
'This service adds a group' // documentation
);
// Define the method WSCreateGroup
function WSCreateGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::add($params['name'], null, null, 1);
}
/* Create group Web Service end */
/* Update group Web Service start */
// Register the data structures used by the service
// Input params for WSUpdateGroup
$server->wsdl->addComplexType(
'updateGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'name' => array('name' => 'name', 'type' => 'xsd:string'),
'description' => array('name' => 'description', 'type' => 'xsd:string'),
'url' => array('name' => 'url', 'type' => 'xsd:string'),
'visibility' => array('name' => 'visibility', 'type' => 'xsd:string'),
'picture_uri' => array('name' => 'picture_uri', 'type' => 'xsd:string'),
'allow_member_group_to_leave' => array('name' => 'allow_member_group_to_leave', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSUpdateGroup', // method name
array('updateGroup' => 'tns:updateGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSUpdateGroup', // soapaction
'rpc', // style
'encoded', // use
'This service updates a group' // documentation
);
// Define the method WSUpdateGroup
function WSUpdateGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
$params['allow_member_group_to_leave'] = null;
return GroupPortalManager::update(
$params['id'],
$params['name'],
$params['description'],
$params['url'],
$params['visibility'],
$params['picture_uri'],
$params['allow_member_group_to_leave']
);
}
/* Update group Web Service end */
/* Delete group Web Service start */
// Register the data structures used by the service
// Input params for WSDeleteGroup
$server->wsdl->addComplexType(
'deleteGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'id' => array('name' => 'id', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSDeleteGroup', // method name
array('deleteGroup' => 'tns:deleteGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSDeleteGroup', // soapaction
'rpc', // style
'encoded', // use
'This service deletes a group' // documentation
);
// Define the method WSDeleteGroup
function WSDeleteGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::delete($params['id']);
}
/* Delete group Web Service end */
/* Bind group to parent Web Service start */
// Register the data structures used by the service
// Input params for GroupBindToParent
$server->wsdl->addComplexType(
'groupBindToParent',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'parent_id' => array('name' => 'parent_id', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('GroupBindToParent', // method name
array('groupBindToParent' => 'tns:groupBindToParent'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#GroupBindToParent', // soapaction
'rpc', // style
'encoded', // use
'This service binds a group to a parent' // documentation
);
// Define the method GroupBindToParent
function GroupBindToParent($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::set_parent_group($params['id'], $params['parent_id']);
}
/* Bind group Web Service end */
/* Unbind group from parent Web Service start */
// Register the data structures used by the service
// Input params for GroupUnbindFromParent
$server->wsdl->addComplexType(
'groupUnbindFromParent',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'id' => array('name' => 'id', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('GroupUnbindFromParent', // method name
array('groupUnbindFromParent' => 'tns:groupUnbindFromParent'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#GroupUnbindFromParent', // soapaction
'rpc', // style
'encoded', // use
'This service unbinds a group from its parent' // documentation
);
// Define the method GroupUnbindFromParent
function GroupUnbindFromParent($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::set_parent_group($params['id'], 0);
}
/* Unbind group Web Service end */
/* Add user to group Web Service start */
// Register the data structures used by the service
// Input params for WSAddUserToGroup
$server->wsdl->addComplexType(
'addUserToGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'),
'group_id' => array('name' => 'group_id', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSAddUserToGroup', // method name
array('addUserToGroup' => 'tns:addUserToGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSAddUserToGroup', // soapaction
'rpc', // style
'encoded', // use
'This service adds a user to a group' // documentation
);
// Define the method WSAddUserToGroup
function WSAddUserToGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::add_user_to_group($params['user_id'], $params['group_id']);
}
/* Add user to group Web Service end */
/* Update user role in group Web Service start */
// Register the data structures used by the service
// Input params for WSUpdateUserRoleInGroup
$server->wsdl->addComplexType(
'updateUserRoleInGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'),
'group_id' => array('name' => 'group_id', 'type' => 'xsd:string'),
'relation_type' => array('name' => 'relation_type', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSUpdateUserRoleInGroup', // method name
array('updateUserRoleInGroup' => 'tns:updateUserRoleInGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSUpdateUserRoleInGroup', // soapaction
'rpc', // style
'encoded', // use
'This service updates a user role in group' // documentation
);
// Define the method WSUpdateUserRoleInGroup
function WSUpdateUserRoleInGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::update_user_role(
$params['user_id'],
$params['group_id'],
$params['relation_type']
);
}
/* Update user role Web Service end */
/* Delete user from group Web Service start */
// Register the data structures used by the service
// Input params for WSDeleteUserFromGroup
$server->wsdl->addComplexType(
'deleteUserFromGroup',
'complexType',
'struct',
'all',
'',
array(
'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string'),
'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'),
'group_id' => array('name' => 'group_id', 'type' => 'xsd:string')
)
);
// Register the method to expose
$server->register('WSDeleteUserFromGroup', // method name
array('deleteUserFromGroup' => 'tns:deleteUserFromGroup'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:WSRegistration', // namespace
'urn:WSRegistration#WSDeleteUserFromGroup', // soapaction
'rpc', // style
'encoded', // use
'This service deletes a user from a group' // documentation
);
// Define the method WSDeleteUserFromGroup
function WSDeleteUserFromGroup($params)
{
if (!WSHelperVerifyKey($params['secret_key'])) {
return return_error(WS_ERROR_SECRET_KEY);
}
return GroupPortalManager::delete_user_rel_group($params['user_id'], $params['group_id']);
}
/* Delete user from group Web Service end */
// Add more webservices by Hooks
if (!empty($hook)) {
$hook->setEventData(array('server' => $server));

Loading…
Cancel
Save