Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
infolog/inc/class.infolog_groupdav.inc.php 3 patches
Braces   +76 added lines, -19 removed lines patch added patch discarded remove patch
@@ -91,7 +91,10 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 		else
93 93
 		{
94
-			if (!is_array($info)) $info = $this->bo->read($info);
94
+			if (!is_array($info))
95
+			{
96
+				$info = $this->bo->read($info);
97
+			}
95 98
 			$name = $info[self::$path_attr];
96 99
 		}
97 100
 		return $name.self::$path_extension;
@@ -159,7 +162,11 @@  discard block
 block discarded – undo
159 162
 		// enable time-range filter for tests via propfind / autoindex
160 163
 		//$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z'));
161 164
 
162
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
165
+		if ($id)
166
+		{
167
+			$path = dirname($path).'/';
168
+		}
169
+		// caldav_name get's added anyway in the callback
163 170
 
164 171
 		if ($this->debug > 1)
165 172
 		{
@@ -226,7 +233,10 @@  discard block
 block discarded – undo
226 233
 	 */
227 234
 	function &propfind_callback($path,array $filter,$start=false)
228 235
 	{
229
-		if ($this->debug) $starttime = microtime(true);
236
+		if ($this->debug)
237
+		{
238
+			$starttime = microtime(true);
239
+		}
230 240
 
231 241
 		if (($calendar_data = $filter['calendar_data']))
232 242
 		{
@@ -242,7 +252,10 @@  discard block
 block discarded – undo
242 252
 		if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches))
243 253
 		{
244 254
 			$order = $matches[1];
245
-			if ($matches[2]) $sort = $matches[2];
255
+			if ($matches[2])
256
+			{
257
+				$sort = $matches[2];
258
+			}
246 259
 			unset($filter['order']);
247 260
 		}
248 261
 		$query = array(
@@ -325,7 +338,10 @@  discard block
 block discarded – undo
325 338
 				--$this->sync_collection_token;
326 339
 			}
327 340
 		}
328
-		if ($this->debug) error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items');
341
+		if ($this->debug)
342
+		{
343
+			error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items');
344
+		}
329 345
 		return $files;
330 346
 	}
331 347
 
@@ -347,7 +363,10 @@  discard block
 block discarded – undo
347 363
 				switch($filter['name'])
348 364
 				{
349 365
 					case 'comp-filter':
350
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
366
+						if ($this->debug > 1)
367
+						{
368
+							error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
369
+						}
351 370
 
352 371
 						switch($filter['attrs']['name'])
353 372
 						{
@@ -359,14 +378,23 @@  discard block
 block discarded – undo
359 378
 						}
360 379
 						break;
361 380
 					case 'prop-filter':
362
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
381
+						if ($this->debug > 1)
382
+						{
383
+							error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
384
+						}
363 385
 						$prop_filter = $filter['attrs']['name'];
364 386
 						break;
365 387
 					case 'text-match':
366
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
388
+						if ($this->debug > 1)
389
+						{
390
+							error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
391
+						}
367 392
 						if (!isset($this->filter_prop2infolog[strtoupper($prop_filter)]))
368 393
 						{
369
-							if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
394
+							if ($this->debug)
395
+							{
396
+								error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
397
+							}
370 398
 						}
371 399
 						else
372 400
 						{
@@ -375,13 +403,19 @@  discard block
 block discarded – undo
375 403
 						unset($prop_filter);
376 404
 						break;
377 405
 					case 'param-filter':
378
-						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
406
+						if ($this->debug)
407
+						{
408
+							error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
409
+						}
379 410
 						break;
380 411
 					case 'time-range':
381 412
 						$cal_filters[] = $this->_time_range_filter($filter['attrs']);
382 413
 						break;
383 414
 					default:
384
-						if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
415
+						if ($this->debug)
416
+						{
417
+							error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
418
+						}
385 419
 						break;
386 420
 				}
387 421
 			}
@@ -450,7 +484,10 @@  discard block
 block discarded – undo
450 484
 					}
451 485
 				}
452 486
 			}
453
-			if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
487
+			if ($this->debug > 1)
488
+			{
489
+				error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
490
+			}
454 491
 		}
455 492
 		return true;
456 493
 	}
@@ -511,7 +548,10 @@  discard block
 block discarded – undo
511 548
  			"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
512 549
 		')';
513 550
 		$sql = '('.implode(' OR ', $to_or).')';
514
-		if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
551
+		if ($this->debug > 1)
552
+		{
553
+			error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
554
+		}
515 555
 		return $sql;
516 556
 	}
517 557
 
@@ -552,7 +592,10 @@  discard block
 block discarded – undo
552 592
 	{
553 593
 		unset($prefix);	// not used, but required by function signature
554 594
 
555
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
595
+		if ($this->debug)
596
+		{
597
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
598
+		}
556 599
 
557 600
 		$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
558 601
 		if (!is_null($oldTask) && !is_array($oldTask))
@@ -580,7 +623,10 @@  discard block
 block discarded – undo
580 623
 		}
581 624
 		if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data)))
582 625
 		{
583
-			if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false");
626
+			if ($this->debug)
627
+			{
628
+				error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false");
629
+			}
584 630
 			return '403 Forbidden';
585 631
 		}
586 632
 
@@ -592,11 +638,13 @@  discard block
 block discarded – undo
592 638
 		// send evtl. necessary respose headers: Location, etag, ...
593 639
 		// but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag
594 640
 		if ($retval !== true)
595
-			// POST with add-member query parameter
641
+		{
642
+					// POST with add-member query parameter
596 643
 			//$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
597 644
 		{
598 645
 			$this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name');
599 646
 		}
647
+		}
600 648
 		return $retval;
601 649
 	}
602 650
 
@@ -607,7 +655,10 @@  discard block
 block discarded – undo
607 655
 	 */
608 656
 	public function update_tags($entry)
609 657
 	{
610
-		if (!is_array($entry)) $entry = $this->read($entry);
658
+		if (!is_array($entry))
659
+		{
660
+			$entry = $this->read($entry);
661
+		}
611 662
 
612 663
 		$this->bo->write($entry, true);
613 664
 	}
@@ -729,7 +780,10 @@  discard block
 block discarded – undo
729 780
 	 */
730 781
 	function check_access($acl,$task)
731 782
 	{
732
-		if (is_null($task)) return true;
783
+		if (is_null($task))
784
+		{
785
+			return true;
786
+		}
733 787
 
734 788
 		$access = $this->bo->check_access($task,$acl);
735 789
 
@@ -737,7 +791,10 @@  discard block
 block discarded – undo
737 791
 		{
738 792
 			$access = true;	// access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
739 793
 		}
740
-		if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
794
+		if ($this->debug > 1)
795
+		{
796
+			error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
797
+		}
741 798
 		return $access;
742 799
 	}
743 800
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param array &$options
142 142
 	 * @param array &$files
143 143
 	 * @param int $user account_id
144
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
144
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
145 145
 	 */
146 146
 	function propfind($path,&$options,&$files,$user,$id='')
