|
|
@ -91,9 +91,9 @@ class Rest extends WebService |
|
|
|
* @param string $username |
|
|
|
* @param string $username |
|
|
|
* @param string $apiKeyToValidate |
|
|
|
* @param string $apiKeyToValidate |
|
|
|
* |
|
|
|
* |
|
|
|
* @return Rest |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return Rest |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function validate($username, $apiKeyToValidate) |
|
|
|
public static function validate($username, $apiKeyToValidate) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -309,11 +309,11 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the user courses. |
|
|
|
* Get the user courses. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws \Doctrine\ORM\TransactionRequiredException |
|
|
|
* @throws \Doctrine\ORM\TransactionRequiredException |
|
|
|
* @throws \Doctrine\ORM\ORMException |
|
|
|
* @throws \Doctrine\ORM\ORMException |
|
|
|
* |
|
|
|
|
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException |
|
|
|
* @throws \Doctrine\ORM\OptimisticLockException |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getUserCourses() |
|
|
|
public function getUserCourses() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -342,9 +342,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseInfo() |
|
|
|
public function getCourseInfo() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -374,9 +374,9 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the course descriptions. |
|
|
|
* Get the course descriptions. |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseDescriptions() |
|
|
|
public function getCourseDescriptions() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -398,9 +398,9 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $directoryId |
|
|
|
* @param int $directoryId |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseDocuments($directoryId = 0) |
|
|
|
public function getCourseDocuments($directoryId = 0) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -476,9 +476,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseAnnouncements() |
|
|
|
public function getCourseAnnouncements() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -517,9 +517,9 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $announcementId |
|
|
|
* @param int $announcementId |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseAnnouncement($announcementId) |
|
|
|
public function getCourseAnnouncement($announcementId) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -552,9 +552,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseAgenda() |
|
|
|
public function getCourseAgenda() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -609,9 +609,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseNotebooks() |
|
|
|
public function getCourseNotebooks() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -639,9 +639,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseForumCategories() |
|
|
|
public function getCourseForumCategories() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -712,9 +712,9 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param int $forumId |
|
|
|
* @param int $forumId |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseForum($forumId) |
|
|
|
public function getCourseForum($forumId) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -837,9 +837,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getCourseLearnPaths() |
|
|
|
public function getCourseLearnPaths() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -951,24 +951,6 @@ class Rest extends WebService |
|
|
|
return $categoryData; |
|
|
|
return $categoryData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param array $additionalParams Optional |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return string |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private function encodeParams(array $additionalParams = []) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$params = array_merge( |
|
|
|
|
|
|
|
$additionalParams, |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'api_key' => $this->apiKey, |
|
|
|
|
|
|
|
'username' => $this->user->getUsername(), |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json_encode($params); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Start login for a user. Then make a redirect to show the learnpath. |
|
|
|
* Start login for a user. Then make a redirect to show the learnpath. |
|
|
|
* |
|
|
|
* |
|
|
@ -1304,9 +1286,9 @@ class Rest extends WebService |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @param $userParam |
|
|
|
* @param $userParam |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function addUser($userParam) |
|
|
|
public function addUser($userParam) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1558,9 +1540,9 @@ class Rest extends WebService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return array |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function addCoursesSession(array $params) |
|
|
|
public function addCoursesSession(array $params) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1620,9 +1602,9 @@ class Rest extends WebService |
|
|
|
* @param $startDate |
|
|
|
* @param $startDate |
|
|
|
* @param $endDate |
|
|
|
* @param $endDate |
|
|
|
* |
|
|
|
* |
|
|
|
* @return int, the id of the new session |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return int, the id of the new session |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function createSessionFromModel($modelSessionId, $sessionName, $startDate, $endDate, array $extraFields = []) |
|
|
|
public function createSessionFromModel($modelSessionId, $sessionName, $startDate, $endDate, array $extraFields = []) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1723,9 +1705,9 @@ class Rest extends WebService |
|
|
|
* @param int $sessionId the session id |
|
|
|
* @param int $sessionId the session id |
|
|
|
* @param string $loginName the user's login name |
|
|
|
* @param string $loginName the user's login name |
|
|
|
* |
|
|
|
* |
|
|
|
* @return boolean, whether it worked |
|
|
|
|
|
|
|
* @throws Exception |
|
|
|
* @throws Exception |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return boolean, whether it worked |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function subscribeUserToSessionFromUsername($sessionId, $loginName) |
|
|
|
public function subscribeUserToSessionFromUsername($sessionId, $loginName) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1757,9 +1739,9 @@ class Rest extends WebService |
|
|
|
* @param $fieldName |
|
|
|
* @param $fieldName |
|
|
|
* @param $fieldValue |
|
|
|
* @param $fieldValue |
|
|
|
* |
|
|
|
* |
|
|
|
* @return int, the matching session id |
|
|
|
|
|
|
|
* @throws Exception when no session matched or more than one session matched |
|
|
|
* @throws Exception when no session matched or more than one session matched |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return int, the matching session id |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getSessionFromExtraField($fieldName, $fieldValue) |
|
|
|
public function getSessionFromExtraField($fieldName, $fieldValue) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1792,9 +1774,9 @@ class Rest extends WebService |
|
|
|
* |
|
|
|
* |
|
|
|
* @param array $parameters |
|
|
|
* @param array $parameters |
|
|
|
* |
|
|
|
* |
|
|
|
* @return boolean, true on success |
|
|
|
|
|
|
|
* @throws Exception on failure |
|
|
|
* @throws Exception on failure |
|
|
|
* |
|
|
|
* |
|
|
|
|
|
|
|
* @return boolean, true on success |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function updateUserFromUserName($parameters) |
|
|
|
public function updateUserFromUserName($parameters) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1927,9 +1909,7 @@ class Rest extends WebService |
|
|
|
$fieldValue = $field['field_value']; |
|
|
|
$fieldValue = $field['field_value']; |
|
|
|
if (!isset($fieldName) || !isset($fieldValue) || |
|
|
|
if (!isset($fieldName) || !isset($fieldValue) || |
|
|
|
!UserManager::update_extra_field_value($userId, $fieldName, $fieldValue)) { |
|
|
|
!UserManager::update_extra_field_value($userId, $fieldName, $fieldValue)) { |
|
|
|
throw new Exception( |
|
|
|
throw new Exception(get_lang('CouldNotUpdateExtraFieldValue').': '.print_r($field, true)); |
|
|
|
get_lang('CouldNotUpdateExtraFieldValue').': '.print_r($field, true) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -1998,4 +1978,22 @@ class Rest extends WebService |
|
|
|
{ |
|
|
|
{ |
|
|
|
return false !== api_get_user_info_from_username($loginname); |
|
|
|
return false !== api_get_user_info_from_username($loginname); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param array $additionalParams Optional |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return string |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private function encodeParams(array $additionalParams = []) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$params = array_merge( |
|
|
|
|
|
|
|
$additionalParams, |
|
|
|
|
|
|
|
[ |
|
|
|
|
|
|
|
'api_key' => $this->apiKey, |
|
|
|
|
|
|
|
'username' => $this->user->getUsername(), |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return json_encode($params); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|