Skip to content

Commit be0ccea

Browse files
committed
Webservice: Add get_extra_fields option to get_sessions WS - refs BT#22302
1 parent 72aa66a commit be0ccea

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

main/inc/lib/webservices/Rest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ public function getCoursesCampus(int $campusId = 0): array
16821682
*
16831683
* @throws Exception
16841684
*/
1685-
public function getSessionsCampus(int $campusId = 0): array
1685+
public function getSessionsCampus(int $campusId = 0, bool $getExtraFields = false): array
16861686
{
16871687
self::protectAdminEndpoint();
16881688

@@ -1695,12 +1695,18 @@ public function getSessionsCampus(int $campusId = 0): array
16951695
);
16961696
$shortList = [];
16971697
foreach ($list as $session) {
1698-
$shortList[] = [
1698+
$bundle = [
16991699
'id' => $session['id'],
17001700
'name' => $session['name'],
17011701
'access_start_date' => $session['access_start_date'],
17021702
'access_end_date' => $session['access_end_date'],
17031703
];
1704+
if ($getExtraFields) {
1705+
$extraFieldValues = new ExtraFieldValue('session');
1706+
$extraFields = $extraFieldValues->getAllValuesByItem($session['id']);
1707+
$bundle['extra_fields'] = $extraFields;
1708+
}
1709+
$shortList[] = $bundle;
17041710
}
17051711

17061712
return $shortList;

main/webservices/api/v2.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,12 @@
794794
if (!empty($_POST['id_campus'])) {
795795
$campusId = (int) $_POST['id_campus'];
796796
}
797+
$getExtraFields = false;
798+
if (!empty($_POST['get_extra_fields']) && ('false' != $_POST['get_extra_fields'])) {
799+
$getExtraFields = true;
800+
}
797801
Event::addEvent(LOG_WS.$action, 'id_campus', $campusId);
798-
$data = $restApi->getSessionsCampus($campusId);
802+
$data = $restApi->getSessionsCampus($campusId, $getExtraFields);
799803
$restResponse->setData($data);
800804
break;
801805
case Rest::ADD_COURSES_SESSION:

0 commit comments

Comments
 (0)