Completed
Pull Request — release-2.1 (#4995)
by Jeremy
06:49
created
Sources/ManageMembers.php 1 patch
Braces   +165 added lines, -124 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
  * The main entrance point for the Manage Members screen.
@@ -109,12 +110,13 @@  discard block
 block discarded – undo
109 110
 	$context['tabs'][$context['last_tab']]['is_last'] = true;
110 111
 
111 112
 	// Find the active tab.
112
-	if (isset($context['tabs'][$context['current_subaction']]))
113
-		$context['tabs'][$context['current_subaction']]['is_selected'] = true;
114
-	elseif (isset($context['current_subaction']))
115
-		foreach ($context['tabs'] as $id_tab => $tab_data)
113
+	if (isset($context['tabs'][$context['current_subaction']])) {
114
+			$context['tabs'][$context['current_subaction']]['is_selected'] = true;
115
+	} elseif (isset($context['current_subaction'])) {
116
+			foreach ($context['tabs'] as $id_tab => $tab_data)
116 117
 			if (!empty($tab_data['selected_actions']) && in_array($context['current_subaction'], $tab_data['selected_actions']))
117 118
 				$context['tabs'][$id_tab]['is_selected'] = true;
119
+	}
118 120
 
119 121
 	call_helper($subActions[$context['current_subaction']][0]);
120 122
 }
@@ -144,8 +146,9 @@  discard block
 block discarded – undo
144 146
 		foreach ($_POST['delete'] as $key => $value)
145 147
 		{
146 148
 			// Don't delete yourself, idiot.
147
-			if ($value != $user_info['id'])
148
-				$delete[$key] = (int) $value;
149
+			if ($value != $user_info['id']) {
150
+							$delete[$key] = (int) $value;
151
+			}
149 152
 		}
150 153
 
151 154
 		if (!empty($delete))
@@ -181,17 +184,18 @@  discard block
 block discarded – undo
181 184
 		);
182 185
 		while ($row = $smcFunc['db_fetch_assoc']($request))
183 186
 		{
184
-			if ($row['min_posts'] == -1)
185
-				$context['membergroups'][] = array(
187
+			if ($row['min_posts'] == -1) {
188
+							$context['membergroups'][] = array(
186 189
 					'id' => $row['id_group'],
187 190
 					'name' => $row['group_name'],
188 191
 					'can_be_additional' => true
189 192
 				);
190
-			else
191
-				$context['postgroups'][] = array(
193
+			} else {
194
+							$context['postgroups'][] = array(
192 195
 					'id' => $row['id_group'],
193 196
 					'name' => $row['group_name']
194 197
 				);
198
+			}
195 199
 		}
196 200
 		$smcFunc['db_free_result']($request);
197 201
 
@@ -263,14 +267,15 @@  discard block
 block discarded – undo
263 267
 		call_integration_hook('integrate_view_members_params', array(&$params));
264 268
 
265 269
 		$search_params = array();
266
-		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types']))
267
-			$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
268
-		elseif (!empty($_POST))
270
+		if ($context['sub_action'] == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) {
271
+					$search_params = $smcFunc['json_decode'](base64_decode($_REQUEST['params']), true);
272
+		} elseif (!empty($_POST))
269 273
 		{
270 274
 			$search_params['types'] = $_POST['types'];
271
-			foreach ($params as $param_name => $param_info)
272
-				if (isset($_POST[$param_name]))
275
+			foreach ($params as $param_name => $param_info) {
276
+							if (isset($_POST[$param_name]))
273 277
 					$search_params[$param_name] = $_POST[$param_name];
278
+			}
274 279
 		}
275 280
 
276 281
 		$search_url_params = isset($search_params) ? base64_encode($smcFunc['json_encode']($search_params)) : null;
@@ -283,34 +288,38 @@  discard block
 block discarded – undo
283 288
 		foreach ($params as $param_name => $param_info)
284 289
 		{
285 290
 			// Not filled in?
286
-			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '')
287
-				continue;
291
+			if (!isset($search_params[$param_name]) || $search_params[$param_name] === '') {
292
+							continue;
293
+			}
288 294
 
289 295
 			// Make sure numeric values are really numeric.
290
-			if (in_array($param_info['type'], array('int', 'age')))
291
-				$search_params[$param_name] = (int) $search_params[$param_name];
296
+			if (in_array($param_info['type'], array('int', 'age'))) {
297
+							$search_params[$param_name] = (int) $search_params[$param_name];
298
+			}
292 299
 			// Date values have to match the specified format.
293 300
 			elseif ($param_info['type'] == 'date')
294 301
 			{
295 302
 				// Check if this date format is valid.
296
-				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0)
297
-					continue;
303
+				if (preg_match('/^\d{4}-\d{1,2}-\d{1,2}$/', $search_params[$param_name]) == 0) {
304
+									continue;
305
+				}
298 306
 
299 307
 				$search_params[$param_name] = strtotime($search_params[$param_name]);
300
-			}
301
-			elseif ($param_info['type'] == 'inet')
308
+			} elseif ($param_info['type'] == 'inet')
302 309
 			{
303 310
 				$search_params[$param_name] = ip2range($search_params[$param_name]);
304
-				if (empty($search_params[$param_name]))
305
-					continue;
311
+				if (empty($search_params[$param_name])) {
312
+									continue;
313
+				}
306 314
 			}
