diff --git a/db/update.sql b/db/update.sql index 4de4a4e4..93f29e89 100644 --- a/db/update.sql +++ b/db/update.sql @@ -1,4 +1,6 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (40, 'view_rooms', 'User can view rooms'); INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (NULL, '-2', '40'); -ALTER TABLE `UserAngelTypes` CHANGE `coordinator` `supporter` BOOLEAN; \ No newline at end of file +ALTER TABLE `UserAngelTypes` CHANGE `coordinator` `supporter` BOOLEAN; + +ALTER TABLE `User` ADD COLUMN `email_by_human_allowed` BOOLEAN NOT NULL; \ No newline at end of file diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php index a9709d38..4f07fe4c 100644 --- a/includes/controller/event_config_controller.php +++ b/includes/controller/event_config_controller.php @@ -19,9 +19,6 @@ function event_config_edit_controller() { $teardown_end_date = null; $event_config = EventConfig(); - if ($event_config === false) { - engelsystem_error('Unable to load event config.'); - } if ($event_config != null) { $event_name = $event_config['event_name']; $buildup_start_date = $event_config['buildup_start_date']; diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php index ac8d5e72..de5073d0 100644 --- a/includes/model/EventConfig_model.php +++ b/includes/model/EventConfig_model.php @@ -6,6 +6,7 @@ function EventConfig() { $event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1"); if ($event_config === false) { + engelsystem_error("Unable to load event config."); return false; } if (count($event_config) > 0) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 831ebb56..4d7bbb65 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -29,6 +29,7 @@ function User_update($user) { `Handy`='" . sql_escape($user['Handy']) . "', `email`='" . sql_escape($user['email']) . "', `email_shiftinfo`=" . sql_bool($user['email_shiftinfo']) . ", + `email_by_human_allowed`=" . sql_bool($user['email_by_human_allowed']) . ", `jabber`='" . sql_escape($user['jabber']) . "', `Size`='" . sql_escape($user['Size']) . "', `Gekommen`='" . sql_escape($user['Gekommen']) . "', diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index d3b5b01b..427de61a 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -67,7 +67,7 @@ function admin_free() { 'shift_state' => User_shift_state_render($usr), 'dect' => $usr['DECT'], 'jabber' => $usr['jabber'], - 'email' => $usr['email'], + 'email' => $usr['email_by_human_allowed'] ? $usr['email'] : glyph('eye-close'), 'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : '' ]; } diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index ef4eb2de..9b1bc0df 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -36,8 +36,9 @@ function admin_user() { $html .= " Telefon" . "\n"; $html .= " Handy" . "\n"; $html .= " DECT" . "\n"; - $html .= " email" . "\n"; - $html .= "" . form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $user_source['email_shiftinfo']) . "\n"; + if ($user_source['email_by_human_allowed']) { + $html .= " email" . "\n"; + } $html .= " jabber" . "\n"; $html .= " Size" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "\n"; @@ -173,7 +174,6 @@ function admin_user() { `Alter` = '" . sql_escape($_POST["eAlter"]) . "', `DECT` = '" . sql_escape($_POST["eDECT"]) . "', `email` = '" . sql_escape($_POST["eemail"]) . "', - `email_shiftinfo` = " . sql_bool(isset($_REQUEST['email_shiftinfo'])) . ", `jabber` = '" . sql_escape($_POST["ejabber"]) . "', `Size` = '" . sql_escape($_POST["eSize"]) . "', `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index 7420e7fb..b30e3d15 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -17,9 +17,6 @@ function guest_register() { global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user; $event_config = EventConfig(); - if ($event_config === false) { - engelsystem_error("Unable to load event config."); - } $msg = ""; $nick = ""; @@ -31,6 +28,7 @@ function guest_register() { $mobile = ""; $mail = ""; $email_shiftinfo = false; + $email_by_human_allowed = false; $jabber = ""; $hometown = ""; $comment = ""; @@ -39,7 +37,7 @@ function guest_register() { $selected_angel_types = []; $planned_arrival_date = null; - $angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); + $angel_types_source = AngelTypes(); $angel_types = []; foreach ($angel_types_source as $angel_type) { $angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : ""); @@ -77,6 +75,10 @@ function guest_register() { $email_shiftinfo = true; } + if (isset($_REQUEST['email_by_human_allowed'])) { + $email_by_human_allowed = true; + } + if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) { $jabber = strip_request_item('jabber'); if (! check_email($jabber)) { @@ -157,6 +159,7 @@ function guest_register() { `Handy`='" . sql_escape($mobile) . "', `email`='" . sql_escape($mail) . "', `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ", + `email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ", `jabber`='" . sql_escape($jabber) . "', `Size`='" . sql_escape($tshirt_size) . "', `Passwort`='" . sql_escape($password_hash) . "', @@ -209,7 +212,8 @@ function guest_register() { ]), div('col-sm-8', [ form_email('mail', _("E-Mail") . ' ' . entry_required(), $mail), - form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $email_shiftinfo) + form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $email_shiftinfo), + form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed) ]) ]), div('row', [ @@ -318,9 +322,6 @@ function guest_login() { } $event_config = EventConfig(); - if ($event_config === false) { - engelsystem_error("Unable to load event config."); - } return page([ div('col-md-12', [ diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 22ead68b..b92f7bd3 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -18,6 +18,7 @@ function user_settings() { $mobile = $user['Handy']; $mail = $user['email']; $email_shiftinfo = $user['email_shiftinfo']; + $email_by_human_allowed = $user['email_by_human_allowed']; $jabber = $user['jabber']; $hometown = $user['Hometown']; $tshirt_size = $user['Size']; @@ -39,8 +40,9 @@ function user_settings() { $valid = false; $msg .= error(_("Please enter your e-mail."), true); } - + $email_shiftinfo = isset($_REQUEST['email_shiftinfo']); + $email_by_human_allowed = isset($_REQUEST['email_by_human_allowed']); if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) { $jabber = strip_request_item('jabber'); @@ -109,6 +111,7 @@ function user_settings() { `Handy`='" . sql_escape($mobile) . "', `email`='" . sql_escape($mail) . "', `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ", + `email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ", `jabber`='" . sql_escape($jabber) . "', `Size`='" . sql_escape($tshirt_size) . "', `Hometown`='" . sql_escape($hometown) . "', @@ -185,7 +188,8 @@ function user_settings() { form_text('dect', _("DECT"), $dect), form_text('mobile', _("Mobile"), $mobile), form_text('mail', _("E-Mail") . ' ' . entry_required(), $mail), - form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $email_shiftinfo), + form_checkbox('email_shiftinfo', _("The engelsystem is allowed to send me an email (e.g. when my shifts change)"), $email_shiftinfo), + form_checkbox('email_by_human_allowed', _("Humans are allowed to send me an email (e.g. for ticket vouchers)"), $email_by_human_allowed), form_text('jabber', _("Jabber"), $jabber), form_text('hometown', _("Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '', diff --git a/public/index.php b/public/index.php index e1af1000..7bf9b169 100644 --- a/public/index.php +++ b/public/index.php @@ -161,9 +161,6 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i } $event_config = EventConfig(); -if ($event_config === false) { - engelsystem_error("Unable to load event config."); -} echo template_render('../templates/layout.html', [ 'theme' => isset($user) ? $user['color'] : $default_theme,