From 358842a847ce67632204135bbb3c9c8f2267f243 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 16 Oct 2014 11:35:14 +0200 Subject: Show notice in menu bar if setup is incomplete --- inc/property.inc.php | 10 ++++++++++ index.php | 3 ++- lang/de/templates/main-menu.json | 1 + lang/en/templates/main-menu.json | 1 + modules/main.inc.php | 18 ++++++++++++------ templates/main-menu.html | 3 +++ 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/inc/property.inc.php b/inc/property.inc.php index e4b4340b..afbdf0de 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -159,5 +159,15 @@ class Property { return self::get('last-warn-event-id', 0); } + + public static function setNeedsSetup($value) + { + self::set('needs-setup', $value); + } + + public static function getNeedsSetup() + { + return self::get('needs-setup'); + } } diff --git a/index.php b/index.php index 2f507e2c..82879041 100644 --- a/index.php +++ b/index.php @@ -119,7 +119,8 @@ Render::addTemplate('main-menu', array( 'langs' => Dictionary::getLanguages(true), 'dbupdate' => Database::needSchemaUpdate(), 'user' => User::getName(), - 'warning' => User::getName() && User::getLastSeenEvent() < Property::getLastWarningId() + 'warning' => User::getName() !== false && User::getLastSeenEvent() < Property::getLastWarningId(), + 'needsSetup' => User::getName() !== false && Property::getNeedsSetup() )); Message::renderList(); diff --git a/lang/de/templates/main-menu.json b/lang/de/templates/main-menu.json index a681ef02..1044f2b0 100644 --- a/lang/de/templates/main-menu.json +++ b/lang/de/templates/main-menu.json @@ -9,6 +9,7 @@ "lang_localization": "Lokalisierung", "lang_login": "Anmelden", "lang_logout": "Abmelden", + "lang_needsSetup": "Einrichtung unvollst\u00e4ndig", "lang_news": "News", "lang_server": "Server", "lang_serverStatus": "Server Status", diff --git a/lang/en/templates/main-menu.json b/lang/en/templates/main-menu.json index 493d8d80..8fe57baa 100644 --- a/lang/en/templates/main-menu.json +++ b/lang/en/templates/main-menu.json @@ -9,6 +9,7 @@ "lang_localization": "Localization", "lang_login": "Login", "lang_logout": "Logout", + "lang_needsSetup": "Setup incomplete", "lang_news": "News", "lang_server": "Server", "lang_serverStatus": "Server status", diff --git a/modules/main.inc.php b/modules/main.inc.php index 01adf768..71d5071a 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -3,9 +3,17 @@ class Page_Main extends Page { + private $sysconfig; + private $minilinux; + private $vmstore; + protected function doPreprocess() { User::load(); + $this->sysconfig = !file_exists(CONFIG_HTTP_DIR . '/default/config.tgz'); + $this->minilinux = !file_exists(CONFIG_HTTP_DIR . '/default/kernel') || !file_exists(CONFIG_HTTP_DIR . '/default/initramfs-stage31') || !file_exists(CONFIG_HTTP_DIR . '/default/stage32.sqfs'); + $this->vmstore = !is_array(Property::getVmStoreConfig()); + Property::setNeedsSetup(($this->sysconfig || $this->minilinux || $this->vmstore) ? 1 : 0); } protected function doRender() @@ -19,14 +27,12 @@ class Page_Main extends Page return; } // Logged in here - $sysconfig = !file_exists(CONFIG_HTTP_DIR . '/default/config.tgz'); - $minilinux = !file_exists(CONFIG_HTTP_DIR . '/default/kernel') || !file_exists(CONFIG_HTTP_DIR . '/default/initramfs-stage31') || !file_exists(CONFIG_HTTP_DIR . '/default/stage32.sqfs'); - $vmstore = !is_array(Property::getVmStoreConfig()); + Render::addTemplate('page-main', array( 'user' => User::getName(), - 'sysconfig' => $sysconfig, - 'minilinux' => $minilinux, - 'vmstore' => $vmstore + 'sysconfig' => $this->sysconfig, + 'minilinux' => $this->minilinux, + 'vmstore' => $this->vmstore )); } diff --git a/templates/main-menu.html b/templates/main-menu.html index da00335c..afc948c9 100644 --- a/templates/main-menu.html +++ b/templates/main-menu.html @@ -49,6 +49,9 @@ {{#warning}}
  • {{lang_warning}}
  • {{/warning}} + {{#needsSetup}} +
  • {{lang_needsSetup}}
  • + {{/needsSetup}}