rename to

main
msquare 8 years ago
parent 81e5a6482c
commit f05f1a3cd4

@ -133,13 +133,13 @@ function angeltype_edit_controller() {
$coordinator_mode = ! in_array('admin_angel_types', $privileges); $coordinator_mode = ! in_array('admin_angel_types', $privileges);
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (! $coordinator_mode) { if (! $coordinator_mode) {
if (isset($_REQUEST['name'])) { if (isset($_REQUEST['name'])) {
list($valid, $name) = AngelType_validate_name($_REQUEST['name'], $angeltype); list($valid, $name) = AngelType_validate_name($_REQUEST['name'], $angeltype);
if (! $valid) { if (! $valid) {
$ok = false; $valid = false;
error(_("Please check the name. Maybe it already exists.")); error(_("Please check the name. Maybe it already exists."));
} }
} }
@ -152,7 +152,7 @@ function angeltype_edit_controller() {
$description = strip_request_item_nl('description'); $description = strip_request_item_nl('description');
} }
if ($ok) { if ($valid) {
if (isset($angeltype)) { if (isset($angeltype)) {
$result = AngelType_update($angeltype['id'], $name, $restricted, $description, $requires_driver_license); $result = AngelType_update($angeltype['id'], $name, $restricted, $description, $requires_driver_license);
if ($result === false) { if ($result === false) {

@ -32,7 +32,7 @@ function event_config_edit_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['event_name'])) { if (isset($_REQUEST['event_name'])) {
$event_name = strip_request_item('event_name'); $event_name = strip_request_item('event_name');
@ -50,41 +50,41 @@ function event_config_edit_controller() {
$result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true); $result = check_request_date('buildup_start_date', _("Please enter buildup start date."), true);
$buildup_start_date = $result->getValue(); $buildup_start_date = $result->getValue();
$ok &= $result->isOk(); $valid &= $result->isOk();
$result = check_request_date('event_start_date', _("Please enter event start date."), true); $result = check_request_date('event_start_date', _("Please enter event start date."), true);
$event_start_date = $result->getValue(); $event_start_date = $result->getValue();
$ok &= $result->isOk(); $valid &= $result->isOk();
$result = check_request_date('event_end_date', _("Please enter event end date."), true); $result = check_request_date('event_end_date', _("Please enter event end date."), true);
$event_end_date = $result->getValue(); $event_end_date = $result->getValue();
$ok &= $result->isOk(); $valid &= $result->isOk();
$result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true); $result = check_request_date('teardown_end_date', _("Please enter teardown end date."), true);
$teardown_end_date = $result->getValue(); $teardown_end_date = $result->getValue();
$ok &= $result->isOk(); $valid &= $result->isOk();
if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) { if ($buildup_start_date != null && $event_start_date != null && $buildup_start_date > $event_start_date) {
$ok = false; $valid = false;
error(_("The buildup start date has to be before the event start date.")); error(_("The buildup start date has to be before the event start date."));
} }
if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) { if ($event_start_date != null && $event_end_date != null && $event_start_date > $event_end_date) {
$ok = false; $valid = false;
error(_("The event start date has to be before the event end date.")); error(_("The event start date has to be before the event end date."));
} }
if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) { if ($event_end_date != null && $teardown_end_date != null && $event_end_date > $teardown_end_date) {
$ok = false; $valid = false;
error(_("The event end date has to be before the teardown end date.")); error(_("The event end date has to be before the teardown end date."));
} }
if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) { if ($buildup_start_date != null && $teardown_end_date != null && $buildup_start_date > $teardown_end_date) {
$ok = false; $valid = false;
error(_("The buildup start date has to be before the teardown end date.")); error(_("The buildup start date has to be before the teardown end date."));
} }
if ($ok) { if ($valid) {
$result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg); $result = EventConfig_update($event_name, $buildup_start_date, $event_start_date, $event_end_date, $teardown_end_date, $event_welcome_msg);
if ($result === false) { if ($result === false) {

@ -68,12 +68,12 @@ function shifttype_edit_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') { if (isset($_REQUEST['name']) && $_REQUEST['name'] != '') {
$name = strip_request_item('name'); $name = strip_request_item('name');
} else { } else {
$ok = false; $valid = false;
error(_('Please enter a name.')); error(_('Please enter a name.'));
} }
@ -87,7 +87,7 @@ function shifttype_edit_controller() {
$description = strip_request_item_nl('description'); $description = strip_request_item_nl('description');
} }
if ($ok) { if ($valid) {
if ($shifttype_id) { if ($shifttype_id) {
$result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description); $result = ShiftType_update($shifttype_id, $name, $angeltype_id, $description);
if ($result === false) { if ($result === false) {

@ -336,18 +336,18 @@ function user_angeltype_add_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) { if (isset($_REQUEST['user_id']) && in_array($_REQUEST['user_id'], array_map(function ($user) {
return $user['UID']; return $user['UID'];
}, $users_source))) { }, $users_source))) {
$user_id = $_REQUEST['user_id']; $user_id = $_REQUEST['user_id'];
} else { } else {
$ok = false; $valid = false;
error(_("Please select a user.")); error(_("Please select a user."));
} }
if ($ok) { if ($valid) {
foreach ($users_source as $user_source) { foreach ($users_source as $user_source) {
if ($user_source['UID'] == $user_id) { if ($user_source['UID'] == $user_id) {
$user_angeltype_id = UserAngelType_create($user_source, $angeltype); $user_angeltype_id = UserAngelType_create($user_source, $angeltype);

@ -109,7 +109,7 @@ function user_driver_license_edit_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
$wants_to_drive = isset($_REQUEST['wants_to_drive']); $wants_to_drive = isset($_REQUEST['wants_to_drive']);
$has_car = isset($_REQUEST['has_car']); $has_car = isset($_REQUEST['has_car']);
$has_license_car = isset($_REQUEST['has_license_car']); $has_license_car = isset($_REQUEST['has_license_car']);
@ -119,11 +119,11 @@ function user_driver_license_edit_controller() {
$has_license_forklift = isset($_REQUEST['has_license_forklift']); $has_license_forklift = isset($_REQUEST['has_license_forklift']);
if ($wants_to_drive && ! $has_license_car && ! $has_license_3_5t_transporter && ! $has_license_7_5t_truck && ! $has_license_12_5t_truck && ! $has_license_forklift) { if ($wants_to_drive && ! $has_license_car && ! $has_license_3_5t_transporter && ! $has_license_7_5t_truck && ! $has_license_12_5t_truck && ! $has_license_forklift) {
$ok = false; $valid = false;
error(_("Please select at least one driving license.")); error(_("Please select at least one driving license."));
} }
if ($ok) { if ($valid) {
if (! $wants_to_drive && $user_driver_license != null) { if (! $wants_to_drive && $user_driver_license != null) {
$result = UserDriverLicenses_delete($user_source['UID']); $result = UserDriverLicenses_delete($user_source['UID']);
if ($result === false) { if ($result === false) {

@ -52,14 +52,14 @@ function user_delete_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (! (isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'], $user['UID']))) { if (! (isset($_REQUEST['password']) && verify_password($_REQUEST['password'], $user['Passwort'], $user['UID']))) {
$ok = false; $valid = false;
error(_("Your password is incorrect. Please try it again.")); error(_("Your password is incorrect. Please try it again."));
} }
if ($ok) { if ($valid) {
$result = User_delete($user_source['UID']); $result = User_delete($user_source['UID']);
if ($result === false) { if ($result === false) {
engelsystem_error('Unable to delete user.'); engelsystem_error('Unable to delete user.');
@ -109,16 +109,16 @@ function user_edit_vouchers_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) { if (isset($_REQUEST['vouchers']) && test_request_int('vouchers') && trim($_REQUEST['vouchers']) >= 0) {
$vouchers = trim($_REQUEST['vouchers']); $vouchers = trim($_REQUEST['vouchers']);
} else { } else {
$ok = false; $valid = false;
error(_("Please enter a valid number of vouchers.")); error(_("Please enter a valid number of vouchers."));
} }
if ($ok) { if ($valid) {
$user_source['got_voucher'] = $vouchers; $user_source['got_voucher'] = $vouchers;
$result = User_update($user_source); $result = User_update($user_source);
@ -225,19 +225,19 @@ function user_password_recovery_controller() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) { if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
if ($_REQUEST['password'] != $_REQUEST['password2']) { if ($_REQUEST['password'] != $_REQUEST['password2']) {
$ok = false; $valid = false;
error(_("Your passwords don't match.")); error(_("Your passwords don't match."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("Your password is to short (please use at least 6 characters).")); error(_("Your password is to short (please use at least 6 characters)."));
} }
if ($ok) { if ($valid) {
$result = set_password($user_source['UID'], $_REQUEST['password']); $result = set_password($user_source['UID'], $_REQUEST['password']);
if ($result === false) { if ($result === false) {
engelsystem_error(_("Password could not be updated.")); engelsystem_error(_("Password could not be updated."));
@ -251,7 +251,7 @@ function user_password_recovery_controller() {
return User_password_set_view(); return User_password_set_view();
} else { } else {
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) { if (isset($_REQUEST['email']) && strlen(strip_request_item('email')) > 0) {
$email = strip_request_item('email'); $email = strip_request_item('email');
@ -261,19 +261,19 @@ function user_password_recovery_controller() {
engelsystem_error("Unable to load user."); engelsystem_error("Unable to load user.");
} }
if ($user_source == null) { if ($user_source == null) {
$ok = false; $valid = false;
error(_("E-mail address is not correct.")); error(_("E-mail address is not correct."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("E-mail address is not correct.")); error(_("E-mail address is not correct."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("Please enter your e-mail.")); error(_("Please enter your e-mail."));
} }
if ($ok) { if ($valid) {
$token = User_generate_password_recovery_token($user_source); $token = User_generate_password_recovery_token($user_source);
if ($token === false) { if ($token === false) {
engelsystem_error("Unable to generate password recovery token."); engelsystem_error("Unable to generate password recovery token.");

@ -21,7 +21,7 @@ function admin_active() {
$show_all_shifts = isset($_REQUEST['show_all_shifts']); $show_all_shifts = isset($_REQUEST['show_all_shifts']);
if (isset($_REQUEST['set_active'])) { if (isset($_REQUEST['set_active'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['count']) && preg_match("/^[0-9]+$/", $_REQUEST['count'])) { if (isset($_REQUEST['count']) && preg_match("/^[0-9]+$/", $_REQUEST['count'])) {
$count = strip_request_item('count'); $count = strip_request_item('count');
@ -30,11 +30,11 @@ function admin_active() {
redirect(page_link_to('admin_active')); redirect(page_link_to('admin_active'));
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter a number of angels to be marked as active."), true); $msg .= error(_("Please enter a number of angels to be marked as active."), true);
} }
if ($ok) { if ($valid) {
$limit = " LIMIT " . $count; $limit = " LIMIT " . $count;
} }
if (isset($_REQUEST['ack'])) { if (isset($_REQUEST['ack'])) {

@ -41,29 +41,29 @@ function admin_import() {
switch ($step) { switch ($step) {
case 'input': case 'input':
$ok = false; $valid = false;
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
$shifttype_id = $_REQUEST['shifttype_id']; $shifttype_id = $_REQUEST['shifttype_id'];
} else { } else {
$ok = false; $valid = false;
error(_('Please select a shift type.')); error(_('Please select a shift type.'));
} }
if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) { if (isset($_REQUEST['add_minutes_start']) && is_numeric(trim($_REQUEST['add_minutes_start']))) {
$add_minutes_start = trim($_REQUEST['add_minutes_start']); $add_minutes_start = trim($_REQUEST['add_minutes_start']);
} else { } else {
$ok = false; $valid = false;
error(_("Please enter an amount of minutes to add to a talk's begin.")); error(_("Please enter an amount of minutes to add to a talk's begin."));
} }
if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) { if (isset($_REQUEST['add_minutes_end']) && is_numeric(trim($_REQUEST['add_minutes_end']))) {
$add_minutes_end = trim($_REQUEST['add_minutes_end']); $add_minutes_end = trim($_REQUEST['add_minutes_end']);
} else { } else {
$ok = false; $valid = false;
error(_("Please enter an amount of minutes to add to a talk's end.")); error(_("Please enter an amount of minutes to add to a talk's end."));
} }
@ -71,21 +71,21 @@ function admin_import() {
if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) { if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) {
libxml_use_internal_errors(true); libxml_use_internal_errors(true);
if (simplexml_load_file($import_file) === false) { if (simplexml_load_file($import_file) === false) {
$ok = false; $valid = false;
error(_('No valid xml/xcal file provided.')); error(_('No valid xml/xcal file provided.'));
unlink($import_file); unlink($import_file);
} }
} else { } else {
$ok = false; $valid = false;
error(_('File upload went wrong.')); error(_('File upload went wrong.'));
} }
} else { } else {
$ok = false; $valid = false;
error(_('Please provide some data.')); error(_('Please provide some data.'));
} }
} }
if ($ok) { if ($valid) {
redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start); redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id . "&add_minutes_end=" . $add_minutes_end . "&add_minutes_start=" . $add_minutes_start);
} else { } else {
$html .= div('well well-sm text-center', [ $html .= div('well well-sm text-center', [

@ -54,16 +54,16 @@ function admin_rooms() {
if ($_REQUEST['show'] == 'edit') { if ($_REQUEST['show'] == 'edit') {
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) { if (isset($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) {
$name = strip_request_item('name'); $name = strip_request_item('name');
if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($id)) > 0) { if (isset($room) && sql_num_query("SELECT * FROM `Room` WHERE `Name`='" . sql_escape($name) . "' AND NOT `RID`=" . sql_escape($id)) > 0) {
$ok = false; $valid = false;
$msg .= error(_("This name is already in use."), true); $msg .= error(_("This name is already in use."), true);
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter a name."), true); $msg .= error(_("Please enter a name."), true);
} }
@ -82,19 +82,19 @@ function admin_rooms() {
if (isset($_REQUEST['number'])) { if (isset($_REQUEST['number'])) {
$number = strip_request_item('number'); $number = strip_request_item('number');
} else { } else {
$ok = false; $valid = false;
} }
foreach ($angeltypes as $angeltype_id => $angeltype) { foreach ($angeltypes as $angeltype_id => $angeltype) {
if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) { if (isset($_REQUEST['angeltype_count_' . $angeltype_id]) && preg_match("/^[0-9]{1,4}$/", $_REQUEST['angeltype_count_' . $angeltype_id])) {
$angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id]; $angeltypes_count[$angeltype_id] = $_REQUEST['angeltype_count_' . $angeltype_id];
} else { } else {
$ok = false; $valid = false;
$msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true); $msg .= error(sprintf(_("Please enter needed angels for type %s.", $angeltype)), true);
} }
} }
if ($ok) { if ($valid) {
if (isset($id)) { if (isset($id)) {
sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($id) . "' LIMIT 1"); sql_query("UPDATE `Room` SET `Name`='" . sql_escape($name) . "', `FromPentabarf`='" . sql_escape($from_pentabarf) . "', `show`='" . sql_escape($public) . "', `Number`='" . sql_escape($number) . "' WHERE `RID`='" . sql_escape($id) . "' LIMIT 1");
engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number); engelsystem_log("Room updated: " . $name . ", pentabarf import: " . $from_pentabarf . ", public: " . $public . ", number: " . $number);

@ -6,7 +6,7 @@ function admin_shifts_title() {
// Assistent zum Anlegen mehrerer neuer Schichten // Assistent zum Anlegen mehrerer neuer Schichten
function admin_shifts() { function admin_shifts() {
$ok = true; $valid = true;
$rid = 0; $rid = 0;
$start = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d") . " 00:00")->getTimestamp(); $start = DateTime::createFromFormat("Y-m-d H:i", date("Y-m-d") . " 00:00")->getTimestamp();
@ -49,13 +49,13 @@ function admin_shifts() {
engelsystem_error('Unable to load shift type.'); engelsystem_error('Unable to load shift type.');
} }
if ($shifttype == null) { if ($shifttype == null) {
$ok = false; $valid = false;
error(_('Please select a shift type.')); error(_('Please select a shift type.'));
} else { } else {
$shifttype_id = $_REQUEST['shifttype_id']; $shifttype_id = $_REQUEST['shifttype_id'];
} }
} else { } else {
$ok = false; $valid = false;
error(_('Please select a shift type.')); error(_('Please select a shift type.'));
} }
@ -66,7 +66,7 @@ function admin_shifts() {
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']; $rid = $_REQUEST['rid'];
} else { } else {
$ok = false; $valid = false;
$rid = $rooms[0]['RID']; $rid = $rooms[0]['RID'];
error(_('Please select a location.')); error(_('Please select a location.'));
} }
@ -74,19 +74,19 @@ function admin_shifts() {
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(); $start = $tmp->getTimestamp();
} else { } else {
$ok = false; $valid = false;
error(_('Please select a start time.')); error(_('Please select a start time.'));
} }
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(); $end = $tmp->getTimestamp();
} else { } else {
$ok = false; $valid = false;
error(_('Please select an end time.')); error(_('Please select an end time.'));
} }
if ($start >= $end) { if ($start >= $end) {
$ok = false; $valid = false;
error(_('The shifts end has to be after its start.')); error(_('The shifts end has to be after its start.'));
} }
@ -98,7 +98,7 @@ function admin_shifts() {
$mode = 'multi'; $mode = 'multi';
$length = trim($_REQUEST['length']); $length = trim($_REQUEST['length']);
} else { } else {
$ok = false; $valid = false;
error(_('Please enter a shift duration in minutes.')); error(_('Please enter a shift duration in minutes.'));
} }
} elseif ($_REQUEST['mode'] == 'variable') { } elseif ($_REQUEST['mode'] == 'variable') {
@ -106,12 +106,12 @@ function admin_shifts() {
$mode = 'variable'; $mode = 'variable';
$change_hours = array_map('trim', explode(",", $_REQUEST['change_hours'])); $change_hours = array_map('trim', explode(",", $_REQUEST['change_hours']));
} else { } else {
$ok = false; $valid = false;
error(_('Please split the shift-change hours by colons.')); error(_('Please split the shift-change hours by colons.'));
} }
} }
} else { } else {
$ok = false; $valid = false;
error(_('Please select a mode.')); error(_('Please select a mode.'));
} }
@ -124,30 +124,30 @@ function admin_shifts() {
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']]))) {
$needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]); $needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
} else { } else {
$ok = false; $valid = false;
error(sprintf(_('Please check the needed angels for team %s.'), $type['name'])); error(sprintf(_('Please check the needed angels for team %s.'), $type['name']));
} }
} }
if (array_sum($needed_angel_types) == 0) { if (array_sum($needed_angel_types) == 0) {
$ok = false; $valid = false;
error(_('There are 0 angels needed. Please enter the amounts of needed angels.')); error(_('There are 0 angels needed. Please enter the amounts of needed angels.'));
} }
} else { } else {
$ok = false; $valid = false;
error(_('Please select a mode for needed angels.')); error(_('Please select a mode for needed angels.'));
} }
} else { } else {
$ok = false; $valid = false;
error(_('Please select needed angels.')); error(_('Please select needed angels.'));
} }
// Beim Zurück-Knopf das Formular zeigen // Beim Zurück-Knopf das Formular zeigen
if (isset($_REQUEST['back'])) { if (isset($_REQUEST['back'])) {
$ok = false; $valid = false;
} }
// Alle Eingaben in Ordnung // Alle Eingaben in Ordnung
if ($ok) { if ($valid) {
if ($angelmode == 'location') { if ($angelmode == 'location') {
$needed_angel_types = []; $needed_angel_types = [];
$needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($rid) . "'"); $needed_angel_types_location = sql_select("SELECT * FROM `NeededAngelTypes` WHERE `room_id`='" . sql_escape($rid) . "'");

@ -49,27 +49,27 @@ function guest_register() {
} }
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) { if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 1) {
$nick = User_validate_Nick($_REQUEST['nick']); $nick = User_validate_Nick($_REQUEST['nick']);
if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) { if (sql_num_query("SELECT * FROM `User` WHERE `Nick`='" . sql_escape($nick) . "' LIMIT 1") > 0) {
$ok = false; $valid = false;
$msg .= error(sprintf(_("Your nick "%s" already exists."), $nick), true); $msg .= error(sprintf(_("Your nick "%s" already exists."), $nick), true);
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true); $msg .= error(sprintf(_("Your nick "%s" is too short (min. 2 characters)."), User_validate_Nick($_REQUEST['nick'])), true);
} }
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) { if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail'); $mail = strip_request_item('mail');
if (! check_email($mail)) { if (! check_email($mail)) {
$ok = false; $valid = false;
$msg .= error(_("E-mail address is not correct."), true); $msg .= error(_("E-mail address is not correct."), true);
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter your e-mail."), true); $msg .= error(_("Please enter your e-mail."), true);
} }
@ -80,7 +80,7 @@ function guest_register() {
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) { if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
$jabber = strip_request_item('jabber'); $jabber = strip_request_item('jabber');
if (! check_email($jabber)) { if (! check_email($jabber)) {
$ok = false; $valid = false;
$msg .= error(_("Please check your jabber account information."), true); $msg .= error(_("Please check your jabber account information."), true);
} }
} }
@ -89,25 +89,25 @@ function guest_register() {
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') { if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']]) && $_REQUEST['tshirt_size'] != '') {
$tshirt_size = $_REQUEST['tshirt_size']; $tshirt_size = $_REQUEST['tshirt_size'];
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please select your shirt size."), true); $msg .= error(_("Please select your shirt size."), true);
} }
} }
if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) { if (isset($_REQUEST['password']) && strlen($_REQUEST['password']) >= MIN_PASSWORD_LENGTH) {
if ($_REQUEST['password'] != $_REQUEST['password2']) { if ($_REQUEST['password'] != $_REQUEST['password2']) {
$ok = false; $valid = false;
$msg .= error(_("Your passwords don't match."), true); $msg .= error(_("Your passwords don't match."), true);
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true); $msg .= error(sprintf(_("Your password is too short (please use at least %s characters)."), MIN_PASSWORD_LENGTH), true);
} }
if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) { if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) {
$planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp(); $planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp();
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter your planned date of arrival."), true); $msg .= error(_("Please enter your planned date of arrival."), true);
} }
@ -144,7 +144,7 @@ function guest_register() {
$comment = strip_request_item_nl('comment'); $comment = strip_request_item_nl('comment');
} }
if ($ok) { if ($valid) {
sql_query(" sql_query("
INSERT INTO `User` SET INSERT INTO `User` SET
`color`='" . sql_escape($default_theme) . "', `color`='" . sql_escape($default_theme) . "',
@ -284,7 +284,7 @@ function guest_login() {
unset($_SESSION['uid']); unset($_SESSION['uid']);
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) { if (isset($_REQUEST['nick']) && strlen(User_validate_Nick($_REQUEST['nick'])) > 0) {
$nick = User_validate_Nick($_REQUEST['nick']); $nick = User_validate_Nick($_REQUEST['nick']);
@ -293,23 +293,23 @@ function guest_login() {
$login_user = $login_user[0]; $login_user = $login_user[0];
if (isset($_REQUEST['password'])) { if (isset($_REQUEST['password'])) {
if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) { if (! verify_password($_REQUEST['password'], $login_user['Passwort'], $login_user['UID'])) {
$ok = false; $valid = false;
error(_("Your password is incorrect. Please try it again.")); error(_("Your password is incorrect. Please try it again."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("Please enter a password.")); error(_("Please enter a password."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask an Dispatcher.")); error(_("No user was found with that Nickname. Please try again. If you are still having problems, ask an Dispatcher."));
} }
} else { } else {
$ok = false; $valid = false;
error(_("Please enter a nickname.")); error(_("Please enter a nickname."));
} }
if ($ok) { if ($valid) {
$_SESSION['uid'] = $login_user['UID']; $_SESSION['uid'] = $login_user['UID'];
$_SESSION['locale'] = $login_user['Sprache']; $_SESSION['locale'] = $login_user['Sprache'];

@ -51,12 +51,12 @@ function user_myshifts() {
$freeload_comment = $shift['freeload_comment']; $freeload_comment = $shift['freeload_comment'];
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = 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 == '') { if ($freeloaded && $freeload_comment == '') {
$ok = false; $valid = false;
error(_("Please enter a freeload comment!")); error(_("Please enter a freeload comment!"));
} }
} }
@ -64,7 +64,7 @@ function user_myshifts() {
$comment = strip_request_item_nl('comment'); $comment = strip_request_item_nl('comment');
$user_source = User($shift['UID']); $user_source = User($shift['UID']);
if ($ok) { if ($valid) {
$result = ShiftEntry_update([ $result = ShiftEntry_update([
'id' => $id, 'id' => $id,
'Comment' => $comment, 'Comment' => $comment,

@ -27,16 +27,16 @@ function user_settings() {
$planned_departure_date = $user['planned_departure_date']; $planned_departure_date = $user['planned_departure_date'];
if (isset($_REQUEST['submit'])) { if (isset($_REQUEST['submit'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) { if (isset($_REQUEST['mail']) && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail'); $mail = strip_request_item('mail');
if (! check_email($mail)) { if (! check_email($mail)) {
$ok = false; $valid = false;
$msg .= error(_("E-mail address is not correct."), true); $msg .= error(_("E-mail address is not correct."), true);
} }
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter your e-mail."), true); $msg .= error(_("Please enter your e-mail."), true);
} }
@ -45,7 +45,7 @@ function user_settings() {
if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) { if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
$jabber = strip_request_item('jabber'); $jabber = strip_request_item('jabber');
if (! check_email($jabber)) { if (! check_email($jabber)) {
$ok = false; $valid = false;
$msg .= error(_("Please check your jabber account information."), true); $msg .= error(_("Please check your jabber account information."), true);
} }
} }
@ -53,13 +53,13 @@ function user_settings() {
if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) { if (isset($_REQUEST['tshirt_size']) && isset($tshirt_sizes[$_REQUEST['tshirt_size']])) {
$tshirt_size = $_REQUEST['tshirt_size']; $tshirt_size = $_REQUEST['tshirt_size'];
} elseif ($enable_tshirt_size) { } elseif ($enable_tshirt_size) {
$ok = false; $valid = false;
} }
if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) { if (isset($_REQUEST['planned_arrival_date']) && DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))) {
$planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp(); $planned_arrival_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_arrival_date']))->getTimestamp();
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter your planned date of arrival."), true); $msg .= error(_("Please enter your planned date of arrival."), true);
} }
@ -67,7 +67,7 @@ function user_settings() {
if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))) { if (DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))) {
$planned_departure_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))->getTimestamp(); $planned_departure_date = DateTime::createFromFormat("Y-m-d", trim($_REQUEST['planned_departure_date']))->getTimestamp();
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter your planned date of departure."), true); $msg .= error(_("Please enter your planned date of departure."), true);
} }
} else { } else {
@ -97,7 +97,7 @@ function user_settings() {
$hometown = strip_request_item('hometown'); $hometown = strip_request_item('hometown');
} }
if ($ok) { if ($valid) {
sql_query(" sql_query("
UPDATE `User` SET UPDATE `User` SET
`Nick`='" . sql_escape($nick) . "', `Nick`='" . sql_escape($nick) . "',
@ -120,7 +120,7 @@ function user_settings() {
redirect(page_link_to('user_settings')); redirect(page_link_to('user_settings'));
} }
} elseif (isset($_REQUEST['submit_password'])) { } elseif (isset($_REQUEST['submit_password'])) {
$ok = true; $valid = true;
if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user['Passwort'], $user['UID'])) { if (! isset($_REQUEST['password']) || ! verify_password($_REQUEST['password'], $user['Passwort'], $user['UID'])) {
$msg .= error(_("-> not OK. Please try again."), true); $msg .= error(_("-> not OK. Please try again."), true);
@ -135,30 +135,30 @@ function user_settings() {
} }
redirect(page_link_to('user_settings')); redirect(page_link_to('user_settings'));
} elseif (isset($_REQUEST['submit_theme'])) { } elseif (isset($_REQUEST['submit_theme'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) { if (isset($_REQUEST['theme']) && isset($themes[$_REQUEST['theme']])) {
$selected_theme = $_REQUEST['theme']; $selected_theme = $_REQUEST['theme'];
} else { } else {
$ok = false; $valid = false;
} }
if ($ok) { if ($valid) {
sql_query("UPDATE `User` SET `color`='" . sql_escape($selected_theme) . "' WHERE `UID`='" . sql_escape($user['UID']) . "'"); sql_query("UPDATE `User` SET `color`='" . sql_escape($selected_theme) . "' WHERE `UID`='" . sql_escape($user['UID']) . "'");
success(_("Theme changed.")); success(_("Theme changed."));
redirect(page_link_to('user_settings')); redirect(page_link_to('user_settings'));
} }
} elseif (isset($_REQUEST['submit_language'])) { } elseif (isset($_REQUEST['submit_language'])) {
$ok = true; $valid = true;
if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) { if (isset($_REQUEST['language']) && isset($locales[$_REQUEST['language']])) {
$selected_language = $_REQUEST['language']; $selected_language = $_REQUEST['language'];
} else { } else {
$ok = false; $valid = false;
} }
if ($ok) { if ($valid) {
sql_query("UPDATE `User` SET `Sprache`='" . sql_escape($selected_language) . "' WHERE `UID`='" . sql_escape($user['UID']) . "'"); sql_query("UPDATE `User` SET `Sprache`='" . sql_escape($selected_language) . "' WHERE `UID`='" . sql_escape($user['UID']) . "'");
$_SESSION['locale'] = $selected_language; $_SESSION['locale'] = $selected_language;

@ -52,7 +52,7 @@ function user_shifts() {
} elseif (isset($_REQUEST['edit_shift']) && in_array('admin_shifts', $privileges)) { } elseif (isset($_REQUEST['edit_shift']) && in_array('admin_shifts', $privileges)) {
// Schicht bearbeiten // Schicht bearbeiten
$msg = ""; $msg = "";
$ok = true; $valid = true;
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']; $shift_id = $_REQUEST['edit_shift'];
@ -115,7 +115,7 @@ function user_shifts() {
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']; $rid = $_REQUEST['rid'];
} else { } else {
$ok = false; $valid = false;
$rid = $rooms[0]['RID']; $rid = $rooms[0]['RID'];
$msg .= error(_("Please select a room."), true); $msg .= error(_("Please select a room."), true);
} }
@ -123,26 +123,26 @@ function user_shifts() {
if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) {
$shifttype_id = $_REQUEST['shifttype_id']; $shifttype_id = $_REQUEST['shifttype_id'];
} else { } else {
$ok = false; $valid = false;
$msg .= error(_('Please select a shifttype.'), true); $msg .= error(_('Please select a shifttype.'), 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(); $start = $tmp->getTimestamp();
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter a valid starting time for the shifts."), true); $msg .= error(_("Please enter a valid starting time for the shifts."), 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(); $end = $tmp->getTimestamp();
} else { } else {
$ok = false; $valid = false;
$msg .= error(_("Please enter a valid ending time for the shifts."), true); $msg .= error(_("Please enter a valid ending time for the shifts."), true);
} }
if ($start >= $end) { if ($start >= $end) {
$ok = false; $valid = false;
$msg .= error(_("The ending time has to be after the starting time."), true); $msg .= error(_("The ending time has to be after the starting time."), true);
} }
@ -150,12 +150,12 @@ function user_shifts() {
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']]))) {
$needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]); $needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
} else { } else {
$ok = false; $valid = false;
$msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $type['name']), true); $msg .= error(sprintf(_("Please check your input for needed angels of type %s."), $type['name']), true);
} }
} }
if ($ok) { if ($valid) {
$shift['shifttype_id'] = $shifttype_id; $shift['shifttype_id'] = $shifttype_id;
$shift['title'] = $title; $shift['title'] = $title;
$shift['RID'] = $rid; $shift['RID'] = $rid;

@ -102,20 +102,20 @@ function check_email($email) {
class ValidationResult { class ValidationResult {
private $ok; private $valid;
private $value; private $value;
/** /**
* Constructor. * Constructor.
* *
* @param boolean $ok * @param boolean $valid
* Is the value valid? * Is the value valid?
* @param * $value * @param * $value
* The validated value * The validated value
*/ */
public function ValidationResult($ok, $value) { public function ValidationResult($valid, $value) {
$this->ok = $ok; $this->ok = $valid;
$this->value = $value; $this->value = $value;
} }

Loading…
Cancel
Save