Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
api/src/MimeMagic.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		{
47 47
 			return $mime;
48 48
 		}
49
-		return lang('%1 file',strtoupper($ext)).' ('.$mime.')';
49
+		return lang('%1 file', strtoupper($ext)).' ('.$mime.')';
50 50
 	}
51 51
 
52 52
 	/**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	{
64 64
 		if (empty($_ext))
65 65
 		{
66
-			return 'text/plain';//assume no extension is a text file
66
+			return 'text/plain'; //assume no extension is a text file
67 67
 		}
68 68
 		$ext = strtolower($_ext);
69 69
 		if (!array_key_exists($ext, self::$mime_extension_map))
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public static function analyze_data($data)
190 190
 	{
191
-		if(!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir']))
191
+		if (!is_writeable(@$GLOBALS['egw_info']['server']['temp_dir']))
192 192
 		{
193 193
 			//nothing we can do but bail out
194 194
 			return false;
195 195
 		}
196 196
 
197 197
 		mt_srand(time());
198
-		$filename = $GLOBALS['egw_info']['server']['temp_dir'] . '/'
199
-			. md5( time() + mt_rand() ) . '.tmp';
198
+		$filename = $GLOBALS['egw_info']['server']['temp_dir'].'/'
199
+			. md5(time() + mt_rand()).'.tmp';
200 200
 
201 201
 		$fp = @fopen($filename, 'ab');
202
-		if(!$fp || !$data)
202
+		if (!$fp || !$data)
203 203
 		{
204 204
 			//houston we have a problem - bail out
205 205
 			return false;
206 206
 		}
207 207
 
208
-		if(!fwrite($fp, $data))
208
+		if (!fwrite($fp, $data))
209 209
 		{
210 210
 			//bail out again
211 211
 			return false;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$mime = self::analyze_file($filename);
217 217
 
218
-		unlink($filename);//remove the temp file
218
+		unlink($filename); //remove the temp file
219 219
 
220 220
 		return $mime;
221 221
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @var array of extenstion to mime mappings
234 234
 	 */