307 315
 
308 316
 			// Those values that are in some kind of range (<, <=, =, >=, >).
309 317
 			if (!empty($param_info['range']))
310 318
 			{
311 319
 				// Default to '=', just in case...
312
-				if (empty($range_trans[$search_params['types'][$param_name]]))
313
-					$search_params['types'][$param_name] = '=';
320
+				if (empty($range_trans[$search_params['types'][$param_name]])) {
321
+									$search_params['types'][$param_name] = '=';
322
+				}
314 323
 
315 324
 				// Handle special case 'age'.
316 325
 				if ($param_info['type'] == 'age')
@@ -338,16 +347,17 @@  discard block
 block discarded – undo
338 347
 				elseif ($param_info['type'] == 'date' && $search_params['types'][$param_name] == '=')
339 348
 				{
340 349
 					$query_parts[] = $param_info['db_fields'][0] . ' > ' . $search_params[$param_name] . ' AND ' . $param_info['db_fields'][0] . ' < ' . ($search_params[$param_name] + 86400);
350
+				} else {
351
+									$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
341 352
 				}
342
-				else
343
-					$query_parts[] = $param_info['db_fields'][0] . ' ' . $range_trans[$search_params['types'][$param_name]] . ' ' . $search_params[$param_name];
344 353
 			}
345 354
 			// Checkboxes.
346 355
 			elseif ($param_info['type'] == 'checkbox')
347 356
 			{
348 357
 				// Each checkbox or no checkbox at all is checked -> ignore.
349
-				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values']))
350
-					continue;
358
+				if (!is_array($search_params[$param_name]) || count($search_params[$param_name]) == 0 || count($search_params[$param_name]) == count($param_info['values'])) {
359
+									continue;
360
+				}
351 361
 
352 362
 				$query_parts[] = ($param_info['db_fields'][0]) . ' IN ({array_string:' . $param_name . '_check})';
353 363
 				$where_params[$param_name . '_check'] = $search_params[$param_name];
@@ -359,24 +369,23 @@  discard block
 block discarded – undo
359 369
 				{
360 370
 					$query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})';
361 371
 					$where_params[$param_name] = $search_params[$param_name][0];
362
-				}
363
-				elseif (count($search_params[$param_name]) === 2)
372
+				} elseif (count($search_params[$param_name]) === 2)
364 373
 				{
365 374
 					$query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})';
366 375
 					$where_params[$param_name.'_low'] = $search_params[$param_name]['low'];
367 376
 					$where_params[$param_name.'_high'] = $search_params[$param_name]['high'];
368 377
 				}
369 378
 				
