From 7f39020e18e5dc2ec49f71130762431c9006c3f7 Mon Sep 17 00:00:00 2001 From: disc5 Date: Tue, 2 Jun 2015 15:44:40 +0200 Subject: [PATCH] Rework CalRoutes --- .../calendar_v1/models/CalendarModel.php | 6 +-- .../calendar_v1/routes/CalendarRoutes.php | 53 ++++++------------- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/models/CalendarModel.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/models/CalendarModel.php index 842b6072..7598d009 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/models/CalendarModel.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/models/CalendarModel.php @@ -102,9 +102,9 @@ function getCalUpcomingEvents($user_id) // see permalink code at ilCalendearAppointmentGUI l.804 (showInfoScreen()) include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php'); - $cat_id = ilCalendarCategoryAssignments::_lookupCategory($entry->getEntryId()); - $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); - $refs = ilObject::_getAllReferences($cat_info['obj_id']); + $cat_id = \ilCalendarCategoryAssignments::_lookupCategory($entry->getEntryId()); + $cat_info = \ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id); + $refs = \ilObject::_getAllReferences($cat_info['obj_id']); $tmp_arr['reference'] = current($refs); // reference id $appointments[] = $tmp_arr; } diff --git a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/routes/CalendarRoutes.php b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/routes/CalendarRoutes.php index 50b6cd49..dcab3441 100755 --- a/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/routes/CalendarRoutes.php +++ b/Customizing/global/plugins/Services/UIComponent/UserInterfaceHook/REST/RESTController/extensions/calendar_v1/routes/CalendarRoutes.php @@ -2,7 +2,7 @@ /** * ILIAS REST Plugin for the ILIAS LMS * - * Authors: D.Schaefer and T. Hufschmidt <(schaefer|hufschmidt)@hrz.uni-marburg.de> + * Authors: D.Schaefer and T.Hufschmidt <(schaefer|hufschmidt)@hrz.uni-marburg.de> * 2014-2015 */ namespace RESTController\extensions\calendar_v1; @@ -23,15 +23,9 @@ $authorizedUserId = $accessToken->getUserId(); if ($authorizedUserId == $id || Libs\RESTLib::isAdminByUserId($authorizedUserId)) { // only the user or the admin is allowed to access the data - try { - $model = new CalendarModel(); - $data = $model->getCalUpcomingEvents($id); - - $app->success($data); - } - catch (\Exception $e) { - $app->halt(500, 'Error: Could not retrieve any events for user '.$id.".", -15); - } + $model = new CalendarModel(); + $data = $model->getCalUpcomingEvents($id); + $app->success($data); } else $app->halt(401, Libs\RESTLib::MSG_NO_ADMIN, Libs\RESTLib::ID_NO_ADMIN); @@ -48,15 +42,10 @@ $authorizedUserId = $accessToken->getUserId(); if ($authorizedUserId == $id || Libs\RESTLib::isAdminByUserId($authorizedUserId)) { // only the user or the admin is allowed to access the data - try { - $model = new CalendarModel(); - $data = $model->getIcalAdress($id); - - $app->success($data); - } - catch (\Exception $e) { - $app->halt(500, 'Error: Could not retrieve ICAL url for user '.$id.".", -15); - } + $model = new CalendarModel(); + $data = $model->getIcalAdress($id); + + $app->success($data); } else $app->halt(401, Libs\RESTLib::MSG_NO_ADMIN, Libs\RESTLib::ID_NO_ADMIN); @@ -74,15 +63,10 @@ if ($authorizedUserId > -1) { // only the user is allowed to access the data $id = $authorizedUserId; - try { - $model = new CalendarModel(); - $data = $model->getCalUpcomingEvents($id); - - $app->success($data); - } - catch (\Exception $e) { - $app->halt(500, 'Error: Could not retrieve any events for user '.$id.".", -15); - } + $model = new CalendarModel(); + $data = $model->getCalUpcomingEvents($id); + + $app->success($data); } else $app->halt(401, Libs\RESTLib::MSG_NO_ADMIN, Libs\RESTLib::ID_NO_ADMIN); @@ -100,15 +84,10 @@ if ($authorizedUserId > -1 ) { // only the user or the admin is allowed to access the data $id = $authorizedUserId; - try { - $model = new CalendarModel(); - $data = $model->getIcalAdress($id); - - $app->success($data); - } - catch (\Exception $e) { - $app->halt(500, 'Error: Could not retrieve ICAL url for user '.$id.".", -15); - } + $model = new CalendarModel(); + $data = $model->getIcalAdress($id); + + $app->success($data); } else $app->halt(401, Libs\RESTLib::MSG_NO_ADMIN, Libs\RESTLib::ID_NO_ADMIN);