[Top][All Lists]
[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: |
Thu, 20 Jul 2006 04:38:11 +0000 |
CVSROOT: /cvsroot/phpgwapi
Module name: phpgwapi
Changes by: Dave Hall <skwashd> 06/07/20 04:38:11
Modified files:
inc : class.acl.inc.php
Log message:
make it work again with LDAP accts :)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.acl.inc.php?cvsroot=phpgwapi&r1=1.80&r2=1.81
Patches:
Index: class.acl.inc.php
===================================================================
RCS file: /cvsroot/phpgwapi/phpgwapi/inc/class.acl.inc.php,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -b -r1.80 -r1.81
--- class.acl.inc.php 9 Jul 2006 14:26:39 -0000 1.80
+++ class.acl.inc.php 20 Jul 2006 04:38:11 -0000 1.81
@@ -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.80 2006/07/09 14:26:39 skwashd
Exp $
+ * @version $Id: class.acl.inc.php,v 1.81 2006/07/20 04:38:11 skwashd
Exp $
*/
/**
@@ -62,7 +62,7 @@
if (!($this->account_id = intval($account_id)))
{
- $this->account_id =
get_account_id($account_id,@$GLOBALS['phpgw_info']['user']['account_id']);
+ $this->account_id = get_account_id($account_id,
(int)$GLOBALS['phpgw_info']['user']['account_id']);
}
}
@@ -118,63 +118,29 @@
/**
* Reads ACL records from database and return array along with
storing it
*
+ * @param string $account_type the type of accounts sought
accounts|groups
* @return array Array with ACL records
* @access private
*/
function read_repository($account_type = 'both')
{
- // For some reason, calling this via XML-RPC doesn't
call the constructor.
- // Here is yet another work around(tm) (jengo)
+ /*
+ For some reason, calling this via XML-RPC doesn't call
the constructor.
+ Here is yet another work around(tm) (jengo)
+ */
if (! $this->account_id)
{
$this->acl();
}
- $sql = "select * from phpgw_acl $this->join
phpgw_accounts on phpgw_acl.acl_account = phpgw_accounts.account_id where
(acl_account in (";
-
- if(!$account_type || $account_type == 'accounts' ||
$account_type == 'both')
+ if (
$GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' )
{
- $account_list[] = $this->account_id;
- $account_list[] = 0;
+ return
$this->_read_repository_ldap($account_type);
}
-
- if($account_type == 'groups' || $account_type == 'both')
- {
- $groups =
$this->get_location_list_for_id('phpgw_group', 1, $this->account_id);
- while($groups && (list($key,$value) =
each($groups)))
+ else
{
- $account_list[] = $value;
- }
+ return
$this->_read_repository_sql($account_type);
}
-
- if(!is_array($account_list))
- {
- return;
- }
-
- $account_list = implode(",",$account_list);
-
- $sql .= $account_list . '))';
- $this->db->query($sql ,__LINE__,__FILE__);
- $count = $this->db->num_rows();
- $this->data = array();
- for ($idx = 0; $idx < $count; ++$idx)
- {
- //reset ($this->data);
- //while(list($idx,$value) = each($this->data)){
- $this->db->next_record();
- $this->data[] = array(
- 'appname' =>
$this->db->f('acl_appname'),
- 'location' =>
$this->db->f('acl_location'),
- 'account' =>
$this->db->f('acl_account'),
- 'rights' => $this->db->f('acl_rights'),
- 'grantor' =>
$this->db->f('acl_grantor'),
- 'type' => $this->db->f('acl_type'),
- 'account_type' =>
$this->db->f('account_type')
- );
- }
- reset ($this->data);
- return $this->data;
}
/**
@@ -1017,4 +983,114 @@
}
}
}
+
+ /**
+ * Reads ACL records from database for LDAP accounts and return
array and caches the data for future look ups
+ *
+ * @param string $account_type the type of accounts sought
accounts|groups
+ * @return array Array with ACL records
+ * @access private
+ */
+ function _read_repository_ldap($account_type)
+ {
+ $this->data = array();
+
+ if(!$account_type || $account_type == 'accounts' ||
$account_type == 'both')
+ {
+ $account_list[] = $this->account_id;
+ $account_list[] = 0;
+ }
+
+ if($account_type == 'groups' || $account_type == 'both')
+ {
+ $groups =
$this->get_location_list_for_id('phpgw_group', 1, $this->account_id);
+ if ( is_array($groups) && count($groups) )
+ {
+ foreach ( $groups as $key => $value )
+ {
+ $account_list[] =
$value;
+ }
+ }
+ }
+
+ if(!is_array($account_list))
+ {
+ return array();
+ }
+
+ $sql = 'SELECT * FROM phpgw_acl WHERE acl_account in ('
. implode(',', $account_list) . ')';
+
+ $this->db->query($sql ,__LINE__,__FILE__);
+
+ while ( $this->db->next_record() )
+ {
+ $this->data[] = array
+ (
+ 'appname' =>
$this->db->f('acl_appname'),
+ 'location' =>
$this->db->f('acl_location'),
+ 'account' =>
$this->db->f('acl_account'),
+ 'rights' =>
$this->db->f('acl_rights'),
+ 'grantor' =>
$this->db->f('acl_grantor'),
+ 'type' =>
$this->db->f('acl_type'),
+ 'account_type' =>
$GLOBALS['phpgw']->accounts->get_type($this->db->f('account_type'))
+ );
+ }
+ return $this->data;
+ }
+
+ /**
+ * Reads ACL records from database for SQL accounts and return
array and caches the data for future look ups
+ *
+ * @param string $account_type the type of accounts sought
accounts|groups
+ * @return array Array with ACL records
+ * @access private
+ */
+ function _read_repository_sql($account_type)
+ {
+ $this->data = array();
+
+ if(!$account_type || $account_type == 'accounts' ||
$account_type == 'both')
+ {
+ $account_list[] = $this->account_id;
+ $account_list[] = 0;
+ }
+
+ if($account_type == 'groups' || $account_type == 'both')
+ {
+ $groups =
$this->get_location_list_for_id('phpgw_group', 1, $this->account_id);
+ if ( is_array($groups) && count($groups) )
+ {
+ foreach ( $groups as $key => $value )
+ {
+ $account_list[] =
$value;
+ }
+ }
+ }
+
+ if(!is_array($account_list))
+ {
+ return array();
+ }
+
+ $sql = 'SELECT * FROM phpgw_acl '
+ . "{$this->join} phpgw_accounts ON
phpgw_acl.acl_account = phpgw_accounts.account_id "
+ . 'WHERE acl_account in (' . implode(',',
$account_list) . ')';
+
+ $this->db->query($sql ,__LINE__,__FILE__);
+
+ while ( $this->db->next_record() )
+ {
+ $this->data[] = array
+ (
+ 'appname' =>
$this->db->f('acl_appname'),
+ 'location' =>
$this->db->f('acl_location'),
+ 'account' =>
$this->db->f('acl_account'),
+ 'rights' =>
$this->db->f('acl_rights'),
+ 'grantor' =>
$this->db->f('acl_grantor'),
+ 'type' =>
$this->db->f('acl_type'),
+ 'account_type' =>
$this->db->f('account_type')
+ );
+ }
+ return $this->data;
+ }
}