phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php


From: Dave Hall
Subject: [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php
Date: Fri, 24 Nov 2006 10:07:06 +0000

CVSROOT:        /sources/phpgwapi
Module name:    phpgwapi
Changes by:     Dave Hall <skwashd>     06/11/24 10:07:06

Modified files:
        inc            : class.acl.inc.php 

Log message:
        fix delete_repository so it only deletes what it is asked to delete, 
add new method for deleting ACL locations

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.acl.inc.php?cvsroot=phpgwapi&r1=1.100&r2=1.101

Patches:
Index: class.acl.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.acl.inc.php,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -b -r1.100 -r1.101
--- class.acl.inc.php   23 Oct 2006 12:42:39 -0000      1.100
+++ class.acl.inc.php   24 Nov 2006 10:07:05 -0000      1.101
@@ -6,7 +6,7 @@
        * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General 
Public License
        * @package phpgwapi
        * @subpackage accounts
-       * @version $Id: class.acl.inc.php,v 1.100 2006/10/23 12:42:39 sigurdne 
Exp $
+       * @version $Id: class.acl.inc.php,v 1.101 2006/11/24 10:07:05 skwashd 
Exp $
        */
 
        /**
@@ -254,27 +254,30 @@
                /**
                * Delete ACL records
                *
-               * @param string|boolean $appname Application name, defaults to 
false which means $GLOBALS['phpgw_info']['flags']['currentapp']
+               * @param string $appname Application name, empty string is 
translated to $GLOBALS['phpgw_info']['flags']['currentapp']
                * @param string $location Application location
                * @param integer $grantor account_id of the user that has 
granted access to his/hers records. No value means that this is a ordinary ACL 
- record
                * @param integer $type mask or right (1 means mask , 0 means 
right)
                * @return array Array with ACL records
                */
-               function delete($appname = '', $location, $grantor = False, 
$type = False)
+               function delete($appname = '', $location, $grantor = 0, $type = 
0)
                {
                        if ($appname == '')
                        {
                                $appname = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        }
+
                        if(isset($this->data[$this->account_id]) && 
is_array($this->data[$this->account_id]))
                        {
-                               $count = count($this->data[$this->account_id]);
-                               reset ($this->data[$this->account_id]);
-                               while(list($idx,$value) = 
each($this->data[$this->account_id]))
+                               foreach ( $this->data[$this->account_id] as 
$idx => $value )
                                {
-                                       if 
((isset($this->data[$this->account_id][$idx]['appname']) && 
$this->data[$this->account_id][$idx]['appname'] == $appname) && 
(strpos($this->data[$this->account_id][$idx]['location'],$location) === 0) && 
$this->data[$this->account_id][$idx]['account'] == $this->account_id && 
$this->data[$this->account_id][$idx]['grantor'] == $grantor && 
$this->data[$this->account_id][$idx]['type'] == $type)
+                                       if ( (isset($value['appname']) && 
$value['appname'] == $appname )
+                                               && strpos($value['location'], 
$location) === 0
+                                               && $value['account'] == 
$this->account_id
+                                               && $value['grantor'] == $grantor
+                                               && $value['type'] == $type )
                                        {
-                                               
$this->data[$this->account_id][$idx] = Array();
+                                               
unset($this->data[$this->account_id][$idx]);
                                        }
                                }
                                reset($this->data[$this->account_id]);
@@ -283,6 +286,53 @@
                }
 
                /**
+               * Deletes an ACL and all associated grants/masks for that 
location
+               *
+               * @param string $appname the application name
+               * @param string $location the location
+               * @param bool $remove_table remove the associate custom 
attributes table if it exists
+               * @return bool was the location found and deleted?
+               */
+               function delete_location($appnane, $location, $remove_table = 
false)
+               {
+                       $appname = $this->db->db_addslashes($appname);
+                       $location = $this->db->db_addslashes($location);
+
+                       $sql = 'SELECT c_attrib_table FROM phpgw_acl_location'
+                               . " WHERE appname = '{$appname}'"
+                               . " AND id = '{$location}'";
+
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       if ( !$this->db->next_record() )
+                       {
+                               return false; //invalid location
+                       }
+
+                       $tbl = $this->db->f('c_attrib_table');
+                       
+                       $oProc = 
createObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+                       $oProc->m_odb =& $this->db;
+                       $Proc->m_odb->Halt_On_Error = 'report';
+
+                       $this->db->transaction_begin();
+
+                       if ( $remove_table )
+                       {
+                               $GLOBALS['phpgw']->oProc->DropTable($tbl);
+                       }
+
+                       $this->db->query('DELETE FROM phpgw_acl_location'
+                               . " WHERE appname = '{$appname}'"
+                               . " AND id = '{$location}'", __LINE__, 
__FILE__);
+
+                       $this->delete_repository($appname, $location);
+
+                       $this->db->transaction_commit();
+
+                       return true;
+               }
+
+               /**
                * Save repository in database
                *
                * @param string $appname Application name (default empty string 
is converted to false $GLOBALS['phpgw_info']['flags']['currentapp'])
@@ -728,6 +778,8 @@
                {
                        static $cache_accountid;
                        
+                       $account_sel = '';
+
                        $accountid = intval($accountid);
                        if ($accountid > 0)
                        {
@@ -740,10 +792,10 @@
                                        $account_id = 
get_account_id($accountid,$this->account_id);
                                        $cache_accountid[$accountid] = 
$account_id;
                                }
-                               $account_sel = ' and acl_account=' . 
$account_id;
+                               $account_sel = ' AND acl_account = ' . 
$account_id;
                        }
 
-                       $sql = "delete from phpgw_acl where acl_appname 
$this->like '" . $app . "' and acl_location $this->like '" . $location . "%'" . 
$account_sel;
+                       $sql = "DELETE FROM phpgw_acl WHERE acl_appname = 
'{$app}' AND acl_location = '{$location}' $account_sel";
                        $this->db->query($sql ,__LINE__,__FILE__);
                        return $this->db->num_rows();
                }
@@ -1080,6 +1132,12 @@
                        return true;
                }
 
+               /**
+               * This does something
+               *
+               * @param ??? $apps_wtih_acl ???
+               * @return ???
+               */
                function verify_location($apps_with_acl)
                {
                        while($apps_with_acl && (list($appname,$value) = 
each($apps_with_acl)))




reply via email to

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