php-mpos/public/include/pages/home.inc.php
Sebastian Grewe 739bd9c7b6 Properly cache on a per-user basis
This will fix an issue with templates of other users being applied to
different users logged in. Basically the first cached page would be
displayed for all users.

Created a new cache key for smarty to allow the user ID to be reference
in the cache key. Hence each user has their own cached file which will
be used.

Improved caching by creating subdirectories for cached files. This way
we won't run into a file limit per directory with a lot of cached files.

This fixes #430 and the mentioned issue in that report.
2013-07-11 13:45:54 +02:00

27 lines
753 B
PHP

<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Include markdown library
use \Michelf\Markdown;
if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
$debug->append('No cached version available, fetching from backend', 3);
// Fetch active news to display
$aNews = $news->getAllActive();
if (is_array($aNews)) {
foreach ($aNews as $key => $aData) {
// Transform Markdown content to HTML
$aNews[$key]['content'] = Markdown::defaultTransform($aData['content']);
}
}
$smarty->assign("NEWS", $aNews);
} else {
$debug->append('Using cached page', 3);
}
// Load news entries for Desktop site and unauthenticated users
$smarty->assign("CONTENT", "default.tpl");
?>