Completed
Push — release-2.1 ( 29513c...1198c1 )
by Colin
08:53
created
Sources/Subs-Membergroups.php 1 patch
Braces   +149 added lines, -112 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Delete one of more membergroups.
@@ -31,15 +32,16 @@  discard block
 block discarded – undo
31 32
 	global $smcFunc, $modSettings, $txt;
32 33
 
33 34
 	// Make sure it's an array.
34
-	if (!is_array($groups))
35
-		$groups = array((int) $groups);
36
-	else
35
+	if (!is_array($groups)) {
36
+			$groups = array((int) $groups);
37
+	} else
37 38
 	{
38 39
 		$groups = array_unique($groups);
39 40
 
40 41
 		// Make sure all groups are integer.
41
-		foreach ($groups as $key => $value)
42
-			$groups[$key] = (int) $value;
42
+		foreach ($groups as $key => $value) {
43
+					$groups[$key] = (int) $value;
44
+		}
43 45
 	}
44 46
 
45 47
 	// Some groups are protected (guests, administrators, moderators, newbies).
@@ -56,15 +58,17 @@  discard block
 block discarded – undo
56 58
 				'is_protected' => 1,
57 59
 			)
58 60
 		);
59
-		while ($row = $smcFunc['db_fetch_assoc']($request))
60
-			$protected_groups[] = $row['id_group'];
61
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
62
+					$protected_groups[] = $row['id_group'];
63
+		}
61 64
 		$smcFunc['db_free_result']($request);
62 65
 	}
63 66
 
64 67
 	// Make sure they don't delete protected groups!
65 68
 	$groups = array_diff($groups, array_unique($protected_groups));
66
-	if (empty($groups))
67
-		return 'no_group_found';
69
+	if (empty($groups)) {
70
+			return 'no_group_found';
71
+	}
68 72
 
69 73
 	// Make sure they don't try to delete a group attached to a paid subscription.
70 74
 	$subscriptions = array();
@@ -74,13 +78,14 @@  discard block
 block discarded – undo
74 78
 		ORDER BY name');
75 79
 	while ($row = $smcFunc['db_fetch_assoc']($request))
76 80
 	{
77
-		if (in_array($row['id_group'], $groups))
78
-			$subscriptions[] = $row['name'];
79
-		else
81
+		if (in_array($row['id_group'], $groups)) {
82
+					$subscriptions[] = $row['name'];
83
+		} else
80 84
 		{
81 85
 			$add_groups = explode(',', $row['add_groups']);
82
-			if (count(array_intersect($add_groups, $groups)) != 0)
83
-				$subscriptions[] = $row['name'];
86
+			if (count(array_intersect($add_groups, $groups)) != 0) {
87
+							$subscriptions[] = $row['name'];
88
+			}
84 89
 		}
85 90
 	}
86 91
 	$smcFunc['db_free_result']($request);
@@ -101,8 +106,9 @@  discard block
 block discarded – undo
101 106
 			'group_list' => $groups,
102 107
 		)
103 108
 	);
104
-	while ($row = $smcFunc['db_fetch_assoc']($request))
105
-		logAction('delete_group', array('group' => $row['group_name']), 'admin');
109
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
110
+			logAction('delete_group', array('group' => $row['group_name']), 'admin');
111
+	}
106 112
 	$smcFunc['db_free_result']($request);
107 113
 
108 114
 	call_integration_hook('integrate_delete_membergroups', array($groups));
@@ -187,12 +193,14 @@  discard block
 block discarded – undo
187 193
 		)
188 194
 	);
189 195
 	$updates = array();
190
-	while ($row = $smcFunc['db_fetch_assoc']($request))
191
-		$updates[$row['additional_groups']][] = $row['id_member'];
196
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
197
+			$updates[$row['additional_groups']][] = $row['id_member'];
198
+	}
192 199
 	$smcFunc['db_free_result']($request);
193 200
 
194
-	foreach ($updates as $additional_groups => $memberArray)
195
-		updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups))));
201
+	foreach ($updates as $additional_groups => $memberArray) {
202
+			updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups))));
203
+	}
196 204
 
197 205
 	// No boards can provide access to these membergroups anymore.
198 206
 	$request = $smcFunc['db_query']('', '
@@ -204,12 +212,13 @@  discard block
 block discarded – undo
204 212
 		)
205 213
 	);
206 214
 	$updates = array();
207
-	while ($row = $smcFunc['db_fetch_assoc']($request))
208
-		$updates[$row['member_groups']][] = $row['id_board'];
215
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
216
+			$updates[$row['member_groups']][] = $row['id_board'];
217
+	}
209 218
 	$smcFunc['db_free_result']($request);
210 219
 
211
-	foreach ($updates as $member_groups => $boardArray)
212
-		$smcFunc['db_query']('', '
220
+	foreach ($updates as $member_groups => $boardArray) {
221
+			$smcFunc['db_query']('', '
213 222
 			UPDATE {db_prefix}boards
214 223
 			SET member_groups = {string:member_groups}
215 224
 			WHERE id_board IN ({array_int:board_lists})',
@@ -218,6 +227,7 @@  discard block
 block discarded – undo
218 227
 				'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)),
219 228
 			)
220 229
 		);
230
+	}
221 231
 
