fix room creation

This commit is contained in:
Philip Häusler 2015-12-29 17:57:16 +01:00
parent 522546795b
commit b479cdaef8
3 changed files with 24 additions and 15 deletions

View File

@ -22,8 +22,8 @@ function Room_create($name, $from_frab, $public) {
$result = sql_query(" $result = sql_query("
INSERT INTO `Room` SET INSERT INTO `Room` SET
`Name`='" . sql_escape($name) . "', `Name`='" . sql_escape($name) . "',
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : 'N') . "', `FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
`show`='" . sql_escape($public ? 'Y' : 'N') . "', `show`='" . sql_escape($public ? 'Y' : '') . "',
`Number`=0"); `Number`=0");
if ($result === false) if ($result === false)
return false; return false;

View File

@ -48,17 +48,24 @@ function user_myshifts() {
AND `UID`='" . sql_escape($shifts_user['UID']) . "' LIMIT 1"); AND `UID`='" . sql_escape($shifts_user['UID']) . "' LIMIT 1");
if (count($shift) > 0) { if (count($shift) > 0) {
$shift = $shift[0]; $shift = $shift[0];
if (isset($_REQUEST['submit'])) {
$freeloaded = $shift['freeloaded']; $freeloaded = $shift['freeloaded'];
$freeload_comment = $shift['freeload_comment']; $freeload_comment = $shift['freeload_comment'];
if (isset($_REQUEST['submit'])) {
$ok = true;
if (in_array("user_shifts_admin", $privileges)) { if (in_array("user_shifts_admin", $privileges)) {
$freeloaded = isset($_REQUEST['freeloaded']); $freeloaded = isset($_REQUEST['freeloaded']);
$freeload_comment = strip_request_item_nl('freeload_comment'); $freeload_comment = strip_request_item_nl('freeload_comment');
if ($freeloaded && $freeload_comment == '') {
$ok = false;
error(_("Please enter a freeload comment!"));
}
} }
$comment = strip_request_item_nl('comment'); $comment = strip_request_item_nl('comment');
$user_source = User($shift['UID']); $user_source = User($shift['UID']);
if ($ok) {
$result = ShiftEntry_update(array( $result = ShiftEntry_update(array(
'id' => $id, 'id' => $id,
'Comment' => $comment, 'Comment' => $comment,
@ -66,12 +73,13 @@ function user_myshifts() {
'freeload_comment' => $freeload_comment 'freeload_comment' => $freeload_comment
)); ));
if ($result === false) if ($result === false)
engelsystem_error('Unable to update shift entr.'); engelsystem_error('Unable to update shift entry.');
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 . ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO")); 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 . ". Freeloaded: " . ($freeloaded ? "YES Comment: " . $freeload_comment : "NO"));
success(_("Shift saved.")); success(_("Shift saved."));
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']); redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);
} }
}
return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges)); return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges));
} else } else

View File

@ -21,6 +21,7 @@ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment,
$freeload_form = array(); $freeload_form = array();
} }
return page_with_title(_("Edit shift entry"), array( return page_with_title(_("Edit shift entry"), array(
msg(),
form(array( form(array(
form_info(_("Angel:"), $angel), form_info(_("Angel:"), $angel),
form_info(_("Date, Duration:"), $date), form_info(_("Date, Duration:"), $date),