if(isset($_REQUEST['id'])&&in_array("user_shifts_admin",$privileges)&&preg_match("/^[0-9]{1,}$/",$_REQUEST['id'])&&sql_num_query("SELECT * FROM `User` WHERE `UID`=".sql_escape($_REQUEST['id']))>0){
$shift=sql_select("SELECT `ShiftEntry`.`Comment`, `ShiftEntry`.`UID`, `Shifts`.*, `Room`.`Name`, `AngelTypes`.`name` as `angel_type` FROM `ShiftEntry` JOIN `AngelTypes` ON (`ShiftEntry`.`TID` = `AngelTypes`.`id`) JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `ShiftEntry`.`id`=".sql_escape($id)." AND `UID`=".sql_escape($shifts_user['UID'])." LIMIT 1");
engelsystem_log("Updated ".User_Nick_render($user_source)."'s shift ".$shift['name']." from ".date("y-m-d H:i",$shift['start'])." to ".date("y-m-d H:i",$shift['end'])." with comment ".$comment);
$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");
$shifts=sql_select("SELECT * FROM `ShiftEntry` JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) WHERE `UID`=".sql_escape($shifts_user['UID'])." ORDER BY `start`");
$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`");
$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']?info(sprintf("You are viewing %s's shifts.",$shifts_user['Nick']),true):'',
$id==$user['UID']&&count($shifts)==0?error(sprintf(_("Go to the <a href=\"%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. <a href=\"%s\">iCal format</a> or <a href=\"%s\">JSON format</a> available (please keep secret, otherwise <a href=\"%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')