@@ 1075-1107 (lines=33) @@ | ||
1072 | * @param array $params - WSFunction parameters (include VerifyKey) |
|
1073 | * @return bool|null|soap_fault A simple boolean (true if teacher successful subscribed, false otherwise) |
|
1074 | */ |
|
1075 | function WSSubscribeTeacherToSessionCourse($params) |
|
1076 | { |
|
1077 | global $debug; |
|
1078 | ||
1079 | if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
1080 | ||
1081 | if (!WSHelperVerifyKey($params)) { |
|
1082 | return returnError(WS_ERROR_SECRET_KEY); |
|
1083 | } |
|
1084 | ||
1085 | if ($debug) error_log('Params '. print_r($params, 1)); |
|
1086 | ||
1087 | $params = parseCourseSessionUserParams($params); |
|
1088 | ||
1089 | $userId = $params['user_id']; |
|
1090 | $courseId = $params['course_id']; |
|
1091 | $sessionId = $params['session_id']; |
|
1092 | SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId); |
|
1093 | $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseId); |
|
1094 | ||
1095 | $result = 0; |
|
1096 | ||
1097 | if (!empty($coaches)) { |
|
1098 | if ($debug) error_log('Coaches: '. print_r($coaches, 1)); |
|
1099 | if (in_array($userId, $coaches)) { |
|
1100 | $result = 1; |
|
1101 | } |
|
1102 | } |
|
1103 | ||
1104 | if ($debug) error_log('Result: '. $result); |
|
1105 | ||
1106 | return $result; |
|
1107 | } |
|
1108 | ||
1109 | $server->register( |
|
1110 | 'WSUnsubscribeTeacherFromSessionCourse', |
|
@@ 1126-1161 (lines=36) @@ | ||
1123 | * @param array $params - WSFunction parameters (include VerifyKey) |
|
1124 | * @return bool|null|soap_fault A simple boolean (true if teacher successful unsubscribed, false otherwise) |
|
1125 | */ |
|
1126 | function WSUnsubscribeTeacherFromSessionCourse($params) |
|
1127 | { |
|
1128 | global $debug; |
|
1129 | ||
1130 | if ($debug) error_log('WSSubscribeTeacherToSessionCourse'); |
|
1131 | ||
1132 | if (!WSHelperVerifyKey($params)) { |
|
1133 | return returnError(WS_ERROR_SECRET_KEY); |
|
1134 | } |
|
1135 | ||
1136 | if ($debug) error_log('Params '. print_r($params, 1)); |
|
1137 | ||
1138 | $params = parseCourseSessionUserParams($params); |
|
1139 | ||
1140 | $userId = $params['user_id']; |
|
1141 | $courseId = $params['course_id']; |
|
1142 | $sessionId = $params['session_id']; |
|
1143 | ||
1144 | SessionManager::removeUsersFromCourseSession([$userId], $sessionId, $courseId); |
|
1145 | $coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseId); |
|
1146 | ||
1147 | $result = 0; |
|
1148 | ||
1149 | if (!empty($coaches)) { |
|
1150 | if ($debug) error_log('Coaches: ' . print_r($coaches, 1)); |
|
1151 | if (!in_array($userId, $coaches)) { |
|
1152 | $result = 1; |
|
1153 | } |
|
1154 | } else { |
|
1155 | $result = 1; |
|
1156 | } |
|
1157 | ||
1158 | if ($debug) error_log('Final Result: '. $result); |
|
1159 | ||
1160 | return $result; |
|
1161 | } |
|
1162 | ||
1163 | /* Register WSCreateUserPasswordCrypted function */ |
|
1164 | // Register the data structures used by the service |