mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-03-11 21:50:15 +01:00
- 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:
parent
c14d006c15
commit
2b549bcfe8
@ -1,20 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**
|
||||||
* eGroupWare - iCalendar Parser *
|
* Addressbook - SIF parser
|
||||||
* http://www.egroupware.org *
|
*
|
||||||
* Written by Lars Kneschke <lkneschke@egroupware.org> *
|
* @link http://www.egroupware.org
|
||||||
* -------------------------------------------- *
|
* @author Lars Kneschke <lkneschke@egroupware.org>
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
* under the terms of the GNU General Public License as published by the *
|
* @package addressbook
|
||||||
* Free Software Foundation; either version 2 of the License. *
|
* @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';
|
class sifaddressbook extends bocontacts
|
||||||
#require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php';
|
|
||||||
|
|
||||||
class sifaddressbook extends boaddressbook
|
|
||||||
{
|
{
|
||||||
var $sifMapping = array(
|
var $sifMapping = array(
|
||||||
'Anniversary' => '',
|
'Anniversary' => '',
|
||||||
@ -80,7 +78,7 @@
|
|||||||
'OtherFaxNumber' => '',
|
'OtherFaxNumber' => '',
|
||||||
'OtherTelephoneNumber' => 'tel_other',
|
'OtherTelephoneNumber' => 'tel_other',
|
||||||
'PagerNumber' => 'tel_pager',
|
'PagerNumber' => 'tel_pager',
|
||||||
'PrimaryTelephoneNumber' => '',
|
'PrimaryTelephoneNumber' => 'tel_prefer',
|
||||||
'Profession' => 'role',
|
'Profession' => 'role',
|
||||||
'RadioTelephoneNumber' => '',
|
'RadioTelephoneNumber' => '',
|
||||||
'Sensitivity' => 'private',
|
'Sensitivity' => 'private',
|
||||||
@ -112,7 +110,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function siftoegw($_sifdata) {
|
function siftoegw($_sifdata) {
|
||||||
$sysCharSet = $GLOBALS['egw']->translation->charset();
|
|
||||||
$sifData = base64_decode($_sifdata);
|
$sifData = base64_decode($_sifdata);
|
||||||
|
|
||||||
#$tmpfname = tempnam('/tmp/sync/contents','sifc_');
|
#$tmpfname = tempnam('/tmp/sync/contents','sifc_');
|
||||||
@ -135,7 +132,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach($this->contact as $key => $value) {
|
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) {
|
switch($key) {
|
||||||
case 'cat_id':
|
case 'cat_id':
|
||||||
if(!empty($value)) {
|
if(!empty($value)) {
|
||||||
@ -156,6 +153,10 @@
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
$finalContact[$key] = $value;
|
$finalContact[$key] = $value;
|
||||||
break;
|
break;
|
||||||
@ -177,7 +178,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(($foundContacts = $this->search($contact)))
|
if(($foundContacts = bocontact::search($contact)))
|
||||||
{
|
{
|
||||||
error_log(print_r($foundContacts,true));
|
error_log(print_r($foundContacts,true));
|
||||||
return $foundContacts[0]['id'];
|
return $foundContacts[0]['id'];
|
||||||
@ -201,8 +202,13 @@
|
|||||||
return false;
|
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);
|
return $this->save($contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +224,7 @@
|
|||||||
$fields = array_unique(array_values($this->sifMapping));
|
$fields = array_unique(array_values($this->sifMapping));
|
||||||
sort($fields);
|
sort($fields);
|
||||||
|
|
||||||
if(!($entry = $this->so->read_entry($_id)))
|
if(!($entry = $this->read($_id)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -29,16 +29,14 @@ class vcaladdressbook extends bocontacts
|
|||||||
return false;
|
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) {
|
if($_abID > 0) {
|
||||||
// update entry
|
// update entry
|
||||||
$contact['id'] = $_abID;
|
$contact['id'] = $_abID;
|
||||||
}
|
}
|
||||||
|
return $this->save($contact);
|
||||||
if($this->save($contact)) {
|
|
||||||
return $contact['id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user