mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-11 16:38:52 +01:00
moved the existing caching-code into the shared class and implemented caching for get_list
This commit is contained in:
parent
32a2083cbb
commit
b58f7c344d
@ -602,25 +602,12 @@
|
||||
|
||||
function name2id($account_lid)
|
||||
{
|
||||
static $name_list;
|
||||
|
||||
if(@isset($name_list[$account_lid]) && $name_list[$account_lid])
|
||||
{
|
||||
return $name_list[$account_lid];
|
||||
}
|
||||
|
||||
/* Don't bother searching for empty account_lid */
|
||||
if(empty($account_lid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
$sri = ldap_search($this->ds, $this->group_context, '(&(cn=' . (string)$account_lid . ')(phpgwaccounttype=g))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if (@$allValues[0]['gidnumber'][0])
|
||||
{
|
||||
$name_list[$account_lid] = (int)$allValues[0]['gidnumber'][0];
|
||||
return (int)$allValues[0]['gidnumber'][0];
|
||||
}
|
||||
|
||||
$sri = ldap_search($this->ds, $this->user_context, '(&(uid=' . (string)$account_lid . ')(phpgwaccounttype=u))');
|
||||
@ -629,29 +616,21 @@
|
||||
|
||||
if (@$allValues[0]['uidnumber'][0])
|
||||
{
|
||||
$name_list[$account_lid] = (int)$allValues[0]['uidnumber'][0];
|
||||
return (int)$allValues[0]['uidnumber'][0];
|
||||
}
|
||||
|
||||
return $name_list[$account_lid];
|
||||
return False;
|
||||
}
|
||||
|
||||
function id2name($account_id)
|
||||
{
|
||||
static $id_list;
|
||||
|
||||
if(isset($id_list[$account_id]))
|
||||
{
|
||||
return $id_list[$account_id];
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->group_context, '(&(gidnumber=' . (int)$account_id . ')(phpgwaccounttype=g))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if (@$allValues[0]['cn'][0])
|
||||
{
|
||||
$id_list[$account_id] = $allValues[0]['cn'][0];
|
||||
return $id_list[$account_id];
|
||||
return $allValues[0]['cn'][0];
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
@ -660,36 +639,20 @@
|
||||
|
||||
if (@$allValues[0]['uid'][0])
|
||||
{
|
||||
$id_list[$account_id] = $allValues[0]['uid'][0];
|
||||
return $id_list[$account_id];
|
||||
return $allValues[0]['uid'][0];
|
||||
}
|
||||
|
||||
return $id_list[$account_id];
|
||||
return False;
|
||||
}
|
||||
|
||||
function get_type($accountid = '')
|
||||
function get_type($account_id)
|
||||
{
|
||||
static $account_type;
|
||||
$account_id = get_account_id($accountid);
|
||||
|
||||
if (isset($this->account_type) && $account_id == $this->account_id)
|
||||
{
|
||||
return $this->account_type;
|
||||
}
|
||||
|
||||
if(@isset($account_type[$account_id]) && @$account_type[$account_id])
|
||||
{
|
||||
return $account_type[$account_id];
|
||||
}
|
||||
$allValues = array();
|
||||
$sri = ldap_search($this->ds, $this->user_context, '(&(uidnumber=' . (int)$account_id . ')(phpgwaccounttype=u))');
|
||||
$allValues = ldap_get_entries($this->ds, $sri);
|
||||
|
||||
if ($allValues[0]['phpgwaccounttype'][0])
|
||||
{
|
||||
$allValues[0]['phpgwaccounttype'][0];
|
||||
$account_type[$account_id] = $allValues[0]['phpgwaccounttype'][0];
|
||||
return $account_type[$account_id];
|
||||
return $allValues[0]['phpgwaccounttype'][0];
|
||||
}
|
||||
|
||||
$allValues = array();
|
||||
@ -698,10 +661,9 @@
|
||||
|
||||
if ($allValues[0]['phpgwaccounttype'][0])
|
||||
{
|
||||
$account_type[$account_id] = $allValues[0]['phpgwaccounttype'][0];
|
||||
return $account_type[$account_id];
|
||||
return $allValues[0]['phpgwaccounttype'][0];
|
||||
}
|
||||
return $account_type[$account_id];
|
||||
return False;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1064,16 +1026,6 @@
|
||||
|
||||
function get_account_name($accountid,&$lid,&$fname,&$lname)
|
||||
{
|
||||
static $account_name;
|
||||
|
||||
$account_id = get_account_id($accountid);
|
||||
if(isset($account_name[$account_id]))
|
||||
{
|
||||
$lid = $account_name[$account_id]['lid'];
|
||||
$fname = $account_name[$account_id]['fname'];
|
||||
$lname = $account_name[$account_id]['lname'];
|
||||
return;
|
||||
}
|
||||
$acct_type = $this->get_type($account_id);
|
||||
|
||||
/* search the dn for the given uid */
|
||||
@ -1089,34 +1041,17 @@
|
||||
|
||||
if($acct_type =='g')
|
||||
{
|
||||
$account_name[$account_id]['lid'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
|
||||
$account_name[$account_id]['fname'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
|
||||
$account_name[$account_id]['lname'] = lang('Group');
|
||||
$lid = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
|
||||
$fname = $GLOBALS['phpgw']->translation->convert($allValues[0]['cn'][0],'utf-8');
|
||||
$lname = lang('Group');
|
||||
}
|
||||
else
|
||||
{
|
||||
$account_name[$account_id]['lid'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['uid'][0],'utf-8');
|
||||
$account_name[$account_id]['fname'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['givenname'][0],'utf-8');
|
||||
$account_name[$account_id]['lname'] = $GLOBALS['phpgw']->translation->convert($allValues[0]['sn'][0],'utf-8');
|
||||
$lid = $GLOBALS['phpgw']->translation->convert($allValues[0]['uid'][0],'utf-8');
|
||||
$fname = $GLOBALS['phpgw']->translation->convert($allValues[0]['givenname'][0],'utf-8');
|
||||
$lname = $GLOBALS['phpgw']->translation->convert($allValues[0]['sn'][0],'utf-8');
|
||||
}
|
||||
$lid = $account_name[$account_id]['lid'];
|
||||
$fname = $account_name[$account_id]['fname'];
|
||||
$lname = $account_name[$account_id]['lname'];
|
||||
return;
|
||||
}
|
||||
|
||||
function get_account_data($account_id)
|
||||
{
|
||||
$this->account_id = $account_id;
|
||||
$this->read_repository();
|
||||
|
||||
$data[$this->data['account_id']]['lid'] = $this->data['account_lid'];
|
||||
$data[$this->data['account_id']]['firstname'] = $this->data['firstname'];
|
||||
$data[$this->data['account_id']]['lastname'] = $this->data['lastname'];
|
||||
$data[$this->data['account_id']]['fullname'] = $this->data['fullname'];
|
||||
$data[$this->data['account_id']]['type'] = $this->data['account_type'];
|
||||
|
||||
return $data;
|
||||
return !empty($lid);
|
||||
}
|
||||
|
||||
function getDNforID($_accountid = '')
|
||||
|
@ -112,6 +112,39 @@
|
||||
);
|
||||
}
|
||||
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '')
|
||||
{
|
||||
static $account_list;
|
||||
|
||||
// For XML-RPC
|
||||
if (is_array($_type))
|
||||
{
|
||||
$p = $_type[0];
|
||||
$_type = $p['type'];
|
||||
$start = $p['start'];
|
||||
$order = $p['order'];
|
||||
$query = $p['query'];
|
||||
$offset = $p['offset'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$p = array(
|
||||
'type' => $_type,
|
||||
'start' => $start,
|
||||
'order' => $order,
|
||||
'query' => $query,
|
||||
'offset' => $offset
|
||||
);
|
||||
}
|
||||
$serial = serialize($p);
|
||||
|
||||
if (isset($account_list[$serial]))
|
||||
{
|
||||
return $account_list[$serial];
|
||||
}
|
||||
return $account_list[$serial] = accounts_::get_list($_type,$start,$sort,$order,$query,$offset);
|
||||
}
|
||||
|
||||
function is_expired()
|
||||
{
|
||||
if ($this->data['expires'] != -1 && $this->data['expires'] < time())
|
||||
@ -147,14 +180,21 @@
|
||||
|
||||
function membership($accountid = '')
|
||||
{
|
||||
static $membership_list;
|
||||
|
||||
$account_id = get_account_id($accountid);
|
||||
|
||||
if (isset($membership_list[$account_id]))
|
||||
{
|
||||
return $membership_list[$account_id];
|
||||
}
|
||||
|
||||
$security_equals = Array();
|
||||
$security_equals = $GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id);
|
||||
|
||||
if ($security_equals == False)
|
||||
{
|
||||
return False;
|
||||
return $membership_list[$account_id] = False;
|
||||
}
|
||||
|
||||
$this->memberships = Array();
|
||||
@ -165,7 +205,7 @@
|
||||
$this->memberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups));
|
||||
}
|
||||
|
||||
return $this->memberships;
|
||||
return $membership_list[$account_id] = $this->memberships;
|
||||
}
|
||||
|
||||
function member($accountid = '')
|
||||
@ -244,6 +284,96 @@
|
||||
return $nextid;
|
||||
}
|
||||
|
||||
function name2id($account_lid)
|
||||
{
|
||||
static $name_list;
|
||||
|
||||
if(@isset($name_list[$account_lid]) && $name_list[$account_lid])
|
||||
{
|
||||
return $name_list[$account_lid];
|
||||
}
|
||||
|
||||
/* Don't bother searching for empty account_lid */
|
||||
if(empty($account_lid))
|
||||
{
|
||||
return False;
|
||||
}
|
||||
return $name_list[$account_lid] = accounts_::name2id($account_lid);
|
||||
}
|
||||
|
||||
function id2name($account_id)
|
||||
{
|
||||
static $id_list;
|
||||
|
||||
if (! $account_id)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if($id_list[$account_id])
|
||||
{
|
||||
return $id_list[$account_id];
|
||||
}
|
||||
return $id_list[$account_id] = accounts_::id2name($account_id);
|
||||
}
|
||||
|
||||
function get_type($accountid)
|
||||
{
|
||||
static $account_type;
|
||||
$account_id = get_account_id($accountid);
|
||||
|
||||
if (isset($this->account_type) && $account_id == $this->account_id)
|
||||
{
|
||||
return $this->account_type;
|
||||
}
|
||||
|
||||
if(@isset($account_type[$account_id]) && @$account_type[$account_id])
|
||||
{
|
||||
return $account_type[$account_id];
|
||||
}
|
||||
elseif($account_id == '')
|
||||
{
|
||||
return False;
|
||||
}
|
||||
return $account_type[$account_id] = accounts_::get_type($account_id);
|
||||
}
|
||||
|
||||
function get_account_name($accountid,&$lid,&$fname,&$lname)
|
||||
{
|
||||
static $account_name;
|
||||
|
||||
$account_id = get_account_id($accountid);
|
||||
if(isset($account_name[$account_id]))
|
||||
{
|
||||
$lid = $account_name[$account_id]['lid'];
|
||||
$fname = $account_name[$account_id]['fname'];
|
||||
$lname = $account_name[$account_id]['lname'];
|
||||
return $account_name[$account_id] !== False;
|
||||
}
|
||||
$Ok = accounts_::get_account_name($accountid,&$lid,&$fname,&$lname);
|
||||
|
||||
$account_name[$account_id] = array(
|
||||
'lid' => $lid,
|
||||
'fname' => $fname,
|
||||
'lname' => $lname,
|
||||
);
|
||||
return $Ok;
|
||||
}
|
||||
|
||||
function get_account_data($account_id)
|
||||
{
|
||||
$this->account_id = $account_id;
|
||||
$this->read_repository();
|
||||
|
||||
$data[$this->data['account_id']]['lid'] = $this->data['account_lid'];
|
||||
$data[$this->data['account_id']]['firstname'] = $this->data['firstname'];
|
||||
$data[$this->data['account_id']]['lastname'] = $this->data['lastname'];
|
||||
$data[$this->data['account_id']]['fullname'] = $this->data['fullname'];
|
||||
$data[$this->data['account_id']]['type'] = $this->data['account_type'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function accounts_popup($app)
|
||||
{
|
||||
$group_id = get_var('group_id',array('GET','POST'));
|
||||
@ -257,7 +387,7 @@
|
||||
{
|
||||
$GLOBALS['query'] = $_POST['query'];
|
||||
}
|
||||
|
||||
|
||||
if(isset($_POST['start']))
|
||||
{
|
||||
$start = (int)$_POST['start'];
|
||||
|
@ -130,17 +130,6 @@
|
||||
|
||||
function get_list($_type='both',$start = '',$sort = '', $order = '', $query = '', $offset = '')
|
||||
{
|
||||
// For XML-RPC
|
||||
/* if (is_array($_type))
|
||||
{
|
||||
$p = $_type;
|
||||
$_type = $p[0]['type'];
|
||||
$start = $p[0]['start'];
|
||||
$order = $p[0]['order'];
|
||||
$query = $p[0]['query'];
|
||||
$offset = $p[0]['offset'];
|
||||
}
|
||||
*/
|
||||
if (! $sort)
|
||||
{
|
||||
$sort = "DESC";
|
||||
@ -219,89 +208,35 @@
|
||||
|
||||
function name2id($account_lid)
|
||||
{
|
||||
static $name_list;
|
||||
|
||||
if (! $account_lid)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if($name_list[$account_lid] && $name_list[$account_lid] != '')
|
||||
{
|
||||
return $name_list[$account_lid];
|
||||
}
|
||||
|
||||
$this->db->query("SELECT account_id FROM phpgw_accounts WHERE account_lid='".$this->db->db_addslashes($account_lid)."'",__LINE__,__FILE__);
|
||||
if($this->db->num_rows())
|
||||
{
|
||||
$this->db->next_record();
|
||||
$name_list[$account_lid] = (int)$this->db->f('account_id');
|
||||
return (int)$this->db->f('account_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
$name_list[$account_lid] = False;
|
||||
}
|
||||
return $name_list[$account_lid];
|
||||
return False;
|
||||
}
|
||||
|
||||
function id2name($account_id)
|
||||
{
|
||||
static $id_list;
|
||||
|
||||
if (! $account_id)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if($id_list[$account_id])
|
||||
{
|
||||
return $id_list[$account_id];
|
||||
}
|
||||
|
||||
$this->db->query('SELECT account_lid FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
||||
if($this->db->num_rows())
|
||||
{
|
||||
$this->db->next_record();
|
||||
$id_list[$account_id] = $this->db->f('account_lid');
|
||||
return $this->db->f('account_lid');
|
||||
}
|
||||
else
|
||||
{
|
||||
$id_list[$account_id] = False;
|
||||
}
|
||||
return $id_list[$account_id];
|
||||
return False;
|
||||
}
|
||||
|
||||
function get_type($accountid)
|
||||
function get_type($account_id)
|
||||
{
|
||||
static $account_type;
|
||||
$account_id = get_account_id($accountid);
|
||||
|
||||
if (isset($this->account_type) && $account_id == $this->account_id)
|
||||
{
|
||||
return $this->account_type;
|
||||
}
|
||||
|
||||
if(@isset($account_type[$account_id]) && @$account_type[$account_id])
|
||||
{
|
||||
return $account_type[$account_id];
|
||||
}
|
||||
elseif($account_id == '')
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$this->db->Halt_On_Error = 'no';
|
||||
$this->db->query('SELECT account_type FROM phpgw_accounts WHERE account_id=' . $account_id,__LINE__,__FILE__);
|
||||
$this->db->query('SELECT account_type FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$this->db->next_record();
|
||||
$account_type[$account_id] = $this->db->f('account_type');
|
||||
return $this->db->f('account_type');
|
||||
}
|
||||
else
|
||||
{
|
||||
$account_type[$account_id] = False;
|
||||
}
|
||||
$this->db->Halt_On_Error = 'yes';
|
||||
return $account_type[$account_id];
|
||||
return False;
|
||||
}
|
||||
|
||||
function exists($account_lid)
|
||||
@ -457,40 +392,17 @@
|
||||
|
||||
function get_account_name($accountid,&$lid,&$fname,&$lname)
|
||||
{
|
||||
static $account_name;
|
||||
|
||||
$account_id = get_account_id($accountid);
|
||||
if(isset($account_name[$account_id]))
|
||||
{
|
||||
$lid = $account_name[$account_id]['lid'];
|
||||
$fname = $account_name[$account_id]['fname'];
|
||||
$lname = $account_name[$account_id]['lname'];
|
||||
return;
|
||||
}
|
||||
$db = $GLOBALS['phpgw']->db;
|
||||
$db->query('SELECT account_lid,account_firstname,account_lastname FROM phpgw_accounts WHERE account_id=' . (int)$account_id,__LINE__,__FILE__);
|
||||
$db->next_record();
|
||||
$account_name[$account_id]['lid'] = $db->f('account_lid');
|
||||
$account_name[$account_id]['fname'] = $db->f('account_firstname');
|
||||
$account_name[$account_id]['lname'] = $db->f('account_lastname');
|
||||
$lid = $account_name[$account_id]['lid'];
|
||||
$fname = $account_name[$account_id]['fname'];
|
||||
$lname = $account_name[$account_id]['lname'];
|
||||
return;
|
||||
}
|
||||
if (!$db->next_record())
|
||||
{
|
||||
return False;
|
||||
}
|
||||
$lid = $db->f('account_lid');
|
||||
$fname = $db->f('account_firstname');
|
||||
$lname = $db->f('account_lastname');
|
||||
|
||||
function get_account_data($account_id)
|
||||
{
|
||||
$this->account_id = $account_id;
|
||||
$this->read_repository();
|
||||
|
||||
$data[$this->data['account_id']]['lid'] = $this->data['account_lid'];
|
||||
$data[$this->data['account_id']]['firstname'] = $this->data['firstname'];
|
||||
$data[$this->data['account_id']]['lastname'] = $this->data['lastname'];
|
||||
$data[$this->data['account_id']]['fullname'] = $this->data['fullname'];
|
||||
$data[$this->data['account_id']]['type'] = $this->data['account_type'];
|
||||
|
||||
return $data;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user