formatting

This commit is contained in:
Miles Lott 2005-07-28 03:44:13 +00:00
parent 9a33b1f7be
commit b8bf4655fb

View File

@ -55,7 +55,7 @@
$vCard = Horde_iCalendar::newComponent('vcard', $container); $vCard = Horde_iCalendar::newComponent('vcard', $container);
if (!$vCard->parsevCalendar($_vcard,'VCARD')) if(!$vCard->parsevCalendar($_vcard,'VCARD'))
{ {
return False; return False;
} }
@ -67,22 +67,34 @@
foreach($vcardValues as $key => $vcardRow) foreach($vcardValues as $key => $vcardRow)
{ {
$rowName = $vcardRow['name']; $rowName = $vcardRow['name'];
$mailtype = ';INTERNET'; $mailtype = ';INTERNET';
$tempVal = ';WORK'; $tempVal = ';WORK';
if(isset($vcardRow['params']['INTERNET'])) if(isset($vcardRow['params']['INTERNET']))
{
$rowName .= ";INTERNET"; $rowName .= ";INTERNET";
}
if(isset($vcardRow['params']['CELL'])) if(isset($vcardRow['params']['CELL']))
{
$rowName .= ';CELL'; $rowName .= ';CELL';
}
if(isset($vcardRow['params']['FAX'])) if(isset($vcardRow['params']['FAX']))
{
$rowName .= ';FAX'; $rowName .= ';FAX';
}
if(isset($vcardRow['params']['PAGER'])) if(isset($vcardRow['params']['PAGER']))
{
$rowName .= ';PAGER'; $rowName .= ';PAGER';
}
if(isset($vcardRow['params']['WORK'])) if(isset($vcardRow['params']['WORK']))
{
$rowName .= ';WORK'; $rowName .= ';WORK';
}
if(isset($vcardRow['params']['HOME'])) if(isset($vcardRow['params']['HOME']))
{
$rowName .= ';HOME'; $rowName .= ';HOME';
}
$rowNames[$rowName] = $key; $rowNames[$rowName] = $key;
} }
@ -104,16 +116,22 @@
case 'TEL;CELL': case 'TEL;CELL':
case 'TEL;PAGER': case 'TEL;PAGER':
if(!isset($rowNames[$rowName.';WORK'])) if(!isset($rowNames[$rowName.';WORK']))
{
$finalRowNames[$rowName.';WORK'] = $vcardKey; $finalRowNames[$rowName.';WORK'] = $vcardKey;
}
break; break;
case 'EMAIL': case 'EMAIL':
case 'EMAIL;WORK': case 'EMAIL;WORK':
if(!isset($rowNames['EMAIL;INTERNET;WORK'])) if(!isset($rowNames['EMAIL;INTERNET;WORK']))
{
$finalRowNames['EMAIL;INTERNET;WORK'] = $vcardKey; $finalRowNames['EMAIL;INTERNET;WORK'] = $vcardKey;
}
break; break;
case 'EMAIL;HOME': case 'EMAIL;HOME':
if(!isset($rowNames['EMAIL;INTERNET;HOME'])) if(!isset($rowNames['EMAIL;INTERNET;HOME']))
{
$finalRowNames['EMAIL;INTERNET;HOME'] = $vcardKey; $finalRowNames['EMAIL;INTERNET;HOME'] = $vcardKey;
}
break; break;
case 'VERSION': case 'VERSION':
break; break;
@ -146,16 +164,46 @@
/* _debug_array($contact);exit; */ /* _debug_array($contact);exit; */
$contact['fn'] = trim($contact['n_given'].' '.$contact['n_family']); $contact['fn'] = trim($contact['n_given'].' '.$contact['n_family']);
if(!$contact['tel_work']) $contact['tel_work'] = ''; if(!$contact['tel_work'])
if(!$contact['tel_home']) $contact['tel_home'] = ''; {
if(!$contact['tel_voice']) $contact['tel_voice'] = ''; $contact['tel_work'] = '';
if(!$contact['tel_fax']) $contact['tel_fax'] = ''; }
if(!$contact['tel_msg']) $contact['tel_msg'] = ''; if(!$contact['tel_home'])
if(!$contact['tel_cell']) $contact['tel_cell'] = ''; {
if(!$contact['tel_pager']) $contact['tel_pager'] = ''; $contact['tel_home'] = '';
if(!$contact['tel_car']) $contact['tel_car'] = ''; }
if(!$contact['tel_isdn']) $contact['tel_isdn'] = ''; if(!$contact['tel_voice'])
if(!$contact['tel_video']) $contact['tel_video'] = ''; {
$contact['tel_voice'] = '';
}
if(!$contact['tel_fax'])
{
$contact['tel_fax'] = '';
}
if(!$contact['tel_msg'])
{
$contact['tel_msg'] = '';
}
if(!$contact['tel_cell'])
{
$contact['tel_cell'] = '';
}
if(!$contact['tel_pager'])
{
$contact['tel_pager'] = '';
}
if(!$contact['tel_car'])
{
$contact['tel_car'] = '';
}
if(!$contact['tel_isdn'])
{
$contact['tel_isdn'] = '';
}
if(!$contact['tel_video'])
{
$contact['tel_video'] = '';
}
$GLOBALS['egw']->translation->convert($contact,'utf-8'); $GLOBALS['egw']->translation->convert($contact,'utf-8');
@ -185,21 +233,20 @@
$vCard =& new Horde_iCalendar_vcard; $vCard =& new Horde_iCalendar_vcard;
#if ($this->xmlrpc && !isset($data['fields'])) #if($this->xmlrpc && !isset($data['fields']))
#{ #{
# $data['fields'] = array_keys(array_merge($this->so->contacts->non_contact_fields,$this->so->contacts->stock_contact_fields,$this->customfields())); # $data['fields'] = array_keys(array_merge($this->so->contacts->non_contact_fields,$this->so->contacts->stock_contact_fields,$this->customfields()));
#} #}
#if ($data['id'] < 0) #if($data['id'] < 0)
#{ #{
# $entry = array($this->user_pseudo_entry(-$data['id'])); # $entry = array($this->user_pseudo_entry(-$data['id']));
# if ($this->xmlrpc) # if($this->xmlrpc)
# { # {
# $entry = $this->data2xmlrpc($entry); # $entry = $this->data2xmlrpc($entry);
# } # }
# return $entry; # return $entry;
#} #}
$vcardFields[0] = array( $vcardFields[0] = array(
'ADR;WORK' => array('','','adr_one_street','adr_one_locality','adr_one_region', 'ADR;WORK' => array('','','adr_one_street','adr_one_locality','adr_one_region',
'adr_one_postalcode','adr_one_countryname'), 'adr_one_postalcode','adr_one_countryname'),
@ -258,7 +305,9 @@
foreach($databaseFields as $databaseField) foreach($databaseFields as $databaseField)
{ {
if(!empty($databaseField)) if(!empty($databaseField))
{
$fields[] = $databaseField; $fields[] = $databaseField;
}
} }
} }
@ -269,7 +318,7 @@
//$data = array('id' => $_id, 'fields' => $fields); //$data = array('id' => $_id, 'fields' => $fields);
$entry = $this->so->read_entry($_id,$fields); $entry = $this->so->read_entry($_id,$fields);
$entry = $this->strip_html($entry); $entry = $this->strip_html($entry);
if ($this->xmlrpc) if($this->xmlrpc)
{ {
$entry = $this->data2xmlrpc($entry); $entry = $this->data2xmlrpc($entry);
} }
@ -284,8 +333,10 @@
{ {
$tempVal = ';'; $tempVal = ';';
if(!empty($databaseField)) if(!empty($databaseField))
{
#$tempVal = trim('value').';'; #$tempVal = trim('value').';';
$tempVal = trim($entry[0][$databaseField]).';'; $tempVal = trim($entry[0][$databaseField]).';';
}
$value .= $tempVal; $value .= $tempVal;
} }
// remove the last ; // remove the last ;
@ -311,11 +362,17 @@
// don't add the entry if it contains only ';' // don't add the entry if it contains only ';'
if(strlen(str_replace(';','',$value)) != 0) if(strlen(str_replace(';','',$value)) != 0)
{
$vCard->setAttribute($vcardField, $value); $vCard->setAttribute($vcardField, $value);
}
if(preg_match('/([\000-\012\015\016\020-\037\075])/',$value)) if(preg_match('/([\000-\012\015\016\020-\037\075])/',$value))
{
$options['ENCODING'] = 'QUOTED-PRINTABLE'; $options['ENCODING'] = 'QUOTED-PRINTABLE';
}
if(preg_match('/([\177-\377])/',$value)) if(preg_match('/([\177-\377])/',$value))
{
$options['CHARSET'] = 'UTF-8'; $options['CHARSET'] = 'UTF-8';
}
$vCard->setParameter($vcardField, $options); $vCard->setParameter($vcardField, $options);
} }
@ -335,7 +392,7 @@
return $result; return $result;
} }
if ($this->xmlrpc) if($this->xmlrpc)
{ {
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']); $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
} }