2001-07-08 15:54:40 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - addressbook *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Joseph Engo <jengo@mail.com> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
class soaddressbook
|
|
|
|
{
|
|
|
|
var $contacts;
|
|
|
|
var $rights;
|
2001-08-04 16:12:32 +02:00
|
|
|
var $grants;
|
|
|
|
var $owner;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
function soaddressbook()
|
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
if (!is_object($GLOBALS['phpgw']->contacts))
|
2001-08-23 06:29:20 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
$GLOBALS['phpgw']->contacts = CreateObject('phpgwapi.contacts');
|
2001-08-23 06:29:20 +02:00
|
|
|
}
|
2003-10-24 21:05:05 +02:00
|
|
|
$this->contacts = &$GLOBALS['phpgw']->contacts;
|
|
|
|
$this->grants = &$this->contacts->grants;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-08-23 06:29:20 +02:00
|
|
|
/* _debug_array($GLOBALS['phpgw_info']); */
|
|
|
|
/* _debug_array($grants); */
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-08-23 08:57:37 +02:00
|
|
|
function read_entries($data)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-23 08:57:37 +02:00
|
|
|
return $this->contacts->read(
|
|
|
|
$data['start'],
|
|
|
|
$data['limit'],
|
|
|
|
$data['fields'],
|
|
|
|
$data['query'],
|
|
|
|
$data['filter'],
|
|
|
|
$data['sort'],
|
2003-08-28 16:16:30 +02:00
|
|
|
$data['order']
|
2001-08-23 08:57:37 +02:00
|
|
|
);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function read_entry($id,$fields)
|
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
return $this->contacts->read_single_entry($id,$fields);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function read_last_entry($fields)
|
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
return $this->contacts->read_last_entry($fields);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-08-09 02:19:28 +02:00
|
|
|
function add_entry($fields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
$owner = $fields['owner'];
|
|
|
|
$access = $fields['access'];
|
|
|
|
$cat_id = $fields['cat_id'];
|
|
|
|
$tid = $fields['tid'];
|
|
|
|
unset($fields['owner']);
|
|
|
|
unset($fields['access']);
|
|
|
|
unset($fields['cat_id']);
|
|
|
|
unset($fields['ab_id']);
|
|
|
|
unset($fields['tid']);
|
2001-09-10 00:55:43 +02:00
|
|
|
|
2003-10-24 21:05:05 +02:00
|
|
|
return $this->contacts->add($owner,$fields,$access,$cat_id,$tid);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_lastid()
|
|
|
|
{
|
|
|
|
$entry = $this->contacts->read_last_entry();
|
2003-10-24 21:05:05 +02:00
|
|
|
return $entry[0]['id'];
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-08-09 02:19:28 +02:00
|
|
|
function update_entry($fields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
$ab_id = $fields['ab_id'];
|
|
|
|
$owner = $fields['owner'];
|
|
|
|
$access = $fields['access'];
|
|
|
|
$cat_id = $fields['cat_id'];
|
|
|
|
$tid = $fields['tid'];
|
|
|
|
unset($fields['owner']);
|
|
|
|
unset($fields['access']);
|
|
|
|
unset($fields['cat_id']);
|
|
|
|
unset($fields['ab_id']);
|
|
|
|
unset($fields['tid']);
|
2001-09-10 00:55:43 +02:00
|
|
|
|
2003-10-24 21:05:05 +02:00
|
|
|
return $this->contacts->update($ab_id,$owner,$fields,$access,$cat_id,$tid);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-12 06:09:12 +02:00
|
|
|
|
2003-10-24 21:05:05 +02:00
|
|
|
function delete_entry($id)
|
2001-07-12 06:09:12 +02:00
|
|
|
{
|
2003-10-24 21:05:05 +02:00
|
|
|
return $this->contacts->delete($id);
|
2001-07-12 06:09:12 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
?>
|