[21014] Improvement: Clear user cache when edit a user 4711:4715

Sigurd Nes <[email protected]> Sun, 07 Feb 2010 10:14:37 +0000
Newsgroups gmane.comp.web.phpgroupware.cvs
Message-ID <[email protected]>
Revision: 21014
          http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=21014
Author:   sigurdne
Date:     2010-02-07 10:14:37 +0000 (Sun, 07 Feb 2010)
Log Message:
-----------
Improvement: Clear user cache when edit a user 4711:4715

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

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php	2010-02-07 10:11:39 UTC (rev 21013)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/accounts/class.accounts_.inc.php	2010-02-07 10:14:37 UTC (rev 21014)
@@ -692,6 +692,7 @@
 
 			$aclobj =& $GLOBALS['phpgw']->acl;
 			$aclobj->set_account_id($user->id, true);
+			$aclobj->clear_user_cache($user->id);
 			foreach ($GLOBALS['phpgw_info']['apps'] as $app => $dummy)
 			{
 				if($app == 'phpgwapi')

Modified: people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php
===================================================================
--- people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php	2010-02-07 10:11:39 UTC (rev 21013)
+++ people/sigurdne/modules/phpgwapi/trunk/inc/class.acl.inc.php	2010-02-07 10:14:37 UTC (rev 21014)
@@ -978,6 +978,35 @@
 		}
 
 		/**
+		* Clear cached permissions for all locations for a given user
+		*
+		* @param integer $account_id Account id - 0 = current user
+		*
+		* @return void
+		*/
+		public function clear_user_cache($account_id = 0)
+		{
+			$account_id = (int)$account_id;
+			if(!$account_id)
+			{
+				$account_id = $this->_account_id;
+			}
+			$locations = array();
+
+			$sql = 'SELECT location_id FROM phpgw_locations';
+			$this->_db->query($sql, __LINE__, __FILE__);
+			while ($this->_db->next_record())
+			{
+				$locations[] = $this->_db->f('location_id');
+			}
+
+			foreach ($locations as $location_id)
+			{
+				$this->_delete_cache($account_id, $location_id);
+			}
+		}
+
+		/**
 		* Delete repository information for an application
 		*
 		* @param string  $app       Application name