Minor code indent changes and fix correct functions

1.10.x
José Loguercio 10 years ago
parent 75fd3c8a8f
commit 2407660737
  1. 2
      main/inc/lib/sessionmanager.lib.php
  2. 4
      main/webservices/soap_session.php
  3. 140
      main/webservices/webservice_session.php

@ -1831,7 +1831,7 @@ class SessionManager
return false; return false;
} }
$courseId = $courseInfo['real_id']; is_array($courseInfo) ? $courseId = $courseInfo['real_id'] : $courseId = $courseInfo;
$statusCondition = null; $statusCondition = null;
if (isset($status) && !is_null($status)) { if (isset($status) && !is_null($status)) {

@ -81,7 +81,7 @@ $s->register(
); );
$s->register( $s->register(
'WSSession.SubscribeTeacherToSession', 'WSSession.SubscribeTeacherToSessionCourse',
array( array(
'secret_key' => 'xsd:string', 'secret_key' => 'xsd:string',
'user_id_field_name' => 'xsd:string', 'user_id_field_name' => 'xsd:string',
@ -94,7 +94,7 @@ $s->register(
); );
$s->register( $s->register(
'WSSession.UnsubscribeTeacherFromSession', 'WSSession.UnsubscribeTeacherFromSessionCourse',
array( array(
'secret_key' => 'xsd:string', 'secret_key' => 'xsd:string',
'user_id_field_name' => 'xsd:string', 'user_id_field_name' => 'xsd:string',

@ -357,87 +357,95 @@ class WSSession extends WS
} }
/** /**
* Change Teacher subscription (helper method) * Change Teacher subscription (helper method)
* *
* @param string User id field name * @param string User id field name
* @param string User id value * @param string User id value
* @param string Session id field name * @param string Session id field name
* @param string Session id value * @param string Session id value
* @param string Course id field name * @param string Course id field name
* @param string Course id value * @param string Course id value
* @param int State (1 to subscribe, 0 to unsubscribe) * @param int State (1 to subscribe, 0 to unsubscribe)
* @return mixed True on success, WSError otherwise * @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) { 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) { $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
return $session_id; if ($session_id instanceof WSError) {
} else { return $session_id;
$user_id = $this->getUserId($user_id_field_name, $user_id_value); } else {
if($user_id instanceof WSError) { $user_id = $this->getUserId($user_id_field_name, $user_id_value);
return $user_id; if ($user_id instanceof WSError) {
} else { return $user_id;
} else {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value); $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if($course_id instanceof WSError) { if ($course_id instanceof WSError) {
return $course_id; return $course_id;
} else { } else {
if($state == 1) { if ($state == 1) {
SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id ); SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id);
} else { } 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) { if (!$result) {
return new WSError(303, 'There was an error unsubscribing this Teacher from the session'); return new WSError(303, 'There was an error unsubscribing this Teacher from the session');
} }
} }
return true; return true;
} }
} }
} }
} }
/** /**
* Subscribe user to a session * Subscribe teacher to a session course
* *
* @param string API secret key * @param string API secret key
* @param string User id field name * @param string User id field name
* @param string User id value * @param string User id value
* @param string Session id field name * @param string Session id field name
* @param string Session id value * @param string Session id value
*/ * @param string Course id field name
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) { * @param string Course id value
$verifKey = $this->verifyKey($secret_key); */
if($verifKey instanceof WSError) { 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)
$this->handleError($verifKey); {
} else { $verifKey = $this->verifyKey($secret_key);
$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 ($verifKey instanceof WSError) {
if($result instanceof WSError) { $this->handleError($verifKey);
$this->handleError($result); } 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 * Subscribe teacher to a session course
* *
* @param string API secret key * @param string API secret key
* @param string User id field name * @param string User id field name
* @param string User id value * @param string User id value
* @param string Session id field name * @param string Session id field name
* @param string Session id value * @param string Session id value
*/ * @param string Course id field name
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) { * @param string Course id value
$verifKey = $this->verifyKey($secret_key); */
if($verifKey instanceof WSError) { 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)
$this->handleError($verifKey); {
} else { $verifKey = $this->verifyKey($secret_key);
$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 ($verifKey instanceof WSError) {
if($result instanceof WSError) { $this->handleError($verifKey);
$this->handleError($result); } 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 * Change course subscription
* *
* @param string Course id field name * @param string Course id field name

Loading…
Cancel
Save