Completed
Push — 16.1 ( 133628...46b074 )
by Ralf
37:08 queued 22:36
created
addressbook/inc/class.addressbook_vcal.inc.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
 	 * @var array
39 39
 	 */
40 40
 	var $databaseFields = array( // all entries e.g. for CardDAV
41
-			'ADR;WORK'			=> array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region',
42
-									'adr_one_postalcode','adr_one_countryname'),
43
-			'ADR;HOME'			=> array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region',
44
-									'adr_two_postalcode','adr_two_countryname'),
41
+			'ADR;WORK'			=> array('', 'adr_one_street2', 'adr_one_street', 'adr_one_locality', 'adr_one_region',
42
+									'adr_one_postalcode', 'adr_one_countryname'),
43
+			'ADR;HOME'			=> array('', 'adr_two_street2', 'adr_two_street', 'adr_two_locality', 'adr_two_region',
44
+									'adr_two_postalcode', 'adr_two_countryname'),
45 45
 			'BDAY'				=> array('bday'),
46 46
 			'CLASS'				=> array('private'),
47 47
 			'CATEGORIES'			=> array('cat_id'),
48 48
 			'EMAIL;WORK'			=> array('email'),
49 49
 			'EMAIL;HOME'			=> array('email_home'),
50
-			'N'				=> array('n_family','n_given','n_middle',
51
-									'n_prefix','n_suffix'),
50
+			'N'				=> array('n_family', 'n_given', 'n_middle',
51
+									'n_prefix', 'n_suffix'),
52 52
 			'FN'				=> array('n_fn'),
53 53
 			'NOTE'				=> array('note'),
54
-			'ORG'				=> array('org_name','org_unit','room'),
54
+			'ORG'				=> array('org_name', 'org_unit', 'room'),
55 55
 			'TEL;CELL;WORK'			=> array('tel_cell'),
56 56
 			'TEL;CELL;HOME'			=> array('tel_cell_private'),
57 57
 			'TEL;CAR'			=> array('tel_car'),
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	* off = false;
97 97
 	*/
98 98
 	var $log = false;
99
-	var $logfile="/tmp/log-vcard";
99
+	var $logfile = "/tmp/log-vcard";
100 100
 	/**
101 101
 	* Constructor
102 102
 	*
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 	* @param string	$_contentType			the content type (version)
105 105
 	* @param array $_clientProperties		client properties
106 106
 	*/
107
-	function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array())
107
+	function __construct($contact_app = 'addressbook', $_contentType = 'text/x-vcard', &$_clientProperties = array())
108 108
 	{
109 109
 		parent::__construct($contact_app);
110 110
 		if ($this->log)
111 111
 		{
112 112
 			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcard";
113
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
114
-				array2string($_contentType)."\n",3,$this->logfile);
113
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
114
+				array2string($_contentType)."\n", 3, $this->logfile);
115 115
 		}
116
-		switch($_contentType)
116
+		switch ($_contentType)
117 117
 		{
118 118
 			case 'text/vcard':
119 119
 				$this->version = '3.0';
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     *                         utf-8 for new format, iso-8859-1 for old format.
136 136
 	* @return int contact id
137 137
 	*/
138
-	function addVCard($_vcard, $_abID=null, $merge=false, $charset=null)
138
+	function addVCard($_vcard, $_abID = null, $merge = false, $charset = null)
139 139
 	{
140 140
 		if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false;
141 141
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 					}
162 162
 					if (is_array($contact['cat_id']))
163 163
 					{
164
-						$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID));
164
+						$contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], $_abID));
165 165
 					}
166 166
 					else
167 167
 					{
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
     	{
178 178
     		if (is_array($contact['cat_id']))
179 179
 			{
180
-				$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
180
+				$contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], -1));
181 181
 			}
182 182
     	}
183 183
     	if (isset($contact['owner']) && $contact['owner'] != $this->user)
184 184
     	{
185
-    		$contact['private'] = 0;	// foreign contacts are never private!
185
+    		$contact['private'] = 0; // foreign contacts are never private!
186 186
     	}
187 187
     	if ($this->log)
188 188
 		{
189
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190
-				array2string($contact)."\n",3,$this->logfile);
189
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
190
+				array2string($contact)."\n", 3, $this->logfile);
191 191
 		}
