2006-11-10 16:35:35 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* eGroupWare - Addressbook - importexport
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package addressbook
|
|
|
|
* @subpackage importexport
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Cornelius Weiss <nelius@cwtech.de>
|
|
|
|
* @copyright Cornelius Weiss <nelius@cwtech.de>
|
2007-06-08 00:31:08 +02:00
|
|
|
* @version $Id: class.egw_addressbook_record.inc.php 22827 2006-11-10 15:35:35Z nelius_weiss $
|
2006-11-10 16:35:35 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-03-22 16:11:12 +01:00
|
|
|
* class addressbook_egw_record
|
2006-11-10 16:35:35 +01:00
|
|
|
* compability layer for iface_egw_record needet for importexport
|
|
|
|
*/
|
2010-03-22 16:11:12 +01:00
|
|
|
class addressbook_egw_record implements importexport_iface_egw_record
|
2006-11-10 16:35:35 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
private $identifier = '';
|
|
|
|
private $contact = array();
|
|
|
|
private $bocontacts;
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2011-05-12 20:01:34 +02:00
|
|
|
// Used in conversions
|
|
|
|
static $types = array(
|
2011-10-25 20:49:14 +02:00
|
|
|
'select-account' => array('owner','creator','modifier'),
|
|
|
|
'date-time' => array('modified','created','last_event','next_event'),
|
|
|
|
'date' => array('bday'),
|
|
|
|
'select-cat' => array('cat_id'),
|
2012-10-12 21:50:26 +02:00
|
|
|
'select' => array('tid')
|
2011-10-25 20:49:14 +02:00
|
|
|
);
|
2008-05-10 14:02:49 +02:00
|
|
|
|
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
* reads record from backend if identifier is given.
|
|
|
|
*
|
|
|
|
* @param string $_identifier
|
|
|
|
*/
|
|
|
|
public function __construct( $_identifier='' ){
|
|
|
|
$this->identifier = $_identifier;
|
2008-05-10 14:02:49 +02:00
|
|
|
$this->bocontacts = new addressbook_bo();
|
2010-11-19 19:35:37 +01:00
|
|
|
if($_identifier) {
|
|
|
|
$this->contact = $this->bocontacts->read($this->identifier);
|
|
|
|
}
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* magic method to set attributes of record
|
|
|
|
*
|
|
|
|
* @param string $_attribute_name
|
|
|
|
*/
|
|
|
|
public function __get($_attribute_name) {
|
2010-10-29 01:14:01 +02:00
|
|
|
return $this->contact[$_attribute_name];
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* magig method to set attributes of record
|
|
|
|
*
|
|
|
|
* @param string $_attribute_name
|
|
|
|
* @param data $data
|
|
|
|
*/
|
|
|
|
public function __set($_attribute_name, $data) {
|
2010-10-29 01:14:01 +02:00
|
|
|
$this->contact[$_attribute_name] = $data;
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
2008-05-10 14:02:49 +02:00
|
|
|
* converts this object to array.
|
2006-11-10 16:35:35 +01:00
|
|
|
* @abstract We need such a function cause PHP5
|
|
|
|
* dosn't allow objects do define it's own casts :-(
|
|
|
|
* once PHP can deal with object casts we will change to them!
|
|
|
|
*
|
|
|
|
* @return array complete record as associative array
|
|
|
|
*/
|
|
|
|
public function get_record_array() {
|
|
|
|
return $this->contact;
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* gets title of record
|
2008-05-10 14:02:49 +02:00
|
|
|
*
|
2006-11-10 16:35:35 +01:00
|
|
|
*@return string tiltle
|
|
|
|
*/
|
|
|
|
public function get_title() {
|
2012-10-16 20:45:13 +02:00
|
|
|
return $this->bocontacts->link_title(empty($this->contact) ? $this->identifier : $this->contact);
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* sets complete record from associative array
|
|
|
|
*
|
|
|
|
* @todo add some checks
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function set_record(array $_record){
|
|
|
|
$this->contact = $_record;
|
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* gets identifier of this record
|
|
|
|
*
|
|
|
|
* @return string identifier of current record
|
|
|
|
*/
|
|
|
|
public function get_identifier() {
|
2014-06-16 22:16:58 +02:00
|
|
|
return $this->identifier ? $this->identifier : $this->id;
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* saves record into backend
|
2008-05-10 14:02:49 +02:00
|
|
|
*
|
2006-11-10 16:35:35 +01:00
|
|
|
* @return string identifier
|
|
|
|
*/
|
|
|
|
public function save ( $_dst_identifier ) {
|
2014-06-16 22:16:58 +02:00
|
|
|
// Not yet implemeted
|
|
|
|
$this->identifier = $_dst_identifier;
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* copys current record to record identified by $_dst_identifier
|
|
|
|
*
|
|
|
|
* @param string $_dst_identifier
|
|
|
|
* @return string dst_identifier
|
|
|
|
*/
|
|
|
|
public function copy ( $_dst_identifier ) {
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* moves current record to record identified by $_dst_identifier
|
|
|
|
* $this will become moved record
|
|
|
|
*
|
|
|
|
* @param string $_dst_identifier
|
|
|
|
* @return string dst_identifier
|
|
|
|
*/
|
|
|
|
public function move ( $_dst_identifier ) {
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* delets current record from backend
|
2008-05-10 14:02:49 +02:00
|
|
|
*
|
2006-11-10 16:35:35 +01:00
|
|
|
*/
|
|
|
|
public function delete () {
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
}
|
2008-05-10 14:02:49 +02:00
|
|
|
|
2006-11-10 16:35:35 +01:00
|
|
|
/**
|
|
|
|
* destructor
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __destruct() {
|
|
|
|
unset ($this->bocontacts);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end of egw_addressbook_record
|
|
|
|
?>
|