| @@ 1915-1943 (lines=29) @@ | ||
| 1912 | } |
|
| 1913 | //Import failed, download content anyway |
|
| 1914 | } |
|
| 1915 | if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD') |
|
| 1916 | { |
|
| 1917 | $addressbook_vcal = new addressbook_vcal(); |
|
| 1918 | // double \r\r\n seems to end a vcard prematurely, so we set them to \r\n |
|
| 1919 | //error_log(__METHOD__.__LINE__.$attachment['attachment']); |
|
| 1920 | $attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']); |
|
| 1921 | $vcard = $addressbook_vcal->vcardtoegw($attachment['attachment']); |
|
| 1922 | if ($vcard['uid']) |
|
| 1923 | { |
|
| 1924 | $vcard['uid'] = trim($vcard['uid']); |
|
| 1925 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
|
| 1926 | $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 1927 | } |
|
| 1928 | if (!$contact) $contact = null; |
|
| 1929 | // 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)) |
|
| 1930 | if ($contact || count($vcard)>2) |
|
| 1931 | { |
|
| 1932 | $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true); |
|
| 1933 | } |
|
| 1934 | if ((int)$contact > 0) |
|
| 1935 | { |
|
| 1936 | $vars = array( |
|
| 1937 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
|
| 1938 | 'contact_id' => $contact, |
|
| 1939 | ); |
|
| 1940 | $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
| 1941 | } |
|
| 1942 | //Import failed, download content anyway |
|
| 1943 | } |
|
| 1944 | } |
|
| 1945 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
|
| 1946 | Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save"); |
|
| @@ 2483-2511 (lines=29) @@ | ||
| 2480 | } |
|
| 2481 | //Import failed, download content anyway |
|
| 2482 | } |
|
| 2483 | if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD') |
|
| 2484 | { |
|
| 2485 | $addressbook_vcal = new addressbook_vcal(); |
|
| 2486 | // double \r\r\n seems to end a vcard prematurely, so we set them to \r\n |
|
| 2487 | //error_log(__METHOD__.__LINE__.$attachment['attachment']); |
|
| 2488 | $attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']); |
|
| 2489 | $vcard = $addressbook_vcal->vcardtoegw($attachment['attachment'], $attachment['charset']); |
|
| 2490 | if ($vcard['uid']) |
|
| 2491 | { |
|
| 2492 | $vcard['uid'] = trim($vcard['uid']); |
|
| 2493 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
|
| 2494 | $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2495 | } |
|
| 2496 | if (!$contact) $contact = null; |
|
| 2497 | // 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)) |
|
| 2498 | if ($contact || count($vcard)>2) |
|
| 2499 | { |
|
| 2500 | $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2501 | } |
|
| 2502 | if ((int)$contact > 0) |
|
| 2503 | { |
|
| 2504 | $vars = array( |
|
| 2505 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
|
| 2506 | 'contact_id' => $contact, |
|
| 2507 | ); |
|
| 2508 | Egw::redirect_link('../index.php',$vars); |
|
| 2509 | } |
|
| 2510 | //Import failed, download content anyway |
|
| 2511 | } |
|
| 2512 | } |
|
| 2513 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
|
| 2514 | $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|