Skip to content

Commit

Permalink
Rework CalRoutes
Browse files Browse the repository at this point in the history
  • Loading branch information
disc5 committed Jun 2, 2015
1 parent 8313b6b commit 7f39020
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 7f39020

Please sign in to comment.