new acl function to grab apps enabled for user and groups associated to

This commit is contained in:
skeeter 2001-03-11 22:38:19 +00:00
parent f77d5388a2
commit 716b8fe6ee
2 changed files with 42 additions and 1 deletions

View File

@ -368,6 +368,44 @@ It should use the values in the $this->data
return $accounts;
}
function get_user_applications($account_id = False)
{
global $phpgw, $phpgw_info;
$db2 = $this->db;
if ($account_id == False){
$account_id = $phpgw_info['user']['account_id'];
}
$memberships = $phpgw->accounts->memberships($account_id);
$sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = 'run' and "
. 'acl_account in ';
$security = '('.$account_id;
while($groups = each($memberships))
{
$group = each($groups);
$security .= ','.$group[1]['account_id'];
}
$security .= ')';
$db2->query($sql . $security ,__LINE__,__FILE__);
if ($db2->num_rows() == 0){ return False; }
while ($db2->next_record())
{
if(isset($apps[$db2->f('acl_appname')]))
{
$rights = $apps[$db2->f('acl_appname')];
}
else
{
$rights = 0;
}
$rights |= $db2->f('acl_rights');
$apps[$db2->f('acl_appname')] |= $rights;
}
return $apps;
}
function get_grants($app=False){
global $phpgw, $phpgw_info;

View File

@ -49,9 +49,12 @@
$this->read_installed_apps();
}
$this->data = Array();
if($this->account_id == False) { return False; }
$apps = $phpgw->acl->get_user_applications($this->account_id);
reset($phpgw_info['apps']);
while ($app = each($phpgw_info['apps'])) {
$check = $phpgw->acl->check('run',1,$app[0]);
// $check = $phpgw->acl->check('run',1,$app[0]);
$check = $apps[$app[0]];
if ($check) {
$this->data[$app[0]] = array('title' => $phpgw_info['apps'][$app[0]]['title'], 'name' => $app[0], 'enabled' => True, 'status' => $phpgw_info['apps'][$app[0]]['status']);
}