phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] property/class.acl2.php, 1.1.1.8


From: nomail
Subject: [Phpgroupware-cvs] property/class.acl2.php, 1.1.1.8
Date: Sun, 23 May 2004 08:33:16 -0000

Update of /property
Modified Files:
        Branch: 
          class.acl2.php

date: 2004/04/29 19:46:58;  author: sigurdne;  state: Exp;  lines: +25 -63

Log Message:
no message
=====================================================================
Index: property/class.acl2.php
diff -u property/class.acl2.php:1.1.1.7 property/class.acl2.php:1.1.1.8
--- property/class.acl2.php:1.1.1.7     Thu Apr 29 12:49:48 2004
+++ property/class.acl2.php     Thu Apr 29 19:46:58 2004
@@ -146,14 +146,10 @@
                */
                function get_ids_for_location($acl_account, $required, 
$location = False)
                {
-//echo 'hepp';
-//html_print_r($GLOBALS['phpgw_data']['flags']['req_app']);
                        if ($location == False)
                        {
                                $location = 
'.'.$GLOBALS['phpgw_data']['flags']['req_app'];
                        }
-//                     $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 fm_acl2 
where acl_location LIKE '%$location%' AND acl_account = '".$acl_account."'";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        $rights = 0;
@@ -261,8 +257,6 @@
 
                function safe_args($expected, $recieved, $line='??', $file='??')
                {
-//html_print_r($expected);
-//html_print_r($recieved);
                        /* This array will contain all the required fields */
                        $required = Array();
 
@@ -375,16 +369,15 @@
                        $expected_args[4] = 
Array('name'=>'no_effective','default'=>false, 'type'=>'any');
 
                        $recieved_args = func_get_args();
-//             html_print_r($recieved_args);
                        $args = $this->safe_args($expected_args, 
$recieved_args,__LINE__,__FILE__);
 
-                       
if(isset($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]))
+                       
if(isset($this->rights_cache[$args['account_id']][$args['location']]))
                        {
                                return;
                        }
 
-                       $sql = "SELECT 
acl_rights,acl_type,acl_data,acl_location FROM fm_acl2 WHERE (acl_appid = 
'".$args['app_id']."' ";
-                       $sql .= " and (acl_account in 
(".$args['account_id']."".$this->memberships_sql.'))';
+                       $sql = "SELECT 
acl_rights,acl_type,acl_data,acl_location FROM fm_acl2 ";
+                       $sql .= " WHERE (acl_account in 
(".$args['account_id']."".$this->memberships_sql.'))';
                        $sql .= " and acl_location = '". $args['location'] . 
"'";
 
                        if($args['grantor']>0)
@@ -396,39 +389,39 @@
                                $sql .= " and (grantor is NULL)";
                        }
 
-                       $sql .= ') ORDER BY acl_location, acl_type DESC';
+                       $sql .= ' ORDER BY acl_location, acl_type DESC';
 
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        while (!$dbresult->EOF)
                        {
-                               
if($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']] 
== 0)
+                               
if($this->rights_cache[$args['account_id']][$args['location']] == 0)
                                {
-                                       
$this->rights_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']]
 = 0;
+                                       
$this->rights_cache[$args['account_id']][$dbresult->fields['acl_location']] = 0;
                                }
 
-                               
if($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']] 
== 0)
+                               
if($this->masks_cache[$args['account_id']][$args['location']] == 0)
                                {
-                                       
$this->masks_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']]
 = 0;
+                                       
$this->masks_cache[$args['account_id']][$dbresult->fields['acl_location']] = 0;
                                }
 
                                if((int)$dbresult->fields['acl_type'] == 0)
                                {
-                                       
$this->rights_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']]
 = 
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']],(int)$dbresult->fields['acl_rights']);
+                                       
$this->rights_cache[$args['account_id']][$dbresult->fields['acl_location']] = 
$this->bit_set($this->rights_cache[$args['account_id']][$dbresult->fields['acl_location']],(int)$dbresult->fields['acl_rights']);
                                }
                                else
                                {
-                                       
$this->masks_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']]
 = 
$this->bit_set($this->rights_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']],(int)$dbresult->fields['acl_rights']);
+                                       
$this->masks_cache[$args['account_id']][$dbresult->fields['acl_location']] = 
$this->bit_set($this->rights_cache[$args['account_id']][$dbresult->fields['acl_location']],(int)$dbresult->fields['acl_rights']);
                                }
 
                                if(!$dbresult->fields['acl_rights'])
                                {
-                                       
$this->rights_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
-                                       
$this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]=0;
+                                       
$this->rights_cache[$args['account_id']][$args['location']]=0;
+                                       
$this->masks_cache[$args['account_id']][$args['location']]=0;
                                }
 
                                if(!$args['no_effective'])
                                {
-                                       
$this->rights_cache[$args['app_id']][$args['account_id']][$dbresult->fields['acl_location']]
 = 
$this->bit_mask($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],
 $this->masks_cache[$args['app_id']][$args['account_id']][$args['location']]);
+                                       
$this->rights_cache[$args['account_id']][$dbresult->fields['acl_location']] = 
$this->bit_mask($this->rights_cache[$args['account_id']][$args['location']], 
$this->masks_cache[$args['account_id']][$args['location']]);
                                }
                                $dbresult->MoveNext();
 
@@ -467,11 +460,11 @@
                        
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],$args['grantor'],$args['no_effective']);
                        if($args['acl_type']==0)
                        {
-                               return 
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+                               return 
$this->bit_check($this->rights_cache[$args['account_id']][$args['location']],$args['required']);
                        }
                        else
                        {
-                               return 
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+                               return 
$this->bit_check($this->masks_cache[$args['account_id']][$args['location']],$args['required']);
                        }
                }
 