370
-			}
371
-			elseif ($param_info['type'] != 'groups')
379
+			} elseif ($param_info['type'] != 'groups')
372 380
 			{
373 381
 				// Replace the wildcard characters ('*' and '?') into MySQL ones.
374 382
 				$parameter = strtolower(strtr($smcFunc['htmlspecialchars']($search_params[$param_name], ENT_QUOTES), array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')));
375 383
 
376
-				if ($smcFunc['db_case_sensitive'])
377
-					$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
378
-				else
379
-					$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
384
+				if ($smcFunc['db_case_sensitive']) {
385
+									$query_parts[] = '(LOWER(' . implode(') LIKE {string:' . $param_name . '_normal} OR LOWER(', $param_info['db_fields']) . ') LIKE {string:' . $param_name . '_normal})';
386
+				} else {
387
+									$query_parts[] = '(' . implode(' LIKE {string:' . $param_name . '_normal} OR ', $param_info['db_fields']) . ' LIKE {string:' . $param_name . '_normal})';
388
+				}
380 389
 				$where_params[$param_name . '_normal'] = '%' . $parameter . '%';
381 390
 			}
382 391
 		}
@@ -392,16 +401,18 @@  discard block
 block discarded – undo
392 401
 		}
393 402
 
394 403
 		// Additional membergroups (these are only relevant if not all primary groups where selected!).
395
-		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1])))
396
-			foreach ($search_params['membergroups'][2] as $mg)
404
+		if (!empty($search_params['membergroups'][2]) && (empty($search_params['membergroups'][1]) || count($context['membergroups']) != count($search_params['membergroups'][1]))) {
405
+					foreach ($search_params['membergroups'][2] as $mg)
397 406
 			{
398 407
 				$mg_query_parts[] = 'FIND_IN_SET({int:add_group_' . $mg . '}, mem.additional_groups) != 0';
408
+		}
399 409
 				$where_params['add_group_' . $mg] = $mg;
400 410
 			}
401 411
 
402 412
 		// Combine the one or two membergroup parts into one query part linked with an OR.
403
-		if (!empty($mg_query_parts))
404
-			$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
413
+		if (!empty($mg_query_parts)) {
414
+					$query_parts[] = '(' . implode(' OR ', $mg_query_parts) . ')';
415
+		}
405 416
 
406 417
 		// Get all selected post count related membergroups.
407 418
 		if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($context['postgroups']))
@@ -413,9 +424,9 @@  discard block
 block discarded – undo
413 424
 		// Construct the where part of the query.
414 425
 		$where = empty($query_parts) ? '1=1' : implode('
415 426
 			AND ', $query_parts);
427
+	} else {
428
+			$search_url_params = null;
416 429
 	}
417
-	else
418
-		$search_url_params = null;
419 430
 
420 431
 	// Construct the additional URL part with the query info in it.
421 432
 	$context['params_url'] = $context['sub_action'] == 'query' ? ';sa=query;params=' . $search_url_params : '';
@@ -538,28 +549,32 @@  discard block
 block discarded – undo
538 549
 					'function' => function($rowData) use ($txt)
539 550
 					{
540 551
 						// Calculate number of days since last online.
541
-						if (empty($rowData['last_login']))
542
-							$difference = $txt['never'];
543
-						else
552
+						if (empty($rowData['last_login'])) {
553
+													$difference = $txt['never'];
554
+						} else
544 555
 						{
545 556
 							$num_days_difference = jeffsdatediff($rowData['last_login']);
546 557
 
547 558
 							// Today.
548
-							if (empty($num_days_difference))
549
-								$difference = $txt['viewmembers_today'];
559
+							if (empty($num_days_difference)) {
560
+															$difference = $txt['viewmembers_today'];
561
+							}
550 562
 
551 563
 							// Yesterday.
552
-							elseif ($num_days_difference == 1)
553
-								$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
564
+							elseif ($num_days_difference == 1) {
565
+															$difference = sprintf('1 %1$s', $txt['viewmembers_day_ago']);
566
+							}
554 567
 
555 568
 							// X days ago.
556
-							else
557
-								$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
569
+							else {
570
+															$difference = sprintf('%1$d %2$s', $num_days_difference, $txt['viewmembers_days_ago']);
571
+							}
558 572
 						}
559 573
 
560 574
 						// Show it in italics if they're not activated...
561
-						if ($rowData['is_activated'] % 10 != 1)
562
-							$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
575
+						if ($rowData['is_activated'] % 10 != 1) {
576
+													$difference = sprintf('<em title="%1$s">%2$s</em>', $txt['not_activated'], $difference);
577
+						}
563 578
 
564 579
 						return $difference;
565 580
 					},
@@ -611,8 +626,9 @@  discard block
 block discarded – undo
611 626
 	);
612 627
 
613 628
 	// Without enough permissions, don't show 'delete members' checkboxes.
