From 044631ed2ac590a5e67ba4ac07267e790f814863 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 18 Oct 2013 13:20:31 +0200 Subject: Show different content on main page depending on logged in/guest status --- inc/message.inc.php | 25 +++++++++++++++++++++++++ modules/main.inc.php | 9 +++++++-- templates/main-menu.html | 2 +- templates/messagebox-info.html | 1 + templates/messagebox-success.html | 1 + templates/messagebox-warning.html | 1 + templates/page-main-guest.html | 5 +++++ templates/page-main.html | 1 + 8 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 templates/messagebox-info.html create mode 100644 templates/messagebox-success.html create mode 100644 templates/messagebox-warning.html create mode 100644 templates/page-main-guest.html create mode 100644 templates/page-main.html diff --git a/inc/message.inc.php b/inc/message.inc.php index 9409db95..238ed939 100644 --- a/inc/message.inc.php +++ b/inc/message.inc.php @@ -18,8 +18,33 @@ class Message ); } + public static function addWarning($id) + { + self::$list[] = array( + 'type' => 'warning', + 'id' => $id + ); + } + + public static function addInfo($id) + { + self::$list[] = array( + 'type' => 'info', + 'id' => $id + ); + } + + public static function addSuccess($id) + { + self::$list[] = array( + 'type' => 'success', + 'id' => $id + ); + } + public static function renderList() { + global $error_text; foreach (self::$list as $item) { Render::addTemplate('messagebox-' . $item['type'], array('message' => $error_text[$item['id']])); } diff --git a/modules/main.inc.php b/modules/main.inc.php index fc6a9fac..007fb296 100644 --- a/modules/main.inc.php +++ b/modules/main.inc.php @@ -4,11 +4,16 @@ User::load(); function render_module() { - Render::setTitle('Wurstgesicht'); + // Render::setTitle('abc'); Render::openTag('h1', array('class' => 'wurst kacke')); Render::closeTag('h1'); - Render::addTemplate('helloworld', array('wurst' => 'käse & bier')); + if (!User::isLoggedIn()) { + Render::addTemplate('page-main-guest'); + return; + } + // Logged in here + Render::addTemplate('page-main', array('user' => User::getName())); } diff --git a/templates/main-menu.html b/templates/main-menu.html index 7e9c3bdc..0b2cdd7f 100644 --- a/templates/main-menu.html +++ b/templates/main-menu.html @@ -11,7 +11,7 @@