allow to optional specify a database object (to access addressbooks in other databases)

This commit is contained in:
Ralf Becker 2010-07-30 15:32:48 +00:00
parent 39d1c63517
commit b01231a5cf
3 changed files with 30 additions and 11 deletions

View File

@ -7,7 +7,7 @@
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @author Joerg Lehrke <jlehrke@noc.de>
* @package addressbook
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
@ -144,9 +144,15 @@ class addressbook_bo extends addressbook_so
*/
protected $delete_history = '';
function __construct($contact_app='addressbook')
/**
* Constructor
*
* @param string $contact_app='addressbook' used for acl->get_grants()
* @param egw_db $db=null
*/
function __construct($contact_app='addressbook',egw_db $db=null)
{
parent::__construct($contact_app);
parent::__construct($contact_app,$db);
if ($this->log)
{
$this->logfile = $GLOBALS['egw_info']['server']['temp_dir'].'/log-addressbook_bo';
@ -1207,6 +1213,7 @@ class addressbook_bo extends addressbook_so
if($options['start'] || $options['num_rows']) {
$limit = array($options['start'], $options['num_rows']);
}
$filter = (array)$options['filter'];
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
if (($contacts = parent::search($criteria,false,'org_name,n_family,n_given,cat_id','','%',false,'OR', $limit, $filter)))
{

View File

@ -6,7 +6,7 @@
* @author Cornelius Weiss <egw-AT-von-und-zu-weiss.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
@ -205,9 +205,15 @@ class addressbook_so
var $sodistrib_list;
var $backend;
function __construct($contact_app='addressbook')
/**
* Constructor
*
* @param string $contact_app='addressbook' used for acl->get_grants()
* @param egw_db $db=null
*/
function __construct($contact_app='addressbook',egw_db $db=null)
{
$this->db = $GLOBALS['egw']->db;
$this->db = is_null($db) ? $GLOBALS['egw']->db : $db;
$this->user = $GLOBALS['egw_info']['user']['account_id'];
$this->memberships = $GLOBALS['egw']->accounts->memberships($this->user,true);
@ -244,7 +250,7 @@ class addressbook_so
{
$this->contact_repository = 'sql-ldap';
}
$this->somain = new addressbook_sql();
$this->somain = new addressbook_sql($db);
if ($this->user) // not set eg. in setup
{
@ -303,7 +309,7 @@ class addressbook_so
}
else
{
$this->soextra = new addressbook_sql();
$this->soextra = new addressbook_sql($db);
}
$this->customfields = config::get_customfields('addressbook');

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -54,9 +54,15 @@ class addressbook_sql extends so_sql_cf
*/
var $ab2list_table = 'egw_addressbook2list';
function __construct()
/**
* Constructor
*
* @param egw_db $db=null
*/
function __construct(egw_db $db=null)
{
parent::__construct('phpgwapi','egw_addressbook','egw_addressbook_extra','contact_');
parent::__construct('phpgwapi','egw_addressbook','egw_addressbook_extra','contact_',
$extra_key='_name',$extra_value='_value',$extra_id='_id',$db);
// Get custom fields from addressbook instead of phpgwapi
$this->customfields = config::get_customfields('addressbook');