614
-	if (!allowedTo('profile_remove_any'))
615
-		unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
629
+	if (!allowedTo('profile_remove_any')) {
630
+			unset($listOptions['cols']['check'], $listOptions['form'], $listOptions['additional_rows']);
631
+	}
616 632
 
617 633
 	require_once($sourcedir . '/Subs-List.php');
618 634
 	createList($listOptions);
@@ -655,17 +671,18 @@  discard block
 block discarded – undo
655 671
 	);
656 672
 	while ($row = $smcFunc['db_fetch_assoc']($request))
657 673
 	{
658
-		if ($row['min_posts'] == -1)
659
-			$context['membergroups'][] = array(
674
+		if ($row['min_posts'] == -1) {
675
+					$context['membergroups'][] = array(
660 676
 				'id' => $row['id_group'],
661 677
 				'name' => $row['group_name'],
662 678
 				'can_be_additional' => true
663 679
 			);
664
-		else
665
-			$context['postgroups'][] = array(
680
+		} else {
681
+					$context['postgroups'][] = array(
666 682
 				'id' => $row['id_group'],
667 683
 				'name' => $row['group_name']
668 684
 			);
685
+		}
669 686
 	}
670 687
 	$smcFunc['db_free_result']($request);
671 688
 
@@ -692,8 +709,9 @@  discard block
 block discarded – undo
692 709
 	$context['page_title'] = $txt['admin_members'];
693 710
 	$context['sub_template'] = 'admin_browse';
694 711
 	$context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve');
695
-	if (isset($context['tabs'][$context['browse_type']]))
696
-		$context['tabs'][$context['browse_type']]['is_selected'] = true;
712
+	if (isset($context['tabs'][$context['browse_type']])) {
713
+			$context['tabs'][$context['browse_type']]['is_selected'] = true;
714
+	}
697 715
 
698 716
 	// Allowed filters are those we can have, in theory.
699 717
 	$context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2);
@@ -704,18 +722,20 @@  discard block
 block discarded – undo
704 722
 	foreach ($context['activation_numbers'] as $type => $amount)
705 723
 	{
706 724
 		// We have some of these...
707
-		if (in_array($type, $context['allowed_filters']) && $amount > 0)
708
-			$context['available_filters'][] = array(
725
+		if (in_array($type, $context['allowed_filters']) && $amount > 0) {
726
+					$context['available_filters'][] = array(
709 727
 				'type' => $type,
710 728
 				'amount' => $amount,
711 729
 				'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?',
712 730
 				'selected' => $type == $context['current_filter']
713 731
 			);
732
+		}
714 733
 	}
715 734
 
716 735
 	// If the filter was not sent, set it to whatever has people in it!
717
-	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount']))
718
-		$context['current_filter'] = $context['available_filters'][0]['type'];
736
+	if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) {
737
+			$context['current_filter'] = $context['available_filters'][0]['type'];
738
+	}
719 739
 
720 740
 	// This little variable is used to determine if we should flag where we are looking.
721 741
 	$context['show_filter'] = ($context['current_filter'] != 0 && $context['current_filter'] != 3) || count($context['available_filters']) > 1;
@@ -730,44 +750,47 @@  discard block
 block discarded – undo
730 750
 	);
731 751
 
732 752
 	// Are we showing duplicate information?
733
-	if (isset($_GET['showdupes']))
734
-		$_SESSION['showdupes'] = (int) $_GET['showdupes'];
753
+	if (isset($_GET['showdupes'])) {
754
+			$_SESSION['showdupes'] = (int) $_GET['showdupes'];
755
+	}
735 756
 	$context['show_duplicates'] = !empty($_SESSION['showdupes']);
736 757
 
737 758
 	// Determine which actions we should allow on this page.
738 759
 	if ($context['browse_type'] == 'approve')
