diff options
author | msquare <msquare@notrademark.de> | 2016-11-25 13:38:16 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2016-11-25 13:38:16 +0100 |
commit | bae3ede662426d362a3b9d33d9124253af7e847b (patch) | |
tree | e5ece21fc12968f5d40d2ff968fbf70766376e31 | |
parent | a8bcb19eaad798a6441a29e58f9c03ae84de4fc5 (diff) |
fixes #279 fix exporting freeload comment in json export
-rw-r--r-- | includes/controller/shifts_controller.php | 23 | ||||
-rw-r--r-- | includes/model/Shifts_model.php | 4 | ||||
-rw-r--r-- | includes/model/User_model.php | 2 | ||||
-rw-r--r-- | includes/pages/user_atom.php | 3 | ||||
-rw-r--r-- | includes/pages/user_ical.php | 3 | ||||
-rw-r--r-- | includes/view/ShiftTypes_view.php | 1 |
6 files changed, 11 insertions, 25 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index 1500b449..1e04c5a8 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -1,6 +1,6 @@ <?php - use Engelsystem\ShiftSignupState; + function shift_link($shift) { return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID']; } @@ -286,7 +286,7 @@ function shifts_json_export_all_controller() { * (Like iCal Export or shifts view) */ function shifts_json_export_controller() { - global $ical_shifts, $user; + global $user; if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) { engelsystem_error("Missing key."); @@ -295,9 +295,6 @@ function shifts_json_export_controller() { $key = $_REQUEST['key']; $user = User_by_api_key($key); - if ($user === false) { - engelsystem_error("Unable to find user."); - } if ($user == null) { engelsystem_error("Key invalid."); } @@ -305,25 +302,17 @@ function shifts_json_export_controller() { engelsystem_error("No privilege for shifts_json_export."); } - $ical_shifts = load_ical_shifts(); + $shifts = load_ical_shifts(); header("Content-Type: application/json; charset=utf-8"); - raw_output(json_encode($ical_shifts)); + raw_output(json_encode($shifts)); } /** - * Returns shifts to export. - * Users shifts or user_shifts filter based shifts if export=user_shifts is given as param. + * Returns users shifts to export. */ function load_ical_shifts() { - global $user, $ical_shifts; - - if (isset($_REQUEST['export']) && $_REQUEST['export'] == 'user_shifts') { - require_once realpath(__DIR__ . '/user_shifts.php'); - view_user_shifts(); - - return $ical_shifts; - } + global $user; return Shifts_by_user($user); } diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 2db0a3d3..67580eee 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -263,7 +263,9 @@ function Shift_create($shift) { */ function Shifts_by_user($user) { $result = sql_select(" - SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, `ShiftEntry`.*, `Shifts`.*, `Room`.* + SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, + `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, + `Shifts`.*, `Room`.* FROM `ShiftEntry` JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 344a3886..3ebd3bf9 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -284,7 +284,7 @@ function User($user_id) { function User_by_api_key($api_key) { $user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1"); if ($user === false) { - return false; + engelsystem_error("Unable to find user by api key."); } if (count($user) == 0) { return null; diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index 1313d92c..9a765634 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -10,9 +10,6 @@ function user_atom() { $key = $_REQUEST['key']; $user = User_by_api_key($key); - if ($user === false) { - engelsystem_error("Unable to find user."); - } if ($user == null) { engelsystem_error("Key invalid."); } diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php index 553b8860..34860b70 100644 --- a/includes/pages/user_ical.php +++ b/includes/pages/user_ical.php @@ -12,9 +12,6 @@ function user_ical() { $key = $_REQUEST['key']; $user = User_by_api_key($key); - if ($user === false) { - engelsystem_error("Unable to find user."); - } if ($user == null) { engelsystem_error("Key invalid."); } diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php index 163d6646..3e4cccc6 100644 --- a/includes/view/ShiftTypes_view.php +++ b/includes/view/ShiftTypes_view.php @@ -55,6 +55,7 @@ function ShiftType_view($shifttype, $angeltype) { button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'), button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete') ]), + heading(_("Description"), 2), $parsedown->parse($shifttype['description']) ]); } |