Skip to content

Commit

Permalink
Webservice: Add service to redirect to My Courses page - refs BT#19868
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed May 2, 2022
1 parent 06bf6af commit 6610277
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions main/inc/lib/webservices/Rest.php
Expand Up @@ -41,6 +41,7 @@ class Rest extends WebService
const VIEW_PROFILE = 'view_user_profile';
const GET_PROFILE = 'user_profile';

const VIEW_MY_COURSES = 'view_my_courses';
const VIEW_COURSE_HOME = 'view_course_home';
const GET_COURSE_INFO = 'course_info';
const GET_COURSE_DESCRIPTIONS = 'course_descriptions';
Expand Down Expand Up @@ -3194,6 +3195,15 @@ public static function isAllowedByRequest(bool $inpersonate = false): bool
return (bool) $restApi;
}

public function viewMyCourses()
{
$url = api_get_path(WEB_PATH).'user_portal.php?'
.http_build_query(['nosession' => 'true']);

header("Location: $url");
exit;
}

protected static function generateApiKeyForUser(int $userId): string
{
UserManager::add_api_key($userId, self::SERVICE_NAME);
Expand Down
3 changes: 3 additions & 0 deletions main/webservices/api/v2.php
Expand Up @@ -184,6 +184,9 @@
$restResponse->setData($userInfo);
break;

case Rest::VIEW_MY_COURSES:
$restApi->viewMyCourses();
break;
case Rest::VIEW_COURSE_HOME:
$restApi->viewCourseHome();
break;
Expand Down

0 comments on commit 6610277

Please sign in to comment.