739 760
 	{
740 761
 		// If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
741
-		if ($context['current_filter'] == 4)
742
-			$context['allowed_actions'] = array(
762
+		if ($context['current_filter'] == 4) {
763
+					$context['allowed_actions'] = array(
743 764
 				'reject' => $txt['admin_browse_w_approve_deletion'],
744 765
 				'ok' => $txt['admin_browse_w_reject'],
745 766
 			);
746
-		else
747
-			$context['allowed_actions'] = array(
767
+		} else {
768
+					$context['allowed_actions'] = array(
748 769
 				'ok' => $txt['admin_browse_w_approve'],
749 770
 				'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'],
750 771
 				'require_activation' => $txt['admin_browse_w_approve_require_activate'],
751 772
 				'reject' => $txt['admin_browse_w_reject'],
752 773
 				'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email'],
753 774
 			);
754
-	}
755
-	elseif ($context['browse_type'] == 'activate')
756
-		$context['allowed_actions'] = array(
775
+		}
776
+	} elseif ($context['browse_type'] == 'activate') {
777
+			$context['allowed_actions'] = array(
757 778
 			'ok' => $txt['admin_browse_w_activate'],
758 779
 			'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'],
759 780
 			'delete' => $txt['admin_browse_w_delete'],
760 781
 			'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'],
761 782
 			'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email'],
762 783
 		);
784
+	}
763 785
 
764 786
 	// Create an option list for actions allowed to be done with selected members.
765 787
 	$allowed_actions = '
766 788
 			<option selected value="">' . $txt['admin_browse_with_selected'] . ':</option>
767 789
 			<option value="" disabled>-----------------------------</option>';
768
-	foreach ($context['allowed_actions'] as $key => $desc)
769
-		$allowed_actions .= '
790
+	foreach ($context['allowed_actions'] as $key => $desc) {
791
+			$allowed_actions .= '
770 792
 			<option value="' . $key . '">' . $desc . '</option>';
793
+	}
771 794
 
772 795
 	// Setup the Javascript function for selecting an action for the list.
773 796
 	$javascript = '
@@ -779,15 +802,16 @@  discard block
 block discarded – undo
779 802
 			var message = "";';
780 803
 
781 804
 	// We have special messages for approving deletion of accounts - it's surprisingly logical - honest.
782
-	if ($context['current_filter'] == 4)
783
-		$javascript .= '
805
+	if ($context['current_filter'] == 4) {
806
+			$javascript .= '
784 807
 			if (document.forms.postForm.todo.value.indexOf("reject") != -1)
785 808
 				message = "' . $txt['admin_browse_w_delete'] . '";
786 809
 			else
787 810
 				message = "' . $txt['admin_browse_w_reject'] . '";';
811
+	}
788 812
 	// Otherwise a nice standard message.
789
-	else
790
-		$javascript .= '
813
+	else {
814
+			$javascript .= '
791 815
 			if (document.forms.postForm.todo.value.indexOf("delete") != -1)
792 816
 				message = "' . $txt['admin_browse_w_delete'] . '";
793 817
 			else if (document.forms.postForm.todo.value.indexOf("reject") != -1)
@@ -796,6 +820,7 @@  discard block
 block discarded – undo
796 820
 				message = "' . $txt['admin_browse_w_remind'] . '";
797 821
 			else
798 822
 				message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";';
823
+	}
799 824
 	$javascript .= '
800 825
 			if (confirm(message + " ' . $txt['admin_browse_warn'] . '"))
801 826
 				document.forms.postForm.submit();
@@ -928,10 +953,11 @@  discard block
 block discarded – undo
928 953
 						$member_links = array();
929 954
 						foreach ($rowData['duplicate_members'] as $member)
930 955
 						{
931
-							if ($member['id'])
932
-								$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
933
-							else
934
-								$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
956
+							if ($member['id']) {
957
+															$member_links[] = '<a href="' . $scripturl . '?action=profile;u=' . $member['id'] . '" ' . (!empty($member['is_banned']) ? 'class="red"' : '') . '>' . $member['name'] . '</a>';
958
+							} else {
959
+															$member_links[] = $member['name'] . ' (' . $txt['guest'] . ')';
960
+							}
935 961
 						}
936 962
 						return implode(', ', $member_links);
937 963
 					},
@@ -980,14 +1006,16 @@  discard block
 block discarded – undo
980 1006
 	);
981 1007
 
982 1008
 	// Pick what column to actually include if we're showing duplicates.
983
-	if ($context['show_duplicates'])
984
-		unset($listOptions['columns']['email']);
985
-	else
986
-		unset($listOptions['columns']['duplicates']);
1009
+	if ($context['show_duplicates']) {
1010
+			unset($listOptions['columns']['email']);
1011
+	} else {
1012
+			unset($listOptions['columns']['duplicates']);
1013
+	}
987 1014
 
