Completed
Push — 16.1 ( 8e92ac...a067d8 )
by Nathan
29:45 queued 13:41
created
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/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.
api/src/Auth/Nis.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
27 27
 	 * @return boolean true if successful authenticated, false otherwise
28 28
 	 */
29
-	function authenticate($username, $passwd, $passwd_type='text')
29
+	function authenticate($username, $passwd, $passwd_type = 'text')
30 30
 	{
31
-		unset($passwd_type);	// not used but required by interface
31
+		unset($passwd_type); // not used but required by interface
32 32
 
33 33
 		$domain = yp_get_default_domain();
34
-		if(!empty($GLOBALS['egw_info']['server']['nis_domain']))
34
+		if (!empty($GLOBALS['egw_info']['server']['nis_domain']))
35 35
 		{
36 36
 			$domain = $GLOBALS['egw_info']['server']['nis_domain'];
37 37
 		}
38 38
 
39 39
 		$map = "passwd.byname";
40
-		if(!empty($GLOBALS['egw_info']['server']['nis_map']))
40
+		if (!empty($GLOBALS['egw_info']['server']['nis_map']))
41 41
 		{
42 42
 			$map = $GLOBALS['egw_info']['server']['nis_map'];
43 43
 		}
44
-		$entry = yp_match( $domain, $map, $username );
44
+		$entry = yp_match($domain, $map, $username);
45 45
 
46 46
 		/*
47 47
 		 * we assume that the map is structured in the usual
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	 * @param int $account_id =0 account id of user whose passwd should be changed
64 64
 	 * @return boolean true if password successful changed, false otherwise
65 65
 	 */
66
-	function change_password($old_passwd, $new_passwd, $account_id=0)
66
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
67 67
 	{
68
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
68
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
69 69
 
70 70
 		// can't change passwords unless server runs as root (bad idea)
71
-		return( False );
71
+		return(False);
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
api/src/Auth/Sqlssl.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
30 30
 	 * @return boolean true if successful authenticated, false otherwise
31 31
 	 */
32
-	function authenticate($username, $passwd, $passwd_type='text')
32
+	function authenticate($username, $passwd, $passwd_type = 'text')
33 33
 	{
34
-		unset($passwd_type);	// not used but required by interface
34
+		unset($passwd_type); // not used but required by interface
35 35
 
36 36
 		$local_debug = False;
37 37
 
38
-		if($local_debug)
38
+		if ($local_debug)
39 39
 		{
40 40
 			echo "<b>Debug SQL: uid - $username passwd - $passwd</b>";
41 41
 		}
42
-		if (!($row = $this->db->select($this->table,'account_lid,account_pwd',array(
42
+		if (!($row = $this->db->select($this->table, 'account_lid,account_pwd', array(
43 43
 			'account_lid' => $username,
44 44
 			'account_status' => 'A',
45 45
 			'account_type'   => 'u',
46
-		),__LINE__,__FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
46
+		), __LINE__, __FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
47 47
 		{
48 48
 			return false;
49 49
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		# Apache + mod_ssl provide the data in the environment
52 52
 		# Certificate (chain) verification occurs inside mod_ssl
53 53
 		# see http://www.modssl.org/docs/2.8/ssl_howto.html#ToC6
54
-		if(!isset($_SERVER['SSL_CLIENT_S_DN']))
54
+		if (!isset($_SERVER['SSL_CLIENT_S_DN']))
55 55
 		{
56 56
 			# if we're not doing SSL authentication, behave like auth_sql
57 57
 			return Api\Auth::compare_password($passwd, $row['account_pwd'], 'md5', strtolower($username));
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @param int $account_id =0 account id of user whose passwd should be changed
68 68
 	 * @return boolean true if password successful changed, false otherwise
69 69
 	 */
70
-	function change_password($old_passwd, $new_passwd, $account_id=0)
70
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
71 71
 	{
72
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
72
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
73 73
 
74 74
 		// deny password changes.
75 75
 		return False;
Please login to merge, or discard this patch.
api/src/Auth/Pam.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
31 31
 	 * @return boolean true if successful authenticated, false otherwise
32 32
 	 */
33
-	function authenticate($username, $passwd, $passwd_type='text')
33
+	function authenticate($username, $passwd, $passwd_type = 'text')
34 34
 	{
35
-		unset($passwd_type);	// not used but required by interface
35
+		unset($passwd_type); // not used but required by interface
36 36
 
37 37
 		if (pam_auth($username, get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd))
38 38
 		{
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 			if (!$GLOBALS['egw']->accounts->name2id($username) &&
41 41
 				function_exists('posix_getpwnam') && ($data = posix_getpwnam($username)))
42 42
 			{
43
-				list($fullname) = explode(',',$data['gecos']);
44
-				$parts = explode(' ',$fullname);
43
+				list($fullname) = explode(',', $data['gecos']);
44
+				$parts = explode(' ', $fullname);
45 45
 				if (count($parts) > 1)
46 46
 				{
47 47
 					$lastname = array_pop($parts);
48
-					$firstname = implode(' ',$parts);
48
+					$firstname = implode(' ', $parts);
49 49
 					$email = Api\Accounts::email($firstname, $lastname, $username);
50 50
 
51 51
 					$GLOBALS['auto_create_acct'] = array(
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @param int $account_id =0 account id of user whose passwd should be changed
70 70
 	 * @return boolean true if password successful changed, false otherwise
71 71
 	 */
72
-	function change_password($old_passwd, $new_passwd, $account_id=0)
72
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
73 73
 	{
74
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
74
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
75 75
 
76 76
 		// deny password changes.
77 77
 		return False;
Please login to merge, or discard this patch.