From 2407660737031d7deb5ac50f42e664550c1b0743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Fri, 6 Nov 2015 11:51:22 -0500 Subject: [PATCH] Minor code indent changes and fix correct functions --- main/inc/lib/sessionmanager.lib.php | 2 +- main/webservices/soap_session.php | 4 +- main/webservices/webservice_session.php | 140 +++++++++++++----------- 3 files changed, 77 insertions(+), 69 deletions(-) diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 34bb454788..b72daf89c9 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/webservices/soap_session.php b/main/webservices/soap_session.php index 55525c8496..2e7b4d7f3b 100755 --- a/main/webservices/soap_session.php +++ b/main/webservices/soap_session.php @@ -81,7 +81,7 @@ $s->register( ); $s->register( - 'WSSession.SubscribeTeacherToSession', + 'WSSession.SubscribeTeacherToSessionCourse', array( 'secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', @@ -94,7 +94,7 @@ $s->register( ); $s->register( - 'WSSession.UnsubscribeTeacherFromSession', + 'WSSession.UnsubscribeTeacherFromSessionCourse', array( 'secret_key' => 'xsd:string', 'user_id_field_name' => 'xsd:string', diff --git a/main/webservices/webservice_session.php b/main/webservices/webservice_session.php index 62006a5f20..7d4270ac35 100755 --- a/main/webservices/webservice_session.php +++ b/main/webservices/webservice_session.php @@ -357,87 +357,95 @@ 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 + * 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 { + * @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) { + if ($course_id instanceof WSError) { return $course_id; } else { - if($state == 1) { - SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id ); + if ($state == 1) { + SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id); } else { - $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id); + $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 user to a session - * - * @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 - */ - public function SubscribeTeacherToSession($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 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 user to a session - * - * @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 - */ - public function UnsubscribeTeacherFromSession($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); - } - } - } + /** + * 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