988 1015
 	// Only show hostname on duplicates as it takes a lot of time.
989
-	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup']))
990
-		unset($listOptions['columns']['hostname']);
1016
+	if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) {
1017
+			unset($listOptions['columns']['hostname']);
1018
+	}
991 1019
 
992 1020
 	// Is there any need to show filters?
993 1021
 	if (isset($context['available_filters']) && count($context['available_filters']) > 1)
@@ -995,9 +1023,10 @@  discard block
 block discarded – undo
995 1023
 		$filterOptions = '
996 1024
 			<strong>' . $txt['admin_browse_filter_by'] . ':</strong>
997 1025
 			<select name="filter" onchange="this.form.submit();">';
998
-		foreach ($context['available_filters'] as $filter)
999
-			$filterOptions .= '
1026
+		foreach ($context['available_filters'] as $filter) {
1027
+					$filterOptions .= '
1000 1028
 				<option value="' . $filter['type'] . '"' . ($filter['selected'] ? ' selected' : '') . '>' . $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']) . '</option>';
1029
+		}
1001 1030
 		$filterOptions .= '
1002 1031
 			</select>
1003 1032
 			<noscript><input type="submit" value="' . $txt['go'] . '" name="filter" class="button"></noscript>';
@@ -1009,12 +1038,13 @@  discard block
 block discarded – undo
1009 1038
 	}
1010 1039
 
1011 1040
 	// What about if we only have one filter, but it's not the "standard" filter - show them what they are looking at.
1012
-	if (!empty($context['show_filter']) && !empty($context['available_filters']))
1013
-		$listOptions['additional_rows'][] = array(
1041
+	if (!empty($context['show_filter']) && !empty($context['available_filters'])) {
1042
+			$listOptions['additional_rows'][] = array(
1014 1043
 			'position' => 'above_column_headers',
1015 1044
 			'value' => '<strong>' . $txt['admin_browse_filter_show'] . ':</strong> ' . $context['available_filters'][0]['desc'],
1016 1045
 			'class' => 'smalltext floatright',
1017 1046
 		);
1047
+	}
1018 1048
 
1019 1049
 	// Now that we have all the options, create the list.
1020 1050
 	require_once($sourcedir . '/Subs-List.php');
@@ -1044,12 +1074,14 @@  discard block
 block discarded – undo
1044 1074
 	$current_filter = (int) $_REQUEST['orig_filter'];
1045 1075
 
1046 1076
 	// If we are applying a filter do just that - then redirect.
1047
-	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter'])
1048
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1077
+	if (isset($_REQUEST['filter']) && $_REQUEST['filter'] != $_REQUEST['orig_filter']) {
1078
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $_REQUEST['filter'] . ';start=' . $_REQUEST['start']);
1079
+	}
1049 1080
 
1050 1081
 	// Nothing to do?
1051
-	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed']))
1052
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1082
+	if (!isset($_POST['todoAction']) && !isset($_POST['time_passed'])) {
1083
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1084
+	}
1053 1085
 
1054 1086
 	// Are we dealing with members who have been waiting for > set amount of time?
1055 1087
 	if (isset($_POST['time_passed']))
@@ -1062,8 +1094,9 @@  discard block
 block discarded – undo
1062 1094
 	else
1063 1095
 	{
1064 1096
 		$members = array();
1065
-		foreach ($_POST['todoAction'] as $id)
1066
-			$members[] = (int) $id;
1097
+		foreach ($_POST['todoAction'] as $id) {
1098
+					$members[] = (int) $id;
1099
+		}
1067 1100
 		$condition = '
1068 1101
 			AND id_member IN ({array_int:members})';
1069 1102
 	}
@@ -1084,8 +1117,9 @@  discard block
 block discarded – undo
1084 1117
 	$member_count = $smcFunc['db_num_rows']($request);
1085 1118
 
1086 1119
 	// If no results then just return!
1087
-	if ($member_count == 0)
1088
-		redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1120
+	if ($member_count == 0) {
1121
+			redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1122
+	}
1089 1123
 
1090 1124
 	$member_info = array();
1091 1125
 	$members = array();
