mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Last commit broke more than was fixed - this reverts most changes
This commit is contained in:
parent
67047e145d
commit
2e69a4dfe8
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - VCard import/export class *
|
||||
* This file written by Miles Lott <milos@groupwhere.org> *
|
||||
* This file written by Miles Lott <milosch@phpgroupware.org> *
|
||||
* Parse vcards->contacts class fields, and vice-versa *
|
||||
* Copyright (C) 2001-2004 Miles Lott *
|
||||
* Copyright (C) 2001 Miles Lott *
|
||||
* -------------------------------------------------------------------------*
|
||||
* This library is part of the phpGroupWare API *
|
||||
* http://www.phpgroupware.org/api *
|
||||
* ------------------------------------------------------------------------ *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published by *
|
||||
@ -136,7 +139,7 @@
|
||||
if ( strstr(strtolower($name), $this->import[$fname]) )
|
||||
{
|
||||
$value = trim($value);
|
||||
$value = str_replace('=0D=0A',"\n",$value);
|
||||
$value = ereg_replace("=0D=0A","\n",$value);
|
||||
$buffer += array($name => $value);
|
||||
}
|
||||
}
|
||||
@ -188,10 +191,10 @@
|
||||
while ( list($name,$value) = @each($buffer) )
|
||||
{
|
||||
$field = split(';',$name);
|
||||
$field[0] = str_replace("A\.",'',$field[0]);
|
||||
$field[0] = str_replace("B\.",'',$field[0]);
|
||||
$field[0] = str_replace("C\.",'',$field[0]);
|
||||
$field[0] = str_replace("D\.",'',$field[0]);
|
||||
$field[0] = ereg_replace("A\.",'',$field[0]);
|
||||
$field[0] = ereg_replace("B\.",'',$field[0]);
|
||||
$field[0] = ereg_replace("C\.",'',$field[0]);
|
||||
$field[0] = ereg_replace("D\.",'',$field[0]);
|
||||
$values = split(';',$value);
|
||||
if ($field[1])
|
||||
{
|
||||
@ -199,10 +202,10 @@
|
||||
switch ($field[0])
|
||||
{
|
||||
case 'LABEL':
|
||||
$entry['label'] = str_replace('=0D=0A',"\n",$values[0]);
|
||||
$entry['label'] = ereg_replace('=0D=0A',"\n",$values[0]);
|
||||
break;
|
||||
case 'NOTE':
|
||||
$entry['note'] = str_replace('=0D=0A',"\n",$values[0]);
|
||||
$entry['note'] = ereg_replace('=0D=0A',"\n",$values[0]);
|
||||
break;
|
||||
case 'ADR':
|
||||
switch ($field[1])
|
||||
@ -385,6 +388,7 @@
|
||||
case 'TEL': // RB 2001/05/07 added for Lotus Organizer ueses TEL;{WORK|HOME};{VOICE|FAX}[;PREF]
|
||||
if ($field[2] == 'FAX' && ($field[1] == 'WORK' || $field[i] == 'HOME'))
|
||||
{
|
||||
/* TODO This is PHP4 only */
|
||||
array_shift($field); // --> ignore the WORK or HOME if FAX follows, HOME;FAX and HOME;TEL are maped later
|
||||
}
|
||||
switch ($field[1])
|
||||
@ -551,23 +555,26 @@
|
||||
$entry['url'] = $values[0];
|
||||
break;
|
||||
case 'NOTE':
|
||||
$entry['note'] = str_replace('=0D=0A',"\n",$values[0]);
|
||||
$entry['note'] = ereg_replace('=0D=0A',"\n",$values[0]);
|
||||
break;
|
||||
case 'KEY':
|
||||
$entry['key'] = str_replace('=0D=0A',"\n",$values[0]);
|
||||
$entry['key'] = ereg_replace('=0D=0A',"\n",$values[0]);
|
||||
break;
|
||||
case 'LABEL':
|
||||
$entry['label'] = str_replace('=0D=0A',"\n",$values[0]);
|
||||
$entry['label'] = ereg_replace('=0D=0A',"\n",$values[0]);
|
||||
break;
|
||||
case 'BDAY': #1969-12-31 OR 19691231
|
||||
case 'BDAY': #1969-12-31
|
||||
if(strlen($values[0]) == 8)
|
||||
{
|
||||
$entry['bday'] = substr($values[0],0,4) . '/' . substr($values[0],4,2) . '/' . substr($values[0],6,2);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = split('-',$values[0]);
|
||||
if($tmp[0])
|
||||
{
|
||||
$entry['bday'] = $tmp[1] . '/' . $tmp[2] . '/' . $tmp[0];
|
||||
}
|
||||
elseif(strlen($values[0]) == 8)
|
||||
{
|
||||
$entry['bday'] = substr($values[0],0,4) . '/' . substr($values[0],4,2) . '/' . substr($values[0],6,2);
|
||||
}
|
||||
break;
|
||||
case 'ORG': // RB 2001/05/07 added for Lotus Organizer: ORG:Company;Department
|
||||
@ -602,7 +609,7 @@
|
||||
$entry = '';
|
||||
$header = 'BEGIN:VCARD' . "\n";
|
||||
$header .= 'VERSION:2.1' . "\n";
|
||||
$header .= 'X-EGROUPWARE-FILE-AS:eGroupWare.org' . "\n";
|
||||
$header .= 'X-PHPGROUPWARE-FILE-AS:phpGroupWare.org' . "\n";
|
||||
|
||||
reset($this->export);
|
||||
while ( list($name,$value) = each($this->export) )
|
||||
@ -614,8 +621,8 @@
|
||||
{ // Normal
|
||||
if (strstr($buffer[$value],"\r\n") || strstr($buffer[$value],"\n"))
|
||||
{
|
||||
$buffer[$value] = str_replace("\r\n","=0D=0A",$buffer[$value]);
|
||||
$buffer[$value] = str_replace("\n","=0D=0A",$buffer[$value]);
|
||||
$buffer[$value] = ereg_replace("\r\n","=0D=0A",$buffer[$value]);
|
||||
$buffer[$value] = ereg_replace("\n","=0D=0A",$buffer[$value]);
|
||||
$entry .= $value . ';QUOTED-PRINTABLE:' . $buffer[$value]."\n";
|
||||
}
|
||||
elseif ($value == 'BDAY')
|
||||
@ -623,14 +630,8 @@
|
||||
$tmp = split('/',$buffer[$value]); # 12/31/1969 -> 1969-12-31
|
||||
if ($tmp[0])
|
||||
{
|
||||
if(strlen($tmp[0]) == 1)
|
||||
{
|
||||
$tmp[0] = '0'.$tmp[0];
|
||||
}
|
||||
if(strlen($tmp[0]) == 1)
|
||||
{
|
||||
$tmp[1] = '0'.$tmp[1];
|
||||
}
|
||||
if (strlen($tmp[0]) == 1) { $tmp[0] = '0'.$tmp[0]; }
|
||||
if (strlen($tmp[0]) == 1) { $tmp[1] = '0'.$tmp[1]; }
|
||||
$entry .= 'BDAY:' . $tmp[2] . '-' . $tmp[0] . '-' . $tmp[1] . "\n";
|
||||
}
|
||||
}
|
||||
@ -748,14 +749,8 @@
|
||||
switch($mult[1])
|
||||
{
|
||||
case 'TYPE':
|
||||
if($mult[2] == 'WORK')
|
||||
{
|
||||
$emailtype = ';' . $buffer[$value];
|
||||
}
|
||||
if($mult[2] == 'HOME')
|
||||
{
|
||||
$hemailtype = ';' . $buffer[$value];
|
||||
}
|
||||
if ($mult[2] == 'WORK') { $emailtype = ';' . $buffer[$value]; }
|
||||
if ($mult[2] == 'HOME') { $hemailtype = ';' . $buffer[$value]; }
|
||||
break;
|
||||
case 'WORK':
|
||||
$newval = 'A.'.$value;
|
||||
@ -794,21 +789,18 @@
|
||||
$entries .= 'ORG:' . $org_name . $org_unit . "\n";
|
||||
}
|
||||
|
||||
$workattr = str_replace('ADR;','',$workattr);
|
||||
$homeattr = str_replace('ADR;','',$homeattr);
|
||||
if(!$buffer['EXT'])
|
||||
{
|
||||
$buffer['EXT'] = ';';
|
||||
}
|
||||
$workattr = ereg_replace('ADR;','',$workattr);
|
||||
$homeattr = ereg_replace('ADR;','',$homeattr);
|
||||
if (!$buffer['EXT']) { $buffer['EXT'] = ';'; }
|
||||
if ($workaddr)
|
||||
{
|
||||
$work = 'A.ADR;' . $workattr . ':;' . $buffer['EXT'] . substr($workaddr,0,-1) . "\n";
|
||||
if (!$buffer['LABEL'])
|
||||
{
|
||||
$wlabel = substr($workaddr,0,-1);
|
||||
$wlabel = str_replace(';','=0D=0A',$wlabel);
|
||||
//$wlabel = str_replace('(',',',$wlabel);
|
||||
//$wlabel = str_replace(')',',',$wlabel);
|
||||
$wlabel = ereg_replace(';','=0D=0A',$wlabel);
|
||||
//$wlabel = ereg_replace('(',',',$wlabel);
|
||||
//$wlabel = ereg_replace(')',',',$wlabel);
|
||||
$wlabel = 'LABEL;WORK;QUOTED-PRINTABLE:' . $wlabel . "\n";
|
||||
}
|
||||
}
|
||||
@ -816,12 +808,12 @@
|
||||
{
|
||||
$home = 'B.ADR;'.$homeattr.':;;'.substr($homeaddr,0,-1)."\n";
|
||||
$hlabel = substr($homeaddr,0,-1);
|
||||
$hlabel = str_replace(';','=0D=0A',$hlabel);
|
||||
//$hlabel = str_replace('(',',',$hlabel);
|
||||
//$hlabel = str_replace(')',',',$hlabel);
|
||||
$hlabel = ereg_replace(';','=0D=0A',$hlabel);
|
||||
//$hlabel = ereg_replace('(',',',$hlabel);
|
||||
//$hlabel = ereg_replace(')',',',$hlabel);
|
||||
$hlabel = 'LABEL;HOME;QUOTED-PRINTABLE:' . $hlabel . "\n";
|
||||
}
|
||||
$entries = str_replace('PUBKEY','KEY',$entries);
|
||||
$entries = ereg_replace('PUBKEY','KEY',$entries);
|
||||
$entries .= $work . $home . $wlabel . $hlabel . 'END:VCARD' . "\n";
|
||||
$entries .= "\n";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user