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

@ -1,89 +1,134 @@
<?php <?php
/**************************************************************************\ /**************************************************************************\
* phpGroupWare API - Accounts manager shared functions * * phpGroupWare API - Accounts manager shared functions *
* This file written by Joseph Engo <jengo@phpgroupware.org> * * This file written by Joseph Engo <jengo@phpgroupware.org> *
* shared functions for other account repository managers * * shared functions for other account repository managers *
* Copyright (C) 2000, 2001 Joseph Engo * * Copyright (C) 2000, 2001 Joseph Engo *
* -------------------------------------------------------------------------* * -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API * * This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api * * http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ * * ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it * * This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by * * under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, * * the Free Software Foundation; either version 2.1 of the License, *
* or any later version. * * or any later version. *
* This library is distributed in the hope that it will be useful, but * * This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of * * WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. * * See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License * * You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/ \**************************************************************************/
/* $Id$ */ /* $Id$ */
class accounts extends accounts_ class accounts extends accounts_
{ {
/**************************************************************************\ /**************************************************************************\
* Standard constructor for setting $this->account_id * * Standard constructor for setting $this->account_id *
* 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)
{
global $phpgw, $phpgw_info;
$this->db = $phpgw->db;
if ($account_id != False){ $this->account_id = $account_id; }
}
function read() function accounts($account_id = False, $db = '')
{ {
if (count($this->data) == 0){ $this->read_repository(); } global $phpgw, $phpgw_info;
reset($this->data);
return $this->data;
}
function update_data($data) { if (! is_object($db))
reset($data); {
$this->data = Array(); $this->db = $phpgw->db;
$this->data = $data; }
reset($this->data); else
return $this->data; {
} $this->db = $db;
}
function memberships($account_id = False) if (! isset($account_id))
{ {
global $phpgw_info, $phpgw; $this->account_id = $account_id;
if ($account_id == False){ $account_id = $phpgw_info['user']['account_id']; } }
elseif (gettype($account_id) == 'string') { $account_id = $this->name2id($account_id); } }
$security_equals = Array(); function read()
$security_equals = $phpgw->acl->get_location_list_for_id('phpgw_group', 1, intval($account_id)); {
if ($security_equals == False) { return False; } if (count($this->data) == 0)
for ($idx=0; $idx<count($security_equals); $idx++){ {
$name = $this->id2name(intval($security_equals[$idx])); $this->read_repository();
$this->memberships[] = Array('account_id' => $security_equals[$idx], 'account_name' => "$name"); }
}
return $this->memberships;
}
function members ($account_id = False) reset($this->data);
{ return $this->data;
global $phpgw_info, $phpgw; }
if ($account_id == False){ $account_id = $phpgw_info['user']['account_id']; }
elseif (gettype($account_id) == 'string') { $account_id = $this->name2id($account_id); }
$security_equals = Array(); function update_data($data)
$acl = CreateObject('phpgwapi.acl'); {
$security_equals = $acl->get_ids_for_location(intval($account_id), 1, 'phpgw_group'); reset($data);
unset($acl); $this->data = Array();
if ($security_equals == False) { return False; } $this->data = $data;
for ($idx=0; $idx<count($security_equals); $idx++){
$name = $this->id2name(intval($security_equals[$idx])); reset($this->data);
$this->members[] = Array('account_id' => intval($security_equals[$idx]), 'account_name' => "$name"); return $this->data;
} }
return $this->members;
} function memberships($account_id = False)
} {
global $phpgw_info, $phpgw;
if ($account_id == False)
{
$account_id = $phpgw_info['user']['account_id'];
}
elseif (gettype($account_id) == 'string')
{
$account_id = $this->name2id($account_id);
}
$security_equals = Array();
$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++)
{
$name = $this->id2name(intval($security_equals[$idx]));
$this->memberships[] = Array('account_id' => $security_equals[$idx], 'account_name' => $name);
}
return $this->memberships;
}
function members ($account_id = False)
{
global $phpgw_info, $phpgw;
if ($account_id == False)
{
$account_id = $phpgw_info['user']['account_id'];
}
elseif (gettype($account_id) == 'string')
{
$account_id = $this->name2id($account_id);
}
$security_equals = Array();
$acl = CreateObject('phpgwapi.acl');
$security_equals = $acl->get_ids_for_location(intval($account_id), 1, 'phpgw_group');
unset($acl);
if ($security_equals == False)
{
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;
}
}
?> ?>