summaryrefslogtreecommitdiff
path: root/includes/controller
diff options
context:
space:
mode:
authorjwacalex <aboehm@dompfaffenweg.de>2016-11-30 23:23:49 +0100
committerjwacalex <aboehm@dompfaffenweg.de>2016-11-30 23:23:49 +0100
commit45cda10479a16c237f917b69dc24ab3f31bffa89 (patch)
tree5aa98a6504d7558b56b7777f04b87a3b976bbedf /includes/controller
parent79b9f9448e4f3ad7abb8d795c1404b3221c95bf9 (diff)
parent53e12065c76af4e5a0a2690e92e6724eed9f2895 (diff)
merged master and issue
Diffstat (limited to 'includes/controller')
-rw-r--r--includes/controller/shifts_controller.php26
-rw-r--r--includes/controller/users_controller.php2
2 files changed, 9 insertions, 19 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index f273c097..1e04c5a8 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -1,4 +1,5 @@
<?php
+use Engelsystem\ShiftSignupState;
function shift_link($shift) {
return page_link_to('shifts') . '&action=view&shift_id=' . $shift['SID'];
@@ -200,13 +201,13 @@ function shift_controller() {
$angeltypes = AngelTypes();
$user_shifts = Shifts_by_user($user);
- $shift_signup_state = null;
+ $shift_signup_state = new ShiftSignupState(ShiftSignupState::OCCUPIED, 0);
foreach ($angeltypes as $angeltype) {
$angeltype_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, $user_shifts);
if ($shift_signup_state == null) {
$shift_signup_state = $angeltype_signup_state;
} else {
- $shift_signup_state = $shift_signup_state->combineWith($angeltype_signup_state);
+ $shift_signup_state->combineWith($angeltype_signup_state);
}
}
@@ -285,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.");
@@ -294,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.");
}
@@ -304,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/controller/users_controller.php b/includes/controller/users_controller.php
index 33abe764..26ca8d00 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -151,7 +151,7 @@ function user_controller() {
}
}
- $shifts = Shifts_by_user($user_source);
+ $shifts = Shifts_by_user($user_source, in_array("user_shifts_admin", $privileges));
foreach ($shifts as &$shift) {
// TODO: Move queries to model
$shift['needed_angeltypes'] = sql_select("SELECT DISTINCT `AngelTypes`.* FROM `ShiftEntry` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID`='" . sql_escape($shift['SID']) . "' ORDER BY `AngelTypes`.`name`");