php-mpos/public/include/pages/statistics/blocks.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

26 lines
761 B
PHP

<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Grab the last blocks found
if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
$debug->append('No cached version available, fetching from backend', 3);
// Grab the last blocks found
$iLimit = 20;
$aBlocksFoundData = $statistics->getBlocksFound($iLimit);
// Propagate content our template
$smarty->assign("BLOCKSFOUND", $aBlocksFoundData);
$smarty->assign("BLOCKLIMIT", $iLimit);
} else {
$debug->append('Using cached page', 3);
}
if ($config['website']['acl']['statistics']['blocks'] == 'public') {
$smarty->assign("CONTENT", "default.tpl");
} else if ($user->isAuthenticated()) {
$smarty->assign("CONTENT", "default.tpl");
}
?>