show freeload comments to supporters (user shift admin)

This commit is contained in:
msquare 2016-11-25 14:27:47 +01:00
parent 476d1daeb7
commit 34248bb20c
2 changed files with 3 additions and 2 deletions

View File

@ -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) { foreach ($shifts as &$shift) {
// TODO: Move queries to model // 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`"); $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`");

View File

@ -261,10 +261,11 @@ function Shift_create($shift) {
/** /**
* Return users shifts. * Return users shifts.
*/ */
function Shifts_by_user($user) { function Shifts_by_user($user, $include_freeload_comments = false) {
$result = sql_select(" $result = sql_select("
SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`, SELECT `ShiftTypes`.`id` as `shifttype_id`, `ShiftTypes`.`name`,
`ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
" . ($include_freeload_comments ? "`ShiftEntry`.`freeload_comment`, " : "") . "
`Shifts`.*, `Room`.* `Shifts`.*, `Room`.*
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)