diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index ea7cd49cc9..62dbbbf5ab 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -5206,6 +5206,9 @@ div#chat-remote-video video { .ui-jqgrid .ui-jqgrid-htable th div{ height: 25px; } +.ui-jqgrid .ui-jqgrid-htable th { + height: 35px; +} .ui-jqgrid .ui-state-highlight, .ui-jqgrid .ui-widget-content .ui-state-highlight,.ui-jqgrid .ui-widget-header .ui-state-highlight{ background: #F7F7F7; } diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index b990cd3d5f..b8e5adbeb8 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -1033,12 +1033,7 @@ function add_edit_template() { $max_width_for_picture = 100; if ($picture_info['width'] > $max_width_for_picture) { - $thumbwidth = $max_width_for_picture; - if (empty($thumbwidth) || $thumbwidth == 0) { - $thumbwidth = $max_width_for_picture; - } - $new_height = round(($thumbwidth / $picture_info['width']) * $picture_info['height']); - $temp->resize($thumbwidth, $new_height, 0); + $temp->resize($max_width_for_picture); } $temp->send_image($upload_dir.$new_file_name); } diff --git a/main/auth/profile.php b/main/auth/profile.php index 4a090bdef8..5129863128 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -500,8 +500,10 @@ if ($form->validate()) { $validPassword = false; $passwordWasChecked = false; if ($user && - !empty($user_data['password0']) && - !empty($user_data['password1']) + (!empty($user_data['password0']) && + !empty($user_data['password1'])) || + (!empty($user_data['password0']) && + api_get_setting('profile', 'email') == 'true') ) { $passwordWasChecked = true; $validPassword = UserManager::isPasswordValid( diff --git a/main/document/document.php b/main/document/document.php index d3f07c8d23..d6f69707a8 100755 --- a/main/document/document.php +++ b/main/document/document.php @@ -1417,12 +1417,7 @@ if ($is_allowed_to_edit || $max_width_for_picture = 100; if ($picture_info['width'] > $max_width_for_picture) { - $thumbwidth = $max_width_for_picture; - if (empty($thumbwidth) || $thumbwidth == 0) { - $thumbwidth = $max_width_for_picture; - } - $new_height = round(($thumbwidth / $picture_info['width']) * $picture_info['height']); - $temp->resize($thumbwidth, $new_height, 0); + $temp->resize($max_width_for_picture); } $temp->send_image($upload_dir.$new_file_name); } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 56da26698b..3746fde582 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -1464,6 +1464,8 @@ function get_forums( } else { $session_id = $sessionId; } + + $sessionIdLink = ($session_id === 0) ? '' : 'AND threads.session_id = item_properties.session_id'; $condition_session = api_get_session_condition( $session_id, @@ -1503,8 +1505,8 @@ function get_forums( INNER JOIN ".$table_item_property." item_properties ON ( threads.thread_id=item_properties.ref AND - threads.c_id = item_properties.c_id AND - threads.session_id = item_properties.session_id + threads.c_id = item_properties.c_id + $sessionIdLink ) WHERE item_properties.visibility=1 AND @@ -1552,8 +1554,8 @@ function get_forums( INNER JOIN ".$table_item_property." item_properties ON ( threads.thread_id=item_properties.ref AND - threads.c_id = item_properties.c_id AND - threads.session_id = item_properties.session_id + threads.c_id = item_properties.c_id + $sessionIdLink ) WHERE item_properties.visibility<>2 AND diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index c4a73cb25b..20fd593dcd 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -1602,7 +1602,7 @@ class Agenda $user_to_array = $items['users']; $event = array(); $event['id'] = 'course_'.$row['id']; - $event['unique_id'] = 'course_'.$row['id'].intval($row['session_id']); + $event['unique_id'] = $row['iid']; // To avoid doubles if (in_array($event['unique_id'], $eventsAdded)) { diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 355f9363eb..4fe71ce570 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1902,7 +1902,7 @@ function api_format_course_array($course_data) if (array_key_exists('add_teachers_to_sessions_courses', $course_data)) { $_course['add_teachers_to_sessions_courses'] = $course_data['add_teachers_to_sessions_courses']; } - + if (file_exists(api_get_path(SYS_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png')) { $url_image = api_get_path(WEB_COURSE_PATH).$course_data['directory'].'/course-pic85x85.png'; } else { diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 40ee39ad05..2ea7867fa6 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -3274,7 +3274,6 @@ class CourseManager $html .= $params['icon']; $html .= ''; } - $html .= ''; $notifications = isset($params['notifications']) ? $params['notifications'] : ''; $param_class = isset($params['class']) ? $params['class'] : ''; diff --git a/main/inc/lib/course_category.lib.php b/main/inc/lib/course_category.lib.php index 727ed4ccd4..10fa9be6b2 100755 --- a/main/inc/lib/course_category.lib.php +++ b/main/inc/lib/course_category.lib.php @@ -134,7 +134,7 @@ function addNode($code, $name, $canHaveCourses, $parent_id) $params = [ 'name' => $name, 'code' => $code, - 'parent_id' => empty($parent_id) ? '' : $parent_id, + 'parent_id' => empty($parent_id) ? null : $parent_id, 'tree_pos' => $tree_pos, 'children_count' => 0, 'auth_course_child' => $canHaveCourses, @@ -595,7 +595,7 @@ function countCoursesInCategory($category_code="", $searchTerm = '') $without_special_courses = ''; if (!empty($specialCourseList)) { - $without_special_courses = ' AND course.code NOT IN (' . implode(',', $specialCourseList) . ')'; + $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; } $visibilityCondition = null; @@ -668,7 +668,7 @@ function browseCoursesInCategory($category_code, $random_value = null, $limit = $without_special_courses = ''; if (!empty($specialCourseList)) { - $without_special_courses = ' AND course.code NOT IN (' . implode(',', $specialCourseList) . ')'; + $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; } $visibilityCondition = null; $hidePrivate = api_get_setting('course_catalog_hide_private'); diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index d08cbd86b7..f15b8fcdae 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -786,7 +786,7 @@ class CourseHome $tool['link'] = $web_code_path.$tool['link']; } - if ($tool['visibility'] == '0' && $toolAdmin != '1' && !isset($tool['original_link'])) { + if ($tool['visibility'] == '0' && $toolAdmin != '1') { $class = 'invisible'; $info = pathinfo($tool['image']); $basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index" diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 714a2e653b..e0d0487b47 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -1831,7 +1831,7 @@ class SessionManager return false; } - $courseId = $courseInfo['real_id']; + is_array($courseInfo) ? $courseId = $courseInfo['real_id'] : $courseId = $courseInfo; $statusCondition = null; if (isset($status) && !is_null($status)) { diff --git a/main/install/install.lib.php b/main/install/install.lib.php index 059de37270..8716d972f1 100755 --- a/main/install/install.lib.php +++ b/main/install/install.lib.php @@ -1391,7 +1391,6 @@ function display_database_settings_form( //Database Name fix replace weird chars if ($installType != INSTALL_TYPE_UPDATE) { $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm); - $dbNameForm = api_replace_dangerous_char($dbNameForm); } displayDatabaseParameter( diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index bd5b872fd9..127e631a98 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -7579,4 +7579,5 @@ $AverageRatingX = "Average rating %s"; $AverageRating = "Average rating"; $GradebookTeacherResultsNotShown = "Teachers results are not shown nor taken into account in the gradebook."; $SocialWallWriteNewPostToFriend = "Write something on your friend's wall"; +$EmptyTemplate = "Blank template"; ?> \ No newline at end of file diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index 429763f9d9..269bcf5433 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -7566,4 +7566,5 @@ $AverageRatingX = "Score moyen: %s"; $AverageRating = "Score moyen"; $GradebookTeacherResultsNotShown = "Les résultats des enseignants ne sont pas affichés ni pris en compte dans l'outil d'évaluations."; $SocialWallWriteNewPostToFriend = "Écris quelque chose d'intéressant sur le mur de ton ami..."; +$EmptyTemplate = "Modèle blanc"; ?> \ No newline at end of file diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index f40e5509b1..0ac3f7112b 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -7604,4 +7604,5 @@ $AverageRatingX = "Promedio de la valoración %s"; $AverageRating = "Promedio de la valoración"; $GradebookTeacherResultsNotShown = "Los resultados de los profesores no se muestran ni están tomados en cuenta en los cálculos de la herramienta de evaluaciones."; $SocialWallWriteNewPostToFriend = "Escribe algo interesante en el muro de tu amigo..."; +$EmptyTemplate = "Plantilla vacía"; ?> \ No newline at end of file diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index 7227303ab6..221426a0ff 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -9753,19 +9753,7 @@ EOD; // Resize the image. $temp = new Image($image_array['tmp_name']); - $picture_infos = $temp->get_image_info(); - if ($picture_infos['width'] > 104) { - $thumbwidth = 104; - } else { - $thumbwidth = $picture_infos['width']; - } - if ($picture_infos['height'] > 96) { - $new_height = 96; - } else { - $new_height = $picture_infos['height']; - } - - $temp->resize($thumbwidth, $new_height, 0); + $temp->resize(104); $result = $temp->send_image($new_path); // Storing the image filename. @@ -9774,7 +9762,7 @@ EOD; $this->set_preview_image($new_file_name); //Resize to 64px to use on course homepage - $temp->resize(64, 64, 0); + $temp->resize(64); $temp->send_image($updir.'/'.$filename.'.64.'.$file_extension); return true; } diff --git a/main/social/my_skills_report.php b/main/social/my_skills_report.php index 7bf820b009..0f1105f07e 100644 --- a/main/social/my_skills_report.php +++ b/main/social/my_skills_report.php @@ -55,7 +55,7 @@ if ($isStudent) { if (!file_exists($thumbSysPath)) { $courseImageThumb = new Image($imageSysPath); - $courseImageThumb->resize(32, 32, 0); + $courseImageThumb->resize(32); $courseImageThumb->send_image($thumbSysPath); } $tableRow['courseImage'] = $thumbWebPath; @@ -100,7 +100,7 @@ if ($isStudent) { if (!file_exists($thumbSysPath)) { $courseImageThumb = new Image($imageSysPath); - $courseImageThumb->resize(32, 32, 0); + $courseImageThumb->resize(32); $courseImageThumb->send_image($thumbSysPath); } $tableRow['courseImage'] = $thumbWebPath; @@ -167,7 +167,7 @@ if ($isStudent) { if (!file_exists($thumbSysPath)) { $courseImageThumb = new Image($imageSysPath); - $courseImageThumb->resize(32, 32, 0); + $courseImageThumb->resize(32); $courseImageThumb->send_image($thumbSysPath); } diff --git a/main/user/user.php b/main/user/user.php index 47783d213a..feae50737d 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -259,11 +259,8 @@ if (api_is_allowed_to_edit(null, true)) { $data[] = $user; if ($_GET['format'] == 'pdf') { $user_info = api_get_user_info($user['user_id']); - $user_image = Display::img( - $user_info['avatar_no_query'], - null, - array('width' => $user_image_pdf_size.'px') - ); + $user_image = ''; + if ($is_western_name_order) { $user_pdf = array( $counter, @@ -349,11 +346,8 @@ if (api_is_allowed_to_edit(null, true)) { } if ($_GET['format'] == 'pdf') { $user_info = api_get_user_info($user['user_id']); - $user_image = Display::img( - $user_info['avatar_no_query'], - null, - array('width' => $user_image_pdf_size.'px') - ); + + $user_image = ''; if ($is_western_name_order) { $user_pdf = array( @@ -412,6 +406,7 @@ if (api_is_allowed_to_edit(null, true)) { 'pdf_title' => $pdfTitle, 'header_attributes' => $header_attributes ); + Export::export_table_pdf($a_users, $params); exit; } diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index f2728f56bd..c4c51637c0 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -969,6 +969,109 @@ function WSCreateUsersPasswordCrypted($params) return $output; } +// Subscribe / Unsubscribe Teacher to Session Course +// +// Prepare Input params for Subscribe Teacher to SC +$server->wsdl->addComplexType( + 'SubscribeTeacherToSessionCourse', + 'complexType', + 'struct', + 'all', + '', + array( + 'userId' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id + 'sessionId' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID + 'courseId' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') + ) +); + +$server->register( + 'WSSubscribeTeacherToSessionCourse', + array('SubscribeTeacherToSessionCourse' => 'tns:SubscribeTeacherToSessionCourse'), + array('return' => 'xsd:string'), + 'urn:WSRegistration', + 'urn:WSRegistration#WSSubscribeTeacherToSessionCourse', + 'rpc', + 'encoded', + 'This webservice subscribe a teacher to a session course' +); + +// Prepare Input params for Unsubscribe Teacher from SC +$server->wsdl->addComplexType( + 'UnsubscribeTeacherFromSessionCourse', + 'complexType', + 'struct', + 'all', + '', + array( + 'userId' => array('name' => 'course', 'type' => 'xsd:string'), // Chamilo user Id + 'sessionId' => array('name' => 'user_id', 'type' => 'xsd:string'), // Current Session course ID + 'courseId' =>array('name' => 'courseId', 'type' => 'xsd:string'), // Course Real Id + 'secret_key' => array('name' => 'secret_key', 'type' => 'xsd:string') + ) +); + +$server->register( + 'WSUnsubscribeTeacherFromSessionCourse', + array('UnsubscribeTeacherFromSessionCourse' => 'tns:UnsubscribeTeacherFromSessionCourse'), + array('return' => 'xsd:string'), + 'urn:WSRegistration', + 'urn:WSRegistration#WSUnsubscribeTeacherFromSessionCourse', + 'rpc', + 'encoded', + 'This webservice unsubscribe a teacher from a session course' +); + + /** + * Subscribe teacher to a session course + * + * @param array $params - WSFunction parameters (include VerifyKey) + * @return bool|null|soap_fault A simple boolean (true if teacher successful subscribed, false otherwise) + */ + function WSSubscribeTeacherToSessionCourse($params) + { + global $debug; + + if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); + if ($debug) error_log('Params '. print_r($params, 1)); + + if (!WSHelperVerifyKey($params)) { + return return_error(WS_ERROR_SECRET_KEY); + } + + $userId = $params['userId']; // Chamilo user Id + $sessionId = $params['sessionId']; // Current Session course ID + $courseId = $params['courseId']; // Course Real Id + + return (SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId)); + } + + /** + * Subscribe teacher to a session course + * + * @param array $params - WSFunction parameters (include VerifyKey) + * @return bool|null|soap_fault A simple boolean (true if teacher successful unsubscribed, false otherwise) + */ + function WSUnsubscribeTeacherFromSessionCourse($params) + { + global $debug; + + if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); + if ($debug) error_log('Params '. print_r($params, 1)); + + if (!WSHelperVerifyKey($params)) { + return return_error(WS_ERROR_SECRET_KEY); + } + + $userId = $params['userId']; // Chamilo user Id + $sessionId = $params['sessionId']; // Current Session course ID + $courseId = $params['courseId']; // Course Real Id + + return (SessionManager::removeUsersFromCourseSession($userId, $sessionId, $courseId)); + + } + /* Register WSCreateUserPasswordCrypted function */ // Register the data structures used by the service diff --git a/main/webservices/soap_session.php b/main/webservices/soap_session.php index 01f22a18ac..9b48f3c7a7 100755 --- a/main/webservices/soap_session.php +++ b/main/webservices/soap_session.php @@ -11,93 +11,119 @@ require_once(dirname(__FILE__).'/soap.php'); $s = WSSoapServer::singleton(); $s->register( - 'WSSession.CreateSession', - array( - 'secret_key' => 'xsd:string', - 'name' => 'xsd:string', - 'start_date' => 'xsd:string', - 'end_date' => 'xsd:string', - 'nb_days_access_before' => 'xsd:int', - 'nb_days_access_after' => 'xsd:int', - 'nolimit' => 'xsd:int', - 'visibility' => 'xsd:int', - 'user_id_field_name' => 'xsd:string', - 'user_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string', - 'extras' => 'tns:extra_field' - ), - array('return' => 'xsd:int') + 'WSSession.CreateSession', + array( + 'secret_key' => 'xsd:string', + 'name' => 'xsd:string', + 'start_date' => 'xsd:string', + 'end_date' => 'xsd:string', + 'nb_days_access_before' => 'xsd:int', + 'nb_days_access_after' => 'xsd:int', + 'nolimit' => 'xsd:int', + 'visibility' => 'xsd:int', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string', + 'extras' => 'tns:extra_field' + ), + array('return' => 'xsd:int') ); $s->register( - 'WSSession.DeleteSession', - array( - 'secret_key' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string' - ) + 'WSSession.DeleteSession', + array( + 'secret_key' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string' + ) ); $s->register( - 'WSSession.EditSession', - array( - 'secret_key' => 'xsd:string', - 'name' => 'xsd:string', - 'start_date' => 'xsd:string', - 'end_date' => 'xsd:string', - 'nb_days_access_before' => 'xsd:int', - 'nb_days_access_after' => 'xsd:int', - 'nolimit' => 'xsd:int', - 'visibility' => 'xsd:int', - 'user_id_field_name' => 'xsd:string', - 'user_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string', - 'extras' => 'tns:extra_field' - ) + 'WSSession.EditSession', + array( + 'secret_key' => 'xsd:string', + 'name' => 'xsd:string', + 'start_date' => 'xsd:string', + 'end_date' => 'xsd:string', + 'nb_days_access_before' => 'xsd:int', + 'nb_days_access_after' => 'xsd:int', + 'nolimit' => 'xsd:int', + 'visibility' => 'xsd:int', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string', + 'extras' => 'tns:extra_field' + ) ); $s->register( - 'WSSession.SubscribeUserToSession', - array( - 'secret_key' => 'xsd:string', - 'user_id_field_name' => 'xsd:string', - 'user_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string' - ) + 'WSSession.SubscribeUserToSession', + array( + 'secret_key' => 'xsd:string', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string' + ) ); $s->register( - 'WSSession.UnsubscribeUserFromSession', - array( - 'secret_key' => 'xsd:string', - 'user_id_field_name' => 'xsd:string', - 'user_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string' - ) + 'WSSession.UnsubscribeUserFromSession', + array( + 'secret_key' => 'xsd:string', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string' + ) ); $s->register( - 'WSSession.SubscribeCourseToSession', - array( - 'secret_key' => 'xsd:string', - 'course_id_field_name' => 'xsd:string', - 'course_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string' - ) + 'WSSession.SubscribeTeacherToSessionCourse', + array( + 'secret_key' => 'xsd:string', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string', + 'course_id_field_name' => 'xsd:string', + 'course_id_value' => 'xsd:string' + ) ); $s->register( - 'WSSession.UnsubscribeCourseFromSession', - array( - 'secret_key' => 'xsd:string', - 'course_id_field_name' => 'xsd:string', - 'course_id_value' => 'xsd:string', - 'session_id_field_name' => 'xsd:string', - 'session_id_value' => 'xsd:string' - ) + 'WSSession.UnsubscribeTeacherFromSessionCourse', + array( + 'secret_key' => 'xsd:string', + 'user_id_field_name' => 'xsd:string', + 'user_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string', + 'course_id_field_name' => 'xsd:string', + 'course_id_value' => 'xsd:string' + ) +); + +$s->register( + 'WSSession.SubscribeCourseToSession', + array( + 'secret_key' => 'xsd:string', + 'course_id_field_name' => 'xsd:string', + 'course_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string' + ) +); + +$s->register( + 'WSSession.UnsubscribeCourseFromSession', + array( + 'secret_key' => 'xsd:string', + 'course_id_field_name' => 'xsd:string', + 'course_id_value' => 'xsd:string', + 'session_id_field_name' => 'xsd:string', + 'session_id_value' => 'xsd:string' + ) ); diff --git a/main/webservices/webservice_session.php b/main/webservices/webservice_session.php index 1da12d1819..7d4270ac35 100755 --- a/main/webservices/webservice_session.php +++ b/main/webservices/webservice_session.php @@ -355,8 +355,97 @@ class WSSession extends WS } } } + + /** + * Change Teacher subscription (helper method) + * + * @param string User id field name + * @param string User id value + * @param string Session id field name + * @param string Session id value + * @param string Course id field name + * @param string Course id value + * @param int State (1 to subscribe, 0 to unsubscribe) + * @return mixed True on success, WSError otherwise + */ + protected function changeTeacherSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value, $state) + { + $session_id = $this->getSessionId($session_id_field_name, $session_id_value); + if ($session_id instanceof WSError) { + return $session_id; + } else { + $user_id = $this->getUserId($user_id_field_name, $user_id_value); + if ($user_id instanceof WSError) { + return $user_id; + } else { + $course_id = $this->getCourseId($course_id_field_name, $course_id_value); + if ($course_id instanceof WSError) { + return $course_id; + } else { + if ($state == 1) { + SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id); + } else { + $user_id = array (0 => $user_id); + $result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id); + if (!$result) { + return new WSError(303, 'There was an error unsubscribing this Teacher from the session'); + } + } + return true; + } + } + } + } - /** + /** + * Subscribe teacher to a session course + * + * @param string API secret key + * @param string User id field name + * @param string User id value + * @param string Session id field name + * @param string Session id value + * @param string Course id field name + * @param string Course id value + */ + public function SubscribeTeacherToSessionCourse($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value) + { + $verifKey = $this->verifyKey($secret_key); + if ($verifKey instanceof WSError) { + $this->handleError($verifKey); + } else { + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value, 1); + if ($result instanceof WSError) { + $this->handleError($result); + } + } + } + + /** + * Subscribe teacher to a session course + * + * @param string API secret key + * @param string User id field name + * @param string User id value + * @param string Session id field name + * @param string Session id value + * @param string Course id field name + * @param string Course id value + */ + public function UnsubscribeTeacherFromSessionCourse($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value) + { + $verifKey = $this->verifyKey($secret_key); + if ($verifKey instanceof WSError) { + $this->handleError($verifKey); + } else { + $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value, 0); + if ($result instanceof WSError) { + $this->handleError($result); + } + } + } + + /** * Change course subscription * * @param string Course id field name