2005-07-20 14:14:39 +02:00
|
|
|
<?php
|
2006-07-09 01:02:30 +02:00
|
|
|
/**
|
|
|
|
* Addressbook - vCard / iCal parser
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Lars Kneschke <lkneschke@egroupware.org>
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
2009-07-15 21:44:09 +02:00
|
|
|
* @author Joerg Lehrke <jlehrke@noc.de>
|
2006-07-09 01:02:30 +02:00
|
|
|
* @package addressbook
|
2008-05-10 14:02:49 +02:00
|
|
|
* @subpackage export
|
2006-07-09 01:02:30 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
2008-04-16 06:37:05 +02:00
|
|
|
* @version $Id$
|
2006-07-09 01:02:30 +02:00
|
|
|
*/
|
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/lib/core.php';
|
|
|
|
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/SyncML/State.php');
|
2006-07-09 01:02:30 +02:00
|
|
|
|
2008-05-10 14:02:49 +02:00
|
|
|
/**
|
|
|
|
* Addressbook - vCard parser
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class addressbook_vcal extends addressbook_bo
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2008-05-10 14:02:49 +02:00
|
|
|
/**
|
|
|
|
* product manufacturer from setSupportedFields (lowercase!)
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2009-07-15 21:44:09 +02:00
|
|
|
var $productManufacturer = 'file';
|
2008-05-10 14:02:49 +02:00
|
|
|
/**
|
|
|
|
* product name from setSupportedFields (lowercase!)
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $productName;
|
2009-08-22 17:57:57 +02:00
|
|
|
/**
|
|
|
|
* supported fields for vCard file and groupdav import/export
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2010-06-09 19:51:27 +02:00
|
|
|
var $supportedFields = array( // all entries e.g. for groupdav
|
|
|
|
'ADR;WORK' => array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region',
|
|
|
|
'adr_one_postalcode','adr_one_countryname'),
|
|
|
|
'ADR;HOME' => array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region',
|
|
|
|
'adr_two_postalcode','adr_two_countryname'),
|
|
|
|
'BDAY' => array('bday'),
|
|
|
|
'CLASS' => array('private'),
|
|
|
|
'CATEGORIES' => array('cat_id'),
|
|
|
|
'EMAIL;WORK' => array('email'),
|
|
|
|
'EMAIL;HOME' => array('email_home'),
|
|
|
|
'N' => array('n_family','n_given','n_middle',
|
|
|
|
'n_prefix','n_suffix'),
|
|
|
|
'FN' => array('n_fn'),
|
|
|
|
'NOTE' => array('note'),
|
|
|
|
'ORG' => array('org_name','org_unit','room'),
|
|
|
|
'TEL;CELL;WORK' => array('tel_cell'),
|
|
|
|
'TEL;CELL;HOME' => array('tel_cell_private'),
|
|
|
|
'TEL;CAR' => array('tel_car'),
|
2010-06-16 18:29:33 +02:00
|
|
|
'TEL;OTHER' => array('tel_other'),
|
2010-06-09 19:51:27 +02:00
|
|
|
'TEL;VOICE;WORK' => array('tel_work'),
|
|
|
|
'TEL;FAX;WORK' => array('tel_fax'),
|
|
|
|
'TEL;HOME;VOICE' => array('tel_home'),
|
|
|
|
'TEL;FAX;HOME' => array('tel_fax_home'),
|
|
|
|
'TEL;PAGER' => array('tel_pager'),
|
|
|
|
'TITLE' => array('title'),
|
|
|
|
'URL;WORK' => array('url'),
|
|
|
|
'URL;HOME' => array('url_home'),
|
|
|
|
'ROLE' => array('role'),
|
|
|
|
'NICKNAME' => array('label'),
|
|
|
|
'FBURL' => array('freebusy_uri'),
|
|
|
|
'PHOTO' => array('jpegphoto'),
|
|
|
|
'X-ASSISTANT' => array('assistent'),
|
|
|
|
'X-ASSISTANT-TEL' => array('tel_assistent'),
|
|
|
|
'UID' => array('uid'),
|
2012-01-31 10:57:59 +01:00
|
|
|
'REV' => array('modified'),
|
2011-10-05 11:24:08 +02:00
|
|
|
);
|
2010-06-09 19:51:27 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
/**
|
|
|
|
* VCard version
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
var $version;
|
|
|
|
/**
|
|
|
|
* Client CTCap Properties
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
var $clientProperties;
|
2009-07-21 13:23:58 +02:00
|
|
|
/**
|
|
|
|
* Set Logging
|
|
|
|
*
|
|
|
|
* @var string
|
2009-12-01 11:24:55 +01:00
|
|
|
* off = false;
|
2009-07-21 13:23:58 +02:00
|
|
|
*/
|
2009-12-01 11:24:55 +01:00
|
|
|
var $log = false;
|
2009-07-27 09:03:10 +02:00
|
|
|
var $logfile="/tmp/log-vcard";
|
2009-07-15 21:44:09 +02:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param string $contact_app the current application
|
|
|
|
* @param string $_contentType the content type (version)
|
|
|
|
* @param array $_clientProperties client properties
|
|
|
|
*/
|
|
|
|
function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array())
|
|
|
|
{
|
|
|
|
parent::__construct($contact_app);
|
2010-01-09 19:04:21 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcard";
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($_contentType)."\n",3,$this->logfile);
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
switch($_contentType)
|
|
|
|
{
|
|
|
|
case 'text/vcard':
|
|
|
|
$this->version = '3.0';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->version = '2.1';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$this->clientProperties = $_clientProperties;
|
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
/**
|
|
|
|
* import a vard into addressbook
|
2008-04-16 06:37:05 +02:00
|
|
|
*
|
2006-07-09 01:02:30 +02:00
|
|
|
* @param string $_vcard the vcard
|
2006-07-10 01:35:16 +02:00
|
|
|
* @param int/string $_abID=null the internal addressbook id or !$_abID for a new enty
|
2009-07-15 21:44:09 +02:00
|
|
|
* @param boolean $merge=false merge data with existing entry
|
2010-03-22 19:03:23 +01:00
|
|
|
* @param string $charset The encoding charset for $text. Defaults to
|
|
|
|
* utf-8 for new format, iso-8859-1 for old format.
|
2006-07-09 01:02:30 +02:00
|
|
|
* @return int contact id
|
|
|
|
*/
|
2010-03-22 19:03:23 +01:00
|
|
|
function addVCard($_vcard, $_abID=null, $merge=false, $charset=null)
|
2005-07-20 14:14:39 +02:00
|
|
|
{
|
2010-03-22 19:03:23 +01:00
|
|
|
if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false;
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
if ($_abID)
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2010-02-09 22:56:39 +01:00
|
|
|
if (($old_contact = $this->read($_abID)))
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2010-02-09 22:56:39 +01:00
|
|
|
if ($merge)
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
|
|
|
foreach ($contact as $key => $value)
|
|
|
|
{
|
|
|
|
if (!empty($old_contact[$key]))
|
|
|
|
{
|
|
|
|
$contact[$key] = $old_contact[$key];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-09 22:56:39 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isset($old_contact['account_id']))
|
|
|
|
{
|
|
|
|
$contact['account_id'] = $old_contact['account_id'];
|
|
|
|
}
|
2010-03-24 12:37:22 +01:00
|
|
|
if (is_array($contact['cat_id']))
|
2010-03-07 00:06:43 +01:00
|
|
|
{
|
2010-03-24 12:37:22 +01:00
|
|
|
$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID));
|
2010-03-07 00:06:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// restore from orignal
|
2010-03-24 12:37:22 +01:00
|
|
|
$contact['cat_id'] = $old_contact['cat_id'];
|
2010-03-07 00:06:43 +01:00
|
|
|
}
|
2010-02-09 22:56:39 +01:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
// update entry
|
2006-07-09 15:29:19 +02:00
|
|
|
$contact['id'] = $_abID;
|
2005-07-20 14:14:39 +02:00
|
|
|
}
|
2010-03-24 12:37:22 +01:00
|
|
|
else
|
2009-11-19 21:52:44 +01:00
|
|
|
{
|
2010-03-24 12:37:22 +01:00
|
|
|
if (is_array($contact['cat_id']))
|
2010-03-07 00:06:43 +01:00
|
|
|
{
|
2010-03-24 12:37:22 +01:00
|
|
|
$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
|
2010-03-07 00:06:43 +01:00
|
|
|
}
|
2009-11-19 21:52:44 +01:00
|
|
|
}
|
2010-09-08 11:45:20 +02:00
|
|
|
if (isset($contact['owner']) && $contact['owner'] != $this->user)
|
2010-06-07 13:55:56 +02:00
|
|
|
{
|
2010-06-07 17:00:30 +02:00
|
|
|
$contact['private'] = 0; // foreign contacts are never private!
|
2010-06-07 13:55:56 +02:00
|
|
|
}
|
2010-03-24 12:37:22 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($contact)."\n",3,$this->logfile);
|
|
|
|
}
|
2006-07-10 00:59:22 +02:00
|
|
|
return $this->save($contact);
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2005-07-20 14:14:39 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
/**
|
|
|
|
* return a vcard
|
|
|
|
*
|
|
|
|
* @param int/string $_id the id of the contact
|
2009-07-15 21:44:09 +02:00
|
|
|
* @param string $_charset='UTF-8' encoding of the vcard, default UTF-8
|
2008-06-07 20:00:29 +02:00
|
|
|
* @param boolean $extra_charset_attribute=true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
|
2006-07-09 01:02:30 +02:00
|
|
|
* @return string containing the vcard
|
|
|
|
*/
|
2009-07-15 21:44:09 +02:00
|
|
|
function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
|
|
|
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar/vcard.php');
|
2005-07-20 14:14:39 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
#Horde::logMessage("vCalAddressbook clientProperties:\n" . print_r($this->clientProperties, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
|
|
|
|
|
|
|
$vCard = new Horde_iCalendar_vcard($this->version);
|
2011-10-05 11:24:08 +02:00
|
|
|
$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['addressbook']['version'].'//'.
|
|
|
|
strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
|
2009-06-29 21:03:43 +02:00
|
|
|
|
2012-01-31 10:57:59 +01:00
|
|
|
$sysCharSet = translation::charset();
|
2009-07-15 21:44:09 +02:00
|
|
|
|
2009-10-07 01:32:02 +02:00
|
|
|
// KAddressbook and Funambol4BlackBerry always requires non-ascii chars to be qprint encoded.
|
|
|
|
if ($this->productName == 'kde' ||
|
|
|
|
($this->productManufacturer == 'funambol' && $this->productName == 'blackberry plug-in'))
|
|
|
|
{
|
|
|
|
$extra_charset_attribute = true;
|
|
|
|
}
|
2009-07-18 15:11:43 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
if (!($entry = $this->read($_id)))
|
|
|
|
{
|
2006-07-09 01:02:30 +02:00
|
|
|
return false;
|
|
|
|
}
|
2009-06-29 21:03:43 +02:00
|
|
|
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$this->fixup_contact($entry);
|
2009-06-29 21:03:43 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
foreach ($this->supportedFields as $vcardField => $databaseFields)
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
|
|
|
$values = array();
|
2006-07-09 01:02:30 +02:00
|
|
|
$options = array();
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$hasdata = 0;
|
2009-07-15 21:44:09 +02:00
|
|
|
// seperate fields from their options/attributes
|
|
|
|
$vcardFields = explode(';', $vcardField);
|
|
|
|
$vcardField = $vcardFields[0];
|
|
|
|
$i = 1;
|
|
|
|
while (isset($vcardFields[$i]))
|
|
|
|
{
|
|
|
|
list($oname, $oval) = explode('=', $vcardFields[$i]);
|
|
|
|
if (!$oval && ($this->version == '3.0'))
|
|
|
|
{
|
|
|
|
// declare OPTION as TYPE=OPTION
|
|
|
|
$options['TYPE'][] = $oname ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$options[$oname] = $oval;
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
if (is_array($options['TYPE']))
|
|
|
|
{
|
|
|
|
$oval = implode(",", $options['TYPE']);
|
|
|
|
unset($options['TYPE']);
|
|
|
|
$options['TYPE'] = $oval;
|
|
|
|
}
|
|
|
|
if (isset($this->clientProperties[$vcardField]['Size']))
|
|
|
|
{
|
|
|
|
$size = $this->clientProperties[$vcardField]['Size'];
|
|
|
|
$noTruncate = $this->clientProperties[$vcardField]['NoTruncate'];
|
2010-01-10 20:02:16 +01:00
|
|
|
if ($this->log && $size > 0)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() $vcardField Size: $size, NoTruncate: " .
|
|
|
|
($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
//Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " .
|
|
|
|
// ($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$size = -1;
|
|
|
|
$noTruncate = false;
|
|
|
|
}
|
|
|
|
foreach ($databaseFields as $databaseField)
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2010-01-08 14:09:36 +01:00
|
|
|
$value = '';
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
|
|
|
if (!empty($databaseField))
|
|
|
|
{
|
|
|
|
$value = trim($entry[$databaseField]);
|
2006-05-17 05:36:48 +02:00
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
switch ($databaseField)
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2012-01-31 10:57:59 +01:00
|
|
|
case 'modified':
|
|
|
|
$value = gmdate("Y-m-d\TH:i:s\Z",egw_time::user2server($value));
|
|
|
|
break;
|
|
|
|
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
case 'private':
|
|
|
|
$value = $value ? 'PRIVATE' : 'PUBLIC';
|
|
|
|
$hasdata++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'bday':
|
|
|
|
if (!empty($value))
|
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
if ($size == 8)
|
|
|
|
{
|
|
|
|
$value = str_replace('-','',$value);
|
|
|
|
}
|
|
|
|
elseif (isset($options['TYPE']) && (
|
|
|
|
$options['TYPE'] == 'BASIC'))
|
|
|
|
{
|
|
|
|
unset($options['TYPE']);
|
|
|
|
// used by old SyncML implementations
|
|
|
|
$value = str_replace('-','',$value).'T000000Z';
|
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$hasdata++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'jpegphoto':
|
2009-07-15 21:44:09 +02:00
|
|
|
if (!empty($value) &&
|
|
|
|
(($size < 0) || (strlen($value) < $size)))
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
if (!isset($options['TYPE']))
|
|
|
|
{
|
|
|
|
$options['TYPE'] = 'JPEG';
|
|
|
|
}
|
|
|
|
if (!isset($options['ENCODING']))
|
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'BASE64';
|
|
|
|
}
|
|
|
|
$hasdata++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$value = '';
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'cat_id':
|
2009-07-16 18:05:40 +02:00
|
|
|
if (!empty($value) && ($values = $this->get_categories($value)))
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2012-01-31 10:57:59 +01:00
|
|
|
$values = (array) translation::convert($values, $sysCharSet, $_charset);
|
2009-07-15 21:44:09 +02:00
|
|
|
$value = implode(',', $values); // just for the CHARSET recognition
|
2010-01-08 14:09:36 +01:00
|
|
|
if (($size > 0) && strlen($value) > $size)
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2010-01-08 14:09:36 +01:00
|
|
|
// let us try with only the first category
|
|
|
|
$value = $values[0];
|
|
|
|
if (strlen($value) > $size)
|
|
|
|
{
|
2010-01-10 20:02:16 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
|
|
|
|
}
|
2010-01-08 14:09:36 +01:00
|
|
|
// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
|
|
|
|
// __FILE__, __LINE__, PEAR_LOG_WARNING);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$values = array();
|
|
|
|
}
|
|
|
|
if (preg_match('/[^\x20-\x7F]/', $value))
|
|
|
|
{
|
|
|
|
if ($extra_charset_attribute || $this->productName == 'kde')
|
|
|
|
{
|
|
|
|
$options['CHARSET'] = $_charset;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
// KAddressbook requires non-ascii chars to be qprint encoded, other clients eg. nokia phones have trouble with that
|
2010-01-08 14:09:36 +01:00
|
|
|
if ($this->productName == 'kde')
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'QUOTED-PRINTABLE';
|
|
|
|
}
|
2010-01-08 14:09:36 +01:00
|
|
|
elseif ($this->productManufacturer == 'funambol')
|
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'FUNAMBOL-QP';
|
|
|
|
}
|
|
|
|
elseif (preg_match('/([\000-\012\015\016\020-\037\075])/', $value))
|
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'QUOTED-PRINTABLE';
|
|
|
|
}
|
|
|
|
elseif (!$extra_charset_attribute)
|
2009-07-18 15:11:43 +02:00
|
|
|
{
|
|
|
|
$options['ENCODING'] = '';
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
2010-01-08 14:09:36 +01:00
|
|
|
$hasdata++;
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
|
|
|
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
default:
|
2009-07-15 21:44:09 +02:00
|
|
|
if (($size > 0) && strlen(implode(',', $values) . $value) > $size)
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
if ($noTruncate)
|
|
|
|
{
|
2010-01-10 20:02:16 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
|
|
|
|
}
|
2009-07-18 15:11:43 +02:00
|
|
|
// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
|
|
|
|
// __FILE__, __LINE__, PEAR_LOG_WARNING);
|
2009-07-15 21:44:09 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// truncate the value to size
|
|
|
|
$cursize = strlen(implode('', $values));
|
|
|
|
$left = $size - $cursize - count($databaseFields) + 1;
|
|
|
|
if ($left > 0)
|
|
|
|
{
|
|
|
|
$value = substr($value, 0, $left);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$value = '';
|
|
|
|
}
|
2010-01-10 20:02:16 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() $vcardField truncated to maximum size $size\n",3,$this->logfile);
|
|
|
|
}
|
2009-07-18 15:11:43 +02:00
|
|
|
//Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size",
|
|
|
|
// __FILE__, __LINE__, PEAR_LOG_INFO);
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
if (!empty($value) // required field
|
|
|
|
|| in_array($vcardField,array('FN','ORG','N'))
|
|
|
|
|| ($size >= 0 && !$noTruncate))
|
|
|
|
{
|
2012-01-31 10:57:59 +01:00
|
|
|
$value = translation::convert(trim($value), $sysCharSet, $_charset);
|
2009-07-15 21:44:09 +02:00
|
|
|
$values[] = $value;
|
2010-01-08 14:09:36 +01:00
|
|
|
if (preg_match('/[^\x20-\x7F]/', $value))
|
2008-04-16 18:05:48 +02:00
|
|
|
{
|
2010-01-08 14:09:36 +01:00
|
|
|
if ($extra_charset_attribute || $this->productName == 'kde')
|
2009-07-18 15:11:43 +02:00
|
|
|
{
|
|
|
|
$options['CHARSET'] = $_charset;
|
|
|
|
}
|
2010-01-08 14:09:36 +01:00
|
|
|
// KAddressbook requires non-ascii chars to be qprint encoded, other clients eg. nokia phones have trouble with that
|
|
|
|
if ($this->productName == 'kde')
|
2008-05-10 14:02:49 +02:00
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'QUOTED-PRINTABLE';
|
|
|
|
}
|
2010-01-08 14:09:36 +01:00
|
|
|
elseif ($this->productManufacturer == 'funambol')
|
|
|
|
{
|
2010-01-09 19:04:21 +01:00
|
|
|
$options['ENCODING'] = 'FUNAMBOL-QP';
|
2010-01-08 14:09:36 +01:00
|
|
|
}
|
|
|
|
elseif (preg_match('/([\000-\012\015\016\020-\037\075])/', $value))
|
|
|
|
{
|
|
|
|
$options['ENCODING'] = 'QUOTED-PRINTABLE';
|
|
|
|
}
|
|
|
|
elseif (!$extra_charset_attribute)
|
|
|
|
{
|
|
|
|
$options['ENCODING'] = '';
|
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
if ($vcardField == 'TEL' && $entry['tel_prefer'] &&
|
|
|
|
($databaseField == $entry['tel_prefer']))
|
|
|
|
{
|
|
|
|
if ($options['TYPE'])
|
|
|
|
{
|
|
|
|
$options['TYPE'] .= ',';
|
|
|
|
}
|
|
|
|
$options['TYPE'] .= 'PREF';
|
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$hasdata++;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$values[] = '';
|
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
break;
|
|
|
|
}
|
2006-03-21 14:19:38 +01:00
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
2008-06-07 20:00:29 +02:00
|
|
|
if ($hasdata <= 0)
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
{
|
2007-10-31 22:17:40 +01:00
|
|
|
// don't add the entry if there is no data for this field,
|
|
|
|
// except it's a mendatory field
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
continue;
|
2006-03-21 14:19:38 +01:00
|
|
|
}
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
$vCard->setAttribute($vcardField, $value, $options, true, $values);
|
|
|
|
//$vCard->setParameter($vcardField, $options);
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
|
2010-03-22 19:03:23 +01:00
|
|
|
$result = $vCard->exportvCalendar($_charset);
|
2009-12-01 11:24:55 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
2010-01-09 19:04:21 +01:00
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($result)."\n",3,$this->logfile);
|
2009-12-01 11:24:55 +01:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
return $result;
|
|
|
|
}
|
2006-03-21 14:19:38 +01:00
|
|
|
|
2010-03-22 19:03:23 +01:00
|
|
|
function search($_vcard, $contentID=null, $relax=false, $charset=null)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2010-02-09 22:56:39 +01:00
|
|
|
$result = array();
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2010-03-22 19:03:23 +01:00
|
|
|
if (($contact = $this->vcardtoegw($_vcard, $charset)))
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2010-03-07 00:06:43 +01:00
|
|
|
if (is_array($contact['category']))
|
|
|
|
{
|
|
|
|
$contact['category'] = implode(',',$this->find_or_add_categories($contact['category'],
|
|
|
|
$contentID ? $contentID : -1));
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
if ($contentID)
|
|
|
|
{
|
2009-12-01 11:24:55 +01:00
|
|
|
$contact['id'] = $contentID;
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
$result = $this->find_contact($contact, $relax);
|
Big SyncML patch from Philip Herbert <pherbert(at)knauber.de>:
- change the processing of slowsync, to use the content_map instead of
trying to build a new one. This caused duplication issues on the
client if multiple similar records where stored, because only the first
one found in the server-db was matched, These duplicate entries at client
side had no entry at serverside, so deleting the wrong one
on the client (the content with a valid map entry) could cause
unwanted data loss at server side, because it is impossible for the
user to see what is a duplicate, and what is not.
see also:
http://www.nabble.com/again---syncml-duplication-issue-to20333619s3741.html
- reenabled UID from syncml clients, because it was partly used this caused
issues during SlowSync if the content was changed.
- infolog, calendar if a uid is found in the provided data, allway try to
find the corresponding content first using only the UID, instead of
using the content-id taken from content_map.
also fixed:
- a few fixes in ./notes
- creating an entry on the client that can not be imported,
(Example, Nokia E Series Appointment without a Title)
will no longer create an invalid content-map entry
However, at client side this is still counted in the Protocol as
Server-Add
2008-11-16 11:42:29 +01:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
return $result;
|
|
|
|
}
|
Big SyncML patch from Philip Herbert <pherbert(at)knauber.de>:
- change the processing of slowsync, to use the content_map instead of
trying to build a new one. This caused duplication issues on the
client if multiple similar records where stored, because only the first
one found in the server-db was matched, These duplicate entries at client
side had no entry at serverside, so deleting the wrong one
on the client (the content with a valid map entry) could cause
unwanted data loss at server side, because it is impossible for the
user to see what is a duplicate, and what is not.
see also:
http://www.nabble.com/again---syncml-duplication-issue-to20333619s3741.html
- reenabled UID from syncml clients, because it was partly used this caused
issues during SlowSync if the content was changed.
- infolog, calendar if a uid is found in the provided data, allway try to
find the corresponding content first using only the UID, instead of
using the content-id taken from content_map.
also fixed:
- a few fixes in ./notes
- creating an entry on the client that can not be imported,
(Example, Nokia E Series Appointment without a Title)
will no longer create an invalid content-map entry
However, at client side this is still counted in the Protocol as
Server-Add
2008-11-16 11:42:29 +01:00
|
|
|
|
2009-08-22 17:57:57 +02:00
|
|
|
function setSupportedFields($_productManufacturer='file', $_productName='', $_supportedFields = null)
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2009-08-22 17:57:57 +02:00
|
|
|
$this->productManufacturer = strtolower($_productManufacturer);
|
|
|
|
$this->productName = strtolower($_productName);
|
2006-03-21 14:19:38 +01:00
|
|
|
|
2009-08-22 17:57:57 +02:00
|
|
|
if (is_array($_supportedFields)) $this->supportedFields = $_supportedFields;
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2010-03-22 19:03:23 +01:00
|
|
|
/**
|
|
|
|
* Parses a string containing vCard data.
|
|
|
|
*
|
|
|
|
* @param string $_vcard The data to parse.
|
|
|
|
* @param string $charset The encoding charset for $text. Defaults to
|
|
|
|
* utf-8 for new format, iso-8859-1 for old format.
|
|
|
|
*
|
|
|
|
* @return array|boolean The contact data or false on errors.
|
|
|
|
*/
|
|
|
|
function vcardtoegw($_vcard, $charset=null)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2006-08-15 14:46:26 +02:00
|
|
|
// the horde class does the charset conversion. DO NOT CONVERT HERE.
|
2009-07-15 21:44:09 +02:00
|
|
|
// be as flexible as possible
|
|
|
|
|
|
|
|
$databaseFields = array(
|
2009-10-12 22:12:52 +02:00
|
|
|
'ADR;WORK' => array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region',
|
2009-07-19 22:05:06 +02:00
|
|
|
'adr_one_postalcode','adr_one_countryname'),
|
2009-10-12 22:12:52 +02:00
|
|
|
'ADR;HOME' => array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region',
|
2009-07-19 22:05:06 +02:00
|
|
|
'adr_two_postalcode','adr_two_countryname'),
|
|
|
|
'BDAY' => array('bday'),
|
|
|
|
'X-CLASS' => array('private'),
|
|
|
|
'CLASS' => array('private'),
|
|
|
|
'CATEGORIES' => array('cat_id'),
|
|
|
|
'EMAIL;WORK' => array('email'),
|
|
|
|
'EMAIL;HOME' => array('email_home'),
|
|
|
|
'N' => array('n_family','n_given','n_middle',
|
|
|
|
'n_prefix','n_suffix'),
|
|
|
|
'FN' => array('n_fn'),
|
|
|
|
'NOTE' => array('note'),
|
|
|
|
'ORG' => array('org_name','org_unit','room'),
|
|
|
|
'TEL;CELL;WORK' => array('tel_cell'),
|
|
|
|
'TEL;CELL;HOME' => array('tel_cell_private'),
|
|
|
|
'TEL;CAR' => array('tel_car'),
|
2010-06-16 18:29:33 +02:00
|
|
|
'TEL;OTHER' => array('tel_other'),
|
2009-07-19 22:05:06 +02:00
|
|
|
'TEL;VOICE;WORK' => array('tel_work'),
|
|
|
|
'TEL;FAX;WORK' => array('tel_fax'),
|
|
|
|
'TEL;HOME;VOICE' => array('tel_home'),
|
|
|
|
'TEL;FAX;HOME' => array('tel_fax_home'),
|
|
|
|
'TEL;PAGER' => array('tel_pager'),
|
|
|
|
'TITLE' => array('title'),
|
|
|
|
'URL;WORK' => array('url'),
|
|
|
|
'URL;HOME' => array('url_home'),
|
|
|
|
'ROLE' => array('role'),
|
|
|
|
'NICKNAME' => array('label'),
|
|
|
|
'FBURL' => array('freebusy_uri'),
|
|
|
|
'PHOTO' => array('jpegphoto'),
|
|
|
|
'X-ASSISTANT' => array('assistent'),
|
2009-07-15 21:44:09 +02:00
|
|
|
'X-ASSISTANT-TEL' => array('tel_assistent'),
|
2009-07-19 22:05:06 +02:00
|
|
|
'UID' => array('uid'),
|
2009-07-15 21:44:09 +02:00
|
|
|
);
|
2006-07-09 01:02:30 +02:00
|
|
|
|
2010-01-09 19:04:21 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($_vcard)."\n",3,$this->logfile);
|
|
|
|
}
|
2009-09-17 22:26:56 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php');
|
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
$container = false;
|
2006-07-09 01:02:30 +02:00
|
|
|
$vCard = Horde_iCalendar::newComponent('vcard', $container);
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2010-03-22 19:03:23 +01:00
|
|
|
if (!$vCard->parsevCalendar($_vcard, 'VCARD', $charset))
|
2008-09-03 19:09:17 +02:00
|
|
|
{
|
2006-07-09 01:02:30 +02:00
|
|
|
return False;
|
|
|
|
}
|
|
|
|
$vcardValues = $vCard->getAllAttributes();
|
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
|
|
|
|
{
|
|
|
|
$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$minimum_uid_length = 8;
|
|
|
|
}
|
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
#print "<pre>$_vcard</pre>";
|
2006-03-21 14:19:38 +01:00
|
|
|
|
2006-07-23 20:10:37 +02:00
|
|
|
#error_log(print_r($vcardValues, true));
|
2009-07-27 09:03:10 +02:00
|
|
|
//Horde::logMessage("vCalAddressbook vcardtoegw: " . print_r($vcardValues, true), __FILE__, __LINE__, PEAR_LOG_DEBUG);
|
2009-07-15 21:44:09 +02:00
|
|
|
|
2009-07-19 01:02:31 +02:00
|
|
|
$email = 1;
|
2009-07-15 21:44:09 +02:00
|
|
|
$tel = 1;
|
|
|
|
$cell = 1;
|
2009-07-19 01:02:31 +02:00
|
|
|
$url = 1;
|
2009-07-15 21:44:09 +02:00
|
|
|
$pref_tel = false;
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
foreach($vcardValues as $key => $vcardRow)
|
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$rowName = strtoupper($vcardRow['name']);
|
|
|
|
if ($vcardRow['value'] == '' && implode('', $vcardRow['values']) == '')
|
|
|
|
{
|
|
|
|
unset($vcardRow);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$rowTypes = array();
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
$vcardRow['uparams'] = array();
|
|
|
|
foreach ($vcardRow['params'] as $pname => $params)
|
|
|
|
{
|
|
|
|
$pname = strtoupper($pname);
|
|
|
|
$vcardRow['uparams'][$pname] = $params;
|
|
|
|
}
|
2007-10-25 08:26:50 +02:00
|
|
|
|
2009-07-22 22:31:15 +02:00
|
|
|
|
|
|
|
// expand 3.0 TYPE paramters to 2.1 qualifiers
|
|
|
|
$vcardRow['tparams'] = array();
|
2009-07-15 21:44:09 +02:00
|
|
|
foreach ($vcardRow['uparams'] as $pname => $params)
|
2007-12-03 11:21:50 +01:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
switch ($pname)
|
2008-09-03 19:09:17 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'TYPE':
|
|
|
|
if (is_array($params))
|
|
|
|
{
|
|
|
|
$rowTypes = array();
|
|
|
|
foreach ($params as $param)
|
|
|
|
{
|
|
|
|
$rowTypes[] = strtoupper($param);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$rowTypes[] = strtoupper($params);
|
|
|
|
}
|
|
|
|
foreach ($rowTypes as $type)
|
|
|
|
{
|
|
|
|
switch ($type)
|
|
|
|
{
|
2009-07-22 22:31:15 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'OTHER':
|
|
|
|
case 'WORK':
|
|
|
|
case 'HOME':
|
2009-07-22 22:31:15 +02:00
|
|
|
$vcardRow['tparams'][$type] = '';
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2009-07-22 22:31:15 +02:00
|
|
|
case 'CELL':
|
|
|
|
case 'PAGER':
|
|
|
|
case 'FAX':
|
|
|
|
case 'VOICE':
|
|
|
|
case 'CAR':
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'PREF':
|
2009-07-22 22:31:15 +02:00
|
|
|
case 'X-CUSTOMLABEL-CAR':
|
2009-09-17 22:26:56 +02:00
|
|
|
case 'X-CUSTOMLABEL-IPHONE':
|
2009-07-15 21:44:09 +02:00
|
|
|
if ($vcardRow['name'] == 'TEL')
|
|
|
|
{
|
2009-07-22 22:31:15 +02:00
|
|
|
$vcardRow['tparams'][$type] = '';
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-07-22 22:31:15 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$vcardRow['uparams'] += $vcardRow['tparams'];
|
|
|
|
ksort($vcardRow['uparams']);
|
|
|
|
|
|
|
|
foreach ($vcardRow['uparams'] as $pname => $params)
|
|
|
|
{
|
|
|
|
switch ($pname)
|
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'PREF':
|
2009-07-22 22:31:15 +02:00
|
|
|
if ($rowName == 'TEL' && !$pref_tel)
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
|
|
|
$pref_tel = $key;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'FAX':
|
|
|
|
case 'PAGER':
|
|
|
|
case 'VOICE':
|
|
|
|
case 'OTHER':
|
|
|
|
case 'CELL':
|
2010-07-27 21:38:01 +02:00
|
|
|
if ($rowName != 'TEL') break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'WORK':
|
|
|
|
case 'HOME':
|
|
|
|
$rowName .= ';' . $pname;
|
|
|
|
break;
|
|
|
|
case 'CAR':
|
|
|
|
case 'X-CUSTOMLABEL-CAR':
|
2009-07-22 22:31:15 +02:00
|
|
|
if ($rowName == 'TEL')
|
|
|
|
{
|
|
|
|
$rowName = 'TEL;CAR';
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2009-09-17 22:26:56 +02:00
|
|
|
case 'X-CUSTOMLABEL-IPHONE':
|
|
|
|
if ($rowName == 'TEL')
|
|
|
|
{
|
|
|
|
$rowName = 'TEL;CELL;HOME';
|
|
|
|
}
|
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
default:
|
2009-07-19 01:02:31 +02:00
|
|
|
if (strpos($pname, 'X-FUNAMBOL-') === 0)
|
|
|
|
{
|
|
|
|
// Propriatary Funambol extension will be ignored
|
|
|
|
$rowName .= ';' . $pname;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2008-09-03 19:09:17 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
if ($rowName == 'EMAIL')
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2009-07-19 01:02:31 +02:00
|
|
|
$rowName .= ';X-egw-Ref' . $email++;
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
if (($rowName == 'TEL;CELL') ||
|
2009-07-15 21:44:09 +02:00
|
|
|
($rowName == 'TEL;CELL;VOICE'))
|
|
|
|
{
|
|
|
|
$rowName = 'TEL;CELL;X-egw-Ref' . $cell++;
|
|
|
|
}
|
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
if (($rowName == 'TEL') ||
|
2009-07-15 21:44:09 +02:00
|
|
|
($rowName == 'TEL;VOICE'))
|
|
|
|
{
|
|
|
|
$rowName = 'TEL;X-egw-Ref' . $tel++;
|
|
|
|
}
|
|
|
|
|
2010-02-26 16:47:51 +01:00
|
|
|
if ($rowName == 'URL')
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2009-07-19 01:02:31 +02:00
|
|
|
$rowName = 'URL;X-egw-Ref' . $url++;
|
2009-07-15 21:44:09 +02:00
|
|
|
}
|
|
|
|
|
2012-02-09 21:09:49 +01:00
|
|
|
// current algorithm cant cope with multiple attributes of same name
|
|
|
|
// --> cumulate them in values, so they can be used later (works only for values, not for parameters!)
|
|
|
|
if (($k = array_search($rowName, $rowNames)) != false)
|
|
|
|
{
|
|
|
|
$vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'],$vcardValues[$key]['values']);
|
|
|
|
}
|
2009-07-22 22:31:15 +02:00
|
|
|
$rowNames[$key] = $rowName;
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
|
|
|
|
2010-01-09 19:04:21 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($rowNames)."\n",3,$this->logfile);
|
|
|
|
}
|
2008-09-03 19:09:17 +02:00
|
|
|
|
2010-01-09 19:04:21 +01:00
|
|
|
// All rowNames of the vCard are now concatenated with their qualifiers.
|
|
|
|
// If qualifiers are missing we apply a default strategy.
|
|
|
|
// E.g. ADR will be either ADR;WORK, if no ADR;WORK is given,
|
|
|
|
// or else ADR;HOME, if not available elsewhere.
|
2009-07-27 09:03:10 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames = array();
|
2009-06-29 21:03:43 +02:00
|
|
|
|
2009-07-22 22:31:15 +02:00
|
|
|
foreach ($rowNames as $vcardKey => $rowName)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2010-02-26 16:47:51 +01:00
|
|
|
switch ($rowName)
|
2006-03-21 14:19:38 +01:00
|
|
|
{
|
2009-07-22 22:31:15 +02:00
|
|
|
case 'VERSION':
|
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'ADR':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('ADR;WORK', $rowNames)
|
|
|
|
&& !isset($finalRowNames['ADR;WORK']))
|
2009-06-29 21:03:43 +02:00
|
|
|
{
|
2009-07-22 22:31:15 +02:00
|
|
|
$finalRowNames['ADR;WORK'] = $vcardKey;
|
2009-06-29 21:03:43 +02:00
|
|
|
}
|
2009-07-22 22:31:15 +02:00
|
|
|
elseif (!in_array('ADR;HOME', $rowNames)
|
|
|
|
&& !isset($finalRowNames['ADR;HOME']))
|
2009-06-29 21:03:43 +02:00
|
|
|
{
|
2009-07-22 22:31:15 +02:00
|
|
|
$finalRowNames['ADR;HOME'] = $vcardKey;
|
2009-06-29 21:03:43 +02:00
|
|
|
}
|
|
|
|
break;
|
2006-07-09 01:02:30 +02:00
|
|
|
case 'TEL;FAX':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;FAX;WORK', $rowNames)
|
2009-07-15 21:44:09 +02:00
|
|
|
&& !isset($finalRowNames['TEL;FAX;WORK']))
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['TEL;FAX;WORK'] = $vcardKey;
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2009-07-22 22:31:15 +02:00
|
|
|
elseif (!in_array('TEL;FAX;HOME', $rowNames)
|
2009-07-15 21:44:09 +02:00
|
|
|
&& !isset($finalRowNames['TEL;FAX;HOME']))
|
2009-07-19 22:05:06 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['TEL;FAX;HOME'] = $vcardKey;
|
2009-07-19 22:05:06 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2009-07-19 22:05:06 +02:00
|
|
|
case 'TEL;WORK':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;VOICE;WORK', $rowNames)
|
2009-07-19 22:05:06 +02:00
|
|
|
&& !isset($finalRowNames['TEL;VOICE;WORK']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;VOICE;WORK'] = $vcardKey;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2009-07-19 22:05:06 +02:00
|
|
|
case 'TEL;HOME':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;HOME;VOICE', $rowNames)
|
2009-07-19 22:05:06 +02:00
|
|
|
&& !isset($finalRowNames['TEL;HOME;VOICE']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;HOME;VOICE'] = $vcardKey;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2010-06-16 18:29:33 +02:00
|
|
|
case 'TEL;OTHER;VOICE':
|
|
|
|
if (!in_array('TEL;OTHER', $rowNames)
|
|
|
|
&& !isset($finalRowNames['TEL;OTHER']))
|
2009-07-19 22:05:06 +02:00
|
|
|
{
|
2010-06-16 18:29:33 +02:00
|
|
|
$finalRowNames['TEL;OTHER'] = $vcardKey;
|
2009-07-19 22:05:06 +02:00
|
|
|
}
|
2011-10-05 11:24:08 +02:00
|
|
|
break;
|
2010-06-16 18:29:33 +02:00
|
|
|
case 'TEL;PAGER;WORK':
|
|
|
|
case 'TEL;PAGER;HOME':
|
|
|
|
if (!in_array('TEL;PAGER', $rowNames)
|
|
|
|
&& !isset($finalRowNames['TEL;PAGER']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;PAGER'] = $vcardKey;
|
|
|
|
}
|
2011-10-05 11:24:08 +02:00
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'TEL;CAR;VOICE':
|
|
|
|
case 'TEL;CAR;CELL':
|
|
|
|
case 'TEL;CAR;CELL;VOICE':
|
2009-07-19 22:05:06 +02:00
|
|
|
if (!isset($finalRowNames['TEL;CAR']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;CAR'] = $vcardKey;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
|
|
|
case 'TEL;X-egw-Ref1':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;VOICE;WORK', $rowNames)
|
|
|
|
&& !in_array('TEL;WORK', $rowNames)
|
2009-07-19 22:05:06 +02:00
|
|
|
&& !isset($finalRowNames['TEL;VOICE;WORK']))
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2009-07-19 22:05:06 +02:00
|
|
|
$finalRowNames['TEL;VOICE;WORK'] = $vcardKey;
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'TEL;X-egw-Ref2':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;HOME;VOICE', $rowNames)
|
|
|
|
&& !in_array('TEL;HOME', $rowNames)
|
2009-07-19 22:05:06 +02:00
|
|
|
&& !isset($finalRowNames['TEL;HOME;VOICE']))
|
2009-07-15 21:44:09 +02:00
|
|
|
{
|
2009-07-19 22:05:06 +02:00
|
|
|
$finalRowNames['TEL;HOME;VOICE'] = $vcardKey;
|
2010-06-29 15:54:23 +02:00
|
|
|
break;
|
2008-09-03 19:09:17 +02:00
|
|
|
}
|
2010-06-29 15:54:23 +02:00
|
|
|
case 'TEL;X-egw-Ref3':
|
2010-06-16 18:29:33 +02:00
|
|
|
if (!in_array('TEL;OTHER', $rowNames)
|
|
|
|
&& !in_array('TEL;OTHER;VOICE', $rowNames)
|
|
|
|
&& !isset($finalRowNames['TEL;OTHER']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;OTHER'] = $vcardKey;
|
|
|
|
}
|
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'TEL;CELL;X-egw-Ref1':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;CELL;WORK', $rowNames)
|
2009-07-15 21:44:09 +02:00
|
|
|
&& !isset($finalRowNames['TEL;CELL;WORK']))
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['TEL;CELL;WORK'] = $vcardKey;
|
|
|
|
break;
|
2009-04-02 14:31:44 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'TEL;CELL;X-egw-Ref2':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('TEL;CELL;HOME', $rowNames)
|
2009-07-15 21:44:09 +02:00
|
|
|
&& !isset($finalRowNames['TEL;CELL;HOME']))
|
|
|
|
{
|
|
|
|
$finalRowNames['TEL;CELL;HOME'] = $vcardKey;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'TEL;CELL;X-egw-Ref3':
|
2009-08-22 17:57:57 +02:00
|
|
|
if (!in_array('TEL;CAR', $rowNames)
|
2009-07-22 22:31:15 +02:00
|
|
|
&& !in_array('TEL;CAR;VOICE', $rowNames)
|
|
|
|
&& !in_array('TEL;CAR;CELL', $rowNames)
|
|
|
|
&& !in_array('TEL;CAR;CELL;VOICE', $rowNames)
|
2009-07-15 21:44:09 +02:00
|
|
|
&& !isset($finalRowNames['TEL;CAR']))
|
2009-04-02 14:31:44 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['TEL;CAR'] = $vcardKey;
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'EMAIL;X-egw-Ref1':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('EMAIL;WORK', $rowNames) &&
|
2009-07-15 21:44:09 +02:00
|
|
|
!isset($finalRowNames['EMAIL;WORK']))
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['EMAIL;WORK'] = $vcardKey;
|
|
|
|
break;
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'EMAIL;X-egw-Ref2':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('EMAIL;HOME', $rowNames) &&
|
2009-07-15 21:44:09 +02:00
|
|
|
!isset($finalRowNames['EMAIL;HOME']))
|
2009-04-02 14:31:44 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$finalRowNames['EMAIL;HOME'] = $vcardKey;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'URL;X-egw-Ref1':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('URL;WORK', $rowNames) &&
|
2009-07-15 21:44:09 +02:00
|
|
|
!isset($finalRowNames['URL;WORK']))
|
|
|
|
{
|
|
|
|
$finalRowNames['URL;WORK'] = $vcardKey;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'URL;X-egw-Ref2':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!in_array('URL;HOME', $rowNames) &&
|
2009-07-15 21:44:09 +02:00
|
|
|
!isset($finalRowNames['URL;HOME']))
|
|
|
|
{
|
|
|
|
$finalRowNames['URL;HOME'] = $vcardKey;
|
2009-04-02 14:31:44 +02:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
break;
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'X-EVOLUTION-ASSISTANT':
|
2009-07-22 22:31:15 +02:00
|
|
|
if (!isset($finalRowNames['X-ASSISTANT']))
|
|
|
|
{
|
|
|
|
$finalRowNames['X-ASSISTANT'] = $vcardKey;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2006-07-09 01:02:30 +02:00
|
|
|
default:
|
2009-07-20 19:41:15 +02:00
|
|
|
if (!isset($finalRowNames[$rowName]))
|
|
|
|
{
|
|
|
|
$finalRowNames[$rowName] = $vcardKey;
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2006-03-21 14:19:38 +01:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
|
2010-01-09 19:04:21 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($finalRowNames)."\n",3,$this->logfile);
|
|
|
|
}
|
2009-07-27 09:03:10 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
$contact = array();
|
2006-03-21 14:19:38 +01:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
foreach ($finalRowNames as $key => $vcardKey)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
if (isset($databaseFields[$key]))
|
2006-03-21 14:19:38 +01:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$fieldNames = $databaseFields[$key];
|
|
|
|
foreach ($fieldNames as $fieldKey => $fieldName)
|
2006-03-21 14:19:38 +01:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
if (!empty($fieldName))
|
2006-03-21 14:19:38 +01:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$value = trim($vcardValues[$vcardKey]['values'][$fieldKey]);
|
|
|
|
if ($pref_tel && (($vcardKey == $pref_tel) ||
|
|
|
|
($vcardValues[$vcardKey]['name'] == 'TEL') &&
|
|
|
|
($vcardValues[$vcardKey]['value'] == $vcardValues[$pref_tel]['value'])))
|
2008-04-16 18:05:48 +02:00
|
|
|
{
|
2009-07-15 21:44:09 +02:00
|
|
|
$contact['tel_prefer'] = $fieldName;
|
2008-04-16 18:05:48 +02:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
switch($fieldName)
|
2006-03-21 14:19:38 +01:00
|
|
|
{
|
2006-07-09 15:29:19 +02:00
|
|
|
case 'bday':
|
2009-07-15 21:44:09 +02:00
|
|
|
$contact[$fieldName] = $vcardValues[$vcardKey]['values']['year'] .
|
|
|
|
'-' . $vcardValues[$vcardKey]['values']['month'] .
|
|
|
|
'-' . $vcardValues[$vcardKey]['values']['mday'];
|
2006-07-09 15:29:19 +02:00
|
|
|
break;
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
case 'private':
|
2008-09-03 19:09:17 +02:00
|
|
|
$contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE');
|
2006-07-09 01:02:30 +02:00
|
|
|
break;
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
case 'cat_id':
|
2010-03-07 00:06:43 +01:00
|
|
|
$contact[$fieldName] = $vcardValues[$vcardKey]['values'];
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'jpegphoto':
|
|
|
|
$contact[$fieldName] = $vcardValues[$vcardKey]['value'];
|
2006-07-09 01:02:30 +02:00
|
|
|
break;
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
2007-07-04 21:13:00 +02:00
|
|
|
case 'note':
|
2010-02-09 22:56:39 +01:00
|
|
|
$contact[$fieldName] = str_replace("\r\n", "\n", $vcardValues[$vcardKey]['value']);
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
|
2009-07-15 21:44:09 +02:00
|
|
|
case 'uid':
|
|
|
|
if (strlen($value) < $minimum_uid_length) {
|
|
|
|
// we don't use it
|
|
|
|
break;
|
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
default:
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$contact[$fieldName] = $value;
|
2009-07-15 21:44:09 +02:00
|
|
|
break;
|
2006-03-21 14:19:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-31 10:57:59 +01:00
|
|
|
// add unsupported attributes as with '##' prefix
|
2012-01-31 20:47:52 +01:00
|
|
|
elseif(($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'],array('PRODID','REV')))
|
2012-01-31 10:57:59 +01:00
|
|
|
{
|
|
|
|
// for attributes with multiple values in multiple lines, merge the values
|
|
|
|
if (isset($contact['##'.$attribute['name']]))
|
|
|
|
{
|
2012-02-09 21:09:49 +01:00
|
|
|
error_log(__METHOD__."() contact['##$attribute[name]'] = ".array2string($contact['##'.$attribute['name']]));
|
2012-01-31 10:57:59 +01:00
|
|
|
$attribute['values'] = array_merge(
|
|
|
|
is_array($contact['##'.$attribute['name']]) ? $contact['##'.$attribute['name']]['values'] : (array)$contact['##'.$attribute['name']],
|
|
|
|
$attribute['values']);
|
|
|
|
}
|
|
|
|
$contact['##'.$attribute['name']] = $attribute['params'] || count($attribute['values']) > 1 ?
|
|
|
|
serialize($attribute) : $attribute['value'];
|
|
|
|
}
|
2006-03-21 14:19:38 +01:00
|
|
|
}
|
2008-04-16 06:37:05 +02:00
|
|
|
|
SyncML patches from patrick.bihan-faou-AT-mindstep.com (without
logout+mbstring stuff), small modification to use the already exiting
methodes to generate full name and fileas)
The code is commited to trunk only at the moment to allow testing of it.
If everything goes well, we intend to commit it to 1.4 branch too.
Here's the original description of the patch by Patrick:
- handles the default config for current versions of funambol (i.e. the
scard/stask/snote/scal locations)
- tries to be a bit smarter on how the data content should be encoded
based on what the client specified (sif+base64/vcard, / fragmented or
not, etc.)
- workaround a bug in some versions of funambol, where funambol does not
specify the proper sif type for the type of requested data
- imported patch #117 from egw's tracker
- make sure that the logs generated by the horde code go to stderr so
they can be view in the webserver's logs
- as much as possible reduce code duplication. For example, the
categories are handled in the parent classes for both the SIF avn VCAL
formats for each type of data (addressbook,infolog,calendar).
- make sure the code can handle more than one categories in each
direction
- treat the 'sony ericsson' vendor string just like 'sonyericsson', the
newer phones apparently have a space in the vendor string... (this
touches some files in the icalsrv as well)
- handle notes: these should now work with everything (funambol or
other)
- remove more code duplication: the syncml "api" for the various data
types (calendar, contacts, infolog) is now common for both the vcard and
sif data formats (cf the files that need to be removed)
- handle the "privat" filter in infolog like the "private" filter (some
part of the code use the name without the trailing e)
- imported patch # 267 from egw's tracker
2007-09-29 12:29:48 +02:00
|
|
|
$this->fixup_contact($contact);
|
2011-10-05 11:24:08 +02:00
|
|
|
|
2010-01-09 19:04:21 +01:00
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
|
|
|
|
"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
|
|
|
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
|
|
|
|
array2string($contact)."\n",3,$this->logfile);
|
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
return $contact;
|
|
|
|
}
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
/**
|
|
|
|
* Exports some contacts: download or write to a file
|
|
|
|
*
|
|
|
|
* @param array $ids contact-ids
|
|
|
|
* @param string $file filename or null for download
|
|
|
|
*/
|
2009-07-15 21:44:09 +02:00
|
|
|
function export($ids, $file=null)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
|
|
|
if (!$file)
|
|
|
|
{
|
2010-04-11 11:34:42 +02:00
|
|
|
html::content_header('addressbook.vcf','text/x-vcard');
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
|
|
|
if (!($fp = fopen($file ? $file : 'php://output','w')))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-13 19:44:09 +02:00
|
|
|
if (isset($GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']))
|
|
|
|
{
|
|
|
|
$charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$charset = 'utf-8';
|
|
|
|
}
|
2009-07-15 21:44:09 +02:00
|
|
|
foreach ($ids as $id)
|
2006-07-09 01:02:30 +02:00
|
|
|
{
|
2010-04-13 19:44:09 +02:00
|
|
|
fwrite($fp,$this->getVCard($id, $charset));
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|
|
|
|
fclose($fp);
|
2008-04-16 06:37:05 +02:00
|
|
|
|
2006-07-09 01:02:30 +02:00
|
|
|
if (!$file)
|
|
|
|
{
|
2012-01-31 10:57:59 +01:00
|
|
|
common::egw_exit();
|
2008-04-16 06:37:05 +02:00
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
return true;
|
2005-07-20 14:14:39 +02:00
|
|
|
}
|
2012-01-31 10:57:59 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* return a groupVCard
|
|
|
|
*
|
|
|
|
* @param array $list values for 'list_uid', 'list_name', 'list_modified', 'members'
|
|
|
|
* @param string $version='3.0' vcard version
|
|
|
|
* @return string containing the vcard
|
|
|
|
*/
|
|
|
|
function getGroupVCard(array $list,$version='3.0')
|
|
|
|
{
|
|
|
|
require_once(EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar/vcard.php');
|
|
|
|
|
|
|
|
$vCard = new Horde_iCalendar_vcard($version);
|
|
|
|
$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['addressbook']['version'].'//'.
|
|
|
|
strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
|
|
|
|
|
2012-02-01 01:31:24 +01:00
|
|
|
$vCard->setAttribute('N',$list['list_name'],array(),true,array($list['list_name'],'','','',''));
|
2012-01-31 10:57:59 +01:00
|
|
|
$vCard->setAttribute('FN',$list['list_name']);
|
|
|
|
|
2012-01-31 18:13:25 +01:00
|
|
|
$vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND','group');
|
2012-01-31 10:57:59 +01:00
|
|
|
foreach($list['members'] as $uid)
|
|
|
|
{
|
2012-01-31 18:13:25 +01:00
|
|
|
$vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER','urn:uuid:'.$uid);
|
2012-01-31 10:57:59 +01:00
|
|
|
}
|
|
|
|
$vCard->setAttribute('REV',egw_time::to($list['list_modified'],'Y-m-d\TH:i:s\Z'));
|
|
|
|
$vCard->setAttribute('UID',$list['list_uid']);
|
|
|
|
|
|
|
|
return $vCard->exportvCalendar();
|
|
|
|
}
|
2006-07-09 01:02:30 +02:00
|
|
|
}
|