summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-11-15 16:28:20 +0100
committermsquare <msquare@notrademark.de>2016-11-15 16:28:20 +0100
commitec6016cd38fc5ce6455cace6ffbc703f78f31096 (patch)
tree961d5d5e90d25c807b77facba897ef6628298d50 /includes/view
parent19d5d68d82232d1047787737795a21bd79f9be95 (diff)
reduce complexity of menu and hints
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/UserHintsRenderer.php57
-rw-r--r--includes/view/User_view.php51
2 files changed, 108 insertions, 0 deletions
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
new file mode 100644
index 00000000..54f9c149
--- /dev/null
+++ b/includes/view/UserHintsRenderer.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Engelsystem;
+
+class UserHintsRenderer {
+
+ private $hints = [];
+
+ private $important = false;
+
+ /**
+ * Render the added hints to a popover for the toolbar.
+ */
+ public function render() {
+ if (count($this->hints) > 0) {
+ $hint_class = $this->important ? 'danger' : 'info';
+ $glyphicon = $this->important ? 'warning-sign' : 'info-sign';
+
+ return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
+ }
+
+ return '';
+ }
+
+ /**
+ * Add a hint to the list, if its not null and a not empty string.
+ *
+ * @param string $hint
+ * The hint
+ * @param boolean $important
+ * Is the hint important?
+ */
+ public function addHint($hint, $important = false) {
+ if ($hint != null && $hint != '') {
+ $this->hints[] = $hint;
+ if ($important) {
+ $this->important = true;
+ }
+ }
+ }
+
+ /**
+ * Get all hints.
+ */
+ public function getHints() {
+ return $this->hints;
+ }
+
+ /**
+ * Are there important hints? This leads to a more intensive icon.
+ */
+ public function isImportant() {
+ return $this->important;
+ }
+}
+
+?> \ No newline at end of file
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 7d677f33..5349711a 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -415,4 +415,55 @@ function User_Nick_render($user_source) {
return '<a class="' . ($user_source['Gekommen'] ? '' : 'text-muted') . '" href="' . page_link_to('users') . '&amp;action=view&amp;user_id=' . $user_source['UID'] . '"><span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . '</a>';
}
+function render_user_departure_date_hint() {
+ global $user;
+
+ if (! isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) {
+ return info(_("Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities."), true);
+ }
+
+ return null;
+}
+
+function render_user_freeloader_hint() {
+ global $user;
+
+ if (User_is_freeloader($user)) {
+ return 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);
+ }
+
+ return null;
+}
+
+// Hinweis für Engel, die noch nicht angekommen sind
+function render_user_arrived_hint() {
+ global $user;
+
+ if ($user['Gekommen'] == 0) {
+ return 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);
+ }
+
+ return null;
+}
+
+function render_user_tshirt_hint() {
+ global $enable_tshirt_size, $user;
+
+ if ($enable_tshirt_size && $user['Size'] == "") {
+ return error(_("You need to specify a tshirt size in your settings!"), true);
+ }
+
+ return null;
+}
+
+function render_user_dect_hint() {
+ global $user;
+
+ if ($user['DECT'] == "") {
+ return error(_("You need to specify a DECT phone number in your settings! If you don't have a DECT phone, just enter \"-\"."), true);
+ }
+
+ return null;
+}
+
?>