[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php |
Date: |
Wed, 11 Oct 2006 18:46:21 +0000 |
CVSROOT: /sources/phpgwapi
Module name: phpgwapi
Changes by: Sigurd Nes <sigurdne> 06/10/11 18:46:21
Modified files:
inc : class.acl.inc.php
Log message:
Simplify the shm code - and fix setting of new rights with shm enabled
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.acl.inc.php?cvsroot=phpgwapi&r1=1.94&r2=1.95
Patches:
Index: class.acl.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.acl.inc.php,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- class.acl.inc.php 11 Oct 2006 10:40:29 -0000 1.94
+++ class.acl.inc.php 11 Oct 2006 18:46:21 -0000 1.95
@@ -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.94 2006/10/11 10:40:29 sigurdne
Exp $
+ * @version $Id: class.acl.inc.php,v 1.95 2006/10/11 18:46:21 sigurdne
Exp $
*/
/**
@@ -46,9 +46,9 @@
var $db;
/**
- * @var bool $loaded_from_shm ACL data loaded from shared memory
+ * @var bool $load_from_shm ACL data loaded from shared memory
*/
- var $loaded_from_shm;
+ var $load_from_shm;
/**
* ACL constructor for setting account id
@@ -78,24 +78,7 @@
if (
isset($GLOBALS['phpgw_info']['server']['shm_lang']) &&
$GLOBALS['phpgw_info']['server']['shm_lang']
&& function_exists('sem_get'))
{
- if ( (!isset($this->data) ||
count($this->data)==0))
- {
- if($this->data =
$GLOBALS['phpgw']->shm->get_value($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data'))
- {
-//_debug_array($this->data);
-//die();
- }
- else
- {
- $this->populate_shm();
- }
-
- $this->loaded_from_shm = true;
- }
- }
- elseif ( !isset($this->data) || !is_array($this->data) )
- {
- $this->data = array();
+ $this->load_from_shm = true;
}
}
@@ -166,15 +149,6 @@
$this->acl();
}
- if(isset($this->loaded_from_shm) &&
$this->loaded_from_shm)
- {
- if(count($this->data)==0)
- {
- $this->data =
$GLOBALS['phpgw']->shm->get_value($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data');
- }
- }
- else
- {
if (
$GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' )
{
return
$this->_read_repository_ldap($account_type);
@@ -184,7 +158,6 @@
return
$this->_read_repository_sql($account_type);
}
}
- }
/**
* Get acl records
@@ -397,6 +370,12 @@
}
$this->db->transaction_commit();
+
+ if($this->load_from_shm)
+ {
+
$GLOBALS['phpgw']->shm->delete_key($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data_' . $this->account_id);
+ }
+
return $unique_data;
}
@@ -425,9 +404,20 @@
if (!isset($this->data[$this->account_id]) ||
count($this->data[$this->account_id]) == 0)
{
+ if($this->load_from_shm)
+ {
+ if(!$this->data[$this->account_id] =
$GLOBALS['phpgw']->shm->get_value($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data_' . $this->account_id))
+ {
$this->read_repository($account_type);
+
$GLOBALS['phpgw']->shm->store_value($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data_' . $this->account_id,$this->data[$this->account_id]);
+ }
}
- if(isset($this->data[$this->account_id]))
+ else
+ {
+ $this->read_repository($account_type);
+ }
+ }
+ if(isset($this->data[$this->account_id]) &&
is_array($this->data[$this->account_id]))
{
reset ($this->data[$this->account_id]);
}
@@ -442,11 +432,12 @@
// return True;
}
$rights = 0;
- //for ($idx = 0; $idx < $count; ++$idx){
- if(isset($this->data[$this->account_id]))
+
+/* if(isset($this->data[$this->account_id]))
{
reset ($this->data[$this->account_id]);
}
+*/
if(isset($this->data[$this->account_id]) &&
is_array($this->data[$this->account_id]))
{
while(list($idx,$value) =
each($this->data[$this->account_id]))
@@ -1065,7 +1056,7 @@
*/
function _read_repository_ldap($account_type)
{
- // $this->data = array();
+ $this->data[$this->account_id] = array();
if(!$account_type || $account_type == 'accounts' ||
$account_type == 'both')
{
@@ -1123,7 +1114,7 @@
*/
function _read_repository_sql($account_type)
{
- // $this->data = array();
+ $this->data[$this->account_id] = array();
if(!$account_type || $account_type == 'accounts' ||
$account_type == 'both')
{
@@ -1169,60 +1160,4 @@
}
return $this->data;
}
-
-
- /**
- * Reads ACL records for all users and groups and loads it into
shared memory
- *
- * @access private
- */
-
- function populate_shm()
- {
- $sql = "SELECT * FROM phpgw_accounts WHERE
account_status = 'A' ";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $active_accounts[] = array(
- 'account_id' =>
$this->db->f('account_id'),
- 'account_type' =>
$this->db->f('account_type'),
- );
- }
-
- foreach ($active_accounts as $entry)
- {
-
- if($entry['account_type']=='g')
- {
- $sql = "SELECT acl_account FROM
phpgw_acl WHERE acl_appname = 'phpgw_group' AND acl_location =" .
(int)$entry['account_id'];
-
$this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
-
$accounts[$this->db->f('acl_account')] = $this->db->f('acl_account');
- }
- }
- else
- {
- $accounts[$entry['account_id']] =
$entry['account_id'];
- }
- }
-
- unset($active_accounts);
-
- $sql = "SELECT account_id FROM phpgw_accounts WHERE
account_status = 'I'";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- unset($accounts[$this->db->f('account_id')]);
- }
-
- foreach($accounts as $account_id)
- {
- $this->account_id = $account_id;
- $this->read_repository();
- }
-//_debug_array($this->data);
-//die();
-
$GLOBALS['phpgw']->shm->store_value($GLOBALS['phpgw_info']['user']['domain'] .
'acl_data',$this->data);
- }
}
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Caeies, 2006/10/02
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Dave Hall, 2006/10/04
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/04
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/09
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/11
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/11
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php,
Sigurd Nes <=
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/22
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Dave Hall, 2006/10/22
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/23
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Dave Hall, 2006/10/23
- [Phpgroupware-cvs] phpgwapi/inc class.acl.inc.php, Sigurd Nes, 2006/10/23