147 147
 	{
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param string $path
223 223
 	 * @param array $filter
224
-	 * @param array|boolean $start =false false=return all or array(start,num)
224
+	 * @param integer[] $start =false false=return all or array(start,num)
225 225
 	 * @return array with "files" array with values for keys path and props
226 226
 	 */
227 227
 	function &propfind_callback($path,array $filter,$start=false)
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 * @param array &$options
531 531
 	 * @param int $id
532 532
 	 * @param int $user =null account_id
533
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
533
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
534 534
 	 */
535 535
 	function get(&$options,$id,$user=null)
536 536
 	{
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 	 * @param int $id
556 556
 	 * @param int $user =null account_id of owner, default null
557 557
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
558
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
558
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
559 559
 	 */
560 560
 	function put(&$options,$id,$user=null,$prefix=null)
561 561
 	{
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	 * @param array &$options
695 695
 	 * @param int $id
696 696
 	 * @param int $user account_id of collection owner
697
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
697
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
698 698
 	 */
699 699
 	function delete(&$options,$id,$user)
700 700
 	{
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	 * etag currently uses the modifcation time (info_datemodified), 1.9.002 adds etag column, but it's not yet used!
772 772
 	 *
773 773
 	 * @param array|int $info array with infolog entry or info_id
774
-	 * @return string|boolean string with etag or false
774
+	 * @return false|string string with etag or false
775 775
 	 */
776 776
 	function get_etag($info)
777 777
 	{
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		}
113 113
 		if ($path == '/infolog/')
114 114
 		{
115
-			$task_filter= 'own';
115
+			$task_filter = 'own';
116 116
 		}
117 117
 		else
118 118
 		{
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			else
124 124
 			{
125
-				$task_filter = 'user' . $user;
125
+				$task_filter = 'user'.$user;
126 126
 			}
127 127
 		}
128 128
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @param int $user account_id
144 144
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
145 145
 	 */
146
-	function propfind($path,&$options,&$files,$user,$id='')
146
+	function propfind($path, &$options, &$files, $user, $id = '')
147 147
 	{
148 148
 		// todo add a filter to limit how far back entries from the past get synced
149 149
 		$filter = $this->get_infolog_filter($path, $user);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		// enable time-range filter for tests via propfind / autoindex
160 160
 		//$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z'));
161 161
 
162
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
162
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
163 163
 
164 164
 		if ($this->debug > 1)
165 165
 		{
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		if (!($filter['calendar_data'] = $options['props'] == 'all' &&
172 172
 			$options['root']['ns'] == Api\CalDAV::CALDAV) && is_array($options['props']))
173 173
 		{
174
-			foreach($options['props'] as $prop)
174
+			foreach ($options['props'] as $prop)
175 175
 			{
176 176
 				if ($prop['name'] == 'calendar-data')
177 177
 				{
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 			$this->sync_collection_token = null;
193 193
 
194
-			$filter['order'] = 'info_datemodified ASC';	// return oldest modifications first
194
+			$filter['order'] = 'info_datemodified ASC'; // return oldest modifications first
195 195
 			$filter['sync-collection'] = true;
196 196
 		}
197 197
 
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
206 206
 			{
207 207
 				--$this->sync_collection_token;
208
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
208
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
209 209
 			}
210 210
 		}
211 211
 		else
212 212
 		{
213 213
 			// return iterator, calling ourself to return result in chunks
214
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
214
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
215 215
 		}
216 216
 		return true;
217 217
 	}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @param array|boolean $start =false false=return all or array(start,num)
225 225
 	 * @return array with "files" array with values for keys path and props
226 226
 	 */
227
-	function &propfind_callback($path,array $filter,$start=false)
227
+	function &propfind_callback($path, array $filter, $start = false)
228 228
 	{
229 229
 		if ($this->debug) $starttime = microtime(true);
230 230
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			'filter'    	=> $task_filter,
252 252
 			'date_format'	=> 'server',
253 253
 			'col_filter'	=> $filter,
254
-			'custom_fields' => true,	// otherwise custom fields get NOT loaded!
254
+			'custom_fields' => true, // otherwise custom fields get NOT loaded!
255 255
 		);
256 256
 		$check_responsible = false;
257 257
 		if (substr($task_filter, -8) == '+deleted')
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$files = array();
281 281
 		// ToDo: add parameter to only return id & etag
282
-		$tasks =& $this->bo->search($query);
282
+		$tasks = & $this->bo->search($query);
283 283
 		if ($tasks && $offset == $query['start'])
284 284
 		{
285
-			foreach($tasks as $task)
285
+			foreach ($tasks as $task)
286 286
 			{
287 287
 				// remove task from requested multiget ids, to be able to report not found urls
288 288
 				if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 					continue;
300 300
 				}
301 301
 				$props = array(
302
-					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar',	// Konqueror (3.5) dont understand it otherwise
302
+					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise
303 303
 					'getlastmodified' => $task['info_datemodified'],
304 304
 					'displayname' => $task['info_subject'],
305 305
 				);
306 306
 				if ($calendar_data)
307 307
 				{
308
-					$content = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
308
+					$content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
309 309
 					$props['getcontentlength'] = bytes($content);
310
-					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
310
+					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
311 311
 				}
312 312
 				$files[] = $this->add_resource($path, $task, $props);
313 313
 			}
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 		// report not found multiget urls
316 316
 		if ($requested_multiget_ids)
317 317
 		{
318
-			foreach($requested_multiget_ids as $id)
318
+			foreach ($requested_multiget_ids as $id)
319 319
 			{
320 320
 				$files[] = array('path' => $path.$id.self::$path_extension);
321 321
 			}
322 322
 		}
323 323
 		// sync-collection report --> return modified of last contact as sync-token
324
-		$sync_collection_report =  $filter['sync-collection'];
324
+		$sync_collection_report = $filter['sync-collection'];
325 325
 		if ($sync_collection_report)
326 326
 		{
327 327
 			$this->sync_collection_token = $task['date_modified'];
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 	 * @param int &$nresult on return limit for number or results or unchanged/null
348 348
 	 * @return boolean true if filter could be processed
349 349
 	 */
350
-	function _report_filters($options,&$cal_filters,$id, &$nresults)
350
+	function _report_filters($options, &$cal_filters, $id, &$nresults)
351 351
 	{
352 352
 		if ($options['filters'])
353 353
 		{
354
-			foreach($options['filters'] as $filter)
354
+			foreach ($options['filters'] as $filter)
355 355
 			{
356
-				switch($filter['name'])
356
+				switch ($filter['name'])
357 357
 				{
358 358
 					case 'comp-filter':
359 359
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
360 360
 
361
-						switch($filter['attrs']['name'])
361
+						switch ($filter['attrs']['name'])
362 362
 						{
363 363
 							case 'VTODO':
364 364
 							case 'VCALENDAR':
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 		    <B:nresults>10</B:nresults>
402 402
 		  </B:limit>
403 403
 		*/
404
-		foreach((array)$options['other'] as $option)
404
+		foreach ((array)$options['other'] as $option)
405 405
 		{
406
-			switch($option['name'])
406
+			switch ($option['name'])
407 407
 			{
408 408
 				case 'nresults':
409 409
 					$nresults = (int)$option['data'];
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 				case 'limit':
413 413
 					break;
414 414
 				case 'href':
415
-					break;	// from addressbook-multiget, handled below
415
+					break; // from addressbook-multiget, handled below
416 416
 				// rfc 6578 sync-report
417 417
 				case 'sync-token':
418 418
 					if (!empty($option['data']))
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 						$parts = explode('/', $option['data']);
421 421
 						$sync_token = array_pop($parts);
422 422
 						$cal_filters[] = 'info_datemodified>'.(int)$sync_token;
423
-						$cal_filters['filter'] .= '+deleted';	// to return deleted entries too
423
+						$cal_filters['filter'] .= '+deleted'; // to return deleted entries too
424 424
 					}
425 425
 					break;
426 426
 				case 'sync-level':
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
 			if ($id)
443 443
 			{
444 444
 				$cal_filters[self::$path_attr] = self::$path_extension ?
445
-					basename($id,self::$path_extension) : $id;
445
+					basename($id, self::$path_extension) : $id;
446 446
 			}
447 447
 			else	// fetch all given url's
448 448
 			{
449
-				foreach($options['other'] as $option)
449
+				foreach ($options['other'] as $option)
450 450
 				{
451 451
 					if ($option['name'] == 'href')
452 452
 					{
453
-						$parts = explode('/',$option['data']);
453
+						$parts = explode('/', $option['data']);
454 454
 						if (($id = basename(urldecode(array_pop($parts)))))
455 455
 						{
456 456
 							$cal_filters[self::$path_attr][] = self::$path_extension ?
457
-								basename($id,self::$path_extension) : $id;
457
+								basename($id, self::$path_extension) : $id;
458 458
 						}
459 459
 					}
460 460
 				}
461 461
 			}
462
-			if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
462
+			if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids));
463 463
 		}
464 464
 		return true;
465 465
 	}
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 		elseif (empty($attrs['start']))
488 488
 		{
489 489
 			$this->caldav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!');
490
-			return '1';	// to not give sql error, but simply not filter out anything
490
+			return '1'; // to not give sql error, but simply not filter out anything
491 491
 		}
492 492
 		// we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate
493 493
 
@@ -517,10 +517,10 @@  discard block
 block discarded – undo
517 517
 			"info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : '').
518 518
 				(isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '.
519 519
 			// we have no completed date, but always a created date
520
- 			"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
520
+ 			"NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : '').
521 521
 		')';
522 522
 		$sql = '('.implode(' OR ', $to_or).')';
523
-		if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
523
+		if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
524 524
 		return $sql;
525 525
 	}
526 526
 
@@ -532,16 +532,16 @@  discard block
 block discarded – undo
532 532
 	 * @param int $user =null account_id
533 533
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
534 534
 	 */
535
-	function get(&$options,$id,$user=null)
535
+	function get(&$options, $id, $user = null)
536 536
 	{
537
-		unset($user);	// not used, but required by function signature
537
+		unset($user); // not used, but required by function signature
538 538
 
539
-		if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id)))
539
+		if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id)))
540 540
 		{
541 541
 			return $task;
542 542
 		}
543 543
 		$handler = $this->_get_handler();
544
-		$options['data'] = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
544
+		$options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
545 545
 		$options['mimetype'] = 'text/calendar; charset=utf-8';
546 546
 		header('Content-Encoding: identity');
547 547
 		header('ETag: "'.$this->get_etag($task).'"');
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
558 558
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
559 559
 	 */
560
-	function put(&$options,$id,$user=null,$prefix=null)
560
+	function put(&$options, $id, $user = null, $prefix = null)
561 561
 	{
562
-		unset($prefix);	// not used, but required by function signature
562
+		unset($prefix); // not used, but required by function signature
563 563
 
564
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
564
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
565 565
 
566
-		$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
566
+		$oldTask = $this->_common_get_put_delete('PUT', $options, $id);
567 567
 		if (!is_null($oldTask) && !is_array($oldTask))
568 568
 		{
569 569
 			return $oldTask;
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 	 * @param array $oldTask =null
629 629
 	 * @return array modified task data
630 630
 	 */
631
-	public function cat_action(array $task, $oldTask=null)
631
+	public function cat_action(array $task, $oldTask = null)
632 632
 	{
633 633
 		$action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'];
634 634
 
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
 			{
662 662
 				unset($task['info_responsible'][$key]);
663 663
 			}
664
-			switch($action)
664
+			switch ($action)
665 665
 			{
666 666
 				case 'set':
667 667
 					$task['info_responsible'] = array();
668 668
 					// fall through
669 669
 				case 'set-user':
670
-					foreach($task['info_responsible'] as $key => $account_id)
670
+					foreach ($task['info_responsible'] as $key => $account_id)
671 671
 					{
672 672
 						if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u')
673 673
 						{
@@ -696,11 +696,11 @@  discard block
 block discarded – undo
696 696
 	 * @param int $user account_id of collection owner
697 697
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
698 698
 	 */
699
-	function delete(&$options,$id,$user)
699
+	function delete(&$options, $id, $user)
700 700
 	{
701
-		unset($user);	// not used, but required by function signature
701
+		unset($user); // not used, but required by function signature
702 702
 
703
-		if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id)))
703
+		if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id)))
704 704
 		{
705 705
 			return $task;
706 706
 		}
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	 */
719 719
 	function read($id)
720 720
 	{
721
-		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server');
721
+		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server');
722 722
 	}
723 723
 
724 724
 	/**
@@ -741,15 +741,15 @@  discard block
 block discarded – undo
741 741
 	 * @param array|int $task task-array or id
742 742
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
743 743
 	 */
744
-	function check_access($acl,$task)
744
+	function check_access($acl, $task)
745 745
 	{
746 746
 		if (is_null($task)) return true;
747 747
 
748
-		$access = $this->bo->check_access($task,$acl);
748
+		$access = $this->bo->check_access($task, $acl);
749 749
 
750 750
 		if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task))
751 751
 		{
752
-			$access = true;	// access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
752
+			$access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
753 753
 		}
754 754
 		if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
755 755
 		return $access;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	 *
761 761
 	 * @return string
762 762
 	 */
763
-	public function getctag($path,$user)
763
+	public function getctag($path, $user)
764 764
 	{
765 765
 		return $this->bo->getctag($this->get_infolog_filter($path, $user));
766 766
 	}
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	{
778 778
 		if (!is_array($info))
779 779
 		{
780
-			$info = $this->bo->read($info,true,'server');
780
+			$info = $this->bo->read($info, true, 'server');
781 781
 		}
782 782
 		if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified']))
783 783
 		{
@@ -795,38 +795,38 @@  discard block
 block discarded – undo
795 795
 	 * @param int $user =null account_id of owner of collection
796 796
 	 * @return array
797 797
 	 */
798
-	public function extra_properties(array $props, $displayname, $base_uri=null,$user=null)
798
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null)
799 799
 	{
800
-		unset($base_uri);	// not used, but required by function signature
800
+		unset($base_uri); // not used, but required by function signature
801 801
 
802 802
 		// calendar description
803
-		$displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname;
804
-		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
803
+		$displayname = Api\Translation::convert(lang('Tasks of'), Api\Translation::charset(), 'utf-8').' '.$displayname;
804
+		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
805 805
 		// supported components, currently only VTODO
806
-		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array(
807
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VTODO')),
806
+		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-component-set', array(
807
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VTODO')),
808 808
 		));
809 809
 		// supported reports
810 810
 		$props['supported-report-set'] = array(
811
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
812
-				Api\CalDAV::mkprop('report',array(
813
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
814
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
815
-				Api\CalDAV::mkprop('report',array(
816
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
811
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
812
+				Api\CalDAV::mkprop('report', array(
813
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
814
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
815
+				Api\CalDAV::mkprop('report', array(
816
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
817 817
 		);
818 818
 		// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
819 819
 		$config = Api\Config::read('infolog');
820 820
 		if ($config['history'])
821 821
 		{
822
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
823
-				Api\CalDAV::mkprop('report',array(
824
-					Api\CalDAV::mkprop('sync-collection','')))));
822
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
823
+				Api\CalDAV::mkprop('report', array(
824
+					Api\CalDAV::mkprop('sync-collection', '')))));
825 825
 		}
826 826
 		// get timezone of calendar
827 827
 		if ($this->caldav->prop_requested('calendar-timezone'))
828 828
 		{
829
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
829
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
830 830
 				calendar_timezones::user_timezone($user));
831 831
 		}
832 832
 		return $props;
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	private function _get_handler()
841 841
 	{
842 842
 		$handler = new infolog_ical();
843
-		$handler->tzid = false;	//	as we read server-time timestamps (!= null=user-time), exports UTC times
844
-		$handler->setSupportedFields('GroupDAV',$this->agent);
843
+		$handler->tzid = false; //	as we read server-time timestamps (!= null=user-time), exports UTC times
844
+		$handler->setSupportedFields('GroupDAV', $this->agent);
845 845
 
846 846
 		return $handler;
847 847
 	}
Please login to merge, or discard this patch.
doc/mail/dovecot_checkpassword_ads.php 2 patches
Braces   +66 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
  */
42 42
 
43 43
 // protect from being called via HTTP
44
-if (php_sapi_name() !== 'cli') die('This is a command line only script!');
44
+if (php_sapi_name() !== 'cli')
45
+{
46
+	die('This is a command line only script!');
47
+}
45 48
 
46 49
 // uncomment to write to log-file, otherwise errors go to stderr
47 50
 //$log = '/var/log/dovecot_checkpassword.log';
@@ -94,7 +97,10 @@  discard block
 block discarded – undo
94 97
 
95 98
 ini_set('display_errors',false);
96 99
 error_reporting(E_ALL & ~E_NOTICE);
97
-if ($log) ini_set('error_log',$log);
100
+if ($log)
101
+{
102
+	ini_set('error_log',$log);
103
+}
98 104
 
99 105
 if ($_SERVER['argc'] < 2)
100 106
 {
@@ -115,8 +121,14 @@  discard block
 block discarded – undo
115 121
 //error_log("dovecot_checkpassword '{$_SERVER['argv'][1]}': username='$username', password='$password', master='$master'");
116 122
 
117 123
 $ds = ldap_connect($ldap_uri);
118
-if ($version) ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version);
119
-if ($use_tls) ldap_start_tls($ds);
124
+if ($version)
125
+{
126
+	ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version);
127
+}
128
+if ($use_tls)
129
+{
130
+	ldap_start_tls($ds);
131
+}
120 132
 
121 133
 if (!@ldap_bind($ds, $bind_dn, $bind_pw))
122 134
 {
@@ -163,10 +175,16 @@  discard block
 block discarded – undo
163 175
 		$dn = $d ? strtr($domain_master_dn,array('%d'=>$domain)) : $master_dn;
164 176
 		if (!@ldap_bind($ds, $dn, $password))
165 177
 		{
166
-			if ($log_verbose) error_log("Can't bind as '$dn' with password '$password'! Authentication as master '$master' for user '$username' failed!");
178
+			if ($log_verbose)
179
+			{
180
+				error_log("Can't bind as '$dn' with password '$password'! Authentication as master '$master' for user '$username' failed!");
181
+			}
167 182
 			exit(111);	// 111 = temporary problem
168 183
 		}
169
-		if ($log_verbose) error_log("Authentication as master '$master' for user '$username' succeeded!");
184
+		if ($log_verbose)
185
+		{
186
+			error_log("Authentication as master '$master' for user '$username' succeeded!");
187
+		}
170 188
 		$passdb_query = false;
171 189
 		$filter = $userdb_filter;
172 190
 	}
@@ -180,7 +198,10 @@  discard block
 block discarded – undo
180 198
 
181 199
 // remove prefixes eg. "{quota:}proxyaddresses"
182 200
 $attrs = $user_attrs;
183
-foreach($attrs as &$a) if ($a[0] == '{') list(,$a) = explode('}', $a);
201
+foreach($attrs as &$a)
202
+{
203
+	if ($a[0] == '{') list(,$a) = explode('}', $a);
204
+}
184 205
 
185 206
 if (!($sr = ldap_search($ds, $base, $filter, array_values($attrs))))
186 207
 {
@@ -191,7 +212,10 @@  discard block
 block discarded – undo
191 212
 
192 213
 if (!$entries['count'])
193 214
 {
194
-	if ($log_verbose) error_log("User '$username' NOT found!");
215
+	if ($log_verbose)
216
+	{
217
+		error_log("User '$username' NOT found!");
218
+	}
195 219
 	exit(3);
196 220
 }
197 221
 
@@ -208,26 +232,44 @@  discard block
 block discarded – undo
208 232
 	// now authenticate user by trying to bind to found dn with given password
209 233
 	if (!@ldap_bind($ds, $entries[0]['dn'], $password))
210 234
 	{
211
-		if ($log_verbose) error_log("Can't bind as '{$entries[0]['dn']}' with password '$password'! Authentication for user '$username' failed!");
235
+		if ($log_verbose)
236
+		{
237
+			error_log("Can't bind as '{$entries[0]['dn']}' with password '$password'! Authentication for user '$username' failed!");
238
+		}
212 239
 		exit(1);
213 240
 	}
214
-	if ($log_verbose) error_log("Successfull authentication user '$username' dn='{$entries[0]['dn']}'.");
215
-}
241
+	if ($log_verbose)
242
+	{
243
+		error_log("Successfull authentication user '$username' dn='{$entries[0]['dn']}'.");
244
+	}
245
+	}
216 246
 else	// user-db query, no authentication
217 247
 {
218
-	if ($log_verbose) error_log("User-db query for user '$username' dn='{$entries[0]['dn']}'.");
219
-}
248
+	if ($log_verbose)
249
+	{
250
+		error_log("User-db query for user '$username' dn='{$entries[0]['dn']}'.");
251
+	}
252
+	}
220 253
 
221 254
 // add additional placeholders from $user_attrs
222 255
 foreach($user_attrs as $placeholder => $attr)
223 256
 {
224
-	if ($attr[0] == '{')	// prefix given --> ignore all values without and remove it
257
+	if ($attr[0] == '{')
258
+	{
259
+		// prefix given --> ignore all values without and remove it
225 260
 	{
226 261
 		list($prefix, $attr) = explode('}', substr($attr, 1));
262
+	}
227 263
 		foreach($entries[0][$attr] as $key => $value)
228 264
 		{
229
-			if ($key === 'count') continue;
230
-			if (strpos($value, $prefix) !== 0) continue;
265
+			if ($key === 'count')
266
+			{
267
+				continue;
268
+			}
269
+			if (strpos($value, $prefix) !== 0)
270
+			{
271
+				continue;
272
+			}
231 273
 			$replace[$placeholder] = substr($value, strlen($prefix));
232 274
 			break;
233 275
 		}
@@ -251,7 +293,10 @@  discard block
 block discarded – undo
251 293
 		$system_groups_user = array();
252 294
 		foreach($groups as $key => $group)
253 295
 		{
254
-			if ($key === 'count') continue;
296
+			if ($key === 'count')
297
+			{
298
+				continue;
299
+			}
255 300
 			$system_groups_user[] = $group[$group_attr][0].$append;
256 301
 		}
257 302
 		$extra['system_groups_user'] = implode(',', $system_groups_user);	// todo: check separator
@@ -289,7 +334,10 @@  discard block
 block discarded – undo
289 334
 
290 335
 // setting USER, HOME, EXTRA
291 336
 putenv('USER='.strtr($user_name, $replace));
292
-if ($user_home) putenv('HOME='.strtr($user_home, $replace));
337
+if ($user_home)
338
+{
339
+	putenv('HOME='.strtr($user_home, $replace));
340
+}
293 341
 if ($extra)
294 342
 {
295 343
 	foreach($extra as $name => $value)
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 //$bind_pw = 'secret';
56 56
 $version = 3;
57 57
 $use_tls = false;
58
-$search_base = $ldap_base;//'o=%d,dc=egroupware';
58
+$search_base = $ldap_base; //'o=%d,dc=egroupware';
59 59
 $passdb_filter = $userdb_filter = '(&(objectCategory=person)(sAMAccountName=%s))';
60 60
 // %d for domain and %s for username given by Dovecot is set automatic
61 61
 $user_attrs = array(
62
-	'%u' => 'samaccountname',	// do NOT remove!
62
+	'%u' => 'samaccountname', // do NOT remove!
63 63
 //	'%n' => 'uidnumber',
64 64
 //	'%h' => 'mailmessagestore',
65 65
 	'%q' => '{quota:}proxyaddresses',
66 66
 	'%x' => 'dn',
67 67
 );
68
-$user_name = '%u';	// '%u@%d';
69
-$user_home = '/var/dovecot/imap/gruene/%u';	//'/var/dovecot/imap/%d/%u';	// mailbox location
68
+$user_name = '%u'; // '%u@%d';
69
+$user_home = '/var/dovecot/imap/gruene/%u'; //'/var/dovecot/imap/%d/%u';	// mailbox location
70 70
 $extra = array(
71 71
 	'userdb_quota_rule' => '*:bytes=%q',
72 72
 /* only for director
@@ -87,26 +87,26 @@  discard block
 block discarded – undo
87 87
 $group_base = $ldap_base;
88 88
 $group_filter = '(&(objectCategory=group)(member=%x))';
89 89
 $group_attr = 'cn';
90
-$group_append = '';	//'@%d';
90
+$group_append = ''; //'@%d';
91 91
 
92
-$master_dn = $bind_dn;	//"cn=admin,dc=egroupware";
92
+$master_dn = $bind_dn; //"cn=admin,dc=egroupware";
93 93
 //$domain_master_dn = "cn=admin,o=%d,dc=egroupware";
94 94
 
95
-ini_set('display_errors',false);
95
+ini_set('display_errors', false);
96 96
 error_reporting(E_ALL & ~E_NOTICE);
97
-if ($log) ini_set('error_log',$log);
97
+if ($log) ini_set('error_log', $log);
98 98
 
99 99
 if ($_SERVER['argc'] < 2)
100 100
 {
101
-	fwrite(STDERR,"\nUsage: {$_SERVER['argv'][0]} prog-to-exec\n\n");
102
-	fwrite(STDERR,"To test run:\n");
103
-	fwrite(STDERR,"echo -en 'username\\0000''password\\0000' | {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n");
104
-	fwrite(STDERR,"echo -en 'username\\0000' | AUTHORIZED=1 {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n");
105
-	fwrite(STDERR,"echo -en '(dovecode-admin@domain|dovecot|cyrus)\\0000''master-password\\0000' | AUTH_LOGIN_USER=username {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n\n");
101
+	fwrite(STDERR, "\nUsage: {$_SERVER['argv'][0]} prog-to-exec\n\n");
102
+	fwrite(STDERR, "To test run:\n");
103
+	fwrite(STDERR, "echo -en 'username\\0000''password\\0000' | {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n");
104
+	fwrite(STDERR, "echo -en 'username\\0000' | AUTHORIZED=1 {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n");
105
+	fwrite(STDERR, "echo -en '(dovecode-admin@domain|dovecot|cyrus)\\0000''master-password\\0000' | AUTH_LOGIN_USER=username {$_SERVER['argv'][0]} env 3<&0 ; echo $?\n\n");
106 106
 	exit(2);
107 107
 }
108 108
 
109
-list($username,$password) = explode("\0",file_get_contents('php://fd/3'));
109
+list($username, $password) = explode("\0", file_get_contents('php://fd/3'));
110 110
 if (isset($_SERVER['AUTH_LOGIN_USER']))
111 111
 {
112 112
 	$master = $username;
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
 if (!@ldap_bind($ds, $bind_dn, $bind_pw))
122 122
 {
123 123
 	error_log("Can't connect to LDAP server $ldap_uri!");
124
-	exit(111);	// 111 = temporary problem
124
+	exit(111); // 111 = temporary problem
125 125
 }
126
-list(,$domain) = explode('@',$username);
127
-if (preg_match('/^(.*)\.imapc$/',$domain,$matches))
126
+list(,$domain) = explode('@', $username);
127
+if (preg_match('/^(.*)\.imapc$/', $domain, $matches))
128 128
 {
129 129
 	$domain = $matches[1];
130 130
 
131 131
 	$username = explode('.', $username);
132 132
 	array_pop($username);
133
-	$username = implode('.',$username);
133
+	$username = implode('.', $username);
134 134
 
135 135
 	$user_home = '/var/tmp/imapc-%d/%s';
136 136
 	$extra = array(
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	// master user name is hardcoded "dovecot", "cyrus" or "dovecot-admin@domain" and mapped currently to cn=admin,[o=domain,]dc=egroupware
155 155
 	if (isset($master))
156 156
 	{
157
-		list($n,$d) = explode('@', $master);
158
-		if (!($n === 'dovecot-admin' && $d === $domain || in_array($master,array('dovecot','cyrus'))))
157
+		list($n, $d) = explode('@', $master);
158
+		if (!($n === 'dovecot-admin' && $d === $domain || in_array($master, array('dovecot', 'cyrus'))))
159 159
 		{
160 160
 			// no valid master-user for given domain
161 161
 			exit(1);
162 162
 		}
163
-		$dn = $d ? strtr($domain_master_dn,array('%d'=>$domain)) : $master_dn;
163
+		$dn = $d ? strtr($domain_master_dn, array('%d'=>$domain)) : $master_dn;
164 164
 		if (!@ldap_bind($ds, $dn, $password))
165 165
 		{
166 166
 			if ($log_verbose) error_log("Can't bind as '$dn' with password '$password'! Authentication as master '$master' for user '$username' failed!");
167
-			exit(111);	// 111 = temporary problem
167
+			exit(111); // 111 = temporary problem
168 168
 		}
169 169
 		if ($log_verbose) error_log("Authentication as master '$master' for user '$username' succeeded!");
170 170
 		$passdb_query = false;
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 
181 181
 // remove prefixes eg. "{quota:}proxyaddresses"
182 182
 $attrs = $user_attrs;
183
-foreach($attrs as &$a) if ($a[0] == '{') list(,$a) = explode('}', $a);
183
+foreach ($attrs as &$a) if ($a[0] == '{') list(,$a) = explode('}', $a);
184 184
 
185 185
 if (!($sr = ldap_search($ds, $base, $filter, array_values($attrs))))
186 186
 {
187 187
 	error_log("Error ldap_search(\$ds, '$base', '$filter')!");
188
-	exit(111);	// 111 = temporary problem
188
+	exit(111); // 111 = temporary problem
189 189
 }
190 190
 $entries = ldap_get_entries($ds, $sr);
191 191
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 {
200 200
 	// should not happen for passdb, but could happen for aliases ...
201 201
 	error_log("Error ldap_search(\$ds, '$base', '$filter') returned more then one user!");
202
-	exit(111);	// 111 = temporary problem
202
+	exit(111); // 111 = temporary problem
203 203
 }
204 204
 //print_r($entries);
205 205
 
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
 }
220 220
 
221 221
 // add additional placeholders from $user_attrs
222
-foreach($user_attrs as $placeholder => $attr)
222
+foreach ($user_attrs as $placeholder => $attr)
223 223
 {
224 224
 	if ($attr[0] == '{')	// prefix given --> ignore all values without and remove it
225 225
 	{
226 226
 		list($prefix, $attr) = explode('}', substr($attr, 1));
227
-		foreach($entries[0][$attr] as $key => $value)
227
+		foreach ($entries[0][$attr] as $key => $value)
228 228
 		{
229 229
 			if ($key === 'count') continue;
230 230
 			if (strpos($value, $prefix) !== 0) continue;
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 	{
250 250
 		//print_r($groups);
251 251
 		$system_groups_user = array();
252
-		foreach($groups as $key => $group)
252
+		foreach ($groups as $key => $group)
253 253
 		{
254 254
 			if ($key === 'count') continue;
255 255
 			$system_groups_user[] = $group[$group_attr][0].$append;
256 256
 		}
257
-		$extra['system_groups_user'] = implode(',', $system_groups_user);	// todo: check separator
257
+		$extra['system_groups_user'] = implode(',', $system_groups_user); // todo: check separator
258 258
 	}
259 259
 	else
260 260
 	{
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 // set host attribute for director to old imap
266 266
 if (isset($host_base) && isset($host_filter))
267 267
 {
268
-	if (!($sr = ldap_search($ds, $host_base, $filter=strtr($host_filter, quote($replace)), array($host_attr))))
268
+	if (!($sr = ldap_search($ds, $host_base, $filter = strtr($host_filter, quote($replace)), array($host_attr))))
269 269
 	{
270 270
 		error_log("Error ldap_search(\$ds, '$host_base', '$filter')!");
271
-		exit(111);	// 111 = temporary problem
271
+		exit(111); // 111 = temporary problem
272 272
 	}
273 273
 	$entries = ldap_get_entries($ds, $sr);
274 274
 	if ($entries['count'] && !isset($entries[0][$host_attr]))
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 // build command to run
283 283
 array_shift($_SERVER['argv']);
284 284
 $cmd = array_shift($_SERVER['argv']);
285
-foreach($_SERVER['argv'] as $arg)
285
+foreach ($_SERVER['argv'] as $arg)
286 286
 {
287 287
 	$cmd .= ' '.escapeshellarg($arg);
288 288
 }
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
 if ($user_home) putenv('HOME='.strtr($user_home, $replace));
293 293
 if ($extra)
294 294
 {
295
-	foreach($extra as $name => $value)
295
+	foreach ($extra as $name => $value)
296 296
 	{
297
-		if (($pos = strpos($value,'%')) !== false)
297
+		if (($pos = strpos($value, '%')) !== false)
298 298
 		{
299 299
 			// check if replacement is set, otherwise skip whole extra-value
300
-			if (!isset($replace[substr($value,$pos,2)]))
300
+			if (!isset($replace[substr($value, $pos, 2)]))
301 301
 			{
302 302
 				unset($extra[$name]);
303 303
 				continue;
304 304
 			}
305
-			$value = strtr($value,$replace);
305
+			$value = strtr($value, $replace);
306 306
 		}
307 307
 		putenv($name.'='.$value);
308 308
 	}
@@ -326,5 +326,5 @@  discard block
 block discarded – undo
326 326
  */
327 327
 function quote($string)
328 328
 {
329
-	return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string);
329
+	return str_replace(array('\\', '*', '(', ')', '\0', ' '), array('\\\\', '\*', '\(', '\)', '\\0', '\20'), $string);
330 330
 }
Please login to merge, or discard this patch.
doc/mail/postfix_tcp_map_ads.php 2 patches
Braces   +90 added lines, -23 removed lines patch added patch discarded remove patch
@@ -71,7 +71,10 @@  discard block
 block discarded – undo
71 71
  */
72 72
 
73 73
 // protect from being called via HTTP
74
-if (php_sapi_name() !== 'cli') die('This is a command line only script!');
74
+if (php_sapi_name() !== 'cli')
75
+{
76
+	die('This is a command line only script!');
77
+}
75 78
 
76 79
 // our defaults
77 80
 $default_host = 'localhost';
@@ -122,14 +125,20 @@  discard block
 block discarded – undo
122 125
 
123 126
 ini_set('display_errors',false);
124 127
 error_reporting(E_ALL & ~E_NOTICE);
125
-if ($log) ini_set('error_log',$log);
128
+if ($log)
129
+{
130
+	ini_set('error_log',$log);
131
+}
126 132
 
127 133
 function usage($extra=null)
128 134
 {
129 135
 	global $maps;
130 136
 	fwrite(STDERR, "\nUsage: $cmd [-v|--verbose] [-h|--help] [-l|--log (syslog|path)] [-q|--query <email-addresse> (mailboxes|alias|groups)] [host]\n\n");
131 137
 	fwrite(STDERR, print_r($maps,true)."\n");
132
-	if ($extra) fwrite(STDERR, "\n\n$extra\n\n");
138
+	if ($extra)
139
+	{
140
+		fwrite(STDERR, "\n\n$extra\n\n");
141
+	}
133 142
 	exit(2);
134 143
 }
135 144
 
@@ -152,9 +161,12 @@  discard block
 block discarded – undo
152 161
 			break;
153 162
 
154 163
 		case '-q': case '--query':
155
-			if (count($_SERVER['argv']) == 2)       // need 2 arguments
164
+			if (count($_SERVER['argv']) == 2)
165
+			{
166
+				// need 2 arguments
156 167
 			{
157 168
 				$request = 'get '.array_shift($_SERVER['argv'])."\n";
169
+			}
158 170
 				$map = array_shift($_SERVER['argv']);
159 171
 				echo respond($request, $map)."\n";
160 172
 				exit;
@@ -166,7 +178,10 @@  discard block
 block discarded – undo
166 178
 			usage("Unknown option '$arg'!");
167 179
 	}
168 180
 }
169
-if ($_SERVER['argv']) usage();
181
+if ($_SERVER['argv'])
182
+{
183
+	usage();
184
+}
170 185
 
171 186
 if ($arg)
172 187
 {
@@ -177,7 +192,10 @@  discard block
 block discarded – undo
177 192
 	$host = $default_host;
178 193
 }
179 194
 
180
-if ($verbose) echo "using $host\n";
195
+if ($verbose)
196
+{
197
+	echo "using $host\n";
198
+}
181 199
 
182 200
 $servers = $clients = $buffers = array();
183 201
 
@@ -194,20 +212,36 @@  discard block
 block discarded – undo
194 212
 	$servers[$data['port']] = $server;
195 213
 	$clients[$data['port']] = array();
196 214
 }
197
-while (true)	// mail loop of tcp server --> never exits
215
+while (true)
216
+{
217
+	// mail loop of tcp server --> never exits
198 218
 {
199 219
 	$read = $servers;
200
-	if ($clients) $read = array_merge($read, call_user_func_array('array_merge', array_values($clients)));
201
-	if ($verbose) print 'about to call socket_select(array('.implode(',',$read).', ...) waiting... ';
202
-	if (stream_select($read, $write=null, $except=null, null))	// null = block forever
220
+}
221
+	if ($clients)
222
+	{
223
+		$read = array_merge($read, call_user_func_array('array_merge', array_values($clients)));
224
+	}
225
+	if ($verbose)
226
+	{
227
+		print 'about to call socket_select(array('.implode(',',$read).', ...) waiting... ';
228
+	}
229
+	if (stream_select($read, $write=null, $except=null, null))
230
+	{
231
+		// null = block forever
203 232
 	{
204 233
 		foreach($read as $sock)
205 234
 		{
206 235
 			if (($port = array_search($sock, $servers)) !== false)
207 236
 			{
208
-				$client = stream_socket_accept($sock,$timeout,$client_addr);	// @ required to get not timeout warning!
237
+				$client = stream_socket_accept($sock,$timeout,$client_addr);
238
+	}
239
+	// @ required to get not timeout warning!
209 240
 
210
-				if ($verbose) echo "accepted connection $client from $client_addr on port $port\n";
241
+				if ($verbose)
242
+				{
243
+					echo "accepted connection $client from $client_addr on port $port\n";
244
+				}
211 245
 
212 246
 				if ($only_client && !preg_match($only_client,$client_addr))
213 247
 				{
@@ -218,9 +252,12 @@  discard block
 block discarded – undo
218 252
 				}
219 253
 				$clients[$port][] = $client;
220 254
 			}
221
-			elseif (feof($sock))	// client connection closed
255
+			elseif (feof($sock))
256
+			{
257
+				// client connection closed
222 258
 			{
223 259
 				if ($verbose) echo "client $sock closed connection\n";
260
+			}
224 261
 
225 262
 				foreach($clients as $port => &$socks)
226 263
 				{
@@ -244,7 +281,10 @@  discard block
 block discarded – undo
244 281
 					{
245 282
 						if (($key = array_search($sock, $clients[$data['port']], true)) !== false)
246 283
 						{
247
-							if ($verbose) echo date('Y-m-d H:i:s').": client send: $request for map $map\n";
284
+							if ($verbose)
285
+							{
286
+								echo date('Y-m-d H:i:s').": client send: $request for map $map\n";
287
+							}
248 288
 
249 289
 							// Respond to client
250 290
 							fwrite($sock,  respond($request, $map));
@@ -293,8 +333,14 @@  discard block
 block discarded – undo
293 333
 	if (!isset($ds) || $reconnect)
294 334
 	{
295 335
 		$ds = ldap_connect($ldap_uri);
296
-		if ($version) ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version);
297
-		if ($use_tls) ldap_start_tls($ds);
336
+		if ($version)
337
+		{
338
+			ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version);
339
+		}
340
+		if ($use_tls)
341
+		{
342
+			ldap_start_tls($ds);
343
+		}
298 344
 
299 345
 		if (!@ldap_bind($ds, $bind_dn, $bind_pw))
300 346
 		{
@@ -329,7 +375,10 @@  discard block
 block discarded – undo
329 375
 	// remove prefix like "{smtp:}proxyaddresses"
330 376
 	foreach($search_attrs as &$attr)
331 377
 	{
332
-		if ($attr[0] == '{') list(,$attr) = explode('}', $attr);
378
+		if ($attr[0] == '{')
379
+		{
380
+			list(,$attr) = explode('}', $attr);
381
+		}
333 382
 	}
334 383
 	unset($attr);
335 384
 
@@ -338,10 +387,13 @@  discard block
 block discarded – undo
338 387
 		$errno = ldap_errno($ds);
339 388
 		$error = ldap_error($ds).' ('.$errno.')';
340 389
 
341
-		if ($errno == -1)		// eg. -1 lost connection to ldap
390
+		if ($errno == -1)
391
+		{
392
+			// eg. -1 lost connection to ldap
342 393
 		{
343 394
 			// as DC closes connections quickly, first try to reconnect once, before returning a temp. failure
344 395
 			if (!$reconnect) return respond($request, $map, $extra, true);
396
+		}
345 397
 
346 398
 			error_log("$map: get '$username' --> 400 $error: !ldap_search(\$ds, '$base', '$filter')");
347 399
 			ldap_close($ds);
@@ -350,7 +402,10 @@  discard block
 block discarded – undo
350 402
 		}
351 403
 		else	// happens if base containing domain does not exist
352 404
 		{
353
-			if ($log_verbose) error_log("$map: get '$username' --> 500 Not found: $error: !ldap_search(\$ds, '$base', '$filter')");
405
+			if ($log_verbose)
406
+			{
407
+				error_log("$map: get '$username' --> 500 Not found: $error: !ldap_search(\$ds, '$base', '$filter')");
408
+			}
354 409
 			return "500 Not found: $error\n";	// 500 not found
355 410
 		}
356 411
 	}
@@ -358,13 +413,19 @@  discard block
 block discarded – undo
358 413
 
359 414
 	if (!$entries['count'])
360 415
 	{
361
-		if ($log_verbose) error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no entries");
416
+		if ($log_verbose)
417
+		{
418
+			error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no entries");
419
+		}
362 420
 		return "500 Not found\n";	// 500: Query returned no result
363 421
 	}
364 422
 	$response = array();
365 423
 	foreach($entries as $key => $entry)
366 424
 	{
367
-		if ($key === 'count') continue;
425
+		if ($key === 'count')
426
+		{
427
+			continue;
428
+		}
368 429
 
369 430
 		foreach($attrs as $attr)
370 431
 		{
@@ -395,7 +456,10 @@  discard block
 block discarded – undo
395 456
 	}
396 457
 	if (!$response)
397 458
 	{
398
-		if ($log_verbose) error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no response");
459
+		if ($log_verbose)
460
+		{
461
+			error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no response");
462
+		}
399 463
 		return "500 Not found\n";	// 500: Query returned no result
400 464
 	}
401 465
 	if (isset($maps[$map]['filter'.(1+$extra)]) && isset($maps[$map]['attrs'.(1+$extra)]))
@@ -403,6 +467,9 @@  discard block
 block discarded – undo
403 467
 		return respond('get '.$response[0], $map, 1+$extra);
404 468
 	}
405 469
 	$response = '200 '.implode(',',$response)."\n";
406
-	if ($log_verbose) error_log("$map: get '$username' --> $response");
470
+	if ($log_verbose)
471
+	{
472
+		error_log("$map: get '$username' --> $response");
473
+	}
407 474
 	return $response;
408 475
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	'mailboxes' => array(
99 99
 		'base' => $base,
100 100
 		'filter' => '(&(objectCategory=person)(proxyAddresses=smtp:%s))',
101
-		'attrs' => 'samaccountname',	// result-attrs must be lowercase!
101
+		'attrs' => 'samaccountname', // result-attrs must be lowercase!
102 102
 		'port' => 2001,
103 103
 	),
104 104
 	// virtual alias maps
105 105
 	'aliases' => array(
106 106
 		'base' => $base,
107 107
 		'filter' => '(&(objectCategory=person)(proxyAddresses=smtp:%s))',
108
-		'attrs' => array('samaccountname','{forward:}proxyaddresses'),
108
+		'attrs' => array('samaccountname', '{forward:}proxyaddresses'),
109 109
 		'port' => 2002,
110 110
 	),
111 111
 	// groups as distribution list
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
 		'attrs' => 'dn',
116 116
 		// continue with resulting dn
117 117
 		'filter1' => '(&(objectCategory=person)(proxyAddresses=smtp:*)(memberOf=%s))',
118
-		'attrs1' => array('samaccountname','{forward:}proxyaddresses'),
118
+		'attrs1' => array('samaccountname', '{forward:}proxyaddresses'),
119 119
 		'port' => 2003,
120 120
 	),
121 121
 );
122 122
 
123
-ini_set('display_errors',false);
123
+ini_set('display_errors', false);
124 124
 error_reporting(E_ALL & ~E_NOTICE);
125
-if ($log) ini_set('error_log',$log);
125
+if ($log) ini_set('error_log', $log);
126 126
 
127
-function usage($extra=null)
127
+function usage($extra = null)
128 128
 {
129 129
 	global $maps;
130 130
 	fwrite(STDERR, "\nUsage: $cmd [-v|--verbose] [-h|--help] [-l|--log (syslog|path)] [-q|--query <email-addresse> (mailboxes|alias|groups)] [host]\n\n");
131
-	fwrite(STDERR, print_r($maps,true)."\n");
131
+	fwrite(STDERR, print_r($maps, true)."\n");
132 132
 	if ($extra) fwrite(STDERR, "\n\n$extra\n\n");
133 133
 	exit(2);
134 134
 }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 
138 138
 while (($arg = array_shift($_SERVER['argv'])) && $arg[0] == '-')
139 139
 {
140
-	switch($arg)
140
+	switch ($arg)
141 141
 	{
142 142
 		case '-v': case '--verbose':
143 143
 			$verbose = $log_verbose = true;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 $servers = $clients = $buffers = array();
183 183
 
184 184
 // Create the server socket
185
-foreach($maps as $map => $data)
185
+foreach ($maps as $map => $data)
186 186
 {
187 187
 	$addr = 'tcp://'.$host.':'.$data['port'];
188 188
 	if (!($server = stream_socket_server($addr, $errno, $errstr)))
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 {
199 199
 	$read = $servers;
200 200
 	if ($clients) $read = array_merge($read, call_user_func_array('array_merge', array_values($clients)));
201
-	if ($verbose) print 'about to call socket_select(array('.implode(',',$read).', ...) waiting... ';
202
-	if (stream_select($read, $write=null, $except=null, null))	// null = block forever
201
+	if ($verbose) print 'about to call socket_select(array('.implode(',', $read).', ...) waiting... ';
202
+	if (stream_select($read, $write = null, $except = null, null))	// null = block forever
203 203
 	{
204
-		foreach($read as $sock)
204
+		foreach ($read as $sock)
205 205
 		{
206 206
 			if (($port = array_search($sock, $servers)) !== false)
207 207
 			{
208
-				$client = stream_socket_accept($sock,$timeout,$client_addr);	// @ required to get not timeout warning!
208
+				$client = stream_socket_accept($sock, $timeout, $client_addr); // @ required to get not timeout warning!
209 209
 
210 210
 				if ($verbose) echo "accepted connection $client from $client_addr on port $port\n";
211 211
 
212
-				if ($only_client && !preg_match($only_client,$client_addr))
212
+				if ($only_client && !preg_match($only_client, $client_addr))
213 213
 				{
214
-					fwrite($client,"Go away!\r\n");
214
+					fwrite($client, "Go away!\r\n");
215 215
 					fclose($client);
216 216
 					error_log(date('Y-m-d H:i:s').": Connection $client from wrong client $client_addr (does NOT match '$only_client') --> terminated");
217 217
 					continue;
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			{
223 223
 				if ($verbose) echo "client $sock closed connection\n";
224 224
 
225
-				foreach($clients as $port => &$socks)
225
+				foreach ($clients as $port => &$socks)
226 226
 				{
227 227
 					if (($key = array_search($sock, $socks, true)) !== false)
228 228
 					{
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			}
233 233
 			else	// client send something
234 234
 			{
235
-				$buffer =& $buffers[$sock];
235
+				$buffer = & $buffers[$sock];
236 236
 
237 237
 				$buffer .= fread($sock, 8096);
238 238
 
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
 				{
241 241
 					list($request, $buffer) = explode("\n", $buffer, 2);
242 242
 
243
-					foreach($maps as $map => $data)
243
+					foreach ($maps as $map => $data)
244 244
 					{
245 245
 						if (($key = array_search($sock, $clients[$data['port']], true)) !== false)
246 246
 						{
247 247
 							if ($verbose) echo date('Y-m-d H:i:s').": client send: $request for map $map\n";
248 248
 
249 249
 							// Respond to client
250
-							fwrite($sock,  respond($request, $map));
250
+							fwrite($sock, respond($request, $map));
251 251
 							break;
252 252
 						}
253 253
 					}
@@ -277,16 +277,16 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function quote($string)
279 279
 {
280
-	return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string);
280
+	return str_replace(array('\\', '*', '(', ')', '\0', ' '), array('\\\\', '\*', '\(', '\)', '\\0', '\20'), $string);
281 281
 }
282 282
 
283
-function respond($request, $map, $extra='', $reconnect=false)
283
+function respond($request, $map, $extra = '', $reconnect = false)
284 284
 {
285 285
 	static $ds;
286 286
 	global $ldap_uri, $version, $use_tls, $bind_dn, $bind_pw;
287 287
 	global $maps, $log_verbose;
288 288
 
289
-	if (($map == 'aliases' || $map == 'groups') && strpos($request,'@') === false && !$extra)
289
+	if (($map == 'aliases' || $map == 'groups') && strpos($request, '@') === false && !$extra)
290 290
 	{
291 291
 		return "500 No domain aliases yet\n";
292 292
 	}
@@ -300,17 +300,17 @@  discard block
 block discarded – undo
300 300
 		{
301 301
 			error_log("$map: Can't connect to LDAP server $ldap_uri!");
302 302
 			$ds = null;
303
-			return "400 Can't connect to LDAP server $ldap_uri!\n";	// 400 (temp.) error
303
+			return "400 Can't connect to LDAP server $ldap_uri!\n"; // 400 (temp.) error
304 304
 		}
305 305
 	}
306 306
 	if (!preg_match('/^get ([^\n]+)\n?$/', $request, $matches))
307 307
 	{
308 308
 		error_log("$map: Wrong format '$request'!");
309
-		return "400 Wrong format '$request'!\n";	// 400 (temp.) error
309
+		return "400 Wrong format '$request'!\n"; // 400 (temp.) error
310 310
 	}
311 311
 	$username = $matches[1];
312 312
 
313
-	list($name,$domain) = explode('@',$username);
313
+	list($name, $domain) = explode('@', $username);
314 314
 
315 315
 	/* check if we are responsible for the given domain
316 316
 	if ($domain && $map != 'domains' && (int)($response = respond("get $domain", 'domains')) != 200)
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	);
325 325
 	$base = strtr($maps[$map]['base'], $replace);
326 326
 	$filter = strtr($maps[$map]['filter'.$extra], $replace);
327
-	$prefix = isset($maps[$map]['prefix'.$extra]) ? str_replace(array('%n','%d','%s'),array($name,$domain,$username),$maps[$map]['prefix']) : '';
327
+	$prefix = isset($maps[$map]['prefix'.$extra]) ? str_replace(array('%n', '%d', '%s'), array($name, $domain, $username), $maps[$map]['prefix']) : '';
328 328
 	$search_attrs = $attrs = (array)$maps[$map]['attrs'.$extra];
329 329
 	// remove prefix like "{smtp:}proxyaddresses"
330
-	foreach($search_attrs as &$attr)
330
+	foreach ($search_attrs as &$attr)
331 331
 	{
332 332
 		if ($attr[0] == '{') list(,$attr) = explode('}', $attr);
333 333
 	}
@@ -345,13 +345,13 @@  discard block
 block discarded – undo
345 345
 
346 346
 			error_log("$map: get '$username' --> 400 $error: !ldap_search(\$ds, '$base', '$filter')");
347 347
 			ldap_close($ds);
348
-			$ds = null;	// force new connection on next lookup
349
-			return "400 $error\n";	// 400 (temp.) error
348
+			$ds = null; // force new connection on next lookup
349
+			return "400 $error\n"; // 400 (temp.) error
350 350
 		}
351 351
 		else	// happens if base containing domain does not exist
352 352
 		{
353 353
 			if ($log_verbose) error_log("$map: get '$username' --> 500 Not found: $error: !ldap_search(\$ds, '$base', '$filter')");
354
-			return "500 Not found: $error\n";	// 500 not found
354
+			return "500 Not found: $error\n"; // 500 not found
355 355
 		}
356 356
 	}
357 357
 	$entries = ldap_get_entries($ds, $sr);
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
 	if (!$entries['count'])
360 360
 	{
361 361
 		if ($log_verbose) error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no entries");
362
-		return "500 Not found\n";	// 500: Query returned no result
362
+		return "500 Not found\n"; // 500: Query returned no result
363 363
 	}
364 364
 	$response = array();
365
-	foreach($entries as $key => $entry)
365
+	foreach ($entries as $key => $entry)
366 366
 	{
367 367
 		if ($key === 'count') continue;
368 368
 
369
-		foreach($attrs as $attr)
369
+		foreach ($attrs as $attr)
370 370
 		{
371 371
 			unset($filter_prefix);
372 372
 			if ($attr[0] == '{')
373 373
 			{
374 374
 				list($filter_prefix, $attr) = explode('}', substr($attr, 1));
375 375
 			}
376
-			foreach((array)$entry[$attr] as $k => $mail)
376
+			foreach ((array)$entry[$attr] as $k => $mail)
377 377
 			{
378 378
 				if ($k !== 'count' && ($mail = trim($mail)))
379 379
 				{
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
 	if (!$response)
397 397
 	{
398 398
 		if ($log_verbose) error_log("$map: get '$username' --> 500 not found ldap_search(\$ds, '$base', '$filter') no response");
399
-		return "500 Not found\n";	// 500: Query returned no result
399
+		return "500 Not found\n"; // 500: Query returned no result
400 400
 	}
401
-	if (isset($maps[$map]['filter'.(1+$extra)]) && isset($maps[$map]['attrs'.(1+$extra)]))
401
+	if (isset($maps[$map]['filter'.(1 + $extra)]) && isset($maps[$map]['attrs'.(1 + $extra)]))
402 402
 	{
403
-		return respond('get '.$response[0], $map, 1+$extra);
403
+		return respond('get '.$response[0], $map, 1 + $extra);
404 404
 	}
405
-	$response = '200 '.implode(',',$response)."\n";
405
+	$response = '200 '.implode(',', $response)."\n";
406 406
 	if ($log_verbose) error_log("$map: get '$username' --> $response");
407 407
 	return $response;
408 408
 }
Please login to merge, or discard this patch.
home/inc/class.home_note_portlet.inc.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,10 @@
 block discarded – undo
32 32
 	 */
33 33
 	public function __construct(Array &$context = array(), &$need_reload = false)
34 34
 	{
35
-		if (false) parent::__construct();
35
+		if (false)
36
+		{
37
+			parent::__construct();
38
+		}
36 39
 
37 40
 		// Title not set for new widgets created via context menu
38 41
 		if(!$context['title'])
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 	/**
31 31
 	 * Context for this portlet
32 32
 	 */
33
-	public function __construct(Array &$context = array(), &$need_reload = false)
33
+	public function __construct(array &$context = array(), &$need_reload = false)
34 34
 	{
35 35
 		if (false) parent::__construct();
36 36
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		if (false) parent::__construct();
36 36
 
37 37
 		// Title not set for new widgets created via context menu
38
-		if(!$context['title'])
38
+		if (!$context['title'])
39 39
 		{
40 40
 			// Set initial size to 3x2, default is too small
41 41
 			$context['width'] = 3;
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$id = $_GET['id'] ? $_GET['id'] : $content['id'];
57 57
 		$height = $_GET['height'] ? $_GET['height'] : $content['height'];
58 58
 
59
-		if($content['group'] && $GLOBALS['egw_info']['apps']['admin'])
59
+		if ($content['group'] && $GLOBALS['egw_info']['apps']['admin'])
60 60
 		{
61 61
 			$prefs = new Api\Preferences(is_numeric($content['group']) ? $content['group'] : $GLOBALS['egw_info']['user']['account_id']);
62 62
 		}
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
 		$type = is_numeric($content['group']) ? "user" : $content['group'];
68 68
 		$arr = $prefs->read_repository();
69 69
 		$portlets = $arr['home'];
70
-		if($content['button'])
70
+		if ($content['button'])
71 71
 		{
72 72
 			// Save updated Api\Preferences
73 73
 			$portlets[$id]['note'] = $content['note'];
74
-			$prefs->add('home', $id, $portlets[$id],$type);
75
-			$prefs->save_repository(True,$type);
74
+			$prefs->add('home', $id, $portlets[$id], $type);
75
+			$prefs->save_repository(True, $type);
76 76
 			// Yay for AJAX submit
77
-			Api\Json\Response::get()->apply('window.opener.app.home.refresh',array($id));
77
+			Api\Json\Response::get()->apply('window.opener.app.home.refresh', array($id));
78 78
 
79
-			if(key($content['button'])=='save')
79
+			if (key($content['button']) == 'save')
80 80
 			{
81
-				Api\Json\Response::get()->apply('window.close',array());
81
+				Api\Json\Response::get()->apply('window.close', array());
82 82
 			}
83 83
 		}
84 84
 		$etemplate = new Etemplate('home.note');
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 			'height'	=>	$height,
91 91
 			'group'		=>	$portlets[$id]['group']
92 92
 		);
93
-		$etemplate->exec('home.home_note_portlet.edit',array(
93
+		$etemplate->exec('home.home_note_portlet.edit', array(
94 94
 			'note'	=> $portlets[$id]['note']
95
-		), array(),array('note'=>false,'save'=>false), $preserve);
95
+		), array(), array('note'=>false, 'save'=>false), $preserve);
96 96
 	}
97 97
 
98 98
 	public function exec($id = null, Etemplate &$etemplate = null)
99 99
 	{
100 100
 		// Allow to submit directly back here
101
-		if(is_array($id) && $id['id'])
101
+		if (is_array($id) && $id['id'])
102 102
 		{
103 103
 			$id = $id['id'];
104 104
 		}
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 		$etemplate->set_dom_id($id);
108 108
 		$content = $this->context;
109 109
 
110
-		if(!$content['note'])
110
+		if (!$content['note'])
111 111
 		{
112 112
 			$content['note'] = '';
113
-			Api\Json\Response::get()->apply('app.home.note_edit',array($id));
113
+			Api\Json\Response::get()->apply('app.home.note_edit', array($id));
114 114
 		}
115 115
 
116
-		$etemplate->exec('home.home_note_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id));
116
+		$etemplate->exec('home.home_note_portlet.exec', $content, array(), array('__ALL__'=>true), array('id' =>$id));
117 117
 	}
118 118
 
119 119
 	public function get_actions()
Please login to merge, or discard this patch.
home/inc/class.home_weather_portlet.inc.php 3 patches
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,10 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function __construct(Array &$context = array(), &$need_reload = false)
38 38
 	{
39
-		if (false) parent::__construct();
39
+		if (false)
40
+		{
41
+			parent::__construct();
42
+		}
40 43
 
41 44
 		// City not set for new widgets created via context menu
42 45
 		if(!$context['city'] || $context['height'] < 2)
@@ -144,14 +147,20 @@  discard block
 block discarded – undo
144 147
 		$data = Api\Cache::getTree('home', json_encode($query), function($query)
145 148
 		{
146 149
 			$debug = false;
147
-			if($debug) error_log('Fetching fresh data from ' . static::API_URL);
150
+			if($debug)
151
+			{
152
+				error_log('Fetching fresh data from ' . static::API_URL);
153
+			}
148 154
 
149 155
 			$url = static::API_URL.'forecast/daily?'. http_build_query($query);
150 156
 			$forecast = file_get_contents($url);
151 157
 
152 158
 			$url = static::API_URL.'weather?'. http_build_query($query);
153 159
 			$current = file_get_contents($url);
154
-			if($debug) error_log(__METHOD__ . ' current: ' . $current);
160
+			if($debug)
161
+			{
162
+				error_log(__METHOD__ . ' current: ' . $current);
163
+			}
155 164
 
156 165
 			return array_merge(array('current' => json_decode($current,true)), json_decode($forecast,true));
157 166
 		}, array($query), self::CACHE_TIME);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * Context for this portlet
36 36
 	 */
37
-	public function __construct(Array &$context = array(), &$need_reload = false)
37
+	public function __construct(array &$context = array(), &$need_reload = false)
38 38
 	{
39 39
 		if (false) parent::__construct();
40 40
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @see http://openweathermap.org/api
131 131
 	 * @param array $query
132 132
 	 */
133
-	public function get_weather(Array $query, $api_url = '')
133
+	public function get_weather(array $query, $api_url = '')
134 134
 	{
135 135
 		static $debug = false;
136 136
 		if(!$api_url)
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		if (false) parent::__construct();
40 40
 
41 41
 		// City not set for new widgets created via context menu
42
-		if(!$context['city'] || $context['height'] < 2)
42
+		if (!$context['city'] || $context['height'] < 2)
43 43
 		{
44 44
 			// Set initial size to 3x2, default is too small
45 45
 			$context['width'] = 3;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	public function exec($id = null, Etemplate &$etemplate = null)
55 55
 	{
56 56
 		// Allow to submit directly back here
57
-		if(is_array($id) && $id['id'])
57
+		if (is_array($id) && $id['id'])
58 58
 		{
59 59
 			$id = $id['id'];
60 60
 		}
@@ -68,24 +68,24 @@  discard block
 block discarded – undo
68 68
 			// Always get (& cache) 10 days, we'll cut down later
69 69
 			'cnt'	=> 10
70 70
 		);
71
-		if($this->context['city_id'])
71
+		if ($this->context['city_id'])
72 72
 		{
73 73
 			$request['id'] = $this->context['city_id'];
74 74
 			$content += $this->get_weather($request);
75 75
 		}
76
-		elseif($this->context['city'])
76
+		elseif ($this->context['city'])
77 77
 		{
78 78
 			$request['q'] = $this->context['city'];
79 79
 			$content += $this->get_weather($request);
80 80
 		}
81 81
 		elseif ($this->context['position'])
82 82
 		{
83
-			list($request['lat'],$request['lon']) = explode(',',$this->context['position']);
83
+			list($request['lat'], $request['lon']) = explode(',', $this->context['position']);
84 84
 			$content += $this->get_weather($request);
85 85
 		}
86 86
 
87 87
 		// Caching is best done by city ID, so store that
88
-		if($content['city_id'] && (!$this->context['city_id'] || $content['city_id'] != $this->context['city_id']))
88
+		if ($content['city_id'] && (!$this->context['city_id'] || $content['city_id'] != $this->context['city_id']))
89 89
 		{
90 90
 
91 91
 			$arr = $GLOBALS['egw']->preferences->read_repository();
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 
103 103
 		// Adjust data to match portlet size
104
-		if($this->context['height'] <= 2 && $this->context['width'] <= 3)
104
+		if ($this->context['height'] <= 2 && $this->context['width'] <= 3)
105 105
 		{
106 106
 			// Too small for the other days
107 107
 			unset($content['list']);
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 			unset($content['current']);
113 113
 		}
114 114
 		// Even too small for current high/low
115
-		if($this->context['width'] < 3)
115
+		if ($this->context['width'] < 3)
116 116
 		{
117 117
 			$content['current']['no_current_temp'] = true;
118 118
 		}
119 119
 
120 120
 
121 121
 		// Direct to full forecast page
122
-		$content['attribution'] ='http://openweathermap.org/city/'.$content['city_id'];
122
+		$content['attribution'] = 'http://openweathermap.org/city/'.$content['city_id'];
123 123
 
124
-		$etemplate->exec('home.home_weather_portlet.exec',$content,array(),array('__ALL__'=>true),array('id' =>$id));
124
+		$etemplate->exec('home.home_weather_portlet.exec', $content, array(), array('__ALL__'=>true), array('id' =>$id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -133,27 +133,27 @@  discard block
 block discarded – undo
133 133
 	public function get_weather(Array $query, $api_url = '')
134 134
 	{
135 135
 		static $debug = false;
136
-		if(!$api_url)
136
+		if (!$api_url)
137 137
 		{
138
-			$api_url = self::API_URL . '/weather?';
138
+			$api_url = self::API_URL.'/weather?';
139 139
 		}
140
-		if(self::API_KEY)
140
+		if (self::API_KEY)
141 141
 		{
142 142
 			$query['APPID'] = self::API_KEY;
143 143
 		}
144 144
 		$data = Api\Cache::getTree('home', json_encode($query), function($query)
145 145
 		{
146 146
 			$debug = false;
147
-			if($debug) error_log('Fetching fresh data from ' . static::API_URL);
147
+			if ($debug) error_log('Fetching fresh data from '.static::API_URL);
148 148
 
149
-			$url = static::API_URL.'forecast/daily?'. http_build_query($query);
149
+			$url = static::API_URL.'forecast/daily?'.http_build_query($query);
150 150
 			$forecast = file_get_contents($url);
151 151
 
152
-			$url = static::API_URL.'weather?'. http_build_query($query);
152
+			$url = static::API_URL.'weather?'.http_build_query($query);
153 153
 			$current = file_get_contents($url);
154
-			if($debug) error_log(__METHOD__ . ' current: ' . $current);
154
+			if ($debug) error_log(__METHOD__.' current: '.$current);
155 155
 
156
-			return array_merge(array('current' => json_decode($current,true)), json_decode($forecast,true));
156
+			return array_merge(array('current' => json_decode($current, true)), json_decode($forecast, true));
157 157
 		}, array($query), self::CACHE_TIME);
158 158
 
159 159
 		// Some sample data, if you need to test
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
 		//$weather = '{"coord":{"lon":-114.05,"lat":53.23},"sys":{"message":0.3098,"country":"Canada","sunrise":1420559329,"sunset":1420587344},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"base":"cmc stations","main":{"temp":-21.414,"temp_min":-21.414,"temp_max":-21.414,"pressure":947.79,"sea_level":1050.73,"grnd_level":947.79,"humidity":69},"wind":{"speed":3,"deg":273.5},"clouds":{"all":32},"dt":1420502430,"id":0,"name":"Thorsby","cod":200}';
162 162
 		//$weather = '{"cod":"200","message":0.1743,"city":{"id":"5978233","name":"Thorsby","coord":{"lon":-114.051,"lat":53.2285},"country":"Canada","population":0},"cnt":6,"list":[{"dt":1420743600,"temp":{"day":-17.49,"min":-27.86,"max":-16.38,"night":-27.86,"eve":-19.91,"morn":-16.77},"pressure":966.21,"humidity":66,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":6.91,"deg":312,"clouds":0,"snow":0.02},{"dt":1420830000,"temp":{"day":-24.86,"min":-29.71,"max":-17.98,"night":-18.31,"eve":-18.32,"morn":-29.51},"pressure":948.46,"humidity":54,"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"speed":3.21,"deg":166,"clouds":20},{"dt":1420916400,"temp":{"day":-18.51,"min":-25.57,"max":-17.86,"night":-23.83,"eve":-23.91,"morn":-19.28},"pressure":947.22,"humidity":74,"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03d"}],"speed":1.97,"deg":314,"clouds":48},{"dt":1421002800,"temp":{"day":-26.69,"min":-29.86,"max":-20.19,"night":-21.82,"eve":-24.66,"morn":-28.85},"pressure":951.93,"humidity":22,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"02d"}],"speed":1.36,"deg":196,"clouds":8},{"dt":1421089200,"temp":{"day":0.9,"min":-8.24,"max":0.9,"night":-4.99,"eve":-0.21,"morn":-8.24},"pressure":929.31,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":6.01,"deg":302,"clouds":5,"snow":0},{"dt":1421175600,"temp":{"day":-1.53,"min":-6.7,"max":2.23,"night":-3.65,"eve":2.23,"morn":-6.7},"pressure":934.51,"humidity":0,"weather":[{"id":800,"main":"Clear","description":"sky is clear","icon":"01d"}],"speed":3.9,"deg":201,"clouds":78}]}';
163 163
 
164
-		if($debug)
164
+		if ($debug)
165 165
 		{
166
-			error_log(__METHOD__ .' weather info:');
167
-			foreach(array_keys($data) as $key)
166
+			error_log(__METHOD__.' weather info:');
167
+			foreach (array_keys($data) as $key)
168 168
 			{
169
-				error_log($key . ': ' .array2string($data[$key]));
169
+				error_log($key.': '.array2string($data[$key]));
170 170
 			}
171 171
 		}
172
-		if(is_string($data['message']))
172
+		if (is_string($data['message']))
173 173
 		{
174 174
 			$desc = $this->get_description();
175
-			Framework::message($desc['displayName'] . ': ' . $desc['title'] . "\n".$data['message'], 'warning');
175
+			Framework::message($desc['displayName'].': '.$desc['title']."\n".$data['message'], 'warning');
176 176
 			return array();
177 177
 		}
178 178
 
179
-		if(array_key_exists('city', $data))
179
+		if (array_key_exists('city', $data))
180 180
 		{
181 181
 			$data['city_id'] = $data['city']['id'];
182 182
 		}
@@ -184,23 +184,23 @@  discard block
 block discarded – undo
184 184
 		{
185 185
 			$data['city_id'] = $data['id'];
186 186
 		}
187
-		if($data['list'])
187
+		if ($data['list'])
188 188
 		{
189
-			$massage =& $data['list'];
189
+			$massage = & $data['list'];
190 190
 
191
-			for($i = 0; $i <  min(count($massage), $this->context['width']); $i++)
191
+			for ($i = 0; $i < min(count($massage), $this->context['width']); $i++)
192 192
 			{
193
-				$forecast =& $massage[$i];
194
-				$forecast['day'] = Api\DateTime::to($forecast['dt'],'l');
193
+				$forecast = & $massage[$i];
194
+				$forecast['day'] = Api\DateTime::to($forecast['dt'], 'l');
195 195
 				self::format_forecast($forecast);
196 196
 			}
197 197
 			// Chop data to fit into portlet
198
-			for($i; $i < count($massage); $i++)
198
+			for ($i; $i < count($massage); $i++)
199 199
 			{
200 200
 				unset($massage[$i]);
201 201
 			}
202 202
 		}
203
-		if($data['current'] && is_array($data['current']))
203
+		if ($data['current'] && is_array($data['current']))
204 204
 		{
205 205
 			// Current weather
206 206
 			$data['current']['temp'] = $data['current']['main'];
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
 		if ($data['list'])
212 212
 		{
213
-			$data['current']['temp'] = array_merge($data['current']['temp'],$data['list'][0]['temp']);
213
+			$data['current']['temp'] = array_merge($data['current']['temp'], $data['list'][0]['temp']);
214 214
 		}
215 215
 		return $data;
216 216
 	}
@@ -220,22 +220,22 @@  discard block
 block discarded – undo
220 220
 	 */
221 221
 	protected static function format_forecast(&$data)
222 222
 	{
223
-		$weather =& $data['weather'] ? $data['weather'] : $data;
224
-		$temp =& $data['temp'] ? $data['temp'] : $data;
223
+		$weather = & $data['weather'] ? $data['weather'] : $data;
224
+		$temp = & $data['temp'] ? $data['temp'] : $data;
225 225
 
226 226
 		// Full URL for icon
227
-		if(is_array($weather))
227
+		if (is_array($weather))
228 228
 		{
229
-			foreach($weather as &$w)
229
+			foreach ($weather as &$w)
230 230
 			{
231
-				$w['icon'] = static::ICON_URL . $w['icon'].'.png';
231
+				$w['icon'] = static::ICON_URL.$w['icon'].'.png';
232 232
 			}
233 233
 		}
234 234
 
235 235
 		// Round
236
-		foreach(array('temp','temp_min','temp_max','min','max') as $temp_name)
236
+		foreach (array('temp', 'temp_min', 'temp_max', 'min', 'max') as $temp_name)
237 237
 		{
238
-			if(array_key_exists($temp_name, $temp))
238
+			if (array_key_exists($temp_name, $temp))
239 239
 			{
240 240
 				$temp[$temp_name] = ''.round($temp[$temp_name]);
241 241
 			}
Please login to merge, or discard this patch.
home/inc/class.home_favorite_portlet.inc.php 3 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,7 +59,10 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function __construct(Array &$context = array(), &$need_reload = false)
61 61
 	{
62
-		if (false) parent::__construct();
62
+		if (false)
63
+		{
64
+			parent::__construct();
65
+		}
63 66
 
64 67
 		// Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
65 68
 		if($context['dropped_data'])
@@ -151,7 +154,8 @@  discard block
 block discarded – undo
151 154
 		Etemplate\Widget::setElementAttribute('','','');
152 155
 	}
153 156
 
154
-	public function get_actions(){
157
+	public function get_actions()
158
+	{
155 159
 		return array();
156 160
 	}
157 161
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 	 * @param context Array portlet settings such as size, as well as values for properties
58 58
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
59 59
 	 */
60
-	public function __construct(Array &$context = array(), &$need_reload = false)
60
+	public function __construct(array &$context = array(), &$need_reload = false)
61 61
 	{
62 62
 		if (false) parent::__construct();
63 63
 
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected $nm_settings = array(
40 40
 		'lettersearch'	=> false,
41
-		'favorites'		=> false,	// Hide favorite control
41
+		'favorites'		=> false, // Hide favorite control
42 42
 		'actions'		=> array(),
43 43
 		'placeholder_actions' => array()
44 44
 	);
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 		if (false) parent::__construct();
63 63
 
64 64
 		// Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
65
-		if($context['dropped_data'])
65
+		if ($context['dropped_data'])
66 66
 		{
67
-			foreach((Array)$context['dropped_data'] as $dropped)
67
+			foreach ((Array)$context['dropped_data'] as $dropped)
68 68
 			{
69 69
 				// Only handle one, but dropped is an array
70 70
 				$context['appname'] = $dropped['appname'];
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			$need_reload = true;
78 78
 		}
79 79
 		// Favorite not set for new widgets created via context menu
80
-		if(!$context['favorite'])
80
+		if (!$context['favorite'])
81 81
 		{
82 82
 			// Set initial size to 6x3, default is way too small
83 83
 			$context['width'] = max($context['width'], 6);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		}
88 88
 
89 89
 		// Load and copy favorite
90
-		if($context['favorite'] && !is_array($context['favorite']))
90
+		if ($context['favorite'] && !is_array($context['favorite']))
91 91
 		{
92 92
 			$favorites = Framework\Favorites::get_favorites($context['appname']);
93 93
 			$context['favorite'] = $favorites[$context['favorite']];
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 		}
96 96
 
97 97
 		$this->favorite = $context['favorite'];
98
-		$this->title = lang($context['appname']) . ': ' . $this->favorite['name'];
98
+		$this->title = lang($context['appname']).': '.$this->favorite['name'];
99 99
 		$this->context = $context;
100
-		if($this->favorite)
100
+		if ($this->favorite)
101 101
 		{
102 102
 			$this->nm_settings['favorite'] = $this->context['favorite'];
103
-			if(is_array($this->favorite['state']))
103
+			if (is_array($this->favorite['state']))
104 104
 			{
105 105
 				$this->nm_settings += $this->favorite['state'];
106 106
 			}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
 	public function exec($id = null, Etemplate &$etemplate = null)
114 114
 	{
115
-		if($etemplate == null)
115
+		if ($etemplate == null)
116 116
 		{
117 117
 			$etemplate = new Etemplate();
118 118
 		}
@@ -124,34 +124,34 @@  discard block
 block discarded – undo
124 124
 		$content['header_node'] = "home-index_{$id}_header";
125 125
 		$sel_options = $content['sel_options'] ? $content['sel_options'] : array();
126 126
 		unset($content['sel_options']);
127
-		$etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']);
127
+		$etemplate->setElementAttribute('nm', 'template', $this->nm_settings['template']);
128 128
 
129 129
 
130 130
 		// Always load app's css
131 131
 		Framework::includeCSS($this->context['appname'], 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
132
-			Framework::includeCSS($this->context['appname'],'app');
132
+			Framework::includeCSS($this->context['appname'], 'app');
133 133
 
134 134
 		// Always load app's javascript, so most actions have a chance of working
135
-		Framework::includeJS('.','app',$this->context['appname']);
135
+		Framework::includeJS('.', 'app', $this->context['appname']);
136 136
 
137 137
 		// Set this so app's JS gets initialized
138 138
 		$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
139 139
 		$GLOBALS['egw_info']['flags']['currentapp'] = $this->context['appname'];
140 140
 
141
-		$etemplate->exec(get_called_class() .'::process',$content,$sel_options);
141
+		$etemplate->exec(get_called_class().'::process', $content, $sel_options);
142 142
 
143 143
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
144 144
 	}
145 145
 
146 146
 	public static function process($content = array())
147 147
 	{
148
-		unset($content);	// not used, but required by function signature
148
+		unset($content); // not used, but required by function signature
149 149
 
150 150
 		// We need to keep the template going, thanks.
151
-		Etemplate\Widget::setElementAttribute('','','');
151
+		Etemplate\Widget::setElementAttribute('', '', '');
152 152
 	}
153 153
 
154
-	public function get_actions(){
154
+	public function get_actions() {
155 155
 		return array();
156 156
 	}
157 157
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 		$properties = parent::get_properties();
196 196
 		$favorites = Framework\Favorites::get_favorites($this->context['appname']);
197 197
 		$favorite_list = array();
198
-		foreach($favorites as $id => $favorite)
198
+		foreach ($favorites as $id => $favorite)
199 199
 		{
200
-			if($favorite)
200
+			if ($favorite)
201 201
 			{
202 202
 				$favorite_list[$id] = $favorite['name'];
203 203
 			}
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			'type'	=>	'select',
209 209
 			'select_options' => $favorite_list
210 210
 		);
211
-		if($this->context['favorite'])
211
+		if ($this->context['favorite'])
212 212
 		{
213 213
 			$favorite['type'] = 'select_ro';
214 214
 		}
Please login to merge, or discard this patch.
home/inc/class.home_legacy_portlet.inc.php 2 patches
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,10 @@  discard block
 block discarded – undo
35 35
 	public function __construct(array &$context = array(), &$need_reload = false)
36 36
 	{
37 37
 		unset($need_reload);	// not used, but required by function signature
38
-		if (false) parent::__construct();
38
+		if (false)
39
+		{
40
+			parent::__construct();
41
+		}
39 42
 
40 43
 		$this->context = $context;
41 44
 
@@ -51,9 +54,12 @@  discard block
 block discarded – undo
51 54
 		// Execute hook to get content
52 55
 		ob_start();
53 56
 		$_content = Api\Hooks::single('home',$appname);
54
-		if (!$_content || $_content == 1)   // content has been echoed and not returned
57
+		if (!$_content || $_content == 1)
58
+		{
59
+			// content has been echoed and not returned
55 60
 		{
56 61
 			$_content = ob_get_contents();
62
+		}
57 63
 			ob_end_clean();
58 64
 		}
59 65
 		if($_content)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 
35 35
 	public function __construct(array &$context = array(), &$need_reload = false)
36 36
 	{
37
-		unset($need_reload);	// not used, but required by function signature
37
+		unset($need_reload); // not used, but required by function signature
38 38
 		if (false) parent::__construct();
39 39
 
40 40
 		$this->context = $context;
41 41
 
42 42
 		// Try to load content here, so all needed info is available
43 43
 		$appname = $this->context['app'];
44
-		if(!$appname || !Api\Hooks::exists('home', $appname))
44
+		if (!$appname || !Api\Hooks::exists('home', $appname))
45 45
 		{
46 46
 			return;
47 47
 		}
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Execute hook to get content
52 52
 		ob_start();
53
-		$_content = Api\Hooks::single('home',$appname);
53
+		$_content = Api\Hooks::single('home', $appname);
54 54
 		if (!$_content || $_content == 1)   // content has been echoed and not returned
55 55
 		{
56 56
 			$_content = ob_get_contents();
57 57
 			ob_end_clean();
58 58
 		}
59
-		if($_content)
59
+		if ($_content)
60 60
 		{
61 61
 			// Now we have to extract the actual content
62 62
 			$dom = new DOMDocument();
63 63
 			libxml_use_internal_errors(true);
64
-			$dom->loadHTML($_content,LIBXML_NOWARNING + LIBXML_NOERROR);
64
+			$dom->loadHTML($_content, LIBXML_NOWARNING + LIBXML_NOERROR);
65 65
 			$finder = new DOMXPath($dom);
66 66
 
67 67
 			// Find header for title
68 68
 			$title = $finder->query("//div[contains(@class,'divSideboxHeader')]/descendant::strong");
69
-			if($title->length)
69
+			if ($title->length)
70 70
 			{
71 71
 				$this->title = $title->item(0)->textContent;
72 72
 			}
73 73
 
74 74
 			// Remove header
75 75
 			$content = $finder->query("//div[contains(@class,'divSideboxHeader')]/descendant::strong/ancestor::tr");
76
-			for($i = 0; $i < $content->length; $i++)
76
+			for ($i = 0; $i < $content->length; $i++)
77 77
 			{
78 78
 				$content->item($i)->parentNode->removeChild($content->item($i));
79 79
 			}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
 		$etemplate->set_dom_id($id);
103 103
 
104
-		$etemplate->exec('home.home_link_portlet.exec',array('legacy' => $this->content), array(),array(),array(),2);
104
+		$etemplate->exec('home.home_link_portlet.exec', array('legacy' => $this->content), array(), array(), array(), 2);
105 105
 	}
106 106
 
107 107
 	/**
Please login to merge, or discard this patch.
home/inc/class.home_portlet.inc.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 	 * @param context Array portlet settings such as size, as well as values for properties
35 35
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
36 36
 	 */
37
-	public abstract function __construct(Array &$context = array(), &$need_reload = false);
37
+	public abstract function __construct(array &$context = array(), &$need_reload = false);
38 38
 
39 39
 	/**
40 40
 	 * Some descriptive information about the portlet, so that users can decide if
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	{
79 79
 		// Include the common attributes, or they won't get saved
80 80
 		$properties = array();
81
-		foreach(self::$common_attributes as $prop)
81
+		foreach (self::$common_attributes as $prop)
82 82
 		{
83 83
 			$properties[$prop] = array('name' => $prop);
84 84
 		}
@@ -123,6 +123,6 @@  discard block
 block discarded – undo
123 123
 
124 124
 	public function __toString()
125 125
 	{
126
-		return get_called_class() . ' Context:' . array2string($this->context);
126
+		return get_called_class().' Context:'.array2string($this->context);
127 127
 	}
128 128
 }
Please login to merge, or discard this patch.
home/inc/class.home_list_portlet.inc.php 3 patches
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,9 +40,15 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function __construct(Array &$context = array(), &$need_reload = false)
42 42
 	{
43
-		if (false) parent::__construct();
43
+		if (false)
44
+		{
45
+			parent::__construct();
46
+		}
44 47
 
45
-		if(!is_array($context['list'])) $context['list'] = array();
48
+		if(!is_array($context['list']))
49
+		{
50
+			$context['list'] = array();
51
+		}
46 52
 
47 53
 		// Process dropped data (Should be GUIDs) into something useable
48 54
 		if($context['dropped_data'])
@@ -118,7 +124,10 @@  discard block
 block discarded – undo
118 124
 		// Filemanager support - links need app = 'file' and type set
119 125
 		foreach($content['list'] as &$list)
120 126
 		{
121
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
127
+			if($list['app'] == 'filemanager')
128
+			{
129
+				$list['app'] = 'file';
130
+			}
122 131
 			if($list['app'] == 'file')
123 132
 			{
124 133
 				$list['app'] = 'file';
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * Construct the portlet
39 39
 	 *
40 40
 	 */
41
-	public function __construct(Array &$context = array(), &$need_reload = false)
41
+	public function __construct(array &$context = array(), &$need_reload = false)
42 42
 	{
43 43
 		if (false) parent::__construct();
44 44
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		$content = $this->context;
114 114
 		if(!is_array($content['list']))
115 115
 		{
116
-			$content['list'] = Array();
116
+			$content['list'] = array();
117 117
 		}
118 118
 		// Filemanager support - links need app = 'file' and type set
119 119
 		foreach($content['list'] as &$list)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 	{
43 43
 		if (false) parent::__construct();
44 44
 
45
-		if(!is_array($context['list'])) $context['list'] = array();
45
+		if (!is_array($context['list'])) $context['list'] = array();
46 46
 
47 47
 		// Process dropped data (Should be GUIDs) into something useable
48
-		if($context['dropped_data'])
48
+		if ($context['dropped_data'])
49 49
 		{
50
-			foreach((Array)$context['dropped_data'] as $dropped)
50
+			foreach ((Array)$context['dropped_data'] as $dropped)
51 51
 			{
52 52
 				$add = array();
53 53
 				list($add['app'], $add['id']) = explode('::', $dropped, 2);
54
-				if($add['app'] && $add['id'])
54
+				if ($add['app'] && $add['id'])
55 55
 				{
56 56
 					$context['list'][] = $add;
57 57
 				}
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 			unset($context['dropped_data']);
61 61
 			$need_reload = true;
62 62
 		}
63
-		if($context['title'])
63
+		if ($context['title'])
64 64
 		{
65 65
 			$this->title = $context['title'];
66 66
 		}
67
-		foreach($context['list'] as &$item)
67
+		foreach ($context['list'] as &$item)
68 68
 		{
69
-			if($item['app'] == 'filemanager' || $item['app'] == 'file')
69
+			if ($item['app'] == 'filemanager' || $item['app'] == 'file')
70 70
 			{
71 71
 				$item['app'] = 'file';
72 72
 				$item['type'] = Vfs::mime_content_type($item['id']);
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$etemplate->set_dom_id($id);
113 113
 		$content = $this->context;
114
-		if(!is_array($content['list']))
114
+		if (!is_array($content['list']))
115 115
 		{
116 116
 			$content['list'] = Array();
117 117
 		}
118 118
 		// Filemanager support - links need app = 'file' and type set
119
-		foreach($content['list'] as &$list)
119
+		foreach ($content['list'] as &$list)
120 120
 		{
121
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
122
-			if($list['app'] == 'file')
121
+			if ($list['app'] == 'filemanager') $list['app'] = 'file';
122
+			if ($list['app'] == 'file')
123 123
 			{
124 124
 				$list['app'] = 'file';
125 125
 				$list['path'] = $list['title'] = $list['icon'] = $list['id'];
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 		}
129 129
 
130
-		$etemplate->exec('home.home_list_portlet.exec',$content);
130
+		$etemplate->exec('home.home_list_portlet.exec', $content);
131 131
 	}
132 132
 
133 133
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 				'type' => 'drop',
183 183
 				'caption' => lang('add'),
184 184
 				'onExecute' => 'javaScript:app.home.add_link',
185
-				'acceptedTypes' => array('file','link') + array_keys($GLOBALS['egw_info']['apps']),
185
+				'acceptedTypes' => array('file', 'link') + array_keys($GLOBALS['egw_info']['apps']),
186 186
 			)
187 187
 		);
188 188
 		return $actions;
@@ -202,6 +202,6 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function accept_drop()
204 204
 	{
205
-		return array('file','link');
205
+		return array('file', 'link');
206 206
 	}
207 207
 }
Please login to merge, or discard this patch.