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