@@ -502,15 +495,14 @@
                                }
                        }
 
-//html_print_r($args);
                        
$this->cache_rights($args['location'],$args['app_id'],$args['account_id'],False,$args['no_effective']);
                        if($args['acl_type']==0)
                        {
-                               return 
$this->bit_check($this->rights_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+                               return 
$this->bit_check($this->rights_cache[$args['account_id']][$args['location']],$args['required']);
                        }
                        else
                        {
-                               return 
$this->bit_check($this->masks_cache[$args['app_id']][$args['account_id']][$args['location']],$args['required']);
+                               return 
$this->bit_check($this->masks_cache[$args['account_id']][$args['location']],$args['required']);
                        }
                }
 
@@ -535,21 +527,17 @@
                        $recieved_args = func_get_args();
                        $args = $this->safe_args($expected_args, 
$recieved_args,__LINE__,__FILE__);
 
-//                     $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid 
= '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = '".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = '".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=".$args['type']." and grantor is NULL)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        if($dbresult->_numOfRows != 0)
                        {
                                $newrights = $this->bit_set($args['rights'], 
(int)$dbresult->fields['acl_rights']);
                                $sql = "UPDATE fm_acl2 SET acl_rights 
=".$newrights;
-//                             $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND 
acl_location='".$args['location']."' AND acl_type=".$args['type'];
                                $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_account=".$args['account_id']." AND acl_location='".$args['location']."' 
AND acl_type=".$args['type'];
                        }
                        else
                        {
-//                             $sql = "INSERT INTO fm_acl2 
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data) 
VALUES 
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$args['location']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
                                $sql = "INSERT INTO fm_acl2 
(acl_host,acl_account,acl_location,acl_rights,acl_type,acl_data) VALUES 
(".$this->host_id.",".$args['account_id'].",'".$args['location']."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
                        }
                        $GLOBALS['phpgw']->db->Execute($sql);
@@ -578,9 +566,7 @@
                                $grantor = $GLOBALS['phpgw_data']['user']['id'];
                        }
 
-//                     $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_appid = '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_account = ".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_account = ".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=".$args['type']." and grantor = $grantor)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        while (!$dbresult->EOF)
@@ -593,7 +579,6 @@
                                {
                                        $sql = "UPDATE fm_acl2 SET acl_rights 
=".$args['rights'];
                                }
-//                             $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND 
acl_location='".$dbresult->fields['acl_location']."' AND 
acl_type=".$args['type'] . " AND grantor = $grantor";
                                $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_account=".$args['account_id']." AND 
acl_location='".$dbresult->fields['acl_location']."' AND 
acl_type=".$args['type'] . " AND grantor = $grantor";
                                $GLOBALS['phpgw']->db->Execute($sql);
 
