[21009] Fix: Clean up ACL and cache when deleting groups 4683:4684

Sigurd Nes <[email protected]> Sat, 30 Jan 2010 20:38:57 +0000
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 21009
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=21009
Author:   sigurdne
Date:     2010-01-30 20:38:56 +0000 (Sat, 30 Jan 2010)
Log Message:
-----------
Fix: Clean up ACL and cache when deleting groups 4683:4684

Modified Paths:
--------------
    people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php	2010-01-30 17:18:02 UTC (rev 21008)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php	2010-01-30 20:38:56 UTC (rev 21009)
@@ -1006,7 +1006,7 @@
 					$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} OR acl_grantor = {$account_id})";
 			}
 
 			$app = $this->_db->db_addslashes($app);
@@ -1031,22 +1031,24 @@
 				. " WHERE location_id IN ({$location_filter}) $account_sel";
 			$this->_db->query($sql, __LINE__, __FILE__);
 
-			$ret = !!$this->_db->num_rows();
+			$ret = !!$this->_db->affected_rows();
 
 			if ( $ret )
 			{
-				$location_id	= $GLOBALS['phpgw']->locations->get_id($app, $location);
-				if($account_id)
+				foreach ($locations as $location_id)
 				{
-					$this->_delete_cache($account_id, $location_id);
-				}
-				else
-				{
-					$account_objects = $GLOBALS['phpgw']->accounts->get_list('both', -1, 'ASC', '', '', -1);
-					foreach($account_objects as $account)
+					if($account_id)
 					{
-						$this->_delete_cache($account->id, $location_id);
+						$this->_delete_cache($account_id, $location_id);
 					}
+					else
+					{
+						$account_objects = $GLOBALS['phpgw']->accounts->get_list('both', -1, 'ASC', '', '', -1);
+						foreach($account_objects as $account)
+						{
+							$this->_delete_cache($account->id, $location_id);
+						}
+					}
 				}
 			}
 			return $ret;