[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/class.acl.php, 1.1.1.1.2.11
From: |
nomail |
Subject: |
[Phpgroupware-cvs] api/class.acl.php, 1.1.1.1.2.11 |
Date: |
Thu, 20 May 2004 14:30:36 -0000 |
Update of /api
Modified Files:
Branch: proposal-branch
class.acl.php
date: 2004/04/16 20:59:48; author: seek3r; state: Exp; lines: +66 -63
Log Message:
bringing savannah cvs back up to date with what we were doing on our private
cvs server. We will not be doing dev from this cvs tree
=====================================================================
No syntax errors detected in -
=====================================================================
Index: api/class.acl.php
diff -u api/class.acl.php:1.1.1.1.2.10 api/class.acl.php:1.1.1.1.2.11
--- api/class.acl.php:1.1.1.1.2.10 Sat Feb 28 10:30:36 2004
+++ api/class.acl.php Fri Apr 16 20:59:48 2004
@@ -26,31 +26,39 @@
$functions = array();
$functions['api_acl'] = array(
- 'type'=>'public',
- 'abstract'=>'Constructor can take an account_id.',
- 'discussion'=>'Detects if the user is valid, if not it creates
the user as anoymous, loads up the base classes and sets the default action for
an anonymous user.
+ 'type' => 'public',
+ 'abstract' => 'Constructor can take an account_id.',
+ 'discussion' => 'Detects if the user is valid, if not it
creates the user as anoymous, loads up the base classes and sets the default
action for an anonymous user.
If the user is valid, then it loads up their base classes. If
the user is logging it, then it authenticates them, and either sends them back
to the login, or loads up their base classes.',
- 'params'=>array(
- 'force'=>array('type'=>'bool', 'default'=>'required',
'desc'=>'account id to be used')
+ 'params' => array(
+ 'force' => array('type' => 'bool', 'default' =>
'required', 'desc' => 'account id to be used')
)
);
$functions['check'] = array(
- 'type'=>'public',
- 'abstract'=>'Determine if the user has rights to the
operation/location.',
- 'discussion'=>'Checks their rights and rights masks to
determine if the user has rights to the specified operation/location.',
- 'params'=>array(
- 'op'=>array('type'=>'alphanumeric',
'default'=>'required', 'desc'=>'operation or location'),
- 'required'=>array('type'=>'number', 'default'=>'1',
'desc'=>'level of rights required'),
- 'acl_isop'=>array('type'=>'alphanumeric',
'default'=>'$this->acl_isop', 'desc'=>'if not an op then it can be used for
group memberships and such')
+ 'type' => 'public',
+ 'abstract' => 'Determine if the user has rights to the
operation/location.',
+ 'discussion' => 'Checks their rights and rights masks to
determine if the user has rights to the specified operation/location.',
+ 'params' => array(
+ 'op' => array('type' => 'alphanumeric', 'default'
=> 'required', 'desc' => 'operation or location'),
+ 'required' => array('type' => 'number', 'default'
=> '1', 'desc' => 'level of rights required'),
+ 'acl_isop' => array('type' => 'alphanumeric', 'default'
=> '$this->acl_isop', 'desc' => 'if not an op then it can be used for group
memberships and such')
)
);
$GLOBALS['docs']['api']['classes']['api_acl'] = array(
- 'abstract'=>'Access Control List (security) object.',
- 'functions'=>$functions
+ 'abstract' => 'Access Control List (security) object.',
+ 'functions' => $functions
);
+ // Some basic common ACL values
+ define('PHPGW_ACL_READ',1);
+ define('PHPGW_ACL_ADD',2);
+ define('PHPGW_ACL_EDIT',4);
+ define('PHPGW_ACL_DELETE',8);
+ define('PHPGW_ACL_PRIVATE',16);
+ define('PHPGW_ACL_GROUP_MANAGERS',32);
+
class api_acl
{
var $account_id;
@@ -71,31 +79,27 @@
$args->set('account_id',
$GLOBALS['phpgw_data']['user']['id'], 'number');
$args->set('host_id', 0, 'number');
$args->set('acl_isop', 1, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
$this->account_id = $args['account_id'];
$this->host_id = $args['host_id'];
$this->acl_isop = $args['acl_isop'];
}
- function pre_serialize()
+ function __sleep()
{
// stub so its gets cache'd. No cleanup needed.
}
- function post_serialize()
- {
- }
-
function get_memberships ()
{
$args = new safe_args();
$args->set('account_id', $this->account_id, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
$sql = "SELECT acl_op,acl_rights FROM phpgw_acl
WHERE (
acl_host='".$this->host_id."' and acl_isop = 0 and acl_account =
".$args['account_id'].")";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
while (!$dbresult->EOF)
{
@@ -112,9 +116,9 @@
function cache_rights()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('acl_isop', $this->acl_isop, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
$full_op_list = $this->get_op_array($args['op']);
$op_list = array_flip($full_op_list);
@@ -138,7 +142,7 @@
ORDER BY
acl_op, acl_type DESC";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
while (!$dbresult->EOF)
{
unset($op_list[$dbresult->fields['acl_op']]);
@@ -189,8 +193,8 @@
function get_op_array()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('op', REQUIRED, 'alphanumeric');
+ $args = $args->get(func_get_args());
if(!strstr($args['op'], '.'))
{
@@ -215,10 +219,10 @@
function get_op_list()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('acl_isop', $this->acl_isop, 'number');
$args->set('return', 'sql', 'alpha');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
$op_list = $this->get_op_array($args['op']);
$num = count($op_list);
@@ -246,10 +250,10 @@
function check()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('required', 1, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
if ($args['acl_isop'] == 1)
{
@@ -266,19 +270,19 @@
@discussion Adds ACL record to $acl->data. <br>
Syntax: array add() <br>
Example1: acl->add();
- @param $appname default False derives value from
$phpgw_data['flags']['currentapp']
+ @param $appname default false derives value from
$phpgw_data['flags']['currentapp']
@param $op op
@param $rights rights
*/
function add()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('rights', 1, 'number');
$args->set('type', 0, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
$args->set('data', NULL, 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
if($args['acl_isop'] == 1 && $args['op'] != '.')
{
@@ -288,19 +292,18 @@
$sql = "SELECT acl_rights FROM phpgw_acl WHERE
(acl_isop = '".$args['acl_isop']."' ";
$sql .= " and acl_account = ".$this->account_id;
$sql .= " and acl_op = '".$args['op']."' and
acl_type=".$args['type'].")";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
- if($dbresult !== false)
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+ if(!$dbresult->EOF)
{
$newrights = $this->bit_set($args['rights'],
(int)$dbresult->fields['acl_rights']);
$sql = "UPDATE phpgw_acl SET acl_rights
=".$newrights;
$sql .= " WHERE acl_host=".$this->host_id." AND
acl_isop=".$args['acl_isop']." AND acl_account=".$this->account_id." AND
acl_op='".$args['op']."' AND acl_type=".$args['type'];
- $dbresult->MoveNext();
}
else
{
$sql = "INSERT INTO phpgw_acl
(acl_host,acl_isop,acl_account,acl_op,acl_rights,acl_type,acl_data) VALUES
(".$this->host_id.",".$args['acl_isop'].",".$this->account_id.",'".$args['op']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
}
- $GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->Execute($sql);
$this->rights_cache = Array();
$this->masks_cache = Array();
}
@@ -308,12 +311,12 @@
function set()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('rights', 1, 'number');
$args->set('type', 0, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
$args->set('data', NULL, 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
if($args['acl_isop'] == 1)
{
@@ -323,8 +326,8 @@
$sql = "SELECT acl_rights FROM phpgw_acl WHERE
(acl_isop = '".$args['acl_isop']."' ";
$sql .= " and acl_account = ".$this->account_id;
$sql .= " and acl_op = '".$args['op']."' and
acl_type=".$args['type'].")";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
- if($dbresult !== false)
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+ if(!$dbresult->EOF)
{
if((int)$args['rights'] == 0)
{
@@ -335,14 +338,14 @@
$sql = "UPDATE phpgw_acl SET acl_rights
=".$args['rights'];
}
$sql .= " WHERE acl_host=".$this->host_id." AND
acl_isop=".$args['acl_isop']." AND acl_account=".$this->account_id." AND
acl_op='".$args['op']."' AND acl_type=".$args['type'];
-
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->Execute($sql);
}
else
{
if($args['rights'] != 0)
{
$sql = "INSERT INTO phpgw_acl
(acl_host,acl_isop,acl_account,acl_op,acl_rights,acl_type,acl_data) VALUES
(".$this->host_id.",".$args['acl_isop'].",".$this->account_id.",'".$args['op']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
-
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->Execute($sql);
}
}
$this->rights_cache = Array();
@@ -352,12 +355,12 @@
function remove()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('rights', 1, 'number');
$args->set('type', 0, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
$args->set('data', NULL, 'any');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
if($args['acl_isop'] == 1)
{
@@ -367,8 +370,8 @@
$sql = "SELECT acl_rights FROM phpgw_acl WHERE
(acl_isop = '".$args['acl_isop']."' ";
$sql .= " and acl_account = ".$this->account_id;
$sql .= " and acl_op = '".$args['op']."' and
acl_type=".$args['type'].")";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
- if($dbresult !== false)
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
+ if(!$dbresult->EOF)
{
$newrights =
$this->bit_mask((int)$dbresult->fields['acl_rights'],$args['rights']);
if ($newrights != 0)
@@ -380,7 +383,7 @@
$sql = "DELETE FROM phpgw_acl";
}
$sql .= " WHERE acl_host=".$this->host_id." AND
acl_isop=".$args['acl_isop']." AND acl_account=".$this->account_id." AND
acl_op='".$args['op']."' AND acl_type=".$args['type'];
-
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->Execute($sql);
$this->rights_cache = Array();
$this->masks_cache = Array();
}
@@ -392,11 +395,11 @@
function check_specific()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('required', 1, 'number');
$args->set('account_id', $this->account_id, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
if($args['acl_isop'] == 1)
{
@@ -406,7 +409,7 @@
$sql = "SELECT acl_rights,acl_type,acl_data FROM
phpgw_acl WHERE (acl_isop = '".$args['acl_isop']."' ";
$sql .= " and acl_account = ".$args['account_id'];
$sql .= " and acl_op = '".$args['op']."' and
acl_type=0)";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
$rights = 0;
while (!$dbresult->EOF)
{
@@ -420,16 +423,16 @@
function delete_account_rights()
{
$args = new safe_args();
- $args->set('account_id','##REQUIRED##','number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args->set('account_id',REQUIRED,'number');
+ $args = $args->get(func_get_args());
- if ($args['account_id'] ==
$GLOBALS['phpgw']['user']['id'])
+ if ($args['account_id'] ==
$GLOBALS['phpgw_data']['user']['id'])
{
- $GLOBALS['msgbox']->add(lang('You can not
delete your own ACL'),__LINE__,__FILE__, 'warning');
- return False;
+ $GLOBALS['msgbox']->add(lang('You can not
delete your own ACL'), 'warning');
+ return false;
}
- $GLOBALS['phpgw']->db->execute("delete from phpgw_acl
where acl_account='" . $args['account_id'] . "'",__LINE__,__FILE__);
+ $GLOBALS['phpgw']->db->Execute("delete from phpgw_acl
where acl_account='" . $args['account_id'] . "'");
return $GLOBALS['phpgw']->db->Affected_Rows();
}
@@ -438,15 +441,15 @@
function check_op()
{
$args = new safe_args();
- $args->set('op', '##REQUIRED##', 'alphanumeric');
+ $args->set('op', REQUIRED, 'alphanumeric');
$args->set('required', 1, 'number');
$args->set('acl_isop', $this->acl_isop, 'number');
- $args = $args->get(func_get_args(),__LINE__,__FILE__);
+ $args = $args->get(func_get_args());
$sql = "SELECT acl_rights,acl_type,acl_data FROM
phpgw_acl WHERE (acl_isop = '".$args['acl_isop']."' ";
$sql .= " and (acl_account in
(".$this->account_id.",".$this->memberships_sql.'))';
$sql .= " and acl_op = '".$args['op']."' and
acl_type=0)";
- $dbresult =
$GLOBALS['phpgw']->db->execute($sql,__LINE__,__FILE__);
+ $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
$rights = 0;
while (!$dbresult->EOF)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/class.acl.php, 1.1.1.1.2.11,
nomail <=