fixed settings validation
This commit is contained in:
parent
d3e942f742
commit
16ed2ae683
|
@ -175,6 +175,22 @@ function User_validate_mail($mail) {
|
|||
return new ValidationResult(check_email($mail), $mail);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate user jabber address
|
||||
*
|
||||
* @param string $jabber
|
||||
* Jabber-ID to validate
|
||||
* @return ValidationResult
|
||||
*/
|
||||
function User_validate_jabber($jabber) {
|
||||
$jabber = strip_item($jabber);
|
||||
if ($jabber == '') {
|
||||
// Empty is ok
|
||||
return new ValidationResult(true, '');
|
||||
}
|
||||
return new ValidationResult(check_email($jabber), $jabber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the planned arrival date
|
||||
*
|
||||
|
|
|
@ -29,7 +29,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
|
|||
$user_source['email_by_human_allowed'] = isset($_REQUEST['email_by_human_allowed']);
|
||||
|
||||
if (isset($_REQUEST['jabber'])) {
|
||||
$result = User_validate_mail($_REQUEST['jabber']);
|
||||
$result = User_validate_jabber($_REQUEST['jabber']);
|
||||
$user_source['jabber'] = $result->getValue();
|
||||
if (! $result->isValid()) {
|
||||
$valid = false;
|
||||
|
@ -77,6 +77,8 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes) {
|
|||
success(_("Settings saved."));
|
||||
redirect(page_link_to('user_settings'));
|
||||
}
|
||||
|
||||
return $user_source;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,6 +125,8 @@ function user_settings_theme($user_source, $themes) {
|
|||
success(_("Theme changed."));
|
||||
redirect(page_link_to('user_settings'));
|
||||
}
|
||||
|
||||
return $user_source;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +153,8 @@ function user_settings_locale($user_source, $locales) {
|
|||
success("Language changed.");
|
||||
redirect(page_link_to('user_settings'));
|
||||
}
|
||||
|
||||
return $user_source;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,13 +179,13 @@ function user_settings() {
|
|||
$user_source = $user;
|
||||
|
||||
if (isset($_REQUEST['submit'])) {
|
||||
user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
|
||||
$user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
|
||||
} elseif (isset($_REQUEST['submit_password'])) {
|
||||
user_settings_password($user_source);
|
||||
} elseif (isset($_REQUEST['submit_theme'])) {
|
||||
user_settings_theme($user_source, $themes);
|
||||
$user_source = user_settings_theme($user_source, $themes);
|
||||
} elseif (isset($_REQUEST['submit_language'])) {
|
||||
user_settings_locale($user_source, $locales);
|
||||
$user_source = user_settings_locale($user_source, $locales);
|
||||
}
|
||||
|
||||
return User_settings_view($user_source, $locales, $themes, $buildup_start_date, $teardown_end_date, $enable_tshirt_size, $tshirt_sizes);
|
||||
|
|
|
@ -12,29 +12,9 @@ function page_link_to_absolute($page) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Renders the header toolbar containing search, login/logout, user and settings links.
|
||||
* Render the user hints
|
||||
*/
|
||||
function header_toolbar() {
|
||||
global $page, $privileges, $user, $enable_tshirt_size, $max_freeloadable_shifts;
|
||||
|
||||
$toolbar_items = [];
|
||||
|
||||
if (isset($user)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
|
||||
}
|
||||
|
||||
if (! isset($user) && in_array('register', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
|
||||
}
|
||||
|
||||
if (in_array('login', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
|
||||
}
|
||||
|
||||
if (isset($user) && in_array('user_messages', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
|
||||
}
|
||||
|
||||
function header_render_hints($user, $page, $enable_tshirt_size) {
|
||||
$hints = [];
|
||||
if (isset($user)) {
|
||||
$hint_class = 'info';
|
||||
|
@ -87,8 +67,36 @@ function header_toolbar() {
|
|||
}
|
||||
}
|
||||
if (count($hints) > 0) {
|
||||
$toolbar_items[] = toolbar_popover($glyphicon . ' text-' . $hint_class, '', $hints, 'bg-' . $hint_class);
|
||||
return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $hints, 'bg-' . $hint_class);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the header toolbar containing search, login/logout, user and settings links.
|
||||
*/
|
||||
function header_toolbar() {
|
||||
global $page, $privileges, $user, $enable_tshirt_size, $max_freeloadable_shifts;
|
||||
|
||||
$toolbar_items = [];
|
||||
|
||||
if (isset($user)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('shifts') . '&action=next', 'time', User_shift_state_render($user));
|
||||
}
|
||||
|
||||
if (! isset($user) && in_array('register', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
|
||||
}
|
||||
|
||||
if (in_array('login', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
|
||||
}
|
||||
|
||||
if (isset($user) && in_array('user_messages', $privileges)) {
|
||||
$toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
|
||||
}
|
||||
|
||||
$toolbar_items[] = header_render_hints($user, $page, $enable_tshirt_size);
|
||||
|
||||
$user_submenu = make_langselect();
|
||||
$user_submenu[] = toolbar_item_divider();
|
||||
|
|
Loading…
Reference in New Issue