[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php,1.70
From: |
ceb |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php,1.70 |
Date: |
Sat, 23 Apr 2005 23:45:00 +0200 |
Update of phpgwapi/inc
Modified Files:
Branch: MAIN
class.acl.inc.php lines: +47 -34
Log Message:
applied patch partially
====================================================
Index: phpgwapi/inc/class.acl.inc.php
diff -u phpgwapi/inc/class.acl.inc.php:1.69 phpgwapi/inc/class.acl.inc.php:1.70
--- phpgwapi/inc/class.acl.inc.php:1.69 Thu Dec 30 06:47:30 2004
+++ phpgwapi/inc/class.acl.inc.php Sat Apr 23 21:45:17 2005
@@ -2,7 +2,7 @@
/**
* Access Control List - Security scheme based on ACL design
* @author Dan Kuykendall <address@hidden>
- * @copyright Copyright (C) 2000-2004 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package phpgwapi
* @subpackage accounts
@@ -54,7 +54,7 @@
*/
function acl($account_id = '')
{
- $this->db = $GLOBALS['phpgw']->db;
+ $this->db = $GLOBALS['phpgw']->db;
if (!($this->account_id = intval($account_id)))
{
@@ -126,9 +126,9 @@
$this->acl();
}
- $sql = 'select * from phpgw_acl where (acl_account in
('.$this->account_id.', 0';
+ $sql = 'select * from phpgw_acl where (acl_account in
(' . $this->account_id . ', 0';
- $groups =
$this->get_location_list_for_id('phpgw_group', 1, $this->account_id);
+ $groups =
$this->get_location_list_for_id('phpgw_group',1,$this->account_id);
while($groups && (list($key,$value) = each($groups)))
{
$sql .= ','.$value;
@@ -142,11 +142,12 @@
//reset ($this->data);
//while(list($idx,$value) = each($this->data)){
$this->db->next_record();
- $this->data[] = array(
- 'appname' =>
$this->db->f('acl_appname'),
- 'location' =>
$this->db->f('acl_location'),
- 'account' =>
$this->db->f('acl_account'),
- 'rights' => $this->db->f('acl_rights')
+ $this->data[] = array
+ (
+ 'appname' =>
$this->db->f('acl_appname'),
+ 'location' =>
$this->db->f('acl_location'),
+ 'account' =>
$this->db->f('acl_account'),
+ 'rights' =>
$this->db->f('acl_rights')
);
}
reset ($this->data);
@@ -244,10 +245,8 @@
return $this->data;
}
-
// These are the non-standard $account_id specific functions
-
/**
* Get rights from the repository not specific to this object
*
@@ -260,9 +259,9 @@
// For XML-RPC, change this once its working correctly
for passing parameters (jengo)
if (is_array($location))
{
- $a = $location;
- $location = $a['location'];
- $appname = $a['appname'];
+ $a = $location;
+ $location = $a['location'];
+ $appname = $a['appname'];
}
if (count($this->data) == 0)
@@ -300,6 +299,7 @@
}
return $rights;
}
+
/**
* Check required rights (not specific to this object)
*
@@ -319,9 +319,10 @@
*
* @param string $location Application location
* @param string|boolean $appname Application name, defaults to
false which means $phpgw_info['flags']['currentapp']
+ * @param $checkgroups optional defaults to False
* @return integer Access rights in bitmask form
*/
- function get_specific_rights($location, $appname = False)
+ function get_specific_rights($location, $appname = False,
$checkgroups = False)
{
if ($appname == False)
{
@@ -335,14 +336,28 @@
return True;
}
$rights = 0;
+
+ $account_list[0] = $this->account_id;
+
+ if($checkgroups)
+ {
+ $user_groups =
$GLOBALS['phpgw']->accounts->membership($this->account_id);
+ $user_groups =
is_array($user_groups)?$user_groups:array();
+ //_debug_array($user_groups);
+
+ foreach($user_groups as $null => $ad_account)
+ {
+
$account_list[$i]=$ad_account['account_id'];
+ ++$i;
+ }
+ }
reset ($this->data);
while(list($idx,$value) = each($this->data))
{
- if ($this->data[$idx]['appname'] == $appname &&
- ($this->data[$idx]['location'] ==
$location ||
- $this->data[$idx]['location'] ==
'everywhere') &&
- $this->data[$idx]['account'] ==
$this->account_id)
+ if ($this->data[$idx]['appname'] == $appname &&
($this->data[$idx]['location'] == $location || $this->data[$idx]['location'] ==
'everywhere') &&
+ //$this->data[$idx]['account'] ==
$this->account_id)
+
in_array($this->data[$idx]['account'],$account_list))
{
if ($this->data[$idx]['rights'] == 0)
{
@@ -353,7 +368,7 @@
}
return $rights;
}
-
+
/**
* Check specific rights
*
@@ -502,7 +517,7 @@
$this->db->query($sql ,__LINE__,__FILE__);
return $this->db->num_rows();
}
-
+
/**
* Get application list for an account id
*
@@ -553,7 +568,7 @@
*
* @param string $app Application name
* @param integer $required Required access rights in bitmap form
- * @param integer $account_id Account id defaults to
$phpgw_info['user']['account_id'];
+ * @param integer $account_id Account id
* @return array|boolean Array with location list or false
*/
function get_location_list_for_id($app, $required, $accountid =
'')
@@ -569,22 +584,21 @@
$account_id =
get_account_id($accountid,$this->account_id);
$cache_accountid[$accountid] = $account_id;
}
- $sql = 'SELECT acl_location, acl_rights ';
- $sql .= "FROM phpgw_acl where acl_appname = '" .
$this->db->db_addslashes($app) . "' ";
- $sql .= 'AND acl_account =' . intval($account_id);
-
+ $sql = "SELECT acl_location, acl_rights FROM phpgw_acl
where acl_appname='" . $this->db->db_addslashes($app)
+ . "' AND acl_account=" .
intval($account_id);
+
$this->db->query($sql ,__LINE__,__FILE__);
$rights = 0;
- if ($this->db->num_rows() == 0 )
+ if($this->db->num_rows() == 0)
{
return False;
}
- while ($this->db->next_record())
+ while($this->db->next_record())
{
- if ($this->db->f('acl_rights'))
+ if($this->db->f('acl_rights'))
{
$rights |= $this->db->f('acl_rights');
- if (!!($rights & $required) == True)
+ if(!!($rights & $required) == True)
{
$locations[] =
$this->db->f('acl_location');
}
@@ -592,7 +606,7 @@
}
return $locations;
}
-
+
/**
* Get ids for location
*
@@ -607,8 +621,7 @@
{
$app =
$GLOBALS['phpgw_info']['flags']['currentapp'];
}
- $sql = "select acl_account, acl_rights from phpgw_acl
where acl_appname = '$app' and ";
- $sql .= "acl_location = '".$location."'";
+ $sql = "SELECT acl_account, acl_rights from phpgw_acl
where acl_appname='" . $app . "' and acl_location ='" . $location . "'";
$this->db->query($sql ,__LINE__,__FILE__);
$rights = 0;
if ($this->db->num_rows() == 0 )
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php,1.70,
ceb <=