From 8ab7322b130496c07ea9442bc94f6935d1077dd5 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 22 Feb 2013 03:26:08 +0100 Subject: [PATCH] Add links for logged in users and reorganize the base include a bit --- public_html/includes/base.php | 41 +++++++++++++++++++++----------- public_html/templates/layout.tpl | 9 +++++-- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/public_html/includes/base.php b/public_html/includes/base.php index 21ddc5c..a515fff 100644 --- a/public_html/includes/base.php +++ b/public_html/includes/base.php @@ -17,8 +17,35 @@ $_CPHP = true; $_CPHP_CONFIG = "../config.json"; require("cphp/base.php"); +/* Autoloader configuration */ require_once('lib/swiftmailer/swift_required.php'); +function autoload_redonate($class_name) +{ + global $_APP; + + $class_name = str_replace("\\", "/", strtolower($class_name)); + + if(file_exists("classes/{$class_name}.php")) + { + require_once("classes/{$class_name}.php"); + } +} + +spl_autoload_register(autoload_redonate); + +/* Set global templater variables */ +NewTemplater::SetGlobalVariable("logged-in", !empty($_SESSION['user_id'])); + +if(!empty($_SESSION['user_id'])) +{ + $sCurrentUser = new User($_SESSION['user_id']); + + $sCurrentUser->SetGlobalVariables(); + + NewTemplater::SetGlobalVariable("logout-key", $_SESSION['logout_key']); +} + NewTemplater::RegisterVariableHook("errors", "get_errors"); NewTemplater::RegisterVariableHook("notices", "get_notices"); @@ -73,20 +100,6 @@ function flash_notice($message) $_SESSION['notices'][] = $message; } -function autoload_redonate($class_name) -{ - global $_APP; - - $class_name = str_replace("\\", "/", strtolower($class_name)); - - if(file_exists("classes/{$class_name}.php")) - { - require_once("classes/{$class_name}.php"); - } -} - -spl_autoload_register(autoload_redonate); - function send_mail($to, $subject, $text, $html) { global $mail_transport, $cphp_config; diff --git a/public_html/templates/layout.tpl b/public_html/templates/layout.tpl index d4dfd1f..6c1123f 100644 --- a/public_html/templates/layout.tpl +++ b/public_html/templates/layout.tpl @@ -19,8 +19,13 @@