fixes #266: add checkbox allowing the users email to be used by humans like event-team

This commit is contained in:
msquare 2016-11-11 15:24:51 +01:00
parent 82b9436c50
commit f5a5f234e4
9 changed files with 24 additions and 21 deletions

View File

@ -2,3 +2,5 @@ INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES (40, 'view_rooms', 'User
INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (NULL, '-2', '40'); INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (NULL, '-2', '40');
ALTER TABLE `UserAngelTypes` CHANGE `coordinator` `supporter` BOOLEAN; ALTER TABLE `UserAngelTypes` CHANGE `coordinator` `supporter` BOOLEAN;
ALTER TABLE `User` ADD COLUMN `email_by_human_allowed` BOOLEAN NOT NULL;

View File

@ -19,9 +19,6 @@ function event_config_edit_controller() {
$teardown_end_date = null; $teardown_end_date = null;
$event_config = EventConfig(); $event_config = EventConfig();
if ($event_config === false) {
engelsystem_error('Unable to load event config.');
}
if ($event_config != null) { if ($event_config != null) {
$event_name = $event_config['event_name']; $event_name = $event_config['event_name'];
$buildup_start_date = $event_config['buildup_start_date']; $buildup_start_date = $event_config['buildup_start_date'];

View File

@ -6,6 +6,7 @@
function EventConfig() { function EventConfig() {
$event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1"); $event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
if ($event_config === false) { if ($event_config === false) {
engelsystem_error("Unable to load event config.");
return false; return false;
} }
if (count($event_config) > 0) { if (count($event_config) > 0) {

View File

@ -29,6 +29,7 @@ function User_update($user) {
`Handy`='" . sql_escape($user['Handy']) . "', `Handy`='" . sql_escape($user['Handy']) . "',
`email`='" . sql_escape($user['email']) . "', `email`='" . sql_escape($user['email']) . "',
`email_shiftinfo`=" . sql_bool($user['email_shiftinfo']) . ", `email_shiftinfo`=" . sql_bool($user['email_shiftinfo']) . ",
`email_by_human_allowed`=" . sql_bool($user['email_by_human_allowed']) . ",
`jabber`='" . sql_escape($user['jabber']) . "', `jabber`='" . sql_escape($user['jabber']) . "',
`Size`='" . sql_escape($user['Size']) . "', `Size`='" . sql_escape($user['Size']) . "',
`Gekommen`='" . sql_escape($user['Gekommen']) . "', `Gekommen`='" . sql_escape($user['Gekommen']) . "',

View File

@ -67,7 +67,7 @@ function admin_free() {
'shift_state' => User_shift_state_render($usr), 'shift_state' => User_shift_state_render($usr),
'dect' => $usr['DECT'], 'dect' => $usr['DECT'],
'jabber' => $usr['jabber'], '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') : '' 'actions' => in_array('admin_user', $privileges) ? button(page_link_to('admin_user') . '&id=' . $usr['UID'], _("edit"), 'btn-xs') : ''
]; ];
} }

View File

@ -36,8 +36,9 @@ function admin_user() {
$html .= " <tr><td>Telefon</td><td>" . "<input type=\"text\" size=\"40\" name=\"eTelefon\" value=\"" . $user_source['Telefon'] . "\"></td></tr>\n"; $html .= " <tr><td>Telefon</td><td>" . "<input type=\"text\" size=\"40\" name=\"eTelefon\" value=\"" . $user_source['Telefon'] . "\"></td></tr>\n";
$html .= " <tr><td>Handy</td><td>" . "<input type=\"text\" size=\"40\" name=\"eHandy\" value=\"" . $user_source['Handy'] . "\"></td></tr>\n"; $html .= " <tr><td>Handy</td><td>" . "<input type=\"text\" size=\"40\" name=\"eHandy\" value=\"" . $user_source['Handy'] . "\"></td></tr>\n";
$html .= " <tr><td>DECT</td><td>" . "<input type=\"text\" size=\"4\" name=\"eDECT\" value=\"" . $user_source['DECT'] . "\"></td></tr>\n"; $html .= " <tr><td>DECT</td><td>" . "<input type=\"text\" size=\"4\" name=\"eDECT\" value=\"" . $user_source['DECT'] . "\"></td></tr>\n";
$html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n"; if ($user_source['email_by_human_allowed']) {
$html .= "<tr><td>" . form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $user_source['email_shiftinfo']) . "</td></tr>\n"; $html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n";
}
$html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n"; $html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n";
$html .= " <tr><td>Size</td><td>" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "</td></tr>\n"; $html .= " <tr><td>Size</td><td>" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "</td></tr>\n";
@ -173,7 +174,6 @@ function admin_user() {
`Alter` = '" . sql_escape($_POST["eAlter"]) . "', `Alter` = '" . sql_escape($_POST["eAlter"]) . "',
`DECT` = '" . sql_escape($_POST["eDECT"]) . "', `DECT` = '" . sql_escape($_POST["eDECT"]) . "',
`email` = '" . sql_escape($_POST["eemail"]) . "', `email` = '" . sql_escape($_POST["eemail"]) . "',
`email_shiftinfo` = " . sql_bool(isset($_REQUEST['email_shiftinfo'])) . ",
`jabber` = '" . sql_escape($_POST["ejabber"]) . "', `jabber` = '" . sql_escape($_POST["ejabber"]) . "',
`Size` = '" . sql_escape($_POST["eSize"]) . "', `Size` = '" . sql_escape($_POST["eSize"]) . "',
`Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "',

View File

@ -17,9 +17,6 @@ function guest_register() {
global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user; global $tshirt_sizes, $enable_tshirt_size, $default_theme, $user;
$event_config = EventConfig(); $event_config = EventConfig();
if ($event_config === false) {
engelsystem_error("Unable to load event config.");
}
$msg = ""; $msg = "";
$nick = ""; $nick = "";
@ -31,6 +28,7 @@ function guest_register() {
$mobile = ""; $mobile = "";
$mail = ""; $mail = "";
$email_shiftinfo = false; $email_shiftinfo = false;
$email_by_human_allowed = false;
$jabber = ""; $jabber = "";
$hometown = ""; $hometown = "";
$comment = ""; $comment = "";
@ -39,7 +37,7 @@ function guest_register() {
$selected_angel_types = []; $selected_angel_types = [];
$planned_arrival_date = null; $planned_arrival_date = null;
$angel_types_source = sql_select("SELECT * FROM `AngelTypes` ORDER BY `name`"); $angel_types_source = AngelTypes();
$angel_types = []; $angel_types = [];
foreach ($angel_types_source as $angel_type) { foreach ($angel_types_source as $angel_type) {
$angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : ""); $angel_types[$angel_type['id']] = $angel_type['name'] . ($angel_type['restricted'] ? " (restricted)" : "");
@ -77,6 +75,10 @@ function guest_register() {
$email_shiftinfo = true; $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) { 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)) {
@ -157,6 +159,7 @@ function guest_register() {
`Handy`='" . sql_escape($mobile) . "', `Handy`='" . sql_escape($mobile) . "',
`email`='" . sql_escape($mail) . "', `email`='" . sql_escape($mail) . "',
`email_shiftinfo`=" . sql_bool($email_shiftinfo) . ", `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ",
`email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ",
`jabber`='" . sql_escape($jabber) . "', `jabber`='" . sql_escape($jabber) . "',
`Size`='" . sql_escape($tshirt_size) . "', `Size`='" . sql_escape($tshirt_size) . "',
`Passwort`='" . sql_escape($password_hash) . "', `Passwort`='" . sql_escape($password_hash) . "',
@ -209,7 +212,8 @@ function guest_register() {
]), ]),
div('col-sm-8', [ div('col-sm-8', [
form_email('mail', _("E-Mail") . ' ' . entry_required(), $mail), 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', [ div('row', [
@ -318,9 +322,6 @@ function guest_login() {
} }
$event_config = EventConfig(); $event_config = EventConfig();
if ($event_config === false) {
engelsystem_error("Unable to load event config.");
}
return page([ return page([
div('col-md-12', [ div('col-md-12', [

View File

@ -18,6 +18,7 @@ function user_settings() {
$mobile = $user['Handy']; $mobile = $user['Handy'];
$mail = $user['email']; $mail = $user['email'];
$email_shiftinfo = $user['email_shiftinfo']; $email_shiftinfo = $user['email_shiftinfo'];
$email_by_human_allowed = $user['email_by_human_allowed'];
$jabber = $user['jabber']; $jabber = $user['jabber'];
$hometown = $user['Hometown']; $hometown = $user['Hometown'];
$tshirt_size = $user['Size']; $tshirt_size = $user['Size'];
@ -41,6 +42,7 @@ function user_settings() {
} }
$email_shiftinfo = isset($_REQUEST['email_shiftinfo']); $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) { if (isset($_REQUEST['jabber']) && strlen(strip_request_item('jabber')) > 0) {
$jabber = strip_request_item('jabber'); $jabber = strip_request_item('jabber');
@ -109,6 +111,7 @@ function user_settings() {
`Handy`='" . sql_escape($mobile) . "', `Handy`='" . sql_escape($mobile) . "',
`email`='" . sql_escape($mail) . "', `email`='" . sql_escape($mail) . "',
`email_shiftinfo`=" . sql_bool($email_shiftinfo) . ", `email_shiftinfo`=" . sql_bool($email_shiftinfo) . ",
`email_by_human_allowed`=" . sql_bool($email_by_human_allowed) . ",
`jabber`='" . sql_escape($jabber) . "', `jabber`='" . sql_escape($jabber) . "',
`Size`='" . sql_escape($tshirt_size) . "', `Size`='" . sql_escape($tshirt_size) . "',
`Hometown`='" . sql_escape($hometown) . "', `Hometown`='" . sql_escape($hometown) . "',
@ -185,7 +188,8 @@ function user_settings() {
form_text('dect', _("DECT"), $dect), form_text('dect', _("DECT"), $dect),
form_text('mobile', _("Mobile"), $mobile), form_text('mobile', _("Mobile"), $mobile),
form_text('mail', _("E-Mail") . ' ' . entry_required(), $mail), 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('jabber', _("Jabber"), $jabber),
form_text('hometown', _("Hometown"), $hometown), form_text('hometown', _("Hometown"), $hometown),
$enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '', $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '',

View File

@ -161,9 +161,6 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i
} }
$event_config = EventConfig(); $event_config = EventConfig();
if ($event_config === false) {
engelsystem_error("Unable to load event config.");
}
echo template_render('../templates/layout.html', [ echo template_render('../templates/layout.html', [
'theme' => isset($user) ? $user['color'] : $default_theme, 'theme' => isset($user) ? $user['color'] : $default_theme,