Added ability to pass the database handle to the accounts const

This commit is contained in:
jengo 2001-03-09 23:21:52 +00:00
parent a3f62fa7cf
commit 4fc5186eb8

View File

@ -30,24 +30,43 @@
* This constructor sets the account id, if string is sent, converts to id * * This constructor sets the account id, if string is sent, converts to id *
* I might move this to the accounts_shared if it stays around * * I might move this to the accounts_shared if it stays around *
\**************************************************************************/ \**************************************************************************/
function accounts($account_id = False)
function accounts($account_id = False, $db = '')
{ {
global $phpgw, $phpgw_info; global $phpgw, $phpgw_info;
if (! is_object($db))
{
$this->db = $phpgw->db; $this->db = $phpgw->db;
if ($account_id != False){ $this->account_id = $account_id; } }
else
{
$this->db = $db;
}
if (! isset($account_id))
{
$this->account_id = $account_id;
}
} }
function read() function read()
{ {
if (count($this->data) == 0){ $this->read_repository(); } if (count($this->data) == 0)
{
$this->read_repository();
}
reset($this->data); reset($this->data);
return $this->data; return $this->data;
} }
function update_data($data) { function update_data($data)
{
reset($data); reset($data);
$this->data = Array(); $this->data = Array();
$this->data = $data; $this->data = $data;
reset($this->data); reset($this->data);
return $this->data; return $this->data;
} }
@ -55,34 +74,60 @@
function memberships($account_id = False) function memberships($account_id = False)
{ {
global $phpgw_info, $phpgw; global $phpgw_info, $phpgw;
if ($account_id == False){ $account_id = $phpgw_info['user']['account_id']; } if ($account_id == False)
elseif (gettype($account_id) == 'string') { $account_id = $this->name2id($account_id); } {
$account_id = $phpgw_info['user']['account_id'];
}
elseif (gettype($account_id) == 'string')
{
$account_id = $this->name2id($account_id);
}
$security_equals = Array(); $security_equals = Array();
$security_equals = $phpgw->acl->get_location_list_for_id('phpgw_group', 1, intval($account_id)); $security_equals = $phpgw->acl->get_location_list_for_id('phpgw_group', 1, intval($account_id));
if ($security_equals == False) { return False; }
for ($idx=0; $idx<count($security_equals); $idx++){ if ($security_equals == False)
$name = $this->id2name(intval($security_equals[$idx])); {
$this->memberships[] = Array('account_id' => $security_equals[$idx], 'account_name' => "$name"); return False;
} }
for ($idx=0; $idx<count($security_equals); $idx++)
{
$name = $this->id2name(intval($security_equals[$idx]));
$this->memberships[] = Array('account_id' => $security_equals[$idx], 'account_name' => $name);
}
return $this->memberships; return $this->memberships;
} }
function members ($account_id = False) function members ($account_id = False)
{ {
global $phpgw_info, $phpgw; global $phpgw_info, $phpgw;
if ($account_id == False){ $account_id = $phpgw_info['user']['account_id']; } if ($account_id == False)
elseif (gettype($account_id) == 'string') { $account_id = $this->name2id($account_id); } {
$account_id = $phpgw_info['user']['account_id'];
}
elseif (gettype($account_id) == 'string')
{
$account_id = $this->name2id($account_id);
}
$security_equals = Array(); $security_equals = Array();
$acl = CreateObject('phpgwapi.acl'); $acl = CreateObject('phpgwapi.acl');
$security_equals = $acl->get_ids_for_location(intval($account_id), 1, 'phpgw_group'); $security_equals = $acl->get_ids_for_location(intval($account_id), 1, 'phpgw_group');
unset($acl); unset($acl);
if ($security_equals == False) { return False; }
for ($idx=0; $idx<count($security_equals); $idx++){ if ($security_equals == False)
$name = $this->id2name(intval($security_equals[$idx])); {
$this->members[] = Array('account_id' => intval($security_equals[$idx]), 'account_name' => "$name"); return False;
} }
for ($idx=0; $idx<count($security_equals); $idx++)
{
$name = $this->id2name(intval($security_equals[$idx]));
$this->members[] = Array('account_id' => intval($security_equals[$idx]), 'account_name' => $name);
}
return $this->members; return $this->members;
} }
} }