mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:04:53 +01:00
Formatting
This commit is contained in:
parent
90d97f0881
commit
637b1c04b5
@ -91,11 +91,13 @@
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$count = $this->db->num_rows();
|
||||
$this->data = Array();
|
||||
for ($idx = 0; $idx < $count; ++$idx){
|
||||
for ($idx = 0; $idx < $count; ++$idx)
|
||||
{
|
||||
//reset ($this->data);
|
||||
//while(list($idx,$value) = each($this->data)){
|
||||
$this->db->next_record();
|
||||
$this->data[] = array('appname' => $this->db->f('acl_appname'),
|
||||
$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')
|
||||
@ -132,7 +134,8 @@
|
||||
*/
|
||||
function add($appname = False, $location, $rights)
|
||||
{
|
||||
if ($appname == False){
|
||||
if ($appname == False)
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
$this->data[] = array('appname' => $appname, 'location' => $location, 'account' => $this->account_id, 'rights' => $rights);
|
||||
@ -151,13 +154,16 @@
|
||||
*/
|
||||
function delete($appname = False, $location)
|
||||
{
|
||||
if ($appname == False){
|
||||
if ($appname == False)
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
$count = count($this->data);
|
||||
reset ($this->data);
|
||||
while(list($idx,$value) = each($this->data)){
|
||||
if ($this->data[$idx]['appname'] == $appname && $this->data[$idx]['location'] == $location && $this->data[$idx]['account'] == $this->account_id){
|
||||
while(list($idx,$value) = each($this->data))
|
||||
{
|
||||
if ($this->data[$idx]['appname'] == $appname && $this->data[$idx]['location'] == $location && $this->data[$idx]['account'] == $this->account_id)
|
||||
{
|
||||
$this->data[$idx] = Array();
|
||||
}
|
||||
}
|
||||
@ -173,7 +179,8 @@
|
||||
example: acl->save_repository()
|
||||
*/
|
||||
|
||||
function save_repository(){
|
||||
function save_repository()
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
reset($this->data);
|
||||
|
||||
@ -182,10 +189,13 @@
|
||||
|
||||
$count = count($this->data);
|
||||
reset ($this->data);
|
||||
while(list($idx,$value) = each($this->data)){
|
||||
if ($this->data[$idx]['account'] == $this->account_id){
|
||||
while(list($idx,$value) = each($this->data))
|
||||
{
|
||||
if ($this->data[$idx]['account'] == $this->account_id)
|
||||
{
|
||||
$sql = 'insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_rights)';
|
||||
$sql .= " values('".$this->data[$idx]['appname']."', '".$this->data[$idx]['location']."', ".$this->account_id.', '.$this->data[$idx]['rights'].')';
|
||||
$sql .= " values('".$this->data[$idx]['appname']."', '"
|
||||
. $this->data[$idx]['location']."', ".$this->account_id.', '.$this->data[$idx]['rights'].')';
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
@ -196,6 +206,7 @@
|
||||
/**************************************************************************\
|
||||
* These are the non-standard $this->account_id specific functions *
|
||||
\**************************************************************************/
|
||||
|
||||
/*!
|
||||
@function get_rights
|
||||
@abstract get rights from the repository not specific to this->account_id (?)
|
||||
@ -203,21 +214,26 @@
|
||||
@param $location app location to get rights from
|
||||
@param $appname optional defaults to $phpgw_info['flags']['currentapp'];
|
||||
*/
|
||||
function get_rights($location,$appname = False){
|
||||
function get_rights($location,$appname = False)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
if (count($this->data) == 0){ $this->read_repository(); }
|
||||
reset ($this->data);
|
||||
if ($appname == False){
|
||||
if ($appname == False)
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
$count = count($this->data);
|
||||
if ($count == 0 && $phpgw_info['server']['acl_default'] != 'deny'){ return True; }
|
||||
$rights = 0;
|
||||
// for ($idx = 0; $idx < $count; ++$idx){
|
||||
//for ($idx = 0; $idx < $count; ++$idx){
|
||||
reset ($this->data);
|
||||
while(list($idx,$value) = each($this->data)){
|
||||
if ($this->data[$idx]['appname'] == $appname) {
|
||||
if ($this->data[$idx]['location'] == $location || $this->data[$idx]['location'] == 'everywhere'){
|
||||
while(list($idx,$value) = each($this->data))
|
||||
{
|
||||
if ($this->data[$idx]['appname'] == $appname)
|
||||
{
|
||||
if ($this->data[$idx]['location'] == $location || $this->data[$idx]['location'] == 'everywhere')
|
||||
{
|
||||
if ($this->data[$idx]['rights'] == 0){ return False; }
|
||||
$rights |= $this->data[$idx]['rights'];
|
||||
}
|
||||
@ -232,7 +248,8 @@
|
||||
@param $required required right to check against
|
||||
@param $appname optional defaults to currentapp
|
||||
*/
|
||||
function check($location, $required, $appname = False){
|
||||
function check($location, $required, $appname = False)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
$rights = $this->get_rights($location,$appname);
|
||||
return !!($rights & $required);
|
||||
@ -244,10 +261,12 @@
|
||||
@param $appname optional defaults to currentapp
|
||||
@result $rights ?
|
||||
*/
|
||||
function get_specific_rights($location, $appname = False){
|
||||
function get_specific_rights($location, $appname = False)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
if ($appname == False){
|
||||
if ($appname == False)
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
|
||||
@ -256,10 +275,13 @@
|
||||
$rights = 0;
|
||||
|
||||
reset ($this->data);
|
||||
while(list($idx,$value) = each($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) {
|
||||
($this->data[$idx]['location'] == $location ||
|
||||
$this->data[$idx]['location'] == 'everywhere') &&
|
||||
$this->data[$idx]['account'] == $this->account_id)
|
||||
{
|
||||
if ($this->data[$idx]['rights'] == 0){ return False; }
|
||||
$rights |= $this->data[$idx]['rights'];
|
||||
}
|
||||
@ -274,7 +296,8 @@
|
||||
@param $appname optional defaults to currentapp
|
||||
@result boolean
|
||||
*/
|
||||
function check_specific($location, $required, $appname = False){
|
||||
function check_specific($location, $required, $appname = False)
|
||||
{
|
||||
$rights = $this->get_specific_rights($location,$appname);
|
||||
return !!($rights & $required);
|
||||
}
|
||||
@ -284,14 +307,17 @@
|
||||
@param $app appname
|
||||
@param $required ?
|
||||
*/
|
||||
function get_location_list($app, $required){
|
||||
function get_location_list($app, $required)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
// User piece
|
||||
$sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' ";
|
||||
$sql .= " and (acl_account in ('".$this->account_id."', 0"; // group 0 covers all users
|
||||
$equalto = $phpgw->accounts->security_equals($this->account_id);
|
||||
if (is_array($equalto) && count($equalto) > 0){
|
||||
for ($idx = 0; $idx < count($equalto); ++$idx){
|
||||
if (is_array($equalto) && count($equalto) > 0)
|
||||
{
|
||||
for ($idx = 0; $idx < count($equalto); ++$idx)
|
||||
{
|
||||
$sql .= ','.$equalto[$idx][0];
|
||||
}
|
||||
}
|
||||
@ -300,12 +326,16 @@
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 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') == 0){ return False; }
|
||||
$rights |= $this->db->f('acl_rights');
|
||||
if (!!($rights & $required) == True){
|
||||
if (!!($rights & $required) == True)
|
||||
{
|
||||
$locations[] = $this->db->f('acl_location');
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -313,12 +343,14 @@
|
||||
}
|
||||
|
||||
/*
|
||||
This is kinda how the function SHOULD work, so that it doesnt need to do its own sql query.
|
||||
It should use the values in the $this->data
|
||||
This is kinda how the function SHOULD work, so that it doesnt need to do its own sql query.
|
||||
It should use the values in the $this->data
|
||||
|
||||
function get_location_list($app, $required){
|
||||
function get_location_list($app, $required)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
if ($appname == False){
|
||||
if ($appname == False)
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
|
||||
@ -327,14 +359,18 @@ It should use the values in the $this->data
|
||||
$rights = 0;
|
||||
|
||||
reset ($this->data);
|
||||
while(list($idx,$value) = each($this->data)){
|
||||
if ($this->data[$idx]['appname'] == $appname && $this->data[$idx]['rights'] != 0){
|
||||
while(list($idx,$value) = each($this->data))
|
||||
{
|
||||
if ($this->data[$idx]['appname'] == $appname && $this->data[$idx]['rights'] != 0)
|
||||
{
|
||||
$location_rights[$this->data[$idx]['location']] |= $this->data[$idx]['rights'];
|
||||
}
|
||||
}
|
||||
reset($location_rights);
|
||||
for ($idx = 0; $idx < count($location_rights); ++$idx){
|
||||
if (!!($location_rights[$idx] & $required) == True){
|
||||
for ($idx = 0; $idx < count($location_rights); ++$idx)
|
||||
{
|
||||
if (!!($location_rights[$idx] & $required) == True)
|
||||
{
|
||||
$location_rights[] = $this->data[$idx]['location'];
|
||||
}
|
||||
}
|
||||
@ -345,6 +381,7 @@ It should use the values in the $this->data
|
||||
/**************************************************************************\
|
||||
* These are the generic functions. Not specific to $this->account_id *
|
||||
\**************************************************************************/
|
||||
|
||||
/*!
|
||||
@function add_repository
|
||||
@abstract add repository information for an app
|
||||
@ -369,7 +406,8 @@ It should use the values in the $this->data
|
||||
@param $location location
|
||||
@param $account_id account id
|
||||
*/
|
||||
function delete_repository($app, $location, $accountid = ''){
|
||||
function delete_repository($app, $location, $accountid = '')
|
||||
{
|
||||
$account_id = get_account_id($accountid,$this->account_id);
|
||||
$sql = "delete from phpgw_acl where acl_appname like '".$app."'"
|
||||
. " and acl_location like '".$location."' and "
|
||||
@ -385,7 +423,8 @@ It should use the values in the $this->data
|
||||
@param $required ?
|
||||
@param $account_id account id defaults to $phpgw_info['user']['account_id'];
|
||||
*/
|
||||
function get_app_list_for_id($location, $required, $accountid = ''){
|
||||
function get_app_list_for_id($location, $required, $accountid = '')
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
$account_id = get_account_id($accountid,$this->account_id);
|
||||
$sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = '$location' and ";
|
||||
@ -393,10 +432,12 @@ It should use the values in the $this->data
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 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') == 0){ return False; }
|
||||
$rights |= $this->db->f('acl_rights');
|
||||
if (!!($rights & $required) == True){
|
||||
if (!!($rights & $required) == True)
|
||||
{
|
||||
$apps[] = $this->db->f('acl_appname');
|
||||
}
|
||||
}
|
||||
@ -411,7 +452,8 @@ It should use the values in the $this->data
|
||||
@param $required required
|
||||
@param $account_id optional defaults to $phpgw_info['user']['account_id'];
|
||||
*/
|
||||
function get_location_list_for_id($app, $required, $accountid = ''){
|
||||
function get_location_list_for_id($app, $required, $accountid = '')
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
$account_id = get_account_id($accountid);
|
||||
$sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' and ";
|
||||
@ -419,10 +461,13 @@ It should use the values in the $this->data
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 0;
|
||||
if ($this->db->num_rows() == 0 ){ return False; }
|
||||
while ($this->db->next_record()) {
|
||||
if ($this->db->f('acl_rights')) {
|
||||
while ($this->db->next_record())
|
||||
{
|
||||
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');
|
||||
}
|
||||
}
|
||||
@ -436,9 +481,11 @@ It should use the values in the $this->data
|
||||
@param $required required
|
||||
@param $app app optional defaults to $phpgw_info['flags']['currentapp'];
|
||||
*/
|
||||
function get_ids_for_location($location, $required, $app = False){
|
||||
function get_ids_for_location($location, $required, $app = False)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
if ($app == False){
|
||||
if ($app == False)
|
||||
{
|
||||
$app = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
$sql = "select acl_account, acl_rights from phpgw_acl where acl_appname = '$app' and ";
|
||||
@ -446,10 +493,12 @@ It should use the values in the $this->data
|
||||
$this->db->query($sql ,__LINE__,__FILE__);
|
||||
$rights = 0;
|
||||
if ($this->db->num_rows() == 0 ){ return False; }
|
||||
while ($this->db->next_record()) {
|
||||
while ($this->db->next_record())
|
||||
{
|
||||
$rights = 0;
|
||||
$rights |= $this->db->f('acl_rights');
|
||||
if (!!($rights & $required) == True){
|
||||
if (!!($rights & $required) == True)
|
||||
{
|
||||
$accounts[] = intval($this->db->f('acl_account'));
|
||||
}
|
||||
}
|
||||
@ -502,7 +551,8 @@ It should use the values in the $this->data
|
||||
@abstract ?
|
||||
@param $app optional defaults to $phpgw_info['flags']['currentapp'];
|
||||
*/
|
||||
function get_grants($app=False){
|
||||
function get_grants($app=False)
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
$db2 = $this->db;
|
||||
|
Loading…
Reference in New Issue
Block a user