Webservice: Add method to show social profile - refs BT#19195

pull/4053/head
Angel Fernando Quiroz Campos 4 years ago
parent d61c1241c3
commit fab5d2b61b
  1. 13
      main/inc/lib/webservices/Rest.php
  2. 5
      main/webservices/api/v2.php

@ -37,6 +37,7 @@ class Rest extends WebService
const GET_USER_COURSES = 'user_courses';
const GET_USER_SESSIONS = 'user_sessions';
const VIEW_PROFILE = 'view_user_profile';
const GET_PROFILE = 'user_profile';
const VIEW_COURSE_HOME = 'view_course_home';
@ -2939,6 +2940,18 @@ class Rest extends WebService
);
}
public function viewUserProfile(int $userId)
{
$url = api_get_path(WEB_CODE_PATH).'social/profile.php';
if ($userId) {
$url .= '?'.http_build_query(['u' => $userId]);
}
header("Location: $url");
exit;
}
public function viewCourseHome()
{
$url = api_get_course_url($this->course->getCode(), $this->session ? $this->session->getId() : 0);

@ -167,6 +167,11 @@ try {
$restResponse->setData($courses);
break;
case Rest::VIEW_PROFILE:
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
$restApi->viewUserProfile($userId);
break;
case Rest::GET_PROFILE:
$userInfo = $restApi->getUserProfile();
$restResponse->setData($userInfo);

Loading…
Cancel
Save