From 8261933bec7d6009e392f64aec7371dabb5149a6 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Sat, 6 Dec 2014 21:40:16 +0100 Subject: try to prevent hint duplication --- public/index.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'public/index.php') diff --git a/public/index.php b/public/index.php index f6dca310..03bc3869 100644 --- a/public/index.php +++ b/public/index.php @@ -90,32 +90,30 @@ if (! isset($_REQUEST['p'])) if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (in_array($_REQUEST['p'], $free_pages) || in_array($_REQUEST['p'], $privileges))) { $p = $_REQUEST['p']; + $title = $p; + $content = ""; + if (isset($user)) { - $hints = ""; - if (User_is_freeloader($user)) error(sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts)); - - // Hinweis für Engel, die noch nicht angekommen sind + + // Hinweis für Engel, die noch nicht angekommen sind if ($user['Gekommen'] == 0) error(_("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already.")); - + if ($enable_tshirt_size && $user['Size'] == "") error(_("You need to specify a tshirt size in your settings!")); - + if ($user['DECT'] == "") error(_("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\".")); - - // Erzengel Hinweis für unbeantwortete Fragen + + // Erzengel Hinweis für unbeantwortete Fragen if ($p != "admin_questions") admin_new_questions(); - + user_angeltypes_unconfirmed_hint(); } - $title = $p; - $content = ""; - if ($p == "api") { require_once realpath(__DIR__ . '/../includes/controller/api.php'); error("Api disabled temporily."); @@ -240,7 +238,7 @@ echo template_render('../templates/layout.html', array( 'title' => $title, 'atom_link' => ($p == 'news' || $p == 'user_meetings') ? '' : '', 'menu' => make_menu(), - 'content' => $content, + 'content' => msg() . $content, 'header_toolbar' => header_toolbar(), 'faq_url' => $faq_url, 'locale' => $_SESSION['locale'] -- cgit v1.2.3-70-g09d2 From d34fae3c407689a465486dccbb0f72ac9d4e1198 Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Sat, 6 Dec 2014 22:26:56 +0100 Subject: move hints to toolbar --- includes/controller/user_angeltypes_controller.php | 2 +- includes/pages/admin_questions.php | 2 +- includes/sys_menu.php | 31 ++++++++++++- includes/sys_template.php | 53 +++++++++++++--------- public/index.php | 21 --------- public/vendor/jquery-ui.min.js | 6 +++ templates/layout.html | 1 + 7 files changed, 70 insertions(+), 46 deletions(-) create mode 100644 public/vendor/jquery-ui.min.js (limited to 'public/index.php') diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index 049d6211..66abc589 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -16,7 +16,7 @@ function user_angeltypes_unconfirmed_hint() { foreach ($unconfirmed_user_angeltypes as $user_angeltype) $unconfirmed_links[] = '' . $user_angeltype['name'] . ''; - return error(sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", count($unconfirmed_user_angeltypes)), count($unconfirmed_user_angeltypes)) . " " . _('Angel types which need approvals:') . ' ' . join(', ', $unconfirmed_links)); + return info(sprintf(ngettext("There is %d unconfirmed angeltype.", "There are %d unconfirmed angeltypes.", count($unconfirmed_user_angeltypes)), count($unconfirmed_user_angeltypes)) . " " . _('Angel types which need approvals:') . ' ' . join(', ', $unconfirmed_links), true); } /** diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index 1b4b9970..e15c3fe4 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -10,7 +10,7 @@ function admin_new_questions() { $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL"); if ($new_messages > 0) - info('Es gibt unbeantwortete Fragen!'); + return info('' . _('There are unanswered questions!') . '', true); } return ""; diff --git a/includes/sys_menu.php b/includes/sys_menu.php index f7a5ba3b..2a6da701 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -14,7 +14,7 @@ function page_link_to_absolute($page) { * Renders the header toolbar containing search, login/logout, user and settings links. */ function header_toolbar() { - global $p, $privileges, $user; + global $p, $privileges, $user, $enable_tshirt_size; $toolbar_items = array(); @@ -30,6 +30,35 @@ function header_toolbar() { if(isset($user) && in_array('user_messages', $privileges)) $toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages()); + $hints = []; + if (isset($user)) { + if (User_is_freeloader($user)) + $hints[] = error(sprintf(_("You freeloaded at least %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $max_freeloadable_shifts), true); + + // Hinweis für Engel, die noch nicht angekommen sind + if ($user['Gekommen'] == 0) + $hints[] = error(_("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already."), true); + + if ($enable_tshirt_size && $user['Size'] == "") + $hints[] = error(_("You need to specify a tshirt size in your settings!"), true); + + if ($user['DECT'] == "") + $hints[] = error(_("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\"."), true); + + // Erzengel Hinweis für unbeantwortete Fragen + if ($p != "admin_questions") { + $new_questions = admin_new_questions(); + if($new_questions != "") + $hints[] = $new_questions; + } + + $unconfirmed_hint = user_angeltypes_unconfirmed_hint(); + if($unconfirmed_hint != '') + $hints[] = $unconfirmed_hint; + } + if(count($hints) > 0) + $toolbar_items[] = toolbar_popover('warning-sign text-danger', '', $hints, 'bg-danger'); + $user_submenu = make_langselect(); $user_submenu[] = toolbar_item_divider(); if (in_array('user_myshifts', $privileges)) diff --git a/includes/sys_template.php b/includes/sys_template.php index 0e396a40..b7617bd6 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -5,13 +5,13 @@ */ $themes = array( "0" => "Engelsystem light", - "1" => "Engelsystem dark" + "1" => "Engelsystem dark" ); /** * Render glyphicon * - * @param string $glyph_name + * @param string $glyph_name */ function glyph($glyph_name) { return ' '; @@ -20,7 +20,7 @@ function glyph($glyph_name) { /** * Renders a tick or a cross by given boolean * - * @param boolean $boolean + * @param boolean $boolean */ function glyph_bool($boolean) { return '' . glyph($boolean ? 'ok' : 'remove') . ''; @@ -34,7 +34,7 @@ function div($class, $content = array(), $id = "") { /** * Render a toolbar. * - * @param array $items + * @param array $items * @return string */ function toolbar($items = array(), $right = false) { @@ -44,10 +44,10 @@ function toolbar($items = array(), $right = false) { /** * Render a link for a toolbar. * - * @param string $href - * @param string $glyphicon - * @param string $label - * @param bool $selected + * @param string $href + * @param string $glyphicon + * @param string $label + * @param bool $selected * @return string */ function toolbar_item_link($href, $glyphicon, $label, $selected = false) { @@ -58,12 +58,21 @@ function toolbar_item_divider() { return '
  • '; } -function toolbar_dropdown($glyphicon, $label, $submenu) { - return ''; } +function toolbar_popover($glyphicon, $label, $content, $class = '') { + $id = md5(microtime() . $glyphicon . $label); + return ''; +} + function form_hidden($name, $value) { return ''; } @@ -111,9 +120,9 @@ function form_checkboxes($name, $label, $items, $selected) { $html = form_element($label, ''); foreach ($items as $key => $item) $html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false); - + return $html; - + $html = "