| @@ 2467-2495 (lines=29) @@ | ||
| 2464 | } |
|
| 2465 | //Import failed, download content anyway |
|
| 2466 | } |
|
| 2467 | if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD') |
|
| 2468 | { |
|
| 2469 | $addressbook_vcal = new addressbook_vcal(); |
|
| 2470 | // double \r\r\n seems to end a vcard prematurely, so we set them to \r\n |
|
| 2471 | //error_log(__METHOD__.__LINE__.$attachment['attachment']); |
|
| 2472 | $attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']); |
|
| 2473 | $vcard = $addressbook_vcal->vcardtoegw($attachment['attachment'], $attachment['charset']); |
|
| 2474 | if ($vcard['uid']) |
|
| 2475 | { |
|
| 2476 | $vcard['uid'] = trim($vcard['uid']); |
|
| 2477 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
|
| 2478 | $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2479 | } |
|
| 2480 | if (!$contact) $contact = null; |
|
| 2481 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
|
| 2482 | if ($contact || count($vcard)>2) |
|
| 2483 | { |
|
| 2484 | $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2485 | } |
|
| 2486 | if ((int)$contact > 0) |
|
| 2487 | { |
|
| 2488 | $vars = array( |
|
| 2489 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
|
| 2490 | 'contact_id' => $contact, |
|
| 2491 | ); |
|
| 2492 | Egw::redirect_link('../index.php',$vars); |
|
| 2493 | } |
|
| 2494 | //Import failed, download content anyway |
|
| 2495 | } |
|
| 2496 | } |
|
| 2497 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
|
| 2498 | $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|
| @@ 1908-1936 (lines=29) @@ | ||
| 1905 | } |
|
| 1906 | //Import failed, download content anyway |
|
| 1907 | } |
|
| 1908 | if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD') |
|
| 1909 | { |
|
| 1910 | $addressbook_vcal = new addressbook_vcal(); |
|
| 1911 | // double \r\r\n seems to end a vcard prematurely, so we set them to \r\n |
|
| 1912 | //error_log(__METHOD__.__LINE__.$attachment['attachment']); |
|
| 1913 | $attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']); |
|
| 1914 | $vcard = $addressbook_vcal->vcardtoegw($attachment['attachment']); |
|
| 1915 | if ($vcard['uid']) |
|
| 1916 | { |
|
| 1917 | $vcard['uid'] = trim($vcard['uid']); |
|
| 1918 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
|
| 1919 | $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 1920 | } |
|
| 1921 | if (!$contact) $contact = null; |
|
| 1922 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
|
| 1923 | if ($contact || count($vcard)>2) |
|
| 1924 | { |
|
| 1925 | $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true); |
|
| 1926 | } |
|
| 1927 | if ((int)$contact > 0) |
|
| 1928 | { |
|
| 1929 | $vars = array( |
|
| 1930 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
|
| 1931 | 'contact_id' => $contact, |
|
| 1932 | ); |
|
| 1933 | $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
| 1934 | } |
|
| 1935 | //Import failed, download content anyway |
|
| 1936 | } |
|
| 1937 | } |
|
| 1938 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
|
| 1939 | Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save"); |
|