Code Duplication    Length = 29-29 lines in 2 locations

mail/inc/class.mail_ui.inc.php 1 location

@@ 2598-2626 (lines=29) @@
2595
				}
2596
				//Import failed, download content anyway
2597
			}
2598
			if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD')
2599
			{
2600
				$addressbook_vcal = new addressbook_vcal();
2601
				// double \r\r\n seems to end a vcard prematurely, so we set them to \r\n
2602
				//error_log(__METHOD__.__LINE__.$attachment['attachment']);
2603
				$attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']);
2604
				$vcard = $addressbook_vcal->vcardtoegw($attachment['attachment'], $attachment['charset']);
2605
				if ($vcard['uid'])
2606
				{
2607
					$vcard['uid'] = trim($vcard['uid']);
2608
					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2609
					$contact = $addressbook_vcal->find_contact($vcard,false);
2610
				}
2611
				if (!$contact) $contact = null;
2612
				// 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))
2613
				if ($contact || count($vcard)>2)
2614
				{
2615
					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2616
				}
2617
				if ((int)$contact > 0)
2618
				{
2619
					$vars = array(
2620
						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2621
						'contact_id'	=> $contact,
2622
					);
2623
					Egw::redirect_link('../index.php',$vars);
2624
				}
2625
				//Import failed, download content anyway
2626
			}
2627
		}
2628
		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2629
		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));

mail/inc/class.mail_compose.inc.php 1 location

@@ 1921-1949 (lines=29) @@
1918
				}
1919
				//Import failed, download content anyway
1920
			}
1921
			if (strtoupper($attachment['type']) == 'TEXT/X-VCARD' || strtoupper($attachment['type']) == 'TEXT/VCARD')
1922
			{
1923
				$addressbook_vcal = new addressbook_vcal();
1924
				// double \r\r\n seems to end a vcard prematurely, so we set them to \r\n
1925
				//error_log(__METHOD__.__LINE__.$attachment['attachment']);
1926
				$attachment['attachment'] = str_replace("\r\r\n", "\r\n", $attachment['attachment']);
1927
				$vcard = $addressbook_vcal->vcardtoegw($attachment['attachment']);
1928
				if ($vcard['uid'])
1929
				{
1930
					$vcard['uid'] = trim($vcard['uid']);
1931
					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
1932
					$contact = $addressbook_vcal->find_contact($vcard,false);
1933
				}
1934
				if (!$contact) $contact = null;
1935
				// 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))
1936
				if ($contact || count($vcard)>2)
1937
				{
1938
					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true);
1939
				}
1940
				if ((int)$contact > 0)
1941
				{
1942
					$vars = array(
1943
						'menuaction'	=> 'addressbook.addressbook_ui.edit',
1944
						'contact_id'	=> $contact,
1945
					);
1946
					$GLOBALS['egw']->redirect_link('../index.php',$vars);
1947
				}
1948
				//Import failed, download content anyway
1949
			}
1950
		}
1951
		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
1952
		Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save");