Should fix bug when using string[] when using webservices see BT#4158

skala
Julio Montoya 13 years ago
parent afa4725985
commit b9186d6844
  1. 20
      main/webservices/client_soap.php
  2. 60
      main/webservices/registration.soap.php

@ -12,8 +12,7 @@
*
*/
//exit; //Uncomment this in order to execute the page
exit; //Uncomment this in order to execute the page
require_once '../inc/global.inc.php';
$libpath = api_get_path(LIBRARY_PATH);
@ -83,6 +82,23 @@ if (!empty($user_id) && is_numeric($user_id)) {
'secret_key' => $secret_key);
$result = $client->call('WSSubscribeUserToCourseSimple', array('subscribeUserToCourseSimple' => $params));
//4. Adding course Test to the Session Session1
$course_id_list = array (
array('course_code' => 'TEST1'),
array('course_code' => 'TEST2')
);
$params = array('coursessessions' => array(
array('original_course_id_values' => $course_id_list,
'original_course_id_name' => 'course_id_name',
'original_session_id_value' => '1',
'original_session_id_name' => 'session_id_value')
),
'secret_key' => $secret_key);
$result = $client->call('WSSuscribeCoursesToSession', array('subscribeCoursesToSession' => $params));
// ------------------------
//Calling the WSSubscribeUserToCourse

@ -4412,7 +4412,8 @@ function WSUnsuscribeUsersFromSession($params) {
/* Register WSSuscribeCoursesToSession function */
// Register the data structures used by the service
$server->wsdl->addComplexType(
/*$server->wsdl->addComplexType(
'originalCoursesList',
'complexType',
'array',
@ -4421,8 +4422,44 @@ $server->wsdl->addComplexType(
array(),
array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'string[]')),
'xsd:string'
);*/
$server->wsdl->addComplexType(
'course_code_type',
'complexType',
'struct',
'all',
'',
array(
'course_code' => array('name' => 'course_code', 'type' => 'xsd:string'),
)
);
$server->wsdl->addComplexType(
'originalCoursesList',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course_code_type[]')),
'tns:course_code_type'
);
$server->wsdl->addComplexType(
'subscribeCoursesToSessionParamsList',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeCoursesToSessionParams[]')),
'tns:subscribeCoursesToSessionParams'
);
$server->wsdl->addComplexType(
'subscribeCoursesToSessionParams',
'complexType',
@ -4498,11 +4535,14 @@ $server->register('WSSuscribeCoursesToSession', // method name
// Define the method WSSuscribeCoursesToSession
function WSSuscribeCoursesToSession($params) {
global $debug;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
if ($debug) error_log('WSSuscribeCoursesToSession: '.print_r($params, 1));
// initialisation
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -4525,8 +4565,11 @@ function WSSuscribeCoursesToSession($params) {
$original_course_id_name = $coursesession_param['original_course_id_name'];
$original_course_id_values = $coursesession_param['original_course_id_values'];
$orig_session_id_value[] = $original_session_id_value;
// get session id from original session id
$sql_session = "SELECT session_id FROM $t_sf sf,$t_sfv sfv WHERE sfv.field_id=sf.id AND field_variable='$original_session_id_name' AND field_value='$original_session_id_value'";
if ($debug) error_log($sql_session);
$res_session = Database::query($sql_session);
$row_session = Database::fetch_row($res_session);
@ -4540,7 +4583,10 @@ function WSSuscribeCoursesToSession($params) {
// Get course list from row_original_course_id_values
$course_list = array();
foreach ($original_course_id_values as $row_original_course_list) {
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$row_original_course_list'";
$course_code = Database::escape_string($row_original_course_list['course_code']);
$sql_course = "SELECT course_code FROM $t_cf cf, $t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'";
$res_course = Database::query($sql_course);
$row_course = Database::fetch_row($res_course);
if (empty($row_course[0])) {
@ -4577,8 +4623,7 @@ function WSSuscribeCoursesToSession($params) {
$nbr_courses=count($existingCourses);
// get list of users subscribed to this session
$sql="SELECT id_user
FROM $tbl_session_rel_user
$sql= "SELECT id_user FROM $tbl_session_rel_user
WHERE id_session = '$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
$result=Database::query($sql);
$user_list=Database::store_result($result);
@ -4638,7 +4683,6 @@ function WSSuscribeCoursesToSession($params) {
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_course_id_values' => $orig_course_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
}
return $output;
}
@ -4728,7 +4772,6 @@ function WSUnsuscribeCoursesFromSession($params) {
// Initialisation
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
@ -4763,7 +4806,9 @@ function WSUnsuscribeCoursesFromSession($params) {
// Get courses list from row_original_course_id_values
$course_list = array();
foreach ($original_course_id_values as $row_original_course_list) {
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$row_original_course_list'";
$course_code = Database::escape_string($row_original_course_list['course_code']);
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'";
$res_course = Database::query($sql_course);
$row_course = Database::fetch_row($res_course);
if (empty($row_course[0])) {
@ -4815,7 +4860,6 @@ function WSUnsuscribeCoursesFromSession($params) {
for($i = 0; $i < $count_results; $i++) {
$output[] = array('original_course_id_values' => $orig_course_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
}
return $output;
}

Loading…
Cancel
Save