diff options
Diffstat (limited to 'includes/pages')
-rw-r--r-- | includes/pages/admin_import.php | 10 | ||||
-rw-r--r-- | includes/pages/admin_shifts.php | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index 8362391d..31b73992 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -1,4 +1,5 @@ <?php + function admin_import_title() { return _("Frab import"); } @@ -116,8 +117,11 @@ function admin_import() { sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1"); list($events_new, $events_updated, $events_deleted) = prepare_events($import_file); - foreach ($events_new as $event) - sql_query("INSERT INTO `Shifts` SET `name`='" . sql_escape($event['name']) . "', `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "'"); + foreach ($events_new as $event) { + $result = Shift_create($event); + if ($result === false) + engelsystem_error('Unable to create shift.'); + } foreach ($events_updated as $event) sql_query("UPDATE `Shifts` SET `name`='" . sql_escape($event['name']) . "', `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "' WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1"); @@ -165,7 +169,7 @@ function prepare_rooms($file) { return array( $rooms_new, - $rooms_deleted + $rooms_deleted ); } diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php index 473022eb..fd5b9b55 100644 --- a/includes/pages/admin_shifts.php +++ b/includes/pages/admin_shifts.php @@ -1,4 +1,5 @@ <?php + function admin_shifts_title() { return _("Create shifts"); } @@ -229,14 +230,17 @@ function admin_shifts() { )) )); } - } elseif (isset($_REQUEST['submit'])) { if (! is_array($_SESSION['admin_shifts_shifts']) || ! is_array($_SESSION['admin_shifts_types'])) redirect(page_link_to('admin_shifts')); foreach ($_SESSION['admin_shifts_shifts'] as $shift) { - sql_query("INSERT INTO `Shifts` SET `start`=" . sql_escape($shift['start']) . ", `end`=" . sql_escape($shift['end']) . ", `RID`=" . sql_escape($shift['RID']) . ", `name`='" . sql_escape($shift['name']) . "'"); - $shift_id = sql_id(); + $shift['URL'] = null; + $shift['PSID'] = null; + $shift_id = Shift_create($shift); + if ($shift_id === false) + engelsystem_error('Unable to create shift.'); + engelsystem_log("Shift created: " . $shift['name'] . " from " . date("Y-m-d H:i", $shift['start']) . " to " . date("Y-m-d H:i", $shift['end'])); $needed_angel_types_info = array(); foreach ($_SESSION['admin_shifts_types'] as $type_id => $count) { |