- fixed sifaddressbook to use bocontacts

- adapted to bocontacts::save returning the id again
- added comment for Lars about the id in LDAP & save
This commit is contained in:
Ralf Becker 2006-07-09 22:59:22 +00:00
parent c14d006c15
commit 2b549bcfe8
2 changed files with 269 additions and 265 deletions

View File

@ -1,20 +1,18 @@
<?php
/**************************************************************************\
* eGroupWare - iCalendar Parser *
* http://www.egroupware.org *
* Written by Lars Kneschke <lkneschke@egroupware.org> *
* -------------------------------------------- *
* 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. *
\**************************************************************************/
/**
* Addressbook - SIF parser
*
* @link http://www.egroupware.org
* @author Lars Kneschke <lkneschke@egroupware.org>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
require_once EGW_SERVER_ROOT.'/addressbook/inc/class.bocontacts.inc.php';
require_once EGW_SERVER_ROOT.'/addressbook/inc/class.boaddressbook.inc.php';
#require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php';
class sifaddressbook extends boaddressbook
class sifaddressbook extends bocontacts
{
var $sifMapping = array(
'Anniversary' => '',
@ -80,7 +78,7 @@
'OtherFaxNumber' => '',
'OtherTelephoneNumber' => 'tel_other',
'PagerNumber' => 'tel_pager',
'PrimaryTelephoneNumber' => '',
'PrimaryTelephoneNumber' => 'tel_prefer',
'Profession' => 'role',
'RadioTelephoneNumber' => '',
'Sensitivity' => 'private',
@ -112,7 +110,6 @@
}
function siftoegw($_sifdata) {
$sysCharSet = $GLOBALS['egw']->translation->charset();
$sifData = base64_decode($_sifdata);
#$tmpfname = tempnam('/tmp/sync/contents','sifc_');
@ -135,7 +132,7 @@
}
foreach($this->contact as $key => $value) {
$value = $GLOBALS['egw']->translation->convert($value, 'utf-8', $sysCharSet);
$value = $GLOBALS['egw']->translation->convert($value, 'utf-8');
switch($key) {
case 'cat_id':
if(!empty($value)) {
@ -156,6 +153,10 @@
}
break;
case 'private':
$finalContact[$key] = (int) $value > 0; // eGW private is 0 (public) or 1 (private), SIF seems to use 0 and 2
break;
default:
$finalContact[$key] = $value;
break;
@ -177,7 +178,7 @@
return false;
}
if(($foundContacts = $this->search($contact)))
if(($foundContacts = bocontact::search($contact)))
{
error_log(print_r($foundContacts,true));
return $foundContacts[0]['id'];
@ -201,8 +202,13 @@
return false;
}
if($_abID > 0) $contact['ab_id'] = $_abID;
// ToDo Lars: This will not work on LDAP
// either we use "if ($_abID)" and false, null, 0 as $_abID for new entries (prefered, as this works in all other apps)
// or we use something like "if ($_abID && $_abID != -1)" ...
if($_abID > 0) {
// update entry
$contact['id'] = $_abID;
}
return $this->save($contact);
}
@ -218,7 +224,7 @@
$fields = array_unique(array_values($this->sifMapping));
sort($fields);
if(!($entry = $this->so->read_entry($_id)))
if(!($entry = $this->read($_id)))
{
return false;
}

View File

@ -29,16 +29,14 @@ class vcaladdressbook extends bocontacts
return false;
}
// ToDo Lars: This will not work on LDAP
// either we use "if ($_abID)" and false, null, 0 as $_abID for new entries (prefered, as this works in all other apps)
// or we use something like "if ($_abID && $_abID != -1)" ...
if($_abID > 0) {
// update entry
$contact['id'] = $_abID;
}
if($this->save($contact)) {
return $contact['id'];
}
return false;
return $this->save($contact);
}
/**