27 if (!isset($params[
'id']))
return;
29 $display_title = (isset($params[
'display']) && $params[
'display'] ==
'title') ?
true :
false;
30 $display_none = (isset($params[
'display']) && $params[
'display'] ==
'none') ?
true :
false;
31 $options = (isset($params[
'options'])) ? $params[
'options'] :
false;
32 $groups = (isset($params[
'groups'])) ? explode(
'|', $params[
'groups']) :
false;
33 $cache = (isset($params[
'cache'])) ? intval($params[
'cache']) :
false;
35 $block_id = intval($params[
'id']);
38 if (!isset($block_objs[$block_id])) {
39 include_once XOOPS_ROOT_PATH .
'/class/xoopsblock.php';
43 if (!is_object($blockObj))
return;
45 $block_objs[$block_id] = $blockObj;
48 $blockObj = $block_objs[$block_id];
51 $user_groups =
$GLOBALS[
'xoopsUser'] ?
$GLOBALS[
'xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
53 static $allowed_blocks;
54 if (count($allowed_blocks) == 0) {
59 if (!array_intersect($user_groups,
$groups))
return;
61 if (!in_array($block_id, $allowed_blocks))
return;
65 $blockObj->setVar(
'options',
$options);
69 $blockObj->setVar(
'bcachetime', $cache);
72 if ($display_title)
return $blockObj->getVar(
'title');
77 $bcachetime = intval($blockObj->getVar(
'bcachetime'));
78 if (empty($bcachetime)) {
79 $template->caching = 0;
81 $template->caching = 2;
82 $template->cache_lifetime = $bcachetime;
85 $template->setCompileId($blockObj->getVar(
'dirname',
'n'));
86 $tplName = ($tplName = $blockObj->getVar(
'template')) ?
"db:{$tplName}" :
"db:system_block_dummy.html";
87 $cacheid =
'blk_' . $block_id;
89 if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) {
91 if (!($bresult = $blockObj->buildBlock())) {
95 $template->assign(
'block', $bresult);
96 $template->display( $tplName, $cacheid );
99 $xoopsLogger->addBlock($blockObj->getVar(
'name'),
true, $bcachetime);
100 if (!$display_none) {
101 $template->display( $tplName, $cacheid );
104 $template->setCompileId($blockObj->getVar(
'dirname',
'n'));