From 52ca2669a83309361912c02acc2d67e308684b9f Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Wed, 4 Mar 2015 15:31:29 -0500 Subject: [PATCH 1/3] Replace group name with full hierarchy group text - refs BT#9431 --- main/admin/group_list.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/main/admin/group_list.php b/main/admin/group_list.php index d3f955d1fb..cd76f5dee0 100755 --- a/main/admin/group_list.php +++ b/main/admin/group_list.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'] = ''.$group['1'].''; + $group['1'] = ''.$name.''; $groups[] = $group; } return $groups; From 08ccd629d37064e6fa3de6e83c5b92df95a29dfe Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Fri, 6 Mar 2015 11:36:38 -0500 Subject: [PATCH 2/3] Add several group web services - refs BT#9431 --- main/webservices/registration.soap.php | 1374 +++++++++++++++--------- 1 file changed, 852 insertions(+), 522 deletions(-) diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index b3942f3616..88bcdf6bd8 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -114,9 +114,9 @@ $server->wsdl->addComplexType( 'all', '', array( - 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), - 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') - ) + 'field_name' => array('name' => 'field_name', 'type' => 'xsd:string'), + 'field_value' => array('name' => 'field_value', 'type' => 'xsd:string') + ) ); $server->wsdl->addComplexType( @@ -152,13 +152,13 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'usersParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),'tns:usersParams' + 'usersParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:usersParams[]')),'tns:usersParams' ); $server->wsdl->addComplexType( @@ -175,25 +175,25 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_createUsers', -'complexType', -'struct', -'all', -'', -array( + 'result_createUsers', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_createUsers', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers' + 'results_createUsers', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:result_createUsers[]')),'tns:result_createUsers' ); // Register the method to expose @@ -597,14 +597,14 @@ $server->wsdl->addComplexType( $server->wsdl->addComplexType( -'createUsersPassEncryptParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createUsersPassEncryptParams[]')), -'tns:createUsersPassEncryptParams' + 'createUsersPassEncryptParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createUsersPassEncryptParams[]')), + 'tns:createUsersPassEncryptParams' ); @@ -623,26 +623,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_createUsersPassEncrypt', -'complexType', -'struct', -'all', -'', -array( + 'result_createUsersPassEncrypt', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_createUsersPassEncrypt', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsersPassEncrypt[]')), -'tns:result_createUsersPassEncrypt' + 'results_createUsersPassEncrypt', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createUsersPassEncrypt[]')), + 'tns:result_createUsersPassEncrypt' ); // Register the method to expose @@ -1221,26 +1221,26 @@ function WSEditUserCredentials($params) { // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_editUsers', -'complexType', -'struct', -'all', -'', -array( + 'result_editUsers', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_editUsers', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editUsers[]')), -'tns:result_editUsers' + 'results_editUsers', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editUsers[]')), + 'tns:result_editUsers' ); // Register the method to expose @@ -1727,14 +1727,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'editUsersPasswordCryptedParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editUsersPasswordCryptedParams[]')), -'tns:editUsersPasswordCryptedParams' + 'editUsersPasswordCryptedParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editUsersPasswordCryptedParams[]')), + 'tns:editUsersPasswordCryptedParams' ); $server->wsdl->addComplexType( @@ -1751,26 +1751,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_editUsersPasswordCrypted', -'complexType', -'struct', -'all', -'', -array( + 'result_editUsersPasswordCrypted', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_editUsersPasswordCrypted', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editUsersPasswordCrypted[]')), -'tns:result_editUsersPasswordCrypted' + 'results_editUsersPasswordCrypted', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editUsersPasswordCrypted[]')), + 'tns:result_editUsersPasswordCrypted' ); // Register the method to expose @@ -2129,13 +2129,13 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( - 'user_ids_array', - 'complexType', - 'array', - '', - 'SOAP-ENC:Array', - array(), - array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id' + 'user_ids_array', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:user_id[]')),'tns:user_id' ); $server->wsdl->addComplexType( @@ -2249,13 +2249,13 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'createCourseParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams' + 'createCourseParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType' => 'tns:createCourseParams[]')),'tns:createCourseParams' ); // Register the data structures used by the service @@ -2273,26 +2273,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_createCourse', -'complexType', -'struct', -'all', -'', -array( + 'result_createCourse', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_createCourse', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createCourse[]')), -'tns:result_createCourse' + 'results_createCourse', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createCourse[]')), + 'tns:result_createCourse' ); // Register the method to expose @@ -2445,14 +2445,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'createCourseByTitleParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseByTitleParams[]')), -'tns:createCourseByTitleParams' + 'createCourseByTitleParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createCourseByTitleParams[]')), + 'tns:createCourseByTitleParams' ); // Register the data structures used by the service @@ -2470,26 +2470,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_createCourseByTitle', -'complexType', -'struct', -'all', -'', -array( + 'result_createCourseByTitle', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_createCourseByTitle', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createCourseByTitle[]')), -'tns:result_createCourseByTitle' + 'results_createCourseByTitle', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createCourseByTitle[]')), + 'tns:result_createCourseByTitle' ); @@ -2669,14 +2669,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'editCourseParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editCourseParams[]')), -'tns:editCourseParams' + 'editCourseParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editCourseParams[]')), + 'tns:editCourseParams' ); $server->wsdl->addComplexType( @@ -2693,26 +2693,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_editCourse', -'complexType', -'struct', -'all', -'', -array( + 'result_editCourse', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_editCourse', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editCourse[]')), -'tns:result_editCourse' + 'results_editCourse', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editCourse[]')), + 'tns:result_editCourse' ); // Register the method to expose @@ -2847,28 +2847,28 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'fields_course_desc', -'complexType', -'struct', -'all', -'', -array( + 'fields_course_desc', + 'complexType', + 'struct', + 'all', + '', + array( 'course_desc_id' => array('name' => 'course_desc_id', 'type' => 'xsd:string'), 'course_desc_default_title' => array('name' => 'course_desc_default_title', 'type' => 'xsd:string'), 'course_desc_title' => array('name' => 'course_desc_title', 'type' => 'xsd:string'), 'course_desc_content' => array('name' => 'course_desc_content', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'fields_course_desc_list', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:fields_course_desc[]')), -'tns:fields_course_desc' + 'fields_course_desc_list', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:fields_course_desc[]')), + 'tns:fields_course_desc' ); @@ -2931,14 +2931,14 @@ function WSCourseDescription($params) { $result = Database::query($sql); $default_titles = array( - get_lang('GeneralDescription'), - get_lang('Objectives'), - get_lang('Topics'), - get_lang('Methodology'), - get_lang('CourseMaterial'), - get_lang('HumanAndTechnicalResources'), - get_lang('Assessment'), - get_lang('AddCategory')); + get_lang('GeneralDescription'), + get_lang('Objectives'), + get_lang('Topics'), + get_lang('Methodology'), + get_lang('CourseMaterial'), + get_lang('HumanAndTechnicalResources'), + get_lang('Assessment'), + get_lang('AddCategory')); // TODO: Hard-coded Spanish texts. //$default_titles = array('Descripcion general', 'Objetivos', 'Contenidos', 'Metodologia', 'Materiales', 'Recursos humanos y tecnicos', 'Evaluacion', 'Apartado'); @@ -2989,14 +2989,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'editCourseDescriptionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editCourseDescriptionParams[]')), -'tns:editCourseDescriptionParams' + 'editCourseDescriptionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editCourseDescriptionParams[]')), + 'tns:editCourseDescriptionParams' ); $server->wsdl->addComplexType( @@ -3014,26 +3014,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_editCourseDescription', -'complexType', -'struct', -'all', -'', -array( + 'result_editCourseDescription', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_editCourseDescription', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editCourseDescription[]')), -'tns:result_editCourseDescription' + 'results_editCourseDescription', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editCourseDescription[]')), + 'tns:result_editCourseDescription' ); @@ -3149,14 +3149,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'deleteCourseParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteCourseParams[]')), -'tns:deleteCourseParams' + 'deleteCourseParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteCourseParams[]')), + 'tns:deleteCourseParams' ); // Register the data structures used by the service. @@ -3174,26 +3174,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array. $server->wsdl->addComplexType( -'result_deleteCourse', -'complexType', -'struct', -'all', -'', -array( + 'result_deleteCourse', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_deleteCourse', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_deleteCourse[]')), -'tns:result_deleteCourse' + 'results_deleteCourse', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_deleteCourse[]')), + 'tns:result_deleteCourse' ); $server->register('WSDeleteCourse', // method name @@ -3288,14 +3288,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'createSessionParamList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createSessionParam[]')), -'tns:createSessionParam' + 'createSessionParamList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:createSessionParam[]')), + 'tns:createSessionParam' ); // Register the data structures used by the service @@ -3313,26 +3313,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_createSession', -'complexType', -'struct', -'all', -'', -array( + 'result_createSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_createSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createSession[]')), -'tns:result_createSession' + 'results_createSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_createSession[]')), + 'tns:result_createSession' ); // Register the method to expose @@ -3417,7 +3417,7 @@ function WSCreateSession($params) { $results[] = 0; continue; } else { - Database::query("INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end) VALUES('".addslashes($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.")"); + Database::query("INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, nb_days_access_before_beginning, nb_days_access_after_end) VALUES('".addslashes($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.")"); $id_session = Database::insert_id(); // Save new fieldlabel into course_field table. @@ -3478,14 +3478,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'editSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editSessionParams[]')), -'tns:editSessionParams' + 'editSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:editSessionParams[]')), + 'tns:editSessionParams' ); $server->wsdl->addComplexType( @@ -3502,26 +3502,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_editSession', -'complexType', -'struct', -'all', -'', -array( + 'result_editSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_editSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editSession[]')), -'tns:result_editSession' + 'results_editSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_editSession[]')), + 'tns:result_editSession' ); @@ -3605,14 +3605,14 @@ function WSEditSession($params) { continue; } else { $sql = "UPDATE $tbl_session SET " . - "name='".addslashes($name)."', " . - "date_start='".$date_start."', " . - "date_end='".$date_end."', " . - "id_coach='". $id_coach."', " . - "session_admin_id='". intval($_user['user_id'])."', " . - "nb_days_access_before_beginning='". $nb_days_acess_before."', " . - "nb_days_access_after_end='". $nb_days_acess_after."'" . - " WHERE id='".$id."'"; + "name='".addslashes($name)."', " . + "date_start='".$date_start."', " . + "date_end='".$date_end."', " . + "id_coach='". $id_coach."', " . + "session_admin_id='". intval($_user['user_id'])."', " . + "nb_days_access_before_beginning='". $nb_days_acess_before."', " . + "nb_days_access_after_end='". $nb_days_acess_after."'" . + " WHERE id='".$id."'"; Database::query($sql); $id_session = Database::insert_id(); @@ -3644,14 +3644,14 @@ function WSEditSession($params) { /* Register WSSubscribeUserToCourse function */ // Register the data structures used by the service $server->wsdl->addComplexType( -'originalUsersList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteSessionParams[]')), -'tns:originalUsersList' + 'originalUsersList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteSessionParams[]')), + 'tns:originalUsersList' ); $server->wsdl->addComplexType( @@ -3682,14 +3682,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'deleteSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteSessionParams[]')), -'tns:deleteSessionParams' + 'deleteSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:deleteSessionParams[]')), + 'tns:deleteSessionParams' ); // Register the data structures used by the service @@ -3707,26 +3707,26 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_deleteSession', -'complexType', -'struct', -'all', -'', -array( + 'result_deleteSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_deleteSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_deleteSession[]')), -'tns:result_deleteSession' + 'results_deleteSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_deleteSession[]')), + 'tns:result_deleteSession' ); $server->register('WSDeleteSession', // method name @@ -3869,7 +3869,7 @@ $server->wsdl->addComplexType( 'SOAP-ENC:Array', array(), array( - array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_course_status[]') + array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:user_course_status[]') ), 'tns:user_course_status' ); @@ -3882,10 +3882,10 @@ $server->wsdl->addComplexType( 'all', '', array ( - 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), - 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), - 'result' => array('name' => 'result', 'type' => 'xsd:int') - ) + 'original_user_id_value' => array('name' => 'original_user_id_value', 'type' => 'xsd:string'), + 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), + 'result' => array('name' => 'result', 'type' => 'xsd:int') + ) ); @@ -3968,11 +3968,11 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'Result', -'complexType', -'struct', -'all', -'', + 'Result', + 'complexType', + 'struct', + 'all', + '', array('message' => array('name' => 'message', 'type' => 'xsd:string')) ); @@ -4054,11 +4054,11 @@ $server->wsdl->addComplexType( 'struct', 'all', '', -array ( + array ( 'user_id' => array('name' => 'user_id', 'type' => 'xsd:string'), 'firstname' => array('name' => 'firstname', 'type' => 'xsd:string'), 'lastname' => array('name' => 'lastname', 'type' => 'xsd:string'), - ) + ) ); // Register the method to expose @@ -4168,14 +4168,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'unsuscribeUserFromCourseParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsuscribeUserFromCourseParams[]')), -'tns:unsuscribeUserFromCourseParams' + 'unsuscribeUserFromCourseParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsuscribeUserFromCourseParams[]')), + 'tns:unsuscribeUserFromCourseParams' ); $server->wsdl->addComplexType( @@ -4192,27 +4192,27 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_unsuscribeUserFromCourse', -'complexType', -'struct', -'all', -'', -array( + 'result_unsuscribeUserFromCourse', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'xsd:string'), 'original_course_id_value' => array('name' => 'original_course_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_unsuscribeUserFromCourse', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsuscribeUserFromCourse[]')), -'tns:result_unsuscribeUserFromCourse' + 'results_unsuscribeUserFromCourse', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsuscribeUserFromCourse[]')), + 'tns:result_unsuscribeUserFromCourse' ); // Register the method to expose @@ -4256,7 +4256,7 @@ function WSUnsubscribeUserFromCourse($params) { $usersList = array(); foreach ($original_user_id_values as $key => $row_original_user_id) { $user_id = UserManager::get_user_id_from_original_id($original_user_id_values[$key], $original_user_id_name[$key]); - if ($user_id == 0) { + if ($user_id == 0) { continue; // user_id doesn't exist. } else { $sql = "SELECT user_id FROM $user_table WHERE user_id ='".$user_id."' AND active= '0'"; @@ -4267,7 +4267,7 @@ function WSUnsubscribeUserFromCourse($params) { } } $usersList[] = $user_id; - } + } $orig_user_id_value[] = implode(',',$usersList); @@ -4333,14 +4333,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'subscribeUsersToSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeUsersToSessionParams[]')), -'tns:subscribeUsersToSessionParams' + 'subscribeUsersToSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeUsersToSessionParams[]')), + 'tns:subscribeUsersToSessionParams' ); $server->wsdl->addComplexType( @@ -4357,27 +4357,27 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array. $server->wsdl->addComplexType( -'result_subscribeUsersToSession', -'complexType', -'struct', -'all', -'', -array( + 'result_subscribeUsersToSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'xsd:string'), 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_subscribeUsersToSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_subscribeUsersToSession[]')), -'tns:result_subscribeUsersToSession' + 'results_subscribeUsersToSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_subscribeUsersToSession[]')), + 'tns:result_subscribeUsersToSession' ); // Register the method to expose @@ -4394,47 +4394,47 @@ $server->register('WSSuscribeUsersToSession', // method // define the method WSSuscribeUsersToSession function WSSuscribeUsersToSession($params){ - if(!WSHelperVerifyKey($params)) { + if(!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } $user_table = Database::get_main_table(TABLE_MAIN_USER); - $t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD); + $t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD); $t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); $t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD); $t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $userssessions_params = $params['userssessions']; + $userssessions_params = $params['userssessions']; $results = array(); $orig_user_id_value = array(); $orig_session_id_value = array(); foreach($userssessions_params as $usersession_params) { - $original_session_id_value = $usersession_params['original_session_id_value']; + $original_session_id_value = $usersession_params['original_session_id_value']; $original_session_id_name = $usersession_params['original_session_id_name']; $original_user_id_name = $usersession_params['original_user_id_name']; $original_user_id_values = $usersession_params['original_user_id_values']; - $orig_session_id_value[] = $original_session_id_value; + $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'"; $res_session = Database::query($sql_session); $row_session = Database::fetch_row($res_session); - $id_session = $row_session[0]; + $id_session = $row_session[0]; - if (Database::num_rows($res_session) < 1) { + if (Database::num_rows($res_session) < 1) { $results[] = 0; continue; } - $usersList = array(); - foreach ($original_user_id_values as $key => $row_original_user_list) { - $user_id = UserManager::get_user_id_from_original_id($original_user_id_values[$key], $original_user_id_name[$key]); - if ($user_id == 0) { + $usersList = array(); + foreach ($original_user_id_values as $key => $row_original_user_list) { + $user_id = UserManager::get_user_id_from_original_id($original_user_id_values[$key], $original_user_id_name[$key]); + if ($user_id == 0) { continue; // user_id doesn't exist. } else { $sql = "SELECT user_id FROM $user_table WHERE user_id ='".$user_id."' AND active= '0'"; @@ -4445,7 +4445,7 @@ function WSSuscribeUsersToSession($params){ } } $usersList[] = $user_id; - } + } if (empty($usersList)) { $results[] = 0; @@ -4456,7 +4456,7 @@ function WSSuscribeUsersToSession($params){ if ($id_session!= strval(intval($id_session))) { $results[] = 0; - continue; + continue; } $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; @@ -4483,7 +4483,7 @@ function WSSuscribeUsersToSession($params){ $enreg_user = Database::escape_string($enreg_user); $insert_sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(id_session,course_code,id_user) VALUES('$id_session','$enreg_course','$enreg_user')"; Database::query($insert_sql); - if (Database::affected_rows()) { + if (Database::affected_rows()) { $nbr_users++; } } @@ -4552,7 +4552,7 @@ function WSSubscribeUserToSessionSimple($params) { global $debug; if ($debug) { - error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']'); + error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']'); } // Check security key @@ -4606,14 +4606,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'unsubscribeUsersFromSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsubscribeUsersFromSessionParams[]')), -'tns:unsubscribeUsersFromSessionParams' + 'unsubscribeUsersFromSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsubscribeUsersFromSessionParams[]')), + 'tns:unsubscribeUsersFromSessionParams' ); $server->wsdl->addComplexType( @@ -4630,27 +4630,27 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_unsubscribeUsersFromSession', -'complexType', -'struct', -'all', -'', -array( + 'result_unsubscribeUsersFromSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_user_id_values' => array('name' => 'original_user_id_values', 'type' => 'xsd:string'), 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_unsubscribeUsersFromSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsubscribeUsersFromSession[]')), -'tns:result_unsubscribeUsersFromSession' + 'results_unsubscribeUsersFromSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsubscribeUsersFromSession[]')), + 'tns:result_unsubscribeUsersFromSession' ); // Register the method to expose @@ -4667,21 +4667,21 @@ $server->register('WSUnsuscribeUsersFromSession', / // define the method WSUnsuscribeUsersFromSession function WSUnsuscribeUsersFromSession($params) { - if(!WSHelperVerifyKey($params)) { + if(!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } $user_table = Database::get_main_table(TABLE_MAIN_USER); - $t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD); + $t_uf = Database::get_main_table(TABLE_MAIN_USER_FIELD); $t_ufv = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES); $t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD); $t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); - $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); - $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); + $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); + $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); - $userssessions_params = $params['userssessions']; + $userssessions_params = $params['userssessions']; $results = array(); $orig_user_id_value = array(); $orig_session_id_value = array(); @@ -4707,8 +4707,8 @@ function WSUnsuscribeUsersFromSession($params) { $usersList = array(); foreach ($original_user_id_values as $key => $row_original_user_list) { - $user_id = UserManager::get_user_id_from_original_id($original_user_id_values[$key], $original_user_id_name[$key]); - if ($user_id == 0) { + $user_id = UserManager::get_user_id_from_original_id($original_user_id_values[$key], $original_user_id_name[$key]); + if ($user_id == 0) { continue; // user_id doesn't exist. } else { $sql = "SELECT user_id FROM $user_table WHERE user_id ='".$user_id."' AND active= '0'"; @@ -4726,14 +4726,14 @@ function WSUnsuscribeUsersFromSession($params) { continue; } - $orig_user_id_value[] = implode(',', $usersList); + $orig_user_id_value[] = implode(',', $usersList); - if ($id_session!= strval(intval($id_session))) { - $results[] = 0; + if ($id_session!= strval(intval($id_session))) { + $results[] = 0; continue; - } + } - $sql = "SELECT id_user FROM $tbl_session_rel_user WHERE id_session='$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH.""; + $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); $existingUsers = array(); while($row = Database::fetch_array($result)){ @@ -4784,7 +4784,7 @@ function WSUnsuscribeUsersFromSession($params) { $row_nbr_users = Database::fetch_row($res_nbr_users); if (Database::num_rows($res_nbr_users) > 0) { - $nbr_users = ($row_nbr_users[0] - $return); + $nbr_users = ($row_nbr_users[0] - $return); } // Update number of users in the session. @@ -4832,26 +4832,26 @@ $server->wsdl->addComplexType( ); $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' + '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' + 'subscribeCoursesToSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeCoursesToSessionParams[]')), + 'tns:subscribeCoursesToSessionParams' ); @@ -4870,14 +4870,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'subscribeCoursesToSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeCoursesToSessionParams[]')), -'tns:subscribeCoursesToSessionParams' + 'subscribeCoursesToSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:subscribeCoursesToSessionParams[]')), + 'tns:subscribeCoursesToSessionParams' ); $server->wsdl->addComplexType( @@ -4894,27 +4894,27 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_subscribeCoursesToSession', -'complexType', -'struct', -'all', -'', -array( + 'result_subscribeCoursesToSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'xsd:string'), 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_subscribeCoursesToSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_subscribeCoursesToSession[]')), -'tns:result_subscribeCoursesToSession' + 'results_subscribeCoursesToSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_subscribeCoursesToSession[]')), + 'tns:result_subscribeCoursesToSession' ); // Register the method to expose @@ -4970,7 +4970,7 @@ function WSSuscribeCoursesToSession($params) { $id_session = $row_session[0]; - if (empty($id_session)) { + if (empty($id_session)) { $results[] = 0; continue; } @@ -5098,14 +5098,14 @@ $server->wsdl->addComplexType( ); $server->wsdl->addComplexType( -'unsubscribeCoursesFromSessionParamsList', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsubscribeCoursesFromSessionParams[]')), -'tns:unsubscribeCoursesFromSessionParams' + 'unsubscribeCoursesFromSessionParamsList', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:unsubscribeCoursesFromSessionParams[]')), + 'tns:unsubscribeCoursesFromSessionParams' ); $server->wsdl->addComplexType( @@ -5122,27 +5122,27 @@ $server->wsdl->addComplexType( // Prepare output params, in this case will return an array $server->wsdl->addComplexType( -'result_unsubscribeCoursesFromSession', -'complexType', -'struct', -'all', -'', -array( + 'result_unsubscribeCoursesFromSession', + 'complexType', + 'struct', + 'all', + '', + array( 'original_course_id_values' => array('name' => 'original_course_id_values', 'type' => 'xsd:string'), 'original_session_id_value' => array('name' => 'original_session_id_value', 'type' => 'xsd:string'), 'result' => array('name' => 'result', 'type' => 'xsd:string') - ) + ) ); $server->wsdl->addComplexType( -'results_unsubscribeCoursesFromSession', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsubscribeCoursesFromSession[]')), -'tns:result_unsubscribeCoursesFromSession' + 'results_unsubscribeCoursesFromSession', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:result_unsubscribeCoursesFromSession[]')), + 'tns:result_unsubscribeCoursesFromSession' ); @@ -5164,7 +5164,7 @@ function WSUnsuscribeCoursesFromSession($params) { return return_error(WS_ERROR_SECRET_KEY); } - // Initialisation + // 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_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); @@ -5191,22 +5191,22 @@ function WSUnsuscribeCoursesFromSession($params) { $res_session = Database::query($sql_session); $row_session = Database::fetch_row($res_session); - $id_session = $row_session[0]; + $id_session = $row_session[0]; - if (empty($id_session)) { + if (empty($id_session)) { $results[] = 0; continue; } // Get courses list from row_original_course_id_values $course_list = array(); - foreach ($original_course_id_values as $row_original_course_list) { - $course_code = Database::escape_string($row_original_course_list['course_code']); + foreach ($original_course_id_values as $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])) { + $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])) { continue; // Course_code doesn't exist' } else { $sql = "SELECT code FROM $tbl_course WHERE code ='".$row_course[0]."' AND visibility = '0'"; @@ -5217,14 +5217,14 @@ function WSUnsuscribeCoursesFromSession($params) { } } $course_list[] = $row_course[0]; - } + } if (empty($course_list)) { $results[] = 0; continue; } - $orig_course_id_value[] = implode(',', $course_list); + $orig_course_id_value[] = implode(',', $course_list); foreach ($course_list as $enreg_course) { $enreg_course = Database::escape_string($enreg_course); @@ -5239,7 +5239,7 @@ function WSUnsuscribeCoursesFromSession($params) { $row_nbr_courses = Database::fetch_row($res_nbr_courses); if (Database::num_rows($res_nbr_courses) > 0) { - $nbr_users = ($row_nbr_courses[0] - $return); + $nbr_users = ($row_nbr_courses[0] - $return); } // Update number of users in the session. @@ -5261,12 +5261,12 @@ function WSUnsuscribeCoursesFromSession($params) { /** WSListCourses **/ $server->wsdl->addComplexType( -'course', -'complexType', -'struct', -'all', -'', -array( + 'course', + 'complexType', + 'struct', + 'all', + '', + array( 'id' => array('name' => 'id', 'type' => 'xsd:int'), 'code' => array('name' => 'code', 'type' => 'xsd:string'), 'external_course_id' => array('name' => 'external_course_id', 'type' => 'xsd:string'), @@ -5275,18 +5275,18 @@ array( 'category_name' => array('name' => 'category_name', 'type' => 'xsd:string'), 'visibility' => array('name' => 'visibility', 'type' => 'xsd:int'), 'number_students' => array('name' => 'number_students', 'type' => 'xsd:int') - ) + ) ); $server->wsdl->addComplexType( -'courses', -'complexType', -'array', -'', -'SOAP-ENC:Array', -array(), -array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), -'tns:course' + 'courses', + 'complexType', + 'array', + '', + 'SOAP-ENC:Array', + array(), + array(array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:course[]')), + 'tns:course' ); @@ -5378,7 +5378,7 @@ function WSUpdateUserApiKey($params) { } $user_id = UserManager::get_user_id_from_original_id($params['original_user_id_value'], $params['original_user_id_name']); - if (!$user_id) { + if (!$user_id) { if (!empty($params['chamilo_username'])) { $info = api_get_user_info_from_username($params['chamilo_username']); $user_id = $info['user_id']; @@ -5622,13 +5622,13 @@ $server->wsdl->addComplexType( $server->wsdl->addComplexType( 'searchedSessionList', 'complexType', - 'array', + 'array', '', 'SOAP-ENC:Array', array(), array( - array('ref' => 'SOAP-ENC:arrayType', - 'wsdl:arrayType' => 'tns:searchedSession[]') + array('ref' => 'SOAP-ENC:arrayType', + 'wsdl:arrayType' => 'tns:searchedSession[]') ), 'tns:searchedSession' ); @@ -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 Web Service start */ +// Register the data structures used by the service + +// Input params for WSBindGroup +$server->wsdl->addComplexType( + 'bindGroup', + '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('WSBindGroup', // method name + array('bindGroup' => 'tns:bindGroup'), // input parameters + array('return' => 'xsd:string'), // output parameters + 'urn:WSRegistration', // namespace + 'urn:WSRegistration#WSBindGroup', // soapaction + 'rpc', // style + 'encoded', // use + 'This service binds a group' // documentation +); + +// Define the method WSBindGroup +function WSBindGroup($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 Web Service start */ +// Register the data structures used by the service + +// Input params for WSUnbindGroup +$server->wsdl->addComplexType( + 'unbindGroup', + '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('WSUnbindGroup', // method name + array('unbindGroup' => 'tns:unbindGroup'), // input parameters + array('return' => 'xsd:string'), // output parameters + 'urn:WSRegistration', // namespace + 'urn:WSRegistration#WSUnbindGroup', // soapaction + 'rpc', // style + 'encoded', // use + 'This service unbinds a group' // documentation +); + +// Define the method WSUnbindGroup +function WSUnbindGroup($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 Web Service start */ +// Register the data structures used by the service + +// Input params for WSUpdateUserRole +$server->wsdl->addComplexType( + 'updateUserRole', + '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('WSUpdateUserRole', // method name + array('updateUserRole' => 'tns:updateUserRole'), // input parameters + array('return' => 'xsd:string'), // output parameters + 'urn:WSRegistration', // namespace + 'urn:WSRegistration#WSUpdateUserRole', // soapaction + 'rpc', // style + 'encoded', // use + 'This service updates a user role' // documentation +); + +// Define the method WSUpdateUserRole +function WSUpdateUserRole($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)); From 185621530ced06f552bf1d98c7e0259d491f2a18 Mon Sep 17 00:00:00 2001 From: Imanol Losada Date: Mon, 9 Mar 2015 10:51:13 -0500 Subject: [PATCH 3/3] Rename WSBindGroup to GroupBindToParent, WSUnbindGroup to GroupUnbindFromParent and WSUpdateUserRole to WSUpdateUserRoleInGroup - refs BT#9431 --- main/webservices/registration.soap.php | 90 +++++++++++++------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index 88bcdf6bd8..114cb64515 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -5875,12 +5875,12 @@ function WSDeleteGroup($params) /* Delete group Web Service end */ -/* Bind group Web Service start */ +/* Bind group to parent Web Service start */ // Register the data structures used by the service -// Input params for WSBindGroup +// Input params for GroupBindToParent $server->wsdl->addComplexType( - 'bindGroup', + 'groupBindToParent', 'complexType', 'struct', 'all', @@ -5893,18 +5893,18 @@ $server->wsdl->addComplexType( ); // Register the method to expose -$server->register('WSBindGroup', // method name - array('bindGroup' => 'tns:bindGroup'), // input parameters - array('return' => 'xsd:string'), // output parameters - 'urn:WSRegistration', // namespace - 'urn:WSRegistration#WSBindGroup', // soapaction - 'rpc', // style - 'encoded', // use - 'This service binds a group' // documentation -); - -// Define the method WSBindGroup -function WSBindGroup($params) +$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); @@ -5914,12 +5914,12 @@ function WSBindGroup($params) /* Bind group Web Service end */ -/* Unbind group Web Service start */ +/* Unbind group from parent Web Service start */ // Register the data structures used by the service -// Input params for WSUnbindGroup +// Input params for GroupUnbindFromParent $server->wsdl->addComplexType( - 'unbindGroup', + 'groupUnbindFromParent', 'complexType', 'struct', 'all', @@ -5931,18 +5931,18 @@ $server->wsdl->addComplexType( ); // Register the method to expose -$server->register('WSUnbindGroup', // method name - array('unbindGroup' => 'tns:unbindGroup'), // input parameters - array('return' => 'xsd:string'), // output parameters - 'urn:WSRegistration', // namespace - 'urn:WSRegistration#WSUnbindGroup', // soapaction - 'rpc', // style - 'encoded', // use - 'This service unbinds a group' // documentation -); - -// Define the method WSUnbindGroup -function WSUnbindGroup($params) +$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); @@ -5991,12 +5991,12 @@ function WSAddUserToGroup($params) /* Add user to group Web Service end */ -/* Update user role Web Service start */ +/* Update user role in group Web Service start */ // Register the data structures used by the service -// Input params for WSUpdateUserRole +// Input params for WSUpdateUserRoleInGroup $server->wsdl->addComplexType( - 'updateUserRole', + 'updateUserRoleInGroup', 'complexType', 'struct', 'all', @@ -6010,18 +6010,18 @@ $server->wsdl->addComplexType( ); // Register the method to expose -$server->register('WSUpdateUserRole', // method name - array('updateUserRole' => 'tns:updateUserRole'), // input parameters - array('return' => 'xsd:string'), // output parameters - 'urn:WSRegistration', // namespace - 'urn:WSRegistration#WSUpdateUserRole', // soapaction - 'rpc', // style - 'encoded', // use - 'This service updates a user role' // documentation -); - -// Define the method WSUpdateUserRole -function WSUpdateUserRole($params) +$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);