This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/includes/smarty/plugins/block.group.php
2008-11-26 14:50:40 -08:00

38 lines
1.1 KiB
PHP

<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: block.group.php
* Type: block
* Name: group
* Purpose: display content to authenticated groups only
* -------------------------------------------------------------
*/
function smarty_block_group($params, $resource, &$smarty)
{
if(empty($resource)) return;
@$id = $params["id"];
$do = false;
$db = &DB();
$sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE
site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND
status = ' . $db->qstr('1') . ' AND
id = ' . $db->qstr($id);
@$result = $db->Execute($sql);
$do = false;
if(@$result->RecordCount() > 0) {
global $C_auth;
@$arr = unserialize($result->fields['group_avail']);
for($i=0; $i<count($arr); $i++)
if($do == false && $C_auth->auth_group_by_id($arr[$i]))
$do = true;
}
if($do) {
echo $resource;
} else {
echo @$params["msg"];
}
}
?>