@@ -629,15 +614,12 @@
                                        {
                                                if($args['rights'] != 0)
                                                {
-       //                                              $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
-       //                                              $sql .= " and 
acl_account = ".$args['account_id'];
-                                                       $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_account = ".$args['account_id']."' ";
+                                                       $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_account = ".$args['account_id'];
                                                        $sql .= " and 
acl_location = '$location' and acl_type=".$args['type']. " AND grantor = 
$grantor)";
                                                        $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql);
 
                                                        
if($dbresult->_numOfRows == 0)
                                                        {
-//                                                             $sql = "INSERT 
INTO fm_acl2 
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data,grantor,grantor_type)
 VALUES 
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."',$grantor,'$grantor_type')";
                                                                $sql = "INSERT 
INTO fm_acl2 
(acl_host,acl_account,acl_location,acl_rights,acl_type,acl_data,grantor,grantor_type)
 VALUES 
(".$this->host_id.",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."',$grantor,'$grantor_type')";
 
                                                                
$GLOBALS['phpgw']->db->Execute($sql);
@@ -645,7 +627,6 @@
                                                        else
                                                        {
                                                                $sql = "UPDATE 
fm_acl2 SET acl_rights =".$args['rights'];
-//                                                             $sql .= " WHERE 
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND 
acl_account=".$args['account_id']." AND acl_location='".$location."' AND 
acl_type=".$args['type']  . " AND grantor = $grantor";
                                                                $sql .= " WHERE 
acl_host=".$this->host_id." AND acl_account=".$args['account_id']." AND 
acl_location='".$location."' AND acl_type=".$args['type']  . " AND grantor = 
$grantor";
                                                                
$GLOBALS['phpgw']->db->Execute($sql);
                                                        }
@@ -669,9 +650,7 @@
                        $expected_args[5] = 
Array('name'=>'data','default'=>NULL, 'type'=>'any');
                        $recieved_args = func_get_args();
                        $args = $this->safe_args($expected_args, 
$recieved_args,__LINE__,__FILE__);
-//                     $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_appid = '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_account = ".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights, acl_location FROM fm_acl2 
WHERE (acl_account = ".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=".$args['type']." AND grantor is NULL)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        while (!$dbresult->EOF)
@@ -684,7 +663,6 @@
                                {
                                        $sql = "UPDATE fm_acl2 SET acl_rights 
=".$args['rights'];
                                }
-//                             $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND 
acl_location='".$dbresult->fields['acl_location']."' AND 
acl_type=".$args['type'] . ' AND grantor is NULL';
                                $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_account=".$args['account_id']." AND 
acl_location='".$dbresult->fields['acl_location']."' AND 
acl_type=".$args['type'] . ' AND grantor is NULL';
                                $GLOBALS['phpgw']->db->Execute($sql);
                                
$updated_locations[]=$dbresult->fields['acl_location'];
@@ -719,14 +697,11 @@
                                        {
                                                if($args['rights'] != 0)
                                                {
-//                                                     $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
-//                                                     $sql .= " and 
acl_account = ".$args['account_id'];
-                                                       $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_account = ".$args['account_id']."' ";
+                                                       $sql = "SELECT 
acl_rights FROM fm_acl2 WHERE (acl_account = ".$args['account_id'];
                                                        $sql .= " and 
acl_location = '$location' and acl_type=".$args['type']." AND grantor is NULL 
)";
                                                        $dbresult = 
$GLOBALS['phpgw']->db->Execute($sql);
                                                        
if($dbresult->_numOfRows == 0)
                                                        {
-//                                                             $sql = "INSERT 
INTO fm_acl2 
(acl_host,acl_appid,acl_account,acl_location,acl_rights,acl_type,acl_data) 
VALUES 
(".$this->host_id.",".$args['app_id'].",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
                                                                $sql = "INSERT 
INTO fm_acl2 (acl_host,acl_account,acl_location,acl_rights,acl_type,acl_data) 
VALUES 
(".$this->host_id.",".$args['account_id'].",'".$location."',".$args['rights'].",".$args['type'].",'".$args['data']."')";
 
                                                                
$GLOBALS['phpgw']->db->Execute($sql);
@@ -734,7 +709,6 @@
                                                        else
                                                        {
                                                                $sql = "UPDATE 
fm_acl2 SET acl_rights =".$args['rights'];
-//                                                             $sql .= " WHERE 
acl_host=".$this->host_id." AND acl_appid=".$args['app_id']." AND 
acl_account=".$args['account_id']." AND acl_location='".$location."' AND 
acl_type=".$args['type'] . ' AND grantor is NULL';
                                                                $sql .= " WHERE 
acl_host=".$this->host_id." AND acl_account=".$args['account_id']." AND 
acl_location='".$location."' AND acl_type=".$args['type'] . ' AND grantor is 
NULL';
                                                                
$GLOBALS['phpgw']->db->Execute($sql);
                                                        }
@@ -759,9 +733,7 @@
                        $recieved_args = func_get_args();
                        $args = $this->safe_args($expected_args, 
$recieved_args,__LINE__,__FILE__);
 
-//                     $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid 
= '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = ".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = ".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=".$args['type']." and grantor is NULL)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        if($dbresult->_numOfRows != 0)
@@ -775,7 +747,6 @@
                                {
                                        $sql = "DELETE FROM fm_acl2";
                                }
-//                             $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND 
acl_location LIKE '%".$args['location']."%' AND acl_type=".$args['type'] . ' 
and grantor is NULL';
                                $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_account=".$args['account_id']." AND acl_location LIKE 
'%".$args['location']."%' AND acl_type=".$args['type'] . ' and grantor is NULL';
                                $GLOBALS['phpgw']->db->Execute($sql);
                                $this->rights_cache = Array();
@@ -804,9 +775,7 @@
                                $grantor = $GLOBALS['phpgw_data']['user']['id'];
                        }
 
-//                     $sql = "SELECT acl_rights FROM fm_acl2 WHERE (acl_appid 
= '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = ".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights FROM fm_acl2 WHERE 
(acl_account = ".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=".$args['type']." and grantor = $grantor)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        if($dbresult->_numOfRows != 0)
@@ -820,7 +789,6 @@
                                {
                                        $sql = "DELETE FROM fm_acl2";
                                }
-//                             $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_appid=".$args['app_id']." AND acl_account=".$args['account_id']." AND 
acl_location LIKE '%".$args['location']."%' AND acl_type=".$args['type'] . " 
and grantor = $grantor";
                                $sql .= " WHERE acl_host=".$this->host_id." AND 
acl_account=".$args['account_id']." AND acl_location LIKE 
'%".$args['location']."%' AND acl_type=".$args['type'] . " and grantor = 
$grantor";
                                $GLOBALS['phpgw']->db->Execute($sql);
                                $this->rights_cache = Array();
@@ -840,9 +808,7 @@
                        $recieved_args = func_get_args();
                        $args = $this->safe_args($expected_args, 
$recieved_args,__LINE__,__FILE__);
 
-//                     $sql = "SELECT acl_rights,acl_type,acl_data FROM 
fm_acl2 WHERE (acl_appid = '".$args['app_id']."' ";
-//                     $sql .= " and acl_account = ".$args['account_id'];
-                       $sql = "SELECT acl_rights,acl_type,acl_data FROM 
fm_acl2 WHERE (acl_account = ".$args['account_id']."' ";
+                       $sql = "SELECT acl_rights,acl_type,acl_data FROM 
fm_acl2 WHERE (acl_account = ".$args['account_id'];
                        $sql .= " and acl_location = '".$args['location']."' 
and acl_type=0)";
                        $dbresult = $GLOBALS['phpgw']->db->Execute($sql);
                        $rights = 0;
@@ -863,15 +829,11 @@
 
                        $app_id = 
$GLOBALS['phpgw']->applications->data[$app]['id'];
 
-//                     $sql = "select grantor,grantor_type, acl_rights from 
fm_acl2  where acl_appid = $app_id AND  acl_type=0  and acl_location = 
'$location' AND grantor is NOT NULL AND"
                        $sql = "select grantor,grantor_type, acl_rights from 
fm_acl2  where  acl_type=0  AND acl_location = '$location' AND grantor is NOT 
NULL AND"
                                . " fm_acl2.acl_account in ";
                        $security = "(". $this->account_id ."";
-//                     $myaccounts = CreateObject('phpgwapi_accounts');
-//                     $my_memberships = 
$myaccounts->membership($this->account_id);
                        $my_memberships = $this->membership($this->account_id);
 
-//                     unset($myaccounts);
                        @reset($my_memberships);
                        while($my_memberships && list($key,$group) = 
each($my_memberships))
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]