222 232
 	// Recalculate the post groups, as they likely changed.
223 233
 	updateStats('postgroups');
@@ -225,8 +235,9 @@  discard block
 block discarded – undo
225 235
 	// Make a note of the fact that the cache may be wrong.
226 236
 	$settings_update = array('settings_updated' => time());
227 237
 	// Have we deleted the spider group?
228
-	if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups))
229
-		$settings_update['spider_group'] = 0;
238
+	if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) {
239
+			$settings_update['spider_group'] = 0;
240
+	}
230 241
 
231 242
 	updateSettings($settings_update);
232 243
 
@@ -250,22 +261,24 @@  discard block
 block discarded – undo
250 261
 	global $smcFunc, $modSettings, $sourcedir;
251 262
 
252 263
 	// You're getting nowhere without this permission, unless of course you are the group's moderator.
253
-	if (!$permissionCheckDone)
254
-		isAllowedTo('manage_membergroups');
264
+	if (!$permissionCheckDone) {
265
+			isAllowedTo('manage_membergroups');
266
+	}
255 267
 
256 268
 	// Assume something will happen.
257 269
 	updateSettings(array('settings_updated' => time()));
258 270
 
259 271
 	// Cleaning the input.
260
-	if (!is_array($members))
261
-		$members = array((int) $members);
262
-	else
272
+	if (!is_array($members)) {
273
+			$members = array((int) $members);
274
+	} else
263 275
 	{
264 276
 		$members = array_unique($members);
265 277
 
266 278
 		// Cast the members to integer.
267
-		foreach ($members as $key => $value)
268
-			$members[$key] = (int) $value;
279
+		foreach ($members as $key => $value) {
280
+					$members[$key] = (int) $value;
281
+		}
269 282
 	}
270 283
 
271 284
 	// Before we get started, let's check we won't leave the admin group empty!
@@ -277,14 +290,15 @@  discard block
 block discarded – undo
277 290
 		// Remove any admins if there are too many.
278 291
 		$non_changing_admins = array_diff(array_keys($admins), $members);
279 292
 
280
-		if (empty($non_changing_admins))
281
-			$members = array_diff($members, array_keys($admins));
293
+		if (empty($non_changing_admins)) {
294
+					$members = array_diff($members, array_keys($admins));
295
+		}
282 296
 	}
283 297
 
284 298
 	// Just in case.
285
-	if (empty($members))
286
-		return false;
287
-	elseif ($groups === null)
299
+	if (empty($members)) {
300
+			return false;
301
+	} elseif ($groups === null)
288 302
 	{
289 303
 		// Wanna remove all groups from these members? That's easy.
290 304
 		$smcFunc['db_query']('', '
@@ -306,20 +320,21 @@  discard block
 block discarded – undo
306 320
 		updateStats('postgroups', $members);
307 321
 
308 322
 		// Log what just happened.
309
-		foreach ($members as $member)
310
-			logAction('removed_all_groups', array('member' => $member), 'admin');
323
+		foreach ($members as $member) {
324
+					logAction('removed_all_groups', array('member' => $member), 'admin');
325
+		}
311 326
 
312 327
 		return true;
313
-	}
314
-	elseif (!is_array($groups))
315
-		$groups = array((int) $groups);
316
-	else
328
+	} elseif (!is_array($groups)) {
329
+			$groups = array((int) $groups);
330
+	} else
317 331
 	{
318 332
 		$groups = array_unique($groups);
319 333
 
320 334
 		// Make sure all groups are integer.
321
-		foreach ($groups as $key => $value)
322
-			$groups[$key] = (int) $value;
335
+		foreach ($groups as $key => $value) {
336
+					$groups[$key] = (int) $value;
337
+		}
323 338
 	}
324 339
 
325 340
 	// Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want.
@@ -335,10 +350,11 @@  discard block
 block discarded – undo
335 350
 	$group_names = array();
336 351
 	while ($row = $smcFunc['db_fetch_assoc']($request))
337 352
 	{
338
-		if ($row['min_posts'] != -1)
339
-			$implicitGroups[] = $row['id_group'];
340
-		else
341
-			$group_names[$row['id_group']] = $row['group_name'];
353
+		if ($row['min_posts'] != -1) {
354
+					$implicitGroups[] = $row['id_group'];
355
+		} else {
356
+					$group_names[$row['id_group']] = $row['group_name'];
357
+		}
342 358
 	}
343 359
 	$smcFunc['db_free_result']($request);
344 360
 
@@ -357,8 +373,9 @@  discard block
 block discarded – undo
357 373
 			)
358 374
 		);
359 375
 		$protected_groups = array(1);
