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");
sql_query("UPDATE `ShiftEntry` SET `Comment`='".sql_escape($comment)."' WHERE `id`=".sql_escape($id)." LIMIT 1");
engelsystem_log("Updated ".$user_source['Nick']."'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']));