192 192
 		return $this->save($contact);
193 193
 	}
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	* @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
201 201
 	* @return string containing the vcard
202 202
 	*/
203
-	function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true)
203
+	function getVCard($_id, $_charset = 'UTF-8', $extra_charset_attribute = true)
204 204
 	{
205 205
 		$vCard = new Horde_Icalendar_Vcard($this->version);
206
-		$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'.
206
+		$vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'.
207 207
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
208 208
 
209 209
 		$sysCharSet = Api\Translation::charset();
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 				if (!$oval && ($this->version == '3.0'))
238 238
 				{
239 239
 					// declare OPTION as TYPE=OPTION
240
-					$options['TYPE'][] = $oname ;
240
+					$options['TYPE'][] = $oname;
241 241
 				}
242 242
 				else
243 243
 				{
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 				$noTruncate = $this->clientProperties[$vcardField]['NoTruncate'];
258 258
 				if ($this->log && $size > 0)
259 259
 				{
260
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
261
-						"() $vcardField Size: $size, NoTruncate: " .
262
-						($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
260
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
261
+						"() $vcardField Size: $size, NoTruncate: ".
262
+						($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
263 263
 				}
264 264
 				//Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " .
265 265
 				//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 				switch ($databaseField)
282 282
 				{
283 283
 					case 'modified':
284
-						$value = gmdate("Y-m-d\TH:i:s\Z",Api\DateTime::user2server($value));
284
+						$value = gmdate("Y-m-d\TH:i:s\Z", Api\DateTime::user2server($value));
285 285
 						$hasdata++;
286 286
 						break;
287 287
 
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 						{
296 296
 							if ($size == 8)
297 297
 							{
298
-								$value = str_replace('-','',$value);
298
+								$value = str_replace('-', '', $value);
299 299
 							}
300 300
 							elseif (isset($options['TYPE']) && (
301 301
 								$options['TYPE'] == 'BASIC'))
302 302
 							{
303 303
 								unset($options['TYPE']);
304 304
 								// used by old SyncML implementations
305
-								$value = str_replace('-','',$value).'T000000Z';
305
+								$value = str_replace('-', '', $value).'T000000Z';
306 306
 							}
307 307
 							$hasdata++;
308 308
 						}
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 					case 'cat_id':
334 334
 						if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//)
335 335
 						{
336
-							$values = (array) Api\Translation::convert($values, $sysCharSet, $_charset);
336
+							$values = (array)Api\Translation::convert($values, $sysCharSet, $_charset);
337 337
 							$value = implode(',', $values); // just for the CHARSET recognition
338 338
 							if (($size > 0) && strlen($value) > $size)
339 339
 							{
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 								{
344 344
 									if ($this->log)
345 345
 									{
346
-										error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
347
-										"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
346
+										error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
347
+										"() $vcardField omitted due to maximum size $size\n", 3, $this->logfile);
348 348
 									}
349 349
 									// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
350 350
 									//		__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 						// fall-through
394 394
 
395 395
 					default:
396
-						if (($size > 0) && strlen(implode(',', $values) . $value) > $size)
396
+						if (($size > 0) && strlen(implode(',', $values).$value) > $size)
397 397
 						{
398 398
 							if ($noTruncate)
399 399
 							{
400 400
 								if ($this->log)
401 401
 								{
402
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
403
-										"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
402
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
403
+										"() $vcardField omitted due to maximum size $size\n", 3, $this->logfile);
404 404
 								}
405 405
 								// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
406 406
 								//		__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
 							}
420 420
 							if ($this->log)
421 421
 							{
422
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
423
-									"() $vcardField truncated to maximum size $size\n",3,$this->logfile);
422
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
423
+									"() $vcardField truncated to maximum size $size\n", 3, $this->logfile);
424 424
 							}
425 425
 							//Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size",
426 426
 							//		__FILE__, __LINE__, PEAR_LOG_INFO);
427 427
 						}
428 428
 						if (!empty($value) // required field
429
-							|| in_array($vcardField,array('FN','ORG','N'))
429
+							|| in_array($vcardField, array('FN', 'ORG', 'N'))
430 430
 							|| ($size >= 0 && !$noTruncate))
431 431
 						{
432 432
 							$value = Api\Translation::convert(trim($value), $sysCharSet, $_charset);
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 
492 492
 		if ($this->log)
493 493
 		{
494
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
495
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
496
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
497
-				array2string($result)."\n",3,$this->logfile);
494
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
495
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
496
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
497
+				array2string($result)."\n", 3, $this->logfile);
498 498
 		}
499 499
 		return $result;
500 500
 	}
501 501
 
502
-	function search($_vcard, $contentID=null, $relax=false, $charset=null)
502
+	function search($_vcard, $contentID = null, $relax = false, $charset = null)
503 503
 	{
504 504
 		$result = array();
505 505
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 		{
508 508
 			if (is_array($contact['category']))
509 509
 			{
510
-					$contact['category'] = implode(',',$this->find_or_add_categories($contact['category'],
510
+					$contact['category'] = implode(',', $this->find_or_add_categories($contact['category'],
511 511
 						$contentID ? $contentID : -1));
512 512
 			}
513 513
 			if ($contentID)
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		return $result;
520 520
 	}
521 521
 
522
-	function setSupportedFields($_productManufacturer='file', $_productName='', $_supportedFields = null)
522
+	function setSupportedFields($_productManufacturer = 'file', $_productName = '', $_supportedFields = null)
523 523
 	{
524 524
 		$this->productManufacturer = strtolower($_productManufacturer);
525 525
 		$this->productName = strtolower($_productName);
@@ -541,18 +541,18 @@  discard block
 block discarded – undo
541 541
      *
542 542
      * @return array|boolean   The contact data or false on errors.
543 543
      */
544
-	function vcardtoegw($_vcard, $charset=null)
544
+	function vcardtoegw($_vcard, $charset = null)
545 545
 	{
546 546
 		// the horde class does the charset conversion. DO NOT CONVERT HERE.
547 547
 		// be as flexible as possible
548 548
 
549 549
 		if ($this->log)
550 550
 		{
551
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
552
-				array2string($_vcard)."\n",3,$this->logfile);
551
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
552
+				array2string($_vcard)."\n", 3, $this->logfile);
553 553
 		}
554 554
 
555
-		if(!($_vcard instanceof Horde_Icalendar))
555
+		if (!($_vcard instanceof Horde_Icalendar))
556 556
 		{
557 557
 			$container = false;
558 558
 			$vCard = Horde_Icalendar::newComponent('vcard', $container);
@@ -593,10 +593,10 @@  discard block
 block discarded – undo
593 593
 		$pref_tel = false;
594 594
 
595 595
 		$rowNames = array();
596
-		foreach($vcardValues as $key => $vcardRow)
596
+		foreach ($vcardValues as $key => $vcardRow)
597 597
 		{
598
-			$rowName  = strtoupper($vcardRow['name']);
599
-			if ($vcardRow['value'] == ''  && implode('', $vcardRow['values']) == '')
598
+			$rowName = strtoupper($vcardRow['name']);
599
+			if ($vcardRow['value'] == '' && implode('', $vcardRow['values']) == '')
600 600
 			{
601 601
 				unset($vcardRow);
602 602
 				continue;
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 				switch ($pname)
672 672
 				{
673 673
 					case 'PREF':
674
-						if (substr($rowName,0,3) == 'TEL' && !$pref_tel)
674
+						if (substr($rowName, 0, 3) == 'TEL' && !$pref_tel)
675 675
 						{
676 676
 							$pref_tel = $key;
677 677
 						}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 						if ($rowName != 'TEL') break;
685 685
 					case 'WORK':
686 686
 					case 'HOME':
687
-						$rowName .= ';' . $pname;
687
+						$rowName .= ';'.$pname;
688 688
 						break;
689 689
 					case 'CAR':
690 690
 					case 'X-CUSTOMLABEL-CAR':
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 						if (strpos($pname, 'X-FUNAMBOL-') === 0)
705 705
 						{
706 706
 							// Propriatary Funambol extension will be ignored
707
-							$rowName .= ';' . $pname;
707
+							$rowName .= ';'.$pname;
708 708
 						}
709 709
 						break;
710 710
 				}
@@ -712,39 +712,39 @@  discard block
 block discarded – undo
712 712
 
713 713
 			if ($rowName == 'EMAIL')
714 714
 			{
715
-				$rowName .= ';X-egw-Ref' . $email++;
715
+				$rowName .= ';X-egw-Ref'.$email++;
716 716
 			}
717 717
 
718 718
 			if (($rowName == 'TEL;CELL') ||
719 719
 					($rowName == 'TEL;CELL;VOICE'))
720 720
 			{
721
-				$rowName = 'TEL;CELL;X-egw-Ref' . $cell++;
721
+				$rowName = 'TEL;CELL;X-egw-Ref'.$cell++;
722 722
 			}
723 723
 
724 724
 			if (($rowName == 'TEL') ||
725 725
 					($rowName == 'TEL;VOICE'))
726 726
 			{
727
-				$rowName = 'TEL;X-egw-Ref' . $tel++;
727
+				$rowName = 'TEL;X-egw-Ref'.$tel++;
728 728
 			}
729 729
 
730 730
 			if ($rowName == 'URL')
731 731
 			{
732
-				$rowName = 'URL;X-egw-Ref' . $url++;
732
+				$rowName = 'URL;X-egw-Ref'.$url++;
733 733
 			}
734 734
 
735 735
 			// current algorithm cant cope with multiple attributes of same name
736 736
 			// --> cumulate them in values, so they can be used later (works only for values, not for parameters!)
737 737
 			if (($k = array_search($rowName, $rowNames)) != false)
738 738
 			{
739
-				$vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'],$vcardValues[$key]['values']);
739
+				$vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'], $vcardValues[$key]['values']);
740 740
 			}
741 741
 			$rowNames[$key] = $rowName;
742 742
 		}
743 743
 
744 744
 		if ($this->log)
745 745
 		{
746
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
747
-				array2string($rowNames)."\n",3,$this->logfile);
746
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
747
+				array2string($rowNames)."\n", 3, $this->logfile);
748 748
 		}
749 749
 
750 750
 		// All rowNames of the vCard are now concatenated with their qualifiers.
@@ -914,15 +914,15 @@  discard block
 block discarded – undo
914 914
 
915 915
 		if ($this->log)
916 916
 		{
917
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
918
-				array2string($finalRowNames)."\n",3,$this->logfile);
917
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
918
+				array2string($finalRowNames)."\n", 3, $this->logfile);
919 919
 		}
920 920
 
921 921
 		$contact = array();
922 922
 		// to be able to delete fields, we have to set all supported fields to at least null
923
-		foreach($this->supportedFields as $fields)
923
+		foreach ($this->supportedFields as $fields)
924 924
 		{
925
-			foreach($fields as $field)
925
+			foreach ($fields as $field)
926 926
 			{
927 927
 				if ($field != 'fileas_type') $contact[$field] = null;
928 928
 			}
@@ -945,16 +945,16 @@  discard block
 block discarded – undo
945 945
 						{
946 946
 							$contact['tel_prefer'] = $fieldName;
947 947
 						}
948
-						switch($fieldName)
948
+						switch ($fieldName)
949 949
 						{
950 950
 							case 'bday':
951
-								$contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'] .
952
-									'-' . $vcardValues[$vcardKey]['value']['month'] .
953
-									'-' . $vcardValues[$vcardKey]['value']['mday'];
951
+								$contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'].
952
+									'-'.$vcardValues[$vcardKey]['value']['month'].
953
+									'-'.$vcardValues[$vcardKey]['value']['mday'];
954 954
 								break;
955 955
 
956 956
 							case 'private':
957
-								$contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE');
957
+								$contact[$fieldName] = (int)(strtoupper($value) == 'PRIVATE');
958 958
 								break;
959 959
 
960 960
 							case 'cat_id':
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 
964 964
 							case 'jpegphoto':
965 965
 								$contact[$fieldName] = $vcardValues[$vcardKey]['value'];
966
-								if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64')))
966
+								if (in_array($vcardValues[$vcardKey]['params']['ENCODING'], array('b', 'B', 'BASE64')))
967 967
 								{
968 968
 									$contact[$fieldName] = base64_decode($contact[$fieldName]);
969 969
 								}
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 				}
995 995
 			}
996 996
 			// add unsupported attributes as with '##' prefix
997
-			elseif(($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'],array('PRODID','REV')))
997
+			elseif (($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'], array('PRODID', 'REV')))
998 998
 			{
999 999
 				// for attributes with multiple values in multiple lines, merge the values
1000 1000
 				if (isset($contact['##'.$attribute['name']]))
@@ -1013,10 +1013,10 @@  discard block
 block discarded – undo
1013 1013
 
1014 1014
 		if ($this->log)
1015 1015
 		{
1016
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__	.
1017
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1018
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1019
-				array2string($contact)."\n",3,$this->logfile);
1016
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1017
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1018
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1019
+				array2string($contact)."\n", 3, $this->logfile);
1020 1020
 		}
1021 1021
 		return $contact;
1022 1022
 	}
@@ -1027,14 +1027,14 @@  discard block
 block discarded – undo
1027 1027
 	 * @param array $ids contact-ids
1028 1028
 	 * @param string $file filename or null for download
1029 1029
 	 */
1030
-	function export($ids, $file=null)
1030
+	function export($ids, $file = null)
1031 1031
 	{
1032 1032
 		if (!$file)
1033 1033
 		{
1034
-			$filename = count($ids) == 1 ? Link::title('addressbook',$ids[0]): 'egw_addressbook_'.date('Y-m-d');
1035
-			Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf','text/x-vcard');
1034
+			$filename = count($ids) == 1 ? Link::title('addressbook', $ids[0]) : 'egw_addressbook_'.date('Y-m-d');
1035
+			Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf', 'text/x-vcard');
1036 1036
 		}
1037
-		if (!($fp = fopen($file ? $file : 'php://output','w')))
1037
+		if (!($fp = fopen($file ? $file : 'php://output', 'w')))
1038 1038
 		{
1039 1039
 			return false;
1040 1040
 		}
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		}
1049 1049
 		foreach ($ids as $id)
1050 1050
 		{
1051
-			fwrite($fp,$this->getVCard($id, $charset));
1051
+			fwrite($fp, $this->getVCard($id, $charset));
1052 1052
 		}
1053 1053
 		fclose($fp);
1054 1054
 
@@ -1066,22 +1066,22 @@  discard block
 block discarded – undo
1066 1066
 	 * @param string $version ='3.0' vcard version
1067 1067
 	 * @return string containing the vcard
1068 1068
 	 */
1069
-	function getGroupVCard(array $list,$version='3.0')
1069
+	function getGroupVCard(array $list, $version = '3.0')
1070 1070
 	{
1071 1071
 		$vCard = new Horde_Icalendar_Vcard($version);
1072
-		$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'.
1072
+		$vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['api']['version'].'//'.
1073 1073
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
1074 1074
 
1075
-		$vCard->setAttribute('N',$list['list_name'],array(),true,array($list['list_name'],'','','',''));
1076
-		$vCard->setAttribute('FN',$list['list_name']);
1075
+		$vCard->setAttribute('N', $list['list_name'], array(), true, array($list['list_name'], '', '', '', ''));
1076
+		$vCard->setAttribute('FN', $list['list_name']);
1077 1077
 
1078
-		$vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND','group');
1079
-		foreach($list['members'] as $uid)
1078
+		$vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND', 'group');
1079
+		foreach ($list['members'] as $uid)
1080 1080
 		{
1081
-			$vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER','urn:uuid:'.$uid);
1081
+			$vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER', 'urn:uuid:'.$uid);
1082 1082
 		}
1083
-		$vCard->setAttribute('REV',Api\DateTime::to($list['list_modified'],'Y-m-d\TH:i:s\Z'));
1084
-		$vCard->setAttribute('UID',$list['list_uid']);
1083
+		$vCard->setAttribute('REV', Api\DateTime::to($list['list_modified'], 'Y-m-d\TH:i:s\Z'));
1084
+		$vCard->setAttribute('UID', $list['list_uid']);
1085 1085
 
1086 1086
 		return $vCard->exportvCalendar();
1087 1087
 	}
Please login to merge, or discard this patch.