360
-		while ($row = $smcFunc['db_fetch_assoc']($request))
361
-			$protected_groups[] = $row['id_group'];
376
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
377
+					$protected_groups[] = $row['id_group'];
378
+		}
362 379
 		$smcFunc['db_free_result']($request);
363 380
 
364 381
 		// If you're not an admin yourself, you can't touch protected groups!
@@ -366,8 +383,9 @@  discard block
 block discarded – undo
366 383
 	}
367 384
 
368 385
 	// Only continue if there are still groups and members left.
369
-	if (empty($groups) || empty($members))
370
-		return false;
386
+	if (empty($groups) || empty($members)) {
387
+			return false;
388
+	}
371 389
 
372 390
 	// First, reset those who have this as their primary group - this is the easy one.
373 391
 	$log_inserts = array();
@@ -381,8 +399,9 @@  discard block
 block discarded – undo
381 399
 			'member_list' => $members,
382 400
 		)
383 401
 	);
384
-	while ($row = $smcFunc['db_fetch_assoc']($request))
385
-		$log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']);
402
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
403
+			$log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']);
404
+	}
386 405
 	$smcFunc['db_free_result']($request);
387 406
 
388 407
 	$smcFunc['db_query']('', '
@@ -414,16 +433,17 @@  discard block
 block discarded – undo
414 433
 	while ($row = $smcFunc['db_fetch_assoc']($request))
415 434
 	{
416 435
 		// What log entries must we make for this one, eh?
417
-		foreach (explode(',', $row['additional_groups']) as $group)
418
-			if (in_array($group, $groups))
436
+		foreach (explode(',', $row['additional_groups']) as $group) {
437
+					if (in_array($group, $groups))
419 438
 				$log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']);
439
+		}
420 440
 
421 441
 		$updates[$row['additional_groups']][] = $row['id_member'];
422 442
 	}
423 443
 	$smcFunc['db_free_result']($request);
424 444
 
425
-	foreach ($updates as $additional_groups => $memberArray)
426
-		$smcFunc['db_query']('', '
445
+	foreach ($updates as $additional_groups => $memberArray) {
446
+			$smcFunc['db_query']('', '
427 447
 			UPDATE {db_prefix}members
428 448
 			SET additional_groups = {string:additional_groups}
429 449
 			WHERE id_member IN ({array_int:member_list})',
@@ -432,6 +452,7 @@  discard block
 block discarded – undo
432 452
 				'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)),
433 453
 			)
434 454
 		);
455
+	}
435 456
 
436 457
 	// Their post groups may have changed now...
437 458
 	updateStats('postgroups', $members);
@@ -440,8 +461,9 @@  discard block
 block discarded – undo
440 461
 	if (!empty($log_inserts) && !empty($modSettings['modlog_enabled']))
441 462
 	{
442 463
 		require_once($sourcedir . '/Logging.php');
443
-		foreach ($log_inserts as $extra)
444
-			logAction('removed_from_group', $extra, 'admin');
464
+		foreach ($log_inserts as $extra) {
465
+					logAction('removed_from_group', $extra, 'admin');
466
+		}
445 467
 	}
446 468
 
447 469
 	// Mission successful.
@@ -477,21 +499,23 @@  discard block
 block discarded – undo
477 499
 	global $smcFunc, $sourcedir;
478 500
 
479 501
 	// Show your licence, but only if it hasn't been done yet.
480
-	if (!$permissionCheckDone)
481
-		isAllowedTo('manage_membergroups');
502
+	if (!$permissionCheckDone) {
503
+			isAllowedTo('manage_membergroups');
504
+	}
482 505
 
483 506
 	// Make sure we don't keep old stuff cached.
484 507
 	updateSettings(array('settings_updated' => time()));
485 508
 
486
-	if (!is_array($members))
487
-		$members = array((int) $members);
488
-	else
509
+	if (!is_array($members)) {
510
+			$members = array((int) $members);
511
+	} else
489 512
 	{
490 513
 		$members = array_unique($members);
491 514
 
492 515
 		// Make sure all members are integer.
493
-		foreach ($members as $key => $value)
494
-			$members[$key] = (int) $value;
516
+		foreach ($members as $key => $value) {
517
+					$members[$key] = (int) $value;
518
+		}
495 519
 	}
496 520
 	$group = (int) $group;
497 521
 
@@ -508,20 +532,23 @@  discard block
 block discarded – undo
508 532
 	$group_names = array();
509 533
 	while ($row = $smcFunc['db_fetch_assoc']($request))
510 534
 	{
511
-		if ($row['min_posts'] != -1)
512
-			$implicitGroups[] = $row['id_group'];
513
-		else
514
-			$group_names[$row['id_group']] = $row['group_name'];
535
+		if ($row['min_posts'] != -1) {
536
+					$implicitGroups[] = $row['id_group'];
537
+		} else {
538
+					$group_names[$row['id_group']] = $row['group_name'];
539
+		}
515 540
 	}
516 541
 	$smcFunc['db_free_result']($request);
517 542
 
518 543
 	// Sorry, you can't join an implicit group.
519
-	if (in_array($group, $implicitGroups) || empty($members))
520
-		return false;
544
+	if (in_array($group, $implicitGroups) || empty($members)) {
545
+			return false;
546
+	}
521 547
 
522 548
 	// Only admins can add admins...
523
-	if (!allowedTo('admin_forum') && $group == 1)
524
-		return false;
549
+	if (!allowedTo('admin_forum') && $group == 1) {
550
+			return false;
551
+	}
525 552
 	// ... and assign protected groups!
526 553
 	elseif (!allowedTo('admin_forum') && !$ignoreProtected)
527 554
 	{
@@ -539,13 +566,14 @@  discard block
 block discarded – undo
539 566
 		$smcFunc['db_free_result']($request);
540 567
 
541 568
 		// Is it protected?
542
-		if ($is_protected == 1)
543
-			return false;
569
+		if ($is_protected == 1) {
570
+					return false;
571
+		}
544 572
 	}
545 573
 
546 574
 	// Do the actual updates.
547
-	if ($type == 'only_additional')
548
-		$smcFunc['db_query']('', '
575
+	if ($type == 'only_additional') {
576
+			$smcFunc['db_query']('', '
549 577
 			UPDATE {db_prefix}members
550 578
 			SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END
551 579
 			WHERE id_member IN ({array_int:member_list})
@@ -559,8 +587,8 @@  discard block
 block discarded – undo
559 587
 				'blank_string' => '',
560 588
 			)
561 589
 		);
562
-	elseif ($type == 'only_primary' || $type == 'force_primary')
563
-		$smcFunc['db_query']('', '
590
+	} elseif ($type == 'only_primary' || $type == 'force_primary') {
591
+			$smcFunc['db_query']('', '
564 592
 			UPDATE {db_prefix}members
565 593
 			SET id_group = {int:id_group}
566 594
 			WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : '
@@ -572,8 +600,8 @@  discard block
 block discarded – undo
572 600
 				'regular_group' => 0,
573 601
 			)
574 602
 		);
575
-	elseif ($type == 'auto')
576
-		$smcFunc['db_query']('', '
603
+	} elseif ($type == 'auto') {
604
+			$smcFunc['db_query']('', '
577 605
 			UPDATE {db_prefix}members
578 606
 			SET
579 607
 				id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END,
@@ -592,9 +620,11 @@  discard block
 block discarded – undo
592 620
 				'id_group_string_extend' => ',' . $group,
593 621
 			)
594 622
 		);
623
+	}
595 624
 	// Ack!!?  What happened?
596
-	else
597
-		trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING);
625
+	else {
626
+			trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING);
627
+	}
598 628
 
