Code Duplication    Length = 29-29 lines in 2 locations

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");

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

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