@@ -1124,8 +1158,9 @@  discard block
 block discarded – undo
1124 1158
 		// Do we have to let the integration code know about the activations?
1125 1159
 		if (!empty($modSettings['integrate_activate']))
1126 1160
 		{
1127
-			foreach ($member_info as $member)
1128
-				call_integration_hook('integrate_activate', array($member['username']));
1161
+			foreach ($member_info as $member) {
1162
+							call_integration_hook('integrate_activate', array($member['username']));
1163
+			}
1129 1164
 		}
1130 1165
 
1131 1166
 		// Check for email.
@@ -1255,20 +1290,23 @@  discard block
 block discarded – undo
1255 1290
 		$log_action = $_POST['todo'] == 'remind' ? 'remind_member' : 'approve_member';
1256 1291
 
1257 1292
 		require_once($sourcedir . '/Logging.php');
1258
-		foreach ($member_info as $member)
1259
-			logAction($log_action, array('member' => $member['id']), 'admin');
1293
+		foreach ($member_info as $member) {
1294
+					logAction($log_action, array('member' => $member['id']), 'admin');
1295
+		}
1260 1296
 	}
1261 1297
 
1262 1298
 	// Although updateStats *may* catch this, best to do it manually just in case (Doesn't always sort out unapprovedMembers).
1263
-	if (in_array($current_filter, array(3, 4, 5)))
1264
-		updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1299
+	if (in_array($current_filter, array(3, 4, 5))) {
1300
+			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > $member_count ? $modSettings['unapprovedMembers'] - $member_count : 0)));
1301
+	}
1265 1302
 
1266 1303
 	// Update the member's stats. (but, we know the member didn't change their name.)
1267 1304
 	updateStats('member', false);
1268 1305
 
1269 1306
 	// If they haven't been deleted, update the post group statistics on them...
1270
-	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind')))
1271
-		updateStats('postgroups', $members);
1307
+	if (!in_array($_POST['todo'], array('delete', 'deleteemail', 'reject', 'rejectemail', 'remind'))) {
1308
+			updateStats('postgroups', $members);
1309
+	}
1272 1310
 
1273 1311
 	redirectexit('action=admin;area=viewmembers;sa=browse;type=' . $_REQUEST['type'] . ';sort=' . $_REQUEST['sort'] . ';filter=' . $current_filter . ';start=' . $_REQUEST['start']);
1274 1312
 }
@@ -1293,10 +1331,11 @@  discard block
 block discarded – undo
1293 1331
 	$dis = time() - $old;
1294 1332
 
1295 1333
 	// Before midnight?
1296
-	if ($dis < $sinceMidnight)
1297
-		return 0;
1298
-	else
1299
-		$dis -= $sinceMidnight;
1334
+	if ($dis < $sinceMidnight) {
1335
+			return 0;
1336
+	} else {
1337
+			$dis -= $sinceMidnight;
1338
+	}
1300 1339
 
1301 1340
 	// Divide out the seconds in a day to get the number of days.
1302 1341
 	return ceil($dis / (24 * 60 * 60));
@@ -1323,16 +1362,18 @@  discard block
 block discarded – undo
1323 1362
 	$context['activation_numbers'] = array();
1324 1363
 	$context['awaiting_activation'] = 0;
1325 1364
 	$context['awaiting_approval'] = 0;
1326
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1327
-		$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
1365
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1366
+			$context['activation_numbers'][$row['is_activated']] = $row['total_members'];
1367
+	}
1328 1368
 	$smcFunc['db_free_result']($request);
1329 1369
 
1330 1370
 	foreach ($context['activation_numbers'] as $activation_type => $total_members)
1331 1371
 	{
1332
-		if (in_array($activation_type, array(0, 2)))
1333
-			$context['awaiting_activation'] += $total_members;
1334
-		elseif (in_array($activation_type, array(3, 4, 5)))
1335
-			$context['awaiting_approval'] += $total_members;
1372
+		if (in_array($activation_type, array(0, 2))) {
1373
+					$context['awaiting_activation'] += $total_members;
1374
+		} elseif (in_array($activation_type, array(3, 4, 5))) {
1375
+					$context['awaiting_approval'] += $total_members;
1376
+		}
1336 1377
 	}
1337 1378
 
1338 1379
 }
Please login to merge, or discard this patch.