235 235
 	static $mime_extension_map = array(
236
-		'txt'				=> 'text/plain',	// should be first, so text/plain maps back to .txt
236
+		'txt'				=> 'text/plain', // should be first, so text/plain maps back to .txt
237 237
 		'3dml'              => 'text/vnd.in3d.3dml',
238 238
 		'3ds'               => 'image/x-3ds',
239 239
 		'3g2'               => 'video/3gpp2',
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,10 @@
 block discarded – undo
106 106
 	public static function mime2ext($_type)
107 107
 	{
108 108
 		$type = strtolower($_type);
109
-		if (isset(self::$mime_alias_map[$type])) $type = self::$mime_alias_map[$type];
109
+		if (isset(self::$mime_alias_map[$type]))
110
+		{
111
+			$type = self::$mime_alias_map[$type];
112
+		}
110 113
 		$key = array_search($type, self::$mime_extension_map);
111 114
 		if (empty($type) || $key === false)
112 115
 		{
Please login to merge, or discard this patch.
api/src/Exception.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 class Exception extends \Exception
30 30
 {
31 31
 	// nothing fancy yet
32
-	function __construct($msg=null,$code=100,\Exception $previous=null)
32
+	function __construct($msg = null, $code = 100, \Exception $previous = null)
33 33
 	{
34 34
 		return parent::__construct($msg, $code, $previous);
35 35
 	}
Please login to merge, or discard this patch.
api/src/Accounts/Sql.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -198,38 +198,38 @@  discard block
 block discarded – undo
198 198
 		if ($data['account_passwd'])
199 199
 		{
200 200
 			// if password it's not already entcrypted, do so now
201
-			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
202
-				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))	// md5 hash
201
+			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i', $data['account_passwd']) &&
202
+				!preg_match('/^[0-9a-f]{32}$/', $data['account_passwd']))	// md5 hash
203 203
 			{
204 204
 				$data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']);
205 205
 			}
206 206
 			$to_write['account_pwd'] = $data['account_passwd'];
207 207
 			$to_write['account_lastpwd_change'] = time();
208 208
 		}
209
-		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0;
209
+		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change'] = 0;
210 210
 		if (!(int)$data['account_id'] || !$this->id2name($data['account_id']))
211 211
 		{
212 212
 			if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1;
213 213
 
214
-			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = '';	// is NOT NULL!
215
-			if (!isset($to_write['account_status'])) $to_write['account_status'] = '';	// is NOT NULL!
214
+			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = ''; // is NOT NULL!
215
+			if (!isset($to_write['account_status'])) $to_write['account_status'] = ''; // is NOT NULL!
216 216
 
217 217
 			// postgres requires the auto-id field to be unset!
218 218
 			if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']);
219 219
 
220
-			if (!in_array($to_write['account_type'],array('u','g')) ||
221
-				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false;
220
+			if (!in_array($to_write['account_type'], array('u', 'g')) ||
221
+				!$this->db->insert($this->table, $to_write, false, __LINE__, __FILE__)) return false;
222 222
 
223 223
 			if (!(int)$data['account_id'])
224 224
 			{
225
-				$data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id');
225
+				$data['account_id'] = $this->db->get_last_insert_id($this->table, 'account_id');
226 226
 				if ($data['account_type'] == 'g') $data['account_id'] *= -1;
227 227
 			}
228 228
 		}
229 229
 		else	// update of existing account
230 230
 		{
231 231
 			unset($to_write['account_id']);
232
-			if (!$this->db->update($this->table,$to_write,array('account_id' => abs($data['account_id'])),__LINE__,__FILE__))
232
+			if (!$this->db->update($this->table, $to_write, array('account_id' => abs($data['account_id'])), __LINE__, __FILE__))
233 233
 			{
234 234
 				return false;
235 235
 			}
@@ -278,16 +278,16 @@  discard block
 block discarded – undo
278 278
 	{
279 279
 		if (!(int)$account_id) return false;
280 280
 
281
-		$contact_id = $this->id2name($account_id,'person_id');
281
+		$contact_id = $this->id2name($account_id, 'person_id');
282 282
 
283
-		if (!$this->db->delete($this->table,array('account_id' => abs($account_id)),__LINE__,__FILE__))
283
+		if (!$this->db->delete($this->table, array('account_id' => abs($account_id)), __LINE__, __FILE__))
284 284
 		{
285 285
 			return false;
286 286
 		}
287 287
 		if ($contact_id)
288 288
 		{
289 289
 			if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
290
-			$this->contacts->delete($contact_id,false);	// false = allow to delete accounts (!)
290
+			$this->contacts->delete($contact_id, false); // false = allow to delete accounts (!)
291 291
 		}
292 292
 		return true;
293 293
 	}
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 		if (!(int)$account_id) return false;
304 304
 
305 305
 		$memberships = array();
306
-		if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
306
+		if (($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
307 307
 		{
308
-			foreach($gids as $gid)
308
+			foreach ($gids as $gid)
309 309
 			{
310
-				$memberships[(string) $gid] = $this->id2name($gid);
310
+				$memberships[(string)$gid] = $this->id2name($gid);
311 311
 			}
312 312
 		}
313 313
 		return $memberships;
@@ -319,17 +319,17 @@  discard block
 block discarded – undo
319 319
 	 * @param array $groups array with gidnumbers
320 320
 	 * @param int $account_id numerical account-id
321 321
 	 */
322
-	function set_memberships($groups,$account_id)
322
+	function set_memberships($groups, $account_id)
323 323
 	{
324 324
 		if (!(int)$account_id) return;
325 325
 
326 326
 		$acl = new Api\Acl($account_id);
327 327
 		$acl->read_repository();
328
-		$acl->delete('phpgw_group',false);
328
+		$acl->delete('phpgw_group', false);
329 329
 
330
-		foreach($groups as $group)
330
+		foreach ($groups as $group)
331 331
 		{
332
-			$acl->add('phpgw_group',$group,1);
332
+			$acl->add('phpgw_group', $group, 1);
333 333
 		}
334 334
 		$acl->save_repository();
335 335
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		if (!is_numeric($account_id)) $account_id = $this->name2id($account_id);
346 346
 
347 347
 		$members = array();
348
-		foreach($this->db->select($this->table, 'account_id,account_lid',
348
+		foreach ($this->db->select($this->table, 'account_id,account_lid',
349 349
 			$this->db->expression(Api\Acl::TABLE, array(
350 350
 				'acl_appname'  => 'phpgw_group',
351 351
 				'acl_location' => $account_id,
@@ -364,15 +364,15 @@  discard block
 block discarded – undo
364 364
 	 * @param array $members array with uidnumber or uid's
365 365
 	 * @param int $gid gidnumber of group to set
366 366
 	 */
367
-	function set_members($members,$gid)
367
+	function set_members($members, $gid)
368 368
 	{
369
-		$GLOBALS['egw']->acl->delete_repository('phpgw_group',$gid,false);
369
+		$GLOBALS['egw']->acl->delete_repository('phpgw_group', $gid, false);
370 370
 
371 371
 		if (is_array($members))
372 372
 		{
373
-			foreach($members as $id)
373
+			foreach ($members as $id)
374 374
 			{
375
-				$GLOBALS['egw']->acl->add_repository('phpgw_group',$gid,$id,1);
375
+				$GLOBALS['egw']->acl->add_repository('phpgw_group', $gid, $id, 1);
376 376
 			}
377 377
 		}
378 378
 	}
@@ -407,20 +407,20 @@  discard block
 block discarded – undo
407 407
 		);
408 408
 
409 409
 		// fetch order of account_fullname from Api\Accounts::format_username
410
-		if (strpos($param['order'],'account_fullname') !== false)
410
+		if (strpos($param['order'], 'account_fullname') !== false)
411 411
 		{
412
-			$param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/',',',str_replace(array('[',']'),'',
413
-				Api\Accounts::format_username('account_lid','account_firstname','account_lastname'))), $param['order']);
412
+			$param['order'] = str_replace('account_fullname', preg_replace('/[ ,]+/', ',', str_replace(array('[', ']'), '',
413
+				Api\Accounts::format_username('account_lid', 'account_firstname', 'account_lastname'))), $param['order']);
414 414
 		}
415
-		$order = str_replace(array_keys($order2contact),array_values($order2contact),$param['order']);
415
+		$order = str_replace(array_keys($order2contact), array_values($order2contact), $param['order']);
416 416
 		// allways add 'account_lid', as it is only valid one for groups
417 417
 		if (strpos($order, 'account_lid') === false)
418 418
 		{
419
-			$order .= ($order?',':'').'account_lid';
419
+			$order .= ($order ? ',' : '').'account_lid';
420 420
 		}
421 421
 		if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
422 422
 
423
-		$search_cols = array('account_lid','n_family','n_given','email');
423
+		$search_cols = array('account_lid', 'n_family', 'n_given', 'email');
424 424
 		$join = $this->contacts_join;
425 425
 		$email_cols = array('email');
426 426
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 		}
437 437
 
438 438
 		$filter = array();
439
-		switch($param['type'])
439
+		switch ($param['type'])
440 440
 		{
441 441
 			case 'accounts':
442 442
 				$filter['owner'] = 0;
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 			case 'groupmembers':
452 452
 			case 'groupmembers+memberships':
453 453
 				$members = array();
454
-				foreach((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name)
454
+				foreach ((array)$this->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $grp => $name)
455 455
 				{
456 456
 					unset($name);
457 457
 					$members = array_unique(array_merge($members, array_keys((array)$this->members($grp))));
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
 		}
487 487
 		if ($param['active'])
488 488
 		{
489
-			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER);
489
+			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())', time(), Api\Contacts\Sql::ACOUNT_ACTIVE_FILTER);
490 490
 		}
491 491
 		$criteria = array();
492 492
 		$wildcard = $param['query_type'] == 'start' || $param['query_type'] == 'exact' ? '' : '%';
493 493
 		if (($query = $param['query']))
494 494
 		{
495
-			switch($param['query_type'])
495
+			switch ($param['query_type'])
496 496
 			{
497 497
 				case 'start':
498 498
 					$query .= '*';
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				case 'all':
501 501
 				default:
502 502
 				case 'exact':
503
-					foreach($search_cols as $col)
503
+					foreach ($search_cols as $col)
504 504
 					{
505 505
 						$criteria[$col] = $query;
506 506
 					}
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 				case 'email':
522 522
 					$criteria['email'] = $query;
523 523
 					// Group email
524
-					if(in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true)))
524
+					if (in_array(Api\Mail\Smtp\Sql::TABLE, $this->db->table_names(true)))
525 525
 					{
526 526
 						$criteria[Api\Mail\Smtp\Sql::TABLE.'.mail_value'] = $query;
527 527
 					}
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 		if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
532 532
 
533 533
 		$accounts = array();
534
-		foreach((array) $this->contacts->search($criteria,
535
-			array_merge(array(1,'n_given','n_family','id','created','modified',$this->table.'.account_id AS account_id'),$email_cols),
536
-			$order,"account_lid,account_type,account_status,account_expires,account_primary_group,account_description",
537
-			$wildcard,false,$query[0] == '!' ? 'AND' : 'OR',
534
+		foreach ((array)$this->contacts->search($criteria,
535
+			array_merge(array(1, 'n_given', 'n_family', 'id', 'created', 'modified', $this->table.'.account_id AS account_id'), $email_cols),
536
+			$order, "account_lid,account_type,account_status,account_expires,account_primary_group,account_description",
537
+			$wildcard, false, $query[0] == '!' ? 'AND' : 'OR',
538 538
 			$param['offset'] ? array($param['start'], $param['offset']) : (is_null($param['start']) ? false : $param['start']),
539
-			$filter,$join) as $contact)
539
+			$filter, $join) as $contact)
540 540
 		{
541 541
 			if ($contact)
542 542
 			{
@@ -576,13 +576,13 @@  discard block
 block discarded – undo
576 576
 	 * @param string $account_type u = user, g = group, default null = try both
577 577
 	 * @return int/false numeric account_id or false on error ($name not found)
578 578
 	 */
579
-	function name2id($name,$which='account_lid',$account_type=null)
579
+	function name2id($name, $which = 'account_lid', $account_type = null)
580 580
 	{
581 581
 		if ($account_type === 'g' && $which != 'account_lid') return false;
582 582
 
583 583
 		$where = array();
584 584
 		$cols = 'account_id';
585
-		switch($which)
585
+		switch ($which)
586 586
 		{
587 587
 			case 'account_fullname':
588 588
 				$table = $this->contacts_table;
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 		}
614 614
 		else
615 615
 		{
616
-			$where[] = 'account_id IS NOT NULL'.	// otherwise contacts with eg. the same email hide the accounts!
617
-				($table == $this->contacts_table ? " AND contact_tid != 'D'" : '');	// ignore deleted accounts contact-data
616
+			$where[] = 'account_id IS NOT NULL'.// otherwise contacts with eg. the same email hide the accounts!
617
+				($table == $this->contacts_table ? " AND contact_tid != 'D'" : ''); // ignore deleted accounts contact-data
618 618
 
619 619
 		}
620
-		if (!($rs = $this->db->select($table,$cols,$where,__LINE__,__FILE__)) || !($row = $rs->fetch()))
620
+		if (!($rs = $this->db->select($table, $cols, $where, __LINE__, __FILE__)) || !($row = $rs->fetch()))
621 621
 		{
622 622
 			//error_log(__METHOD__."('$name', '$which', ".array2string($account_type).") db->select('$table', '$cols', ".array2string($where).") returned ".array2string($rs).' '.function_backtrace());
623 623
 			return false;
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param string $which ='account_lid' type to convert to: account_lid (default), account_email, ...
635 635
 	 * @return string/false converted value or false on error ($account_id not found)
636 636
 	 */
637
-	function id2name($account_id,$which='account_lid')
637
+	function id2name($account_id, $which = 'account_lid')
638 638
 	{
639
-		return $this->frontend->id2name($account_id,$which);
639
+		return $this->frontend->id2name($account_id, $which);
640 640
 	}
641 641
 
642 642
 	/**
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
 	 */
649 649
 	function update_lastlogin($account_id, $ip)
650 650
 	{
651
-		$previous_login = $this->db->select($this->table,'account_lastlogin',array('account_id'=>abs($account_id)),__LINE__,__FILE__)->fetchColumn();
651
+		$previous_login = $this->db->select($this->table, 'account_lastlogin', array('account_id'=>abs($account_id)), __LINE__, __FILE__)->fetchColumn();
652 652
 
653
-		$this->db->update($this->table,array(
653
+		$this->db->update($this->table, array(
654 654
 			'account_lastloginfrom' => $ip,
655 655
 			'account_lastlogin'     => time(),
656
-		),array(
656
+		), array(
657 657
 			'account_id' => abs($account_id),
658
-		),__LINE__,__FILE__);
658
+		), __LINE__, __FILE__);
659 659
 
660 660
 		return $previous_login;
661 661
 	}
Please login to merge, or discard this patch.
Braces   +94 added lines, -23 removed lines patch added patch discarded remove patch
@@ -122,7 +122,10 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	function read($account_id)
124 124
 	{
125
-		if (!(int)$account_id) return false;
125
+		if (!(int)$account_id)
126
+		{
127
+			return false;
128
+		}
126 129
 
127 130
 		if ($account_id > 0)
128 131
 		{
@@ -152,11 +155,14 @@  discard block
 block discarded – undo
152 155
 			unset($e);
153 156
 		}
154 157
 
155
-		if (!$rs)	// handle not (yet) existing mailaccounts table
158
+		if (!$rs)
159
+		{
160
+			// handle not (yet) existing mailaccounts table
156 161
 		{
157 162
 			$rs = $this->db->select($this->table, $this->table.'.*',
158 163
 				$this->table.'.account_id='.abs($account_id), __LINE__, __FILE__);
159 164
 		}
165
+		}
160 166
 		if (!$rs || !($data = $rs->fetch()))
161 167
 		{
162 168
 			return false;
@@ -166,7 +172,10 @@  discard block
 block discarded – undo
166 172
 			$data['account_id'] = -$data['account_id'];
167 173
 			$data['mailAllowed'] = true;
168 174
 		}
169
-		if (!$data['account_firstname']) $data['account_firstname'] = $data['account_lid'];
175
+		if (!$data['account_firstname'])
176
+		{
177
+			$data['account_firstname'] = $data['account_lid'];
178
+		}
170 179
 		if (!$data['account_lastname'])
171 180
 		{
172 181
 			$data['account_lastname'] = $data['account_type'] == 'g' ? 'Group' : 'User';
@@ -177,7 +186,10 @@  discard block
 block discarded – undo
177 186
 				$data['account_lastname'] = lang($data['account_lastname']);
178 187
 			}
179 188
 		}
180
-		if (!$data['account_fullname']) $data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
189
+		if (!$data['account_fullname'])
190
+		{
191
+			$data['account_fullname'] = $data['account_firstname'].' '.$data['account_lastname'];
192
+		}
181 193
 
182 194
 		return $data;
183 195
 	}
@@ -199,31 +211,57 @@  discard block
 block discarded – undo
199 211
 		{
200 212
 			// if password it's not already entcrypted, do so now
201 213
 			if (!preg_match('/^\\{[a-z5]{3,5}\\}.+/i',$data['account_passwd']) &&
202
-				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))	// md5 hash
214
+				!preg_match('/^[0-9a-f]{32}$/',$data['account_passwd']))
215
+			{
216
+				// md5 hash
203 217
 			{
204 218
 				$data['account_passwd'] = Api\Auth::encrypt_sql($data['account_passwd']);
205 219
 			}
220
+			}
206 221
 			$to_write['account_pwd'] = $data['account_passwd'];
207 222
 			$to_write['account_lastpwd_change'] = time();
208 223
 		}
209
-		if ($data['mustchangepassword'] == 1) $to_write['account_lastpwd_change']=0;
224
+		if ($data['mustchangepassword'] == 1)
225
+		{
226
+			$to_write['account_lastpwd_change']=0;
227
+		}
210 228
 		if (!(int)$data['account_id'] || !$this->id2name($data['account_id']))
211 229
 		{
212
-			if ($to_write['account_id'] < 0) $to_write['account_id'] *= -1;
230
+			if ($to_write['account_id'] < 0)
231
+			{
232
+				$to_write['account_id'] *= -1;
233
+			}
213 234
 
214
-			if (!isset($to_write['account_pwd'])) $to_write['account_pwd'] = '';	// is NOT NULL!
215
-			if (!isset($to_write['account_status'])) $to_write['account_status'] = '';	// is NOT NULL!
235
+			if (!isset($to_write['account_pwd']))
236
+			{
237
+				$to_write['account_pwd'] = '';
238
+			}
239
+			// is NOT NULL!
240
+			if (!isset($to_write['account_status']))
241
+			{
242
+				$to_write['account_status'] = '';
243
+			}
244
+			// is NOT NULL!
216 245
 
217 246
 			// postgres requires the auto-id field to be unset!
218
-			if (isset($to_write['account_id']) && !$to_write['account_id']) unset($to_write['account_id']);
247
+			if (isset($to_write['account_id']) && !$to_write['account_id'])
248
+			{
249
+				unset($to_write['account_id']);
250
+			}
219 251
 
220 252
 			if (!in_array($to_write['account_type'],array('u','g')) ||
221
-				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__)) return false;
253
+				!$this->db->insert($this->table,$to_write,false,__LINE__,__FILE__))
254
+			{
255
+				return false;
256
+			}
222 257
 
223 258
 			if (!(int)$data['account_id'])
224 259
 			{
225 260
 				$data['account_id'] = $this->db->get_last_insert_id($this->table,'account_id');
226
-				if ($data['account_type'] == 'g') $data['account_id'] *= -1;
261
+				if ($data['account_type'] == 'g')
262
+				{
263
+					$data['account_id'] *= -1;
264
+				}
227 265
 			}
228 266
 		}
229 267
 		else	// update of existing account
@@ -276,7 +314,10 @@  discard block
 block discarded – undo
276 314
 	 */
277 315
 	function delete($account_id)
278 316
 	{
279
-		if (!(int)$account_id) return false;
317
+		if (!(int)$account_id)
318
+		{
319
+			return false;
320
+		}
280 321
 
281 322
 		$contact_id = $this->id2name($account_id,'person_id');
282 323
 
@@ -286,7 +327,10 @@  discard block
 block discarded – undo
286 327
 		}
287 328
 		if ($contact_id)
288 329
 		{
289
-			if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
330
+			if (!isset($this->contacts))
331
+			{
332
+				$this->contacts = new Api\Contacts();
333
+			}
290 334
 			$this->contacts->delete($contact_id,false);	// false = allow to delete accounts (!)
291 335
 		}
292 336
 		return true;
@@ -300,7 +344,10 @@  discard block
 block discarded – undo
300 344
 	 */
301 345
 	function memberships($account_id)
302 346
 	{
303
-		if (!(int)$account_id) return false;
347
+		if (!(int)$account_id)
348
+		{
349
+			return false;
350
+		}
304 351
 
305 352
 		$memberships = array();
306 353
 		if(($gids = $GLOBALS['egw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id)))
@@ -321,7 +368,10 @@  discard block
 block discarded – undo
321 368
 	 */
322 369
 	function set_memberships($groups,$account_id)
323 370
 	{
324
-		if (!(int)$account_id) return;
371
+		if (!(int)$account_id)
372
+		{
373
+			return;
374
+		}
325 375
 
326 376
 		$acl = new Api\Acl($account_id);
327 377
 		$acl->read_repository();
@@ -342,7 +392,10 @@  discard block
 block discarded – undo
342 392
 	 */
343 393
 	function members($account_id)
344 394
 	{
345
-		if (!is_numeric($account_id)) $account_id = $this->name2id($account_id);
395
+		if (!is_numeric($account_id))
396
+		{
397
+			$account_id = $this->name2id($account_id);
398
+		}
346 399
 
347 400
 		$members = array();
348 401
 		foreach($this->db->select($this->table, 'account_id,account_lid',
@@ -418,7 +471,10 @@  discard block
 block discarded – undo
418 471
 		{
419 472
 			$order .= ($order?',':'').'account_lid';
420 473
 		}
421
-		if ($param['sort']) $order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
474
+		if ($param['sort'])
475
+		{
476
+			$order = implode(' '.$param['sort'].',', explode(',', $order)).' '.$param['sort'];
477
+		}
422 478
 
423 479
 		$search_cols = array('account_lid','n_family','n_given','email');
424 480
 		$join = $this->contacts_join;
@@ -455,7 +511,10 @@  discard block
 block discarded – undo
455 511
 				{
456 512
 					unset($name);
457 513
 					$members = array_unique(array_merge($members, array_keys((array)$this->members($grp))));
458
-					if ($param['type'] == 'groupmembers+memberships') $members[] = abs($grp);
514
+					if ($param['type'] == 'groupmembers+memberships')
515
+					{
516
+						$members[] = abs($grp);
517
+					}
459 518
 				}
460 519
 				$filter['account_id'] = $members;
461 520
 				break;
@@ -474,9 +533,12 @@  discard block
 block discarded – undo
474 533
 		// fix ambigous account_id (used in accounts and contacts table)
475 534
 		if (array_key_exists('account_id', $filter))
476 535
 		{
477
-			if (!$filter['account_id'])	// eg. group without members (would give SQL error)
536
+			if (!$filter['account_id'])
537
+			{
538
+				// eg. group without members (would give SQL error)
478 539
 			{
479 540
 				$this->total = 0;
541
+			}
480 542
 				return array();
481 543
 			}
482 544
 			$filter[] = $this->db->expression($this->table, $this->table.'.', array(
@@ -528,7 +590,10 @@  discard block
 block discarded – undo
528 590
 					break;
529 591
 			}
530 592
 		}
531
-		if (!isset($this->contacts)) $this->contacts = new Api\Contacts();
593
+		if (!isset($this->contacts))
594
+		{
595
+			$this->contacts = new Api\Contacts();
596
+		}
532 597
 
533 598
 		$accounts = array();
534 599
 		foreach((array) $this->contacts->search($criteria,
@@ -578,7 +643,10 @@  discard block
 block discarded – undo
578 643
 	 */
579 644
 	function name2id($name,$which='account_lid',$account_type=null)
580 645
 	{
581
-		if ($account_type === 'g' && $which != 'account_lid') return false;
646
+		if ($account_type === 'g' && $which != 'account_lid')
647
+		{
648
+			return false;
649
+		}
582 650
 
583 651
 		$where = array();
584 652
 		$cols = 'account_id';
@@ -601,9 +669,12 @@  discard block
 block discarded – undo
601 669
 				$cols .= ',account_type';
602 670
 				$where[$which] = $name;
603 671
 				// check if we need to treat username case-insensitive
604
-				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])	// = is case sensitiv eg. on postgres, but not on mysql!
672
+				if ($which == 'account_lid' && !$GLOBALS['egw_info']['server']['case_sensitive_username'])
673
+				{
674
+					// = is case sensitiv eg. on postgres, but not on mysql!
605 675
 				{
606 676
 					$where[] = 'account_lid '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote($where['account_lid']);
677
+				}
607 678
 					unset($where['account_lid']);
608 679
 				}
609 680
 		}
Please login to merge, or discard this patch.
api/src/Cache/Memcache.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -54,26 +54,26 @@  discard block
 block discarded – undo
54 54
 	 * @throws Exception if connection to backend could not be established
55 55
 	 * @param array $params eg. array('localhost'[,'localhost:11211',...])
56 56
 	 */
57
-	function __construct(array $params=null)
57
+	function __construct(array $params = null)
58 58
 	{
59
-		check_load_extension('memcache',true);
59
+		check_load_extension('memcache', true);
60 60
 		$this->memcache = new \Memcache();
61 61
 
62
-		if (!$params) $params = array('localhost');	// some reasonable default
62
+		if (!$params) $params = array('localhost'); // some reasonable default
63 63
 
64 64
 		$ok = false;
65
-		foreach($params as $host_port)
65
+		foreach ($params as $host_port)
66 66
 		{
67
-			$parts = explode(':',$host_port);
67
+			$parts = explode(':', $host_port);
68 68
 			$host = array_shift($parts);
69
-			$port = $parts ? array_shift($parts) : 11211;	// default port
69
+			$port = $parts ? array_shift($parts) : 11211; // default port
70 70
 
71
-			$ok = $this->memcache->addServer($host,$port) || $ok;
71
+			$ok = $this->memcache->addServer($host, $port) || $ok;
72 72
 			//error_log(__METHOD__."(".array2string($params).") memcache->addServer('$host',$port) = ".(int)$ok);
73 73
 		}
74 74
 		if (!$ok)
75 75
 		{
76
-			throw new Exception (__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!");
76
+			throw new Exception(__METHOD__.'('.array2string($params).") Can't open connection to any memcached server!");
77 77
 		}
78 78
 		$this->igbinary_available = function_exists('igbinary_serialize') && function_exists('igbinary_unserialize');
79 79
 	}
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @param int $expiration =0
87 87
 	 * @return boolean true on success, false on error, incl. key already exists in cache
88 88
 	 */
89
-	function add(array $keys,$data,$expiration=0)
89
+	function add(array $keys, $data, $expiration = 0)
90 90
 	{
91 91
 		return $this->memcache->add(self::key($keys),
92 92
 			$this->igbinary_available ? igbinary_serialize($data) : serialize($data),
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @param int $expiration =0
102 102
 	 * @return boolean true on success, false on error
103 103
 	 */
104
-	function set(array $keys,$data,$expiration=0)
104
+	function set(array $keys, $data, $expiration = 0)
105 105
 	{
106 106
 		return $this->memcache->set(self::key($keys),
107 107
 			$this->igbinary_available ? igbinary_serialize($data) : serialize($data),
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	function get(array $keys)
118 118
 	{
119
-		if (($data = $this->memcache->get($key=self::key($keys))) === false)
119
+		if (($data = $this->memcache->get($key = self::key($keys))) === false)
120 120
 		{
121 121
 			//error_log(__METHOD__."(".array2string($keys).") key='$key' NOT found!");
122 122
 			return null;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	{
136 136
 		$locations = array_pop($keys);
137 137
 		$prefix = self::key($keys);
138
-		foreach($locations as &$location)
138
+		foreach ($locations as &$location)
139 139
 		{
140 140
 			$location = $prefix.'::'.$location;
141 141
 		}
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 			return array();
145 145
 		}
146 146
 		$ret = array();
147
-		$prefix_len = strlen($prefix)+2;
148
-		foreach($multiple as $location => $data)
147
+		$prefix_len = strlen($prefix) + 2;
148
+		foreach ($multiple as $location => $data)
149 149
 		{
150
-			$key = substr($location,$prefix_len);
150
+			$key = substr($location, $prefix_len);
151 151
 			//error_log(__METHOD__."(".array2string($locations).") key='$key' found ".bytes($data)." bytes).");
152 152
 			$ret[$key] = $this->igbinary_available && $data[1] !== ':' ? igbinary_unserialize($data) : unserialize($data);
153 153
 		}
@@ -175,6 +175,6 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	private function key(array $keys)
177 177
 	{
178
-		return implode('::',$keys);
178
+		return implode('::', $keys);
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
Braces   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,11 @@
 block discarded – undo
59 59
 		check_load_extension('memcache',true);
60 60
 		$this->memcache = new \Memcache();
61 61
 
62
-		if (!$params) $params = array('localhost');	// some reasonable default
62
+		if (!$params)
63
+		{
64
+			$params = array('localhost');
65
+		}
66
+		// some reasonable default
63 67
 
64 68
 		$ok = false;
65 69
 		foreach($params as $host_port)
Please login to merge, or discard this patch.
api/src/Cache/Base.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param boolean $verbose =false true: echo failed checks
29 29
 	 * @return int number of failed checks
30 30
 	 */
31
-	function check($verbose=false)
31
+	function check($verbose = false)
32 32
 	{
33 33
 		// set us up as provider for Api\Cache class
34 34
 		$GLOBALS['egw_info']['server']['install_id'] = md5(microtime(true));
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 		Api\Cache::$default_provider = get_class($this);
38 38
 
39 39
 		$failed = 0;
40
-		foreach(array(
40
+		foreach (array(
41 41
 			Api\Cache::TREE => 'tree',
42 42
 			Api\Cache::INSTANCE => 'instance',
43 43
 		) as $level => $label)
44 44
 		{
45 45
 			$locations = array();
46
-			foreach(array('string',123,true,false,null,array(),array(1,2,3)) as $data)
46
+			foreach (array('string', 123, true, false, null, array(), array(1, 2, 3)) as $data)
47 47
 			{
48 48
 				$location = md5(microtime(true).$label.serialize($data));
49
-				$get_before_set = $this->get(array($level,__CLASS__,$location));
49
+				$get_before_set = $this->get(array($level, __CLASS__, $location));
50 50
 				if (!is_null($get_before_set))
51 51
 				{
52 52
 					if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
53 53
 					++$failed;
54 54
 				}
55
-				if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true)
55
+				if (($set = $this->set(array($level, __CLASS__, $location), $data, 10)) !== true)
56 56
 				{
57 57
 					if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n";
58 58
 					++$failed;
59 59
 				}
60
-				$get_after_set = $this->get(array($level,__CLASS__,$location));
60
+				$get_after_set = $this->get(array($level, __CLASS__, $location));
61 61
 				if ($get_after_set !== $data)
62 62
 				{
63 63
 					if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
 				}
66 66
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
67 67
 				{
68
-					$mget_after_set = $this->mget(array($level,__CLASS__,array($location)));
68
+					$mget_after_set = $this->mget(array($level, __CLASS__, array($location)));
69 69
 					if ($mget_after_set[$location] !== $data)
70 70
 					{
71 71
 						if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
72 72
 						++$failed;
73 73
 					}
74 74
 				}
75
-				$add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data');
75
+				$add_after_set = $this->add(array($level, __CLASS__, $location), 'other-data');
76 76
 				if ($add_after_set !== false)
77 77
 				{
78 78
 					if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n";
79 79
 					++$failed;
80 80
 				}
81
-				if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true)
81
+				if (($delete = $this->delete(array($level, __CLASS__, $location))) !== true)
82 82
 				{
83 83
 					if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
84 84
 					++$failed;
85 85
 				}
86
-				$get_after_delete = $this->get(array($level,__CLASS__,$location));
86
+				$get_after_delete = $this->get(array($level, __CLASS__, $location));
87 87
 				if (!is_null($get_after_delete))
88 88
 				{
89 89
 					if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
94 94
 				{
95 95
 					$locations[$location] = $data;
96
-					$mget_after_delete = $this->mget(array($level,__CLASS__,array($location)));
96
+					$mget_after_delete = $this->mget(array($level, __CLASS__, array($location)));
97 97
 					if (isset($mget_after_delete[$location]))
98 98
 					{
99 99
 						if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				{
105 105
 					$locations[$location] = $data;
106 106
 				}
107
-				$add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10);
107
+				$add_after_delete = $this->add(array($level, __CLASS__, $location), $data, 10);
108 108
 				if ($add_after_delete !== true)
109 109
 				{
110 110
 					if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 				}
113 113
 				else
114 114
 				{
115
-					$get_after_add = $this->get(array($level,__CLASS__,$location));
115
+					$get_after_add = $this->get(array($level, __CLASS__, $location));
116 116
 					if ($get_after_add !== $data)
117 117
 					{
118 118
 						if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			// get all above in one request
124 124
 			$keys = array_keys($locations);
125
-			$keys_bogus = array_merge(array('not-set'),array_keys($locations),array('not-set-too'));
125
+			$keys_bogus = array_merge(array('not-set'), array_keys($locations), array('not-set-too'));
126 126
 			if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
127 127
 			{
128
-				$mget = $this->mget(array($level,__CLASS__,$keys));
129
-				$mget_bogus = $this->mget(array($level,__CLASS__,$keys_bogus));
128
+				$mget = $this->mget(array($level, __CLASS__, $keys));
129
+				$mget_bogus = $this->mget(array($level, __CLASS__, $keys_bogus));
130 130
 			/* Api\Cache::getCache() gives a different result, as it does NOT use $level direkt
131 131
 			}
132 132
 			else
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	function flush(array $keys)
162 162
 	{
163
-		unset($keys);	// required by function signature
163
+		unset($keys); // required by function signature
164 164
 		return false;
165 165
 	}
166 166
 }
Please login to merge, or discard this patch.
Braces   +52 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,18 +49,27 @@  discard block
 block discarded – undo
49 49
 				$get_before_set = $this->get(array($level,__CLASS__,$location));
50 50
 				if (!is_null($get_before_set))
51 51
 				{
52
-					if ($verbose) echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
52
+					if ($verbose)
53
+					{
54
+						echo "$label: get_before_set=".array2string($get_before_set)." != NULL\n";
55
+					}
53 56
 					++$failed;
54 57
 				}
55 58
 				if (($set = $this->set(array($level,__CLASS__,$location), $data, 10)) !== true)
56 59
 				{
57
-					if ($verbose) echo "$label: set returned ".array2string($set)." !== TRUE\n";
60
+					if ($verbose)
61
+					{
62
+						echo "$label: set returned ".array2string($set)." !== TRUE\n";
63
+					}
58 64
 					++$failed;
59 65
 				}
60 66
 				$get_after_set = $this->get(array($level,__CLASS__,$location));
61 67
 				if ($get_after_set !== $data)
62 68
 				{
63
-					if ($verbose) echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
69
+					if ($verbose)
70
+					{
71
+						echo "$label: get_after_set=".array2string($get_after_set)." !== ".array2string($data)."\n";
72
+					}
64 73
 					++$failed;
65 74
 				}
66 75
 				if (is_a($this, 'EGroupware\Api\Cache\ProviderMultiple'))
@@ -68,25 +77,37 @@  discard block
 block discarded – undo
68 77
 					$mget_after_set = $this->mget(array($level,__CLASS__,array($location)));
69 78
 					if ($mget_after_set[$location] !== $data)
70 79
 					{
71
-						if ($verbose) echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
80
+						if ($verbose)
81
+						{
82
+							echo "$label: mget_after_set['$location']=".array2string($mget_after_set[$location])." !== ".array2string($data)."\n";
83
+						}
72 84
 						++$failed;
73 85
 					}
74 86
 				}
75 87
 				$add_after_set = $this->add(array($level,__CLASS__,$location), 'other-data');
76 88
 				if ($add_after_set !== false)
77 89
 				{
78
-					if ($verbose) echo "$label: add_after_set=".array2string($add_after_set)."\n";
90
+					if ($verbose)
91
+					{
92
+						echo "$label: add_after_set=".array2string($add_after_set)."\n";
93
+					}
79 94
 					++$failed;
80 95
 				}
81 96
 				if (($delete = $this->delete(array($level,__CLASS__,$location))) !== true)
82 97
 				{
83
-					if ($verbose) echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
98
+					if ($verbose)
99
+					{
100
+						echo "$label: delete returned ".array2string($delete)." !== TRUE\n";
101
+					}
84 102
 					++$failed;
85 103
 				}
86 104
 				$get_after_delete = $this->get(array($level,__CLASS__,$location));
87 105
 				if (!is_null($get_after_delete))
88 106
 				{
89
-					if ($verbose) echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
107
+					if ($verbose)
108
+					{
109
+						echo "$label: get_after_delete=".array2string($get_after_delete)." != NULL\n";
110
+					}
90 111
 					++$failed;
91 112
 				}
92 113
 				// prepare for mget of everything
@@ -96,18 +117,27 @@  discard block
 block discarded – undo
96 117
 					$mget_after_delete = $this->mget(array($level,__CLASS__,array($location)));
97 118
 					if (isset($mget_after_delete[$location]))
98 119
 					{
99
-						if ($verbose) echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
120
+						if ($verbose)
121
+						{
122
+							echo "$label: mget_after_delete['$location']=".array2string($mget_after_delete[$location])." != NULL\n";
123
+						}
100 124
 						++$failed;
101 125
 					}
102 126
 				}
103
-				elseif (!is_null($data))	// emulation can NOT distinquish between null and not set
127
+				elseif (!is_null($data))
128
+				{
129
+					// emulation can NOT distinquish between null and not set
104 130
 				{
105 131
 					$locations[$location] = $data;
106 132
 				}
133
+				}
107 134
 				$add_after_delete = $this->add(array($level,__CLASS__,$location), $data, 10);
108 135
 				if ($add_after_delete !== true)
109 136
 				{
110
-					if ($verbose) echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
137
+					if ($verbose)
138
+					{
139
+						echo "$label: add_after_delete=".array2string($add_after_delete)."\n";
140
+					}
111 141
 					++$failed;
112 142
 				}
113 143
 				else
@@ -115,7 +145,10 @@  discard block
 block discarded – undo
115 145
 					$get_after_add = $this->get(array($level,__CLASS__,$location));
116 146
 					if ($get_after_add !== $data)
117 147
 					{
118
-						if ($verbose) echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
148
+						if ($verbose)
149
+						{
150
+							echo "$label: get_after_add=".array2string($get_after_add)." !== ".array2string($data)."\n";
151
+						}
119 152
 						++$failed;
120 153
 					}
121 154
 				}
@@ -136,12 +169,18 @@  discard block
 block discarded – undo
136 169
 			}*/
137 170
 				if ($mget !== $locations)
138 171
 				{
139
-					if ($verbose) echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
172
+					if ($verbose)
173
+					{
174
+						echo "$label: mget=\n".array2string($mget)." !==\n".array2string($locations)."\n";
175
+					}
140 176
 					++$failed;
141 177
 				}
142 178
 				if ($mget_bogus !== $locations)
143 179
 				{
144
-					if ($verbose) echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
180
+					if ($verbose)
181
+					{
182
+						echo "$label: mget(".array2string($keys_bogus).")=\n".array2string($mget_bogus)." !==\n".array2string($locations)."\n";
183
+					}
145 184
 					++$failed;
146 185
 				}
147 186
 			}
Please login to merge, or discard this patch.
api/src/Cache/Provider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int $expiration =0
39 39
 	 * @return boolean true on success, false on error, incl. key already exists in cache
40 40
 	 */
41
-	function add(array $keys,$data,$expiration=0);
41
+	function add(array $keys, $data, $expiration = 0);
42 42
 
43 43
 	/**
44 44
 	 * Stores some data in the cache
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param int $expiration =0
49 49
 	 * @return boolean true on success, false on error
50 50
 	 */
51
-	function set(array $keys,$data,$expiration=0);
51
+	function set(array $keys, $data, $expiration = 0);
52 52
 
53 53
 	/**
54 54
 	 * Get some data from the cache
Please login to merge, or discard this patch.
api/src/Cache/Apc.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	{
47 47
 		if (!function_exists('apc_fetch'))	// apc >= 3.0
48 48
 		{
49
-			throw new Exception (__METHOD__.'('.array2string($params).") No function apc_fetch()!");
49
+			throw new Exception(__METHOD__.'('.array2string($params).") No function apc_fetch()!");
50 50
 		}
51 51
 	}
52 52
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 			// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
67 67
 			if (is_numeric($size) && $size <= 1048576) $size .= 'M';
68 68
 
69
-			switch(strtoupper(substr($size, -1)))
69
+			switch (strtoupper(substr($size, -1)))
70 70
 			{
71 71
 				case 'G':
72 72
 					$size *= 1024;
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
 	 * @param int $expiration =0
93 93
 	 * @return boolean true on success, false on error, incl. key already exists in cache
94 94
 	 */
95
-	function add(array $keys,$data,$expiration=0)
95
+	function add(array $keys, $data, $expiration = 0)
96 96
 	{
97
-		return apc_add(self::key($keys),$data,$expiration);
97
+		return apc_add(self::key($keys), $data, $expiration);
98 98
 	}
99 99
 
100 100
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @param int $expiration =0
106 106
 	 * @return boolean true on success, false on error
107 107
 	 */
108
-	function set(array $keys,$data,$expiration=0)
108
+	function set(array $keys, $data, $expiration = 0)
109 109
 	{
110
-		return apc_store(self::key($keys),$data,$expiration);
110
+		return apc_store(self::key($keys), $data, $expiration);
111 111
 	}
112 112
 
113 113
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	function get(array $keys)
120 120
 	{
121 121
 		$success = null;
122
-		$data = apc_fetch($key=self::key($keys),$success);
122
+		$data = apc_fetch($key = self::key($keys), $success);
123 123
 
124 124
 		if (!$success)
125 125
 		{
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 		// APC >= 3.1.1, but also seems to be missing if apc is disabled eg. for cli
153 153
 		if (!class_exists('APCIterator'))
154 154
 		{
155
-			if (function_exists('apc_clear_cache')) apc_clear_cache ('user');
155
+			if (function_exists('apc_clear_cache')) apc_clear_cache('user');
156 156
 
157 157
 			return false;
158 158
 		}
159 159
 		//error_log(__METHOD__."(".array2string($keys).")");
160
-		foreach(new \APCIterator('user', $preg='/^'.preg_quote(self::key($keys).'/')) as $item)
160
+		foreach (new \APCIterator('user', $preg = '/^'.preg_quote(self::key($keys).'/')) as $item)
161 161
 		{
162 162
 			//error_log(__METHOD__."(".array2string($keys).") preg='$preg': calling apc_delete('$item[key]')");
163 163
 			apc_delete($item['key']);
@@ -173,6 +173,6 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	private static function key(array $keys)
175 175
 	{
176
-		return implode('::',$keys);
176
+		return implode('::', $keys);
177 177
 	}
178 178
 }
Please login to merge, or discard this patch.
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -44,10 +44,13 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	function __construct(array $params)
46 46
 	{
47
-		if (!function_exists('apc_fetch'))	// apc >= 3.0
47
+		if (!function_exists('apc_fetch'))
48
+		{
49
+			// apc >= 3.0
48 50
 		{
49 51
 			throw new Exception (__METHOD__.'('.array2string($params).") No function apc_fetch()!");
50 52
 		}
53
+		}
51 54
 	}
52 55
 
53 56
 	/**
@@ -64,7 +67,10 @@  discard block
 block discarded – undo
64 67
 		{
65 68
 			$size = ini_get('apc.shm_size');
66 69
 			// ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit
67
-			if (is_numeric($size) && $size <= 1048576) $size .= 'M';
70
+			if (is_numeric($size) && $size <= 1048576)
71
+			{
72
+				$size .= 'M';
73
+			}
68 74
 
69 75
 			switch(strtoupper(substr($size, -1)))
70 76
 			{
@@ -152,7 +158,10 @@  discard block
 block discarded – undo
152 158
 		// APC >= 3.1.1, but also seems to be missing if apc is disabled eg. for cli
153 159
 		if (!class_exists('APCIterator'))
154 160
 		{
155
-			if (function_exists('apc_clear_cache')) apc_clear_cache ('user');
161
+			if (function_exists('apc_clear_cache'))
162
+			{
163
+				apc_clear_cache ('user');
164
+			}
156 165
 
157 166
 			return false;
158 167
 		}
Please login to merge, or discard this patch.
api/src/Country.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	 * @param boolean $translated =true use translated name or english
365 365
 	 * @return string
366 366
 	 */
367
-	public static function get_full_name($code,$translated=true)
367
+	public static function get_full_name($code, $translated = true)
368 368
 	{
369 369
 		if ($translated)
370 370
 		{
@@ -383,36 +383,36 @@  discard block
 block discarded – undo
383 383
 	 */
384 384
 	public static function country_code($name)
385 385
 	{
386
-		if (!$name) return '';	// nothing to do
386
+		if (!$name) return ''; // nothing to do
387 387
 
388 388
 		if (strlen($name) == 2 && isset(self::$country_array[$name]))
389 389
 		{
390
-			return $name;	// $name is already a country-code
390
+			return $name; // $name is already a country-code
391 391
 		}
392 392
 
393
-		if (($code = array_search(strtoupper($name),self::$country_array)) !== false)
393
+		if (($code = array_search(strtoupper($name), self::$country_array)) !== false)
394 394
 		{
395 395
 			return $code;
396 396
 		}
397 397
 		if (!self::$countries_translated) self::_translate_countries();
398 398
 
399
-		if (($code = array_search(strtoupper($name),self::$countries_translated)) !== false ||
400
-			($code = array_search($name,self::$countries_translated)) !== false)
399
+		if (($code = array_search(strtoupper($name), self::$countries_translated)) !== false ||
400
+			($code = array_search($name, self::$countries_translated)) !== false)
401 401
 		{
402 402
 			return $code;
403 403
 		}
404 404
 		// search case-insensitive all translations for the english phrase of given country $name
405 405
 		// we do that to catch all possible cases of translations
406
-		static $en_names = array();	// we do some caching to minimize db-accesses
406
+		static $en_names = array(); // we do some caching to minimize db-accesses
407 407
 		if (isset($en_names[$name]))
408 408
 		{
409 409
 			$name = $en_names[$name];
410 410
 		}
411
-		elseif (($name_en = Translation::get_message_id($name,'common')))
411
+		elseif (($name_en = Translation::get_message_id($name, 'common')))
412 412
 		{
413 413
 			$name = $en_names[$name] = strtoupper($name_en);
414 414
 		}
415
-		if (($code = array_search(strtoupper($name),self::$country_array)) !== false)
415
+		if (($code = array_search(strtoupper($name), self::$country_array)) !== false)
416 416
 		{
417 417
 			return $code;
418 418
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 * @param boolean $translated =true use translated names or english
426 426
 	 * @return array with 2-letter code => name pairs
427 427
 	 */
428
-	public static function countries($translated=true)
428
+	public static function countries($translated = true)
429 429
 	{
430 430
 		if ($translated)
431 431
 		{
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 
448 448
 		self::$countries_translated = self::$country_array;
449 449
 		// try to translate them and sort alphabetic
450
-		foreach(self::$countries_translated as $k => $name)
450
+		foreach (self::$countries_translated as $k => $name)
451 451
 		{
452 452
 			self::$countries_translated[$k] = lang($name);
453 453
 		}
454 454
 
455
-		if(class_exists('Collator') && class_exists('Locale'))
455
+		if (class_exists('Collator') && class_exists('Locale'))
456 456
 		{
457 457
 			$col = new \Collator(Preferences::setlocale());
458 458
 			$col->asort(self::$countries_translated);
Please login to merge, or discard this patch.
Braces   +21 added lines, -5 removed lines patch added patch discarded remove patch
@@ -368,7 +368,10 @@  discard block
 block discarded – undo
368 368
 	{
369 369
 		if ($translated)
370 370
 		{
371
-			if (!self::$countries_translated) self::_translate_countries();
371
+			if (!self::$countries_translated)
372
+			{
373
+				self::_translate_countries();
374
+			}
372 375
 
373 376
 			return self::$countries_translated[strtoupper($code)];
374 377
 		}
@@ -383,7 +386,11 @@  discard block
 block discarded – undo
383 386
 	 */
384 387
 	public static function country_code($name)
385 388
 	{
386
-		if (!$name) return '';	// nothing to do
389
+		if (!$name)
390
+		{
391
+			return '';
392
+		}
393
+		// nothing to do
387 394
 
388 395
 		if (strlen($name) == 2 && isset(self::$country_array[$name]))
389 396
 		{
@@ -394,7 +401,10 @@  discard block
 block discarded – undo
394 401
 		{
395 402
 			return $code;
396 403
 		}
397
-		if (!self::$countries_translated) self::_translate_countries();
404
+		if (!self::$countries_translated)
405
+		{
406
+			self::_translate_countries();
407
+		}
398 408
 
399 409
 		if (($code = array_search(strtoupper($name),self::$countries_translated)) !== false ||
400 410
 			($code = array_search($name,self::$countries_translated)) !== false)
@@ -429,7 +439,10 @@  discard block
 block discarded – undo
429 439
 	{
430 440
 		if ($translated)
431 441
 		{
432
-			if (!self::$countries_translated) self::_translate_countries();
442
+			if (!self::$countries_translated)
443
+			{
444
+				self::_translate_countries();
445
+			}
433 446
 
434 447
 			return self::$countries_translated;
435 448
 		}
@@ -443,7 +456,10 @@  discard block
 block discarded – undo
443 456
 	 */
444 457
 	protected static function _translate_countries()
445 458
 	{
446
-		if (self::$countries_translated) return;
459
+		if (self::$countries_translated)
460
+		{
461
+			return;
462
+		}
447 463
 
448 464
 		self::$countries_translated = self::$country_array;
449 465
 		// try to translate them and sort alphabetic
Please login to merge, or discard this patch.
api/src/Auth/Fallbackmail2sql.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	/**
23 23
 	 * Constructor
24 24
 	 */
25
-	function __construct($primary='mail', $fallback='sql')
25
+	function __construct($primary = 'mail', $fallback = 'sql')
26 26
 	{
27 27
 		parent::__construct($primary, $fallback);
28 28
 	}
Please login to merge, or discard this patch.