$shift = sql_select("SELECT `Shifts`.`start` FROM `Shifts` INNER JOIN `ShiftEntry` USING (`SID`) WHERE `ShiftEntry`.`id`=" . sql_escape($id) . " AND `UID`=" . sql_escape($shifts_user['UID']) . " LIMIT 1");
if (count($shift) > 0) {
@ -72,13 +63,13 @@ function user_myshifts() {
foreach ($shifts as $shift) {
$shift_info = $shift['name'];
$needed_angel_types_source = 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`");
foreach($needed_angel_types_source as $needed_angel_type) {
foreach($needed_angel_types_source as $needed_angel_type) {
$users_source = sql_select("SELECT `User`.* FROM `ShiftEntry` JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` WHERE `ShiftEntry`.`SID`=" . sql_escape($shift['SID']) . " AND `ShiftEntry`.`TID`=" . sql_escape($needed_angel_type['id']));
$id == $user['UID'] ? sprintf(_('These are your shifts.<br/>Please try to appear <b>15 minutes</b> before your shift begins!<br/>You can remove yourself from a shift up to %d hours before it starts.'), $LETZTES_AUSTRAGEN) : '',
$id == $user['UID'] && count($shifts) == 0 ? error(sprintf(_("Go to the <ahref=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : '',
"<h2>Exports</h2>" . sprintf(_("Export of shown shifts. <ahref=\"%s\">iCal format</a> or <ahref=\"%s\">JSON format</a> available (please keep secret, otherwise <ahref=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $shifts_user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $shifts_user['api_key'], page_link_to('user_myshifts') . '&reset')
'<h2>' . _("Exports") . '</h2>' . sprintf(_("Export of shown shifts. <ahref=\"%s\">iCal format</a> or <ahref=\"%s\">JSON format</a> available (please keep secret, otherwise <ahref=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $shifts_user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $shifts_user['api_key'], page_link_to('user_myshifts') . '&reset')
if (isset($_REQUEST['edit_shift']) && test_request_int('edit_shift'))
if (isset($_REQUEST['edit_shift']) && test_request_int('edit_shift'))
$shift_id = $_REQUEST['edit_shift'];
else
redirect(page_link_to('user_shifts'));
/*
if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1") > 0) {
error("Du kannst nur Schichten bearbeiten, bei denen niemand eingetragen ist.");
redirect(page_link_to('user_shift'));
}
* if (sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1") > 0) { error("Du kannst nur Schichten bearbeiten, bei denen niemand eingetragen ist."); redirect(page_link_to('user_shift')); }
*/
$shift = sql_select("SELECT * FROM `Shifts` JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1");
@ -48,14 +44,14 @@ function user_shifts() {
// Locations laden
$rooms = sql_select("SELECT * FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
$room_array = array();
$room_array = array();
foreach ($rooms as $room)
$room_array[$room['RID']] = $room['Name'];
// Engeltypen laden
$types = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`");
$angel_types = array();
$needed_angel_types = array();
$needed_angel_types = array();
foreach ($types as $type) {
$angel_types[$type['id']] = $type;
$needed_angel_types[$type['id']] = 0;
@ -64,15 +60,15 @@ function user_shifts() {
// Benötigte Engeltypen vom Raum
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`room_id`=" . sql_escape($shift['RID']) . ") ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type) {
if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
}
// Benötigte Engeltypen von der Schicht
$needed_angel_types_source = sql_select("SELECT `AngelTypes`.*, `NeededAngelTypes`.`count` FROM `AngelTypes` LEFT JOIN `NeededAngelTypes` ON (`NeededAngelTypes`.`angel_type_id` = `AngelTypes`.`id` AND `NeededAngelTypes`.`shift_id`=" . sql_escape($shift_id) . ") ORDER BY `AngelTypes`.`name`");
foreach ($needed_angel_types_source as $type){
if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
foreach ($needed_angel_types_source as $type){
if($type['count'] != "")
$needed_angel_types[$type['id']] =$type['count'];
}
$name = $shift['name'];
@ -80,12 +76,12 @@ function user_shifts() {
$start = $shift['start'];
$end = $shift['end'];
if (isset($_REQUEST['submit'])) {
if (isset($_REQUEST['submit'])) {
// Name/Bezeichnung der Schicht, darf leer sein
$name = strip_request_item('name');
// Auswahl der sichtbaren Locations für die Schichten
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']]))
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']]))
$rid = $_REQUEST['rid'];
else {
$ok = false;
@ -93,14 +89,14 @@ function user_shifts() {
$msg .= error("Wähle bitte einen Raum aus.", true);
}
if (isset($_REQUEST['start']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start'])))
if (isset($_REQUEST['start']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['start'])))
$start = $tmp->getTimestamp();
else {
$ok = false;
$msg .= error("Bitte gib einen Startzeitpunkt für die Schichten an.", true);
}
if (isset($_REQUEST['end']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['end'])))
if (isset($_REQUEST['end']) && $tmp = DateTime::createFromFormat("Y-m-d H:i", trim($_REQUEST['end'])))
$end = $tmp->getTimestamp();
else {
$ok = false;
@ -113,7 +109,7 @@ function user_shifts() {
}
foreach ($needed_angel_types_source as $type) {
if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) {
if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) {
@ -287,48 +274,48 @@ function view_user_shifts() {
global $user, $privileges;
global $ical_shifts;
$ical_shifts = array();
$ical_shifts = array();
$days = sql_select_single_col("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`");
$rooms = sql_select("SELECT `RID` AS `id`, `Name` AS `name` FROM `Room` WHERE `show`='Y' ORDER BY `Name`");
if(in_array('user_shifts_admin', $privileges))
if(in_array('user_shifts_admin', $privileges))
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` ORDER BY `AngelTypes`.`name`");
else
$types = sql_select("SELECT `AngelTypes`.`id`, `AngelTypes`.`name`, (`AngelTypes`.`restricted`=0 OR (NOT `UserAngelTypes`.`confirm_user_id` IS NULL OR `UserAngelTypes`.`id` IS NULL)) as `enabled` FROM `AngelTypes` LEFT JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` AND `UserAngelTypes`.`user_id`=" . sql_escape($user['UID']) . ") ORDER BY `AngelTypes`.`name`");
if (empty($types))
$types = sql_select("SELECT `id`, `name` FROM `AngelTypes` WHERE `restricted` = 0");
$query .= " AND `angel_type_id` IN (" . implode(',', $_SESSION['user_shifts']['types']) . ") ";
$query .= " ORDER BY `AngelTypes`.`name`";
$angeltypes = sql_select($query);
@ -504,16 +484,16 @@ function view_user_shifts() {
if (count($angeltypes) > 0) {
foreach ($angeltypes as $angeltype) {
$entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`");
$my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0;
foreach ($angeltypes as &$angeltype) {
$entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`");
'task_notice' => '<sup>1</sup>' . _("The tasks shown here are influenced by the preferences you defined in your settings! <ahref=\"https://events.ccc.de/congress/2012/wiki/Volunteers#What_kind_of_volunteers_are_needed.3F\">Description of the jobs</a>."),
'new_style_checkbox' => '<label><inputtype="checkbox"name="new_style"value="1"'.($_SESSION['user_shifts']['new_style']?'checked':'').'> Use new style if possible</label>',
'new_style_checkbox' => '<label><inputtype="checkbox"name="new_style"value="1"'.($_SESSION['user_shifts']['new_style']?'checked':'').'> Use new style if possible</label>',
'shifts_table' => $shifts_table,
'ical_text' => sprintf(_("Export of shown shifts. <ahref=\"%s\">iCal format</a> or <ahref=\"%s\">JSON format</a> available (please keep secret, otherwise <ahref=\"%s\">reset the api key</a>)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset'),
'filter' => _("Filter"),
));
'filter' => _("Filter")
));
}
function make_user_shifts_export_link($page, $key) {
@ -734,17 +714,17 @@ function get_ids_from_array($array) {
}
function make_select($items, $selected, $name, $title = null) {