599 629
 	call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names));
600 630
 
@@ -603,8 +633,9 @@  discard block
 block discarded – undo
603 633
 
604 634
 	// Log the data.
605 635
 	require_once($sourcedir . '/Logging.php');
606
-	foreach ($members as $member)
607
-		logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin');
636
+	foreach ($members as $member) {
637
+			logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin');
638
+	}
608 639
 
609 640
 	return true;
610 641
 }
@@ -632,8 +663,9 @@  discard block
 block discarded – undo
632 663
 		)
633 664
 	);
634 665
 	$members = array();
635
-	while ($row = $smcFunc['db_fetch_assoc']($request))
636
-		$members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
666
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
667
+			$members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
668
+	}
637 669
 	$smcFunc['db_free_result']($request);
638 670
 
639 671
 	// If there are more than $limit members, add a 'more' link.
@@ -641,10 +673,10 @@  discard block
 block discarded – undo
641 673
 	{
642 674
 		array_pop($members);
643 675
 		return true;
676
+	} else {
677
+			return false;
678
+	}
644 679
 	}
645
-	else
646
-		return false;
647
-}
648 680
 
649 681
 /**
650 682
  * Retrieve a list of (visible) membergroups used by the cache.
@@ -669,8 +701,9 @@  discard block
 block discarded – undo
669 701
 		)
670 702
 	);
671 703
 	$groupCache = array();
672
-	while ($row = $smcFunc['db_fetch_assoc']($request))
673
-		$groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>';
704
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
705
+			$groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>';
706
+	}
674 707
 	$smcFunc['db_free_result']($request);
675 708
 
676 709
 	return array(
@@ -716,8 +749,9 @@  discard block
 block discarded – undo
716 749
 	while ($row = $smcFunc['db_fetch_assoc']($request))
717 750
 	{
718 751
 		// We only list the groups they can see.
719
-		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups'))
720
-			continue;
752
+		if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) {
753
+					continue;
754
+		}
721 755
 
722 756
 		$row['icons'] = explode('#', $row['icons']);
723 757
 
@@ -752,12 +786,11 @@  discard block
 block discarded – undo
752 786
 					'group_list' => $group_ids,
753 787
 				)
754 788
 			);
755
-			while ($row = $smcFunc['db_fetch_assoc']($query))
756
-				$groups[$row['id_group']]['num_members'] += $row['num_members'];
789
+			while ($row = $smcFunc['db_fetch_assoc']($query)) {
790
+							$groups[$row['id_group']]['num_members'] += $row['num_members'];
791
+			}
757 792
 			$smcFunc['db_free_result']($query);
758
-		}
759
-
760
-		else
793
+		} else
761 794
 		{
762 795
 			$query = $smcFunc['db_query']('', '
763 796
 				SELECT id_group, COUNT(*) AS num_members
@@ -768,8 +801,9 @@  discard block
 block discarded – undo
768 801
 					'group_list' => $group_ids,
769 802
 				)
770 803
 			);
771
-			while ($row = $smcFunc['db_fetch_assoc']($query))
772
-				$groups[$row['id_group']]['num_members'] += $row['num_members'];
804
+			while ($row = $smcFunc['db_fetch_assoc']($query)) {
805
+							$groups[$row['id_group']]['num_members'] += $row['num_members'];
806
+			}
773 807
 			$smcFunc['db_free_result']($query);
774 808
 
775 809
 			// Only do additional groups if we can moderate...
@@ -788,8 +822,9 @@  discard block
 block discarded – undo
788 822
 						'blank_string' => '',
789 823
 					)
790 824
 				);
791
-				while ($row = $smcFunc['db_fetch_assoc']($query))
792
-					$groups[$row['id_group']]['num_members'] += $row['num_members'];
825
+				while ($row = $smcFunc['db_fetch_assoc']($query)) {
826
+									$groups[$row['id_group']]['num_members'] += $row['num_members'];
827
+				}
793 828
 				$smcFunc['db_free_result']($query);
794 829
 			}
795 830
 		}
@@ -803,8 +838,9 @@  discard block
 block discarded – undo
803 838
 				'group_list' => $group_ids,
804 839
 			)
805 840
 		);
806
-		while ($row = $smcFunc['db_fetch_assoc']($query))
807
-			$groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
841
+		while ($row = $smcFunc['db_fetch_assoc']($query)) {
842
+					$groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
843
+		}
808 844
 		$smcFunc['db_free_result']($query);
809 845
 	}
810 846
 
@@ -813,8 +849,9 @@  discard block
 block discarded – undo
813 849
 	{
814 850
 		$sort_ascending = strpos($sort, 'DESC') === false;
815 851
 
816
-		foreach ($groups as $group)
817
-			$sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1;
852
+		foreach ($groups as $group) {
853
+					$sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1;
854
+		}
818 855
 
819 856
 		array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups);
820 857
 	}
Please login to merge, or discard this patch.
Sources/Logging.php 1 patch
Braces   +154 added lines, -111 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Truncate the GET array to a specified length
@@ -26,24 +27,28 @@  discard block
 block discarded – undo
26 27
 function truncateArray($arr, $max_length=1900)
27 28
 {
28 29
 	$curr_length = 0;
29
-	foreach ($arr as $key => $value)
30
-		if (is_array($value))
30
+	foreach ($arr as $key => $value) {
31
+			if (is_array($value))
31 32
 			foreach ($value as $key2 => $value2)
32 33
 				$curr_length += strlen ($value2);
33
-		else
34
-			$curr_length += strlen ($value);
35
-	if ($curr_length <= $max_length)
36
-		return $arr;
37
-	else
34
+	}
35
+		else {
36
+					$curr_length += strlen ($value);
37
+		}
38
+	if ($curr_length <= $max_length) {
39
+			return $arr;
40
+	} else
38 41
 	{
39 42
 		// Truncate each element's value to a reasonable length
40 43
 		$param_max = floor($max_length/count($arr));
41
-		foreach ($arr as $key => &$value)
42
-			if (is_array($value))
44
+		foreach ($arr as $key => &$value) {
45
+					if (is_array($value))
43 46
 				foreach ($value as $key2 => &$value2)
44 47
 					$value2 = substr($value2, 0, $param_max - strlen($key) - 5);
45
-			else
46
-				$value = substr($value, 0, $param_max - strlen($key) - 5);
48
+		}
49
+			else {
50
+							$value = substr($value, 0, $param_max - strlen($key) - 5);
51
+			}
47 52
 		return $arr;
48 53
 	}
49 54
 }
@@ -65,8 +70,9 @@  discard block
 block discarded – undo
65 70
 		// Don't update for every page - this isn't wholly accurate but who cares.
66 71
 		if ($topic)
67 72
 		{
68
-			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic)
69
-				$force = false;
73
+			if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) {
74
+							$force = false;
75
+			}
70 76
 			$_SESSION['last_topic_id'] = $topic;
71 77
 		}
72 78
 	}
@@ -79,22 +85,24 @@  discard block
 block discarded – undo
79 85
 	}
80 86
 
81 87
 	// Don't mark them as online more than every so often.
82
-	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force)
83
-		return;
88
+	if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) {
89
+			return;
90
+	}
84 91
 
85 92
 	if (!empty($modSettings['who_enabled']))
86 93
 	{
87 94
 		$encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
88 95
 
89 96
 		// In the case of a dlattach action, session_var may not be set.
90
-		if (!isset($context['session_var']))
91
-			$context['session_var'] = $_SESSION['session_var'];
97
+		if (!isset($context['session_var'])) {
98
+					$context['session_var'] = $_SESSION['session_var'];
99
+		}
92 100
 
93 101
 		unset($encoded_get['sesc'], $encoded_get[$context['session_var']]);
94 102
 		$encoded_get = $smcFunc['json_encode']($encoded_get);
103
+	} else {
104
+			$encoded_get = '';
95 105
 	}
96
-	else
97
-		$encoded_get = '';
98 106
 
99 107
 	// Guests use 0, members use their session ID.
100 108
 	$session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id();
@@ -134,17 +142,18 @@  discard block
 block discarded – undo
134 142
 		);
135 143
 
136 144
 		// Guess it got deleted.
137
-		if ($smcFunc['db_affected_rows']() == 0)
145
+		if ($smcFunc['db_affected_rows']() == 0) {
146
+					$_SESSION['log_time'] = 0;
147
+		}
148
+	} else {
138 149
 			$_SESSION['log_time'] = 0;
139 150
 	}
140
-	else
141
-		$_SESSION['log_time'] = 0;
142 151
 
143 152
 	// Otherwise, we have to delete and insert.
144 153
 	if (empty($_SESSION['log_time']))
145 154
 	{
146
-		if ($do_delete || !empty($user_info['id']))
147
-			$smcFunc['db_query']('', '
155
+		if ($do_delete || !empty($user_info['id'])) {
156
+					$smcFunc['db_query']('', '
148 157
 				DELETE FROM {db_prefix}log_online
149 158
 				WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'),
150 159
 				array(
@@ -152,6 +161,7 @@  discard block
 block discarded – undo
152 161
 					'log_time' => time() - $modSettings['lastActive'] * 60,
153 162
 				)
154 163
 			);
164
+		}
155 165
 
156 166
 		$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
157 167
 			'{db_prefix}log_online',
@@ -165,21 +175,24 @@  discard block
 block discarded – undo
165 175
 	$_SESSION['log_time'] = time();
166 176
 
167 177
 	// Well, they are online now.
168
-	if (empty($_SESSION['timeOnlineUpdated']))
169
-		$_SESSION['timeOnlineUpdated'] = time();
178
+	if (empty($_SESSION['timeOnlineUpdated'])) {
179
+			$_SESSION['timeOnlineUpdated'] = time();
180
+	}
170 181
 
171 182
 	// Set their login time, if not already done within the last minute.
172 183
 	if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa'))))
173 184
 	{
174 185
 		// Don't count longer than 15 minutes.
175
-		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15)
176
-			$_SESSION['timeOnlineUpdated'] = time();
186
+		if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) {
187
+					$_SESSION['timeOnlineUpdated'] = time();
188
+		}
177 189
 
178 190
 		$user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
179 191
 		updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in']));
180 192
 
181
-		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
182
-			cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
193
+		if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
194
+					cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60);
195
+		}
183 196
 
184 197
 		$user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated'];
185 198
 		$_SESSION['timeOnlineUpdated'] = time();
@@ -216,8 +229,7 @@  discard block
 block discarded – undo
216 229
 			// Oops. maybe we have no more disk space left, or some other troubles, troubles...
217 230
 			// Copy the file back and run for your life!
218 231
 			@copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php');
219
-		}
220
-		else
232
+		} else
221 233
 		{
222 234
 			@touch($boarddir . '/' . 'Settings.php');
223 235
 			return true;
@@ -237,22 +249,27 @@  discard block
 block discarded – undo
237 249
 	global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt;
238 250
 
239 251
 	// Add to Settings.php if you want to show the debugging information.
240
-	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery'))
241
-		return;
252
+	if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) {
253
+			return;
254
+	}
242 255
 
243
-	if (empty($_SESSION['view_queries']))
244
-		$_SESSION['view_queries'] = 0;
245
-	if (empty($context['debug']['language_files']))
246
-		$context['debug']['language_files'] = array();
247
-	if (empty($context['debug']['sheets']))
248
-		$context['debug']['sheets'] = array();
256
+	if (empty($_SESSION['view_queries'])) {
257
+			$_SESSION['view_queries'] = 0;
258
+	}
259
+	if (empty($context['debug']['language_files'])) {
260
+			$context['debug']['language_files'] = array();
261
+	}
262
+	if (empty($context['debug']['sheets'])) {
263
+			$context['debug']['sheets'] = array();
264
+	}
249 265
 
250 266
 	$files = get_included_files();
251 267
 	$total_size = 0;
252 268
 	for ($i = 0, $n = count($files); $i < $n; $i++)
253 269
 	{
254
-		if (file_exists($files[$i]))
255
-			$total_size += filesize($files[$i]);
270
+		if (file_exists($files[$i])) {
271
+					$total_size += filesize($files[$i]);
272
+		}
256 273
 		$files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)'));
257 274
 	}
258 275
 
@@ -261,8 +278,9 @@  discard block
 block discarded – undo
261 278
 	{
262 279
 		foreach ($db_cache as $q => $query_data)
263 280
 		{
264
-			if (!empty($query_data['w']))
265
-				$warnings += count($query_data['w']);
281
+			if (!empty($query_data['w'])) {
282
+							$warnings += count($query_data['w']);
283
+			}
266 284
 		}
267 285
 
268 286
 		$_SESSION['debug'] = &$db_cache;
@@ -283,12 +301,14 @@  discard block
 block discarded – undo
283 301
 	',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),'
284 302
 	', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>';
285 303
 
286
-	if (function_exists('memory_get_peak_usage'))
287
-		echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
304
+	if (function_exists('memory_get_peak_usage')) {
305
+			echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>';
306
+	}
288 307
 
289 308
 	// What tokens are active?
290
-	if (isset($_SESSION['token']))
291
-		echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
309
+	if (isset($_SESSION['token'])) {
310
+			echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>';
311
+	}
292 312
 
293 313
 	if (!empty($modSettings['cache_enable']) && !empty($cache_hits))
294 314
 	{
@@ -302,10 +322,12 @@  discard block
 block discarded – undo
302 322
 			$total_t += $cache_hit['t'];
303 323
 			$total_s += $cache_hit['s'];
304 324
 		}
305
-		if (!isset($cache_misses))
306
-			$cache_misses = array();
307
-		foreach ($cache_misses as $missed)
308
-			$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
325
+		if (!isset($cache_misses)) {
326
+					$cache_misses = array();
327
+		}
328
+		foreach ($cache_misses as $missed) {
329
+					$missed_entries[] = $missed['d'] . ' ' . $missed['k'];
330
+		}
309 331
 
310 332
 		echo '
311 333
 	', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br>
@@ -316,38 +338,44 @@  discard block
 block discarded – undo
316 338
 	<a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br>
317 339
 	<br>';
318 340
 
319
-	if ($_SESSION['view_queries'] == 1 && !empty($db_cache))
320
-		foreach ($db_cache as $q => $query_data)
341
+	if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) {
342
+			foreach ($db_cache as $q => $query_data)
321 343
 		{
322 344
 			$is_select = strpos(trim($query_data['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($query_data['q'])) != 0;
345
+	}
323 346
 			// Temporary tables created in earlier queries are not explainable.
324 347
 			if ($is_select)
325 348
 			{
326
-				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp)
327
-					if (strpos(trim($query_data['q']), $tmp) !== false)
349
+				foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) {
350
+									if (strpos(trim($query_data['q']), $tmp) !== false)
328 351
 					{
329 352
 						$is_select = false;
353
+				}
330 354
 						break;
331 355
 					}
332 356
 			}
333 357
 			// But actual creation of the temporary tables are.
334
-			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0)
335
-				$is_select = true;
358
+			elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) {
359
+							$is_select = true;
360
+			}
336 361
 
337 362
 			// Make the filenames look a bit better.
338
-			if (isset($query_data['f']))
339
-				$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
363
+			if (isset($query_data['f'])) {
364
+							$query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']);
365
+			}
340 366
 
341 367
 			echo '
342 368
 	<strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", '&nbsp;&nbsp;&nbsp;', $smcFunc['htmlspecialchars'](ltrim($query_data['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br>
343 369
 	&nbsp;&nbsp;&nbsp;';
344
-			if (!empty($query_data['f']) && !empty($query_data['l']))
345
-				echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
370
+			if (!empty($query_data['f']) && !empty($query_data['l'])) {
371
+							echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']);
372
+			}
346 373
 
347
-			if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at']))
348
-				echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>';
349
-			elseif (isset($query_data['t']))
350
-				echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>';
374
+			if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) {
375
+							echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>';
376
+			} elseif (isset($query_data['t'])) {
377
+							echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>';
378
+			}
351 379
 			echo '
352 380
 	<br>';
353 381
 		}
@@ -372,12 +400,14 @@  discard block
 block discarded – undo
372 400
 	global $modSettings, $smcFunc;
373 401
 	static $cache_stats = array();
374 402
 
375
-	if (empty($modSettings['trackStats']))
376
-		return false;
377
-	if (!empty($stats))
378
-		return $cache_stats = array_merge($cache_stats, $stats);
379
-	elseif (empty($cache_stats))
380
-		return false;
403
+	if (empty($modSettings['trackStats'])) {
404
+			return false;
405
+	}
406
+	if (!empty($stats)) {
407
+			return $cache_stats = array_merge($cache_stats, $stats);
408
+	} elseif (empty($cache_stats)) {
409
+			return false;
410
+	}
381 411
 
382 412
 	$setStringUpdate = '';
383 413
 	$insert_keys = array();
@@ -390,10 +420,11 @@  discard block
 block discarded – undo
390 420
 		$setStringUpdate .= '
391 421
 			' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ',';
392 422
 
393
-		if ($change === '+')
394
-			$cache_stats[$field] = 1;
395
-		else
396
-			$update_parameters[$field] = $change;
423
+		if ($change === '+') {
424
+					$cache_stats[$field] = 1;
425
+		} else {
426
+					$update_parameters[$field] = $change;
427
+		}
397 428
 		$insert_keys[$field] = 'int';
398 429
 	}
399 430
 
@@ -457,43 +488,50 @@  discard block
 block discarded – undo
457 488
 	);
458 489
 
459 490
 	// Make sure this particular log is enabled first...
460
-	if (empty($modSettings['modlog_enabled']))
461
-		unset ($log_types['moderate']);
462
-	if (empty($modSettings['userlog_enabled']))
463
-		unset ($log_types['user']);
464
-	if (empty($modSettings['adminlog_enabled']))
465
-		unset ($log_types['admin']);
491
+	if (empty($modSettings['modlog_enabled'])) {
492
+			unset ($log_types['moderate']);
493
+	}
494
+	if (empty($modSettings['userlog_enabled'])) {
495
+			unset ($log_types['user']);
496
+	}
497
+	if (empty($modSettings['adminlog_enabled'])) {
498
+			unset ($log_types['admin']);
499
+	}
466 500
 
467 501
 	call_integration_hook('integrate_log_types', array(&$log_types));
468 502
 
469 503
 	foreach ($logs as $log)
470 504
 	{
471
-		if (!isset($log_types[$log['log_type']]))
472
-			return false;
505
+		if (!isset($log_types[$log['log_type']])) {
506
+					return false;
507
+		}
473 508
 
474
-		if (!is_array($log['extra']))
475
-			trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
509
+		if (!is_array($log['extra'])) {
510
+					trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE);
511
+		}
476 512
 
477 513
 		// Pull out the parts we want to store separately, but also make sure that the data is proper
478 514
 		if (isset($log['extra']['topic']))
479 515
 		{
480
-			if (!is_numeric($log['extra']['topic']))
481
-				trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
516
+			if (!is_numeric($log['extra']['topic'])) {
517
+							trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE);
518
+			}
482 519
 			$topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic'];
483 520
 			unset($log['extra']['topic']);
521
+		} else {
522
+					$topic_id = 0;
484 523
 		}
485
-		else
486
-			$topic_id = 0;
487 524
 
488 525
 		if (isset($log['extra']['message']))
489 526
 		{
490
-			if (!is_numeric($log['extra']['message']))
491
-				trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
527
+			if (!is_numeric($log['extra']['message'])) {
528
+							trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE);
529
+			}
492 530
 			$msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message'];
493 531
 			unset($log['extra']['message']);
532
+		} else {
533
+					$msg_id = 0;
494 534
 		}
495
-		else
496
-			$msg_id = 0;
497 535
 
498 536
 		// @todo cache this?
499 537
 		// Is there an associated report on this?
@@ -520,23 +558,26 @@  discard block
 block discarded – undo
520 558
 			$smcFunc['db_free_result']($request);
521 559
 		}
522 560
 
523
-		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member']))
524
-			trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
561
+		if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) {
562
+					trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE);
563
+		}
525 564
 
526 565
 		if (isset($log['extra']['board']))
527 566
 		{
528
-			if (!is_numeric($log['extra']['board']))
529
-				trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
567
+			if (!is_numeric($log['extra']['board'])) {
568
+							trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE);
569
+			}
530 570
 			$board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board'];
531 571
 			unset($log['extra']['board']);
572
+		} else {
573
+					$board_id = 0;
532 574
 		}
533
-		else
534
-			$board_id = 0;
535 575
 
536 576
 		if (isset($log['extra']['board_to']))
537 577
 		{
538
-			if (!is_numeric($log['extra']['board_to']))
539
-				trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
578
+			if (!is_numeric($log['extra']['board_to'])) {
579
+							trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE);
580
+			}
540 581
 			if (empty($board_id))
541 582
 			{
542 583
 				$board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to'];
@@ -544,15 +585,17 @@  discard block
 block discarded – undo
544 585
 			}
545 586
 		}
546 587
 
547
-		if (isset($log['extra']['member_affected']))
548
-			$memID = $log['extra']['member_affected'];
549
-		else
550
-			$memID = $user_info['id'];
588
+		if (isset($log['extra']['member_affected'])) {
589
+					$memID = $log['extra']['member_affected'];
590
+		} else {
591
+					$memID = $user_info['id'];
592
+		}
551 593
 		
552
-		if (isset($user_info['ip']))
553
-			$memIP = $user_info['ip'];
554
-		else
555
-			$memIP = 'null';
594
+		if (isset($user_info['ip'])) {
595
+					$memIP = $user_info['ip'];
596
+		} else {
597
+					$memIP = 'null';
598
+		}
556 599
 
557 600
 		$inserts[] = array(
558 601
 			time(), $log_types[$log['log_type']], $memID, $memIP, $log['action'],
Please login to merge, or discard this patch.