Completed
Push — release-2.1 ( 669841...0c3a4e )
by Michael
11:40 queued 03:55
created
Themes/default/BoardIndex.template.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		echo '
74 74
 		<div class="main_container">
75
-			<div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '','" id="category_', $category['id'], '">
75
+			<div class="cat_bar ', $category['is_collapsed'] ? 'collapsed' : '', '" id="category_', $category['id'], '">
76 76
 				<h3 class="catbg">';
77 77
 
78 78
 		// If this category even can collapse, show a link to collapse it.
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		foreach ($board['children'] as $child)
248 248
 		{
249 249
 			if (!$child['is_redirect'])
250
-				$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
250
+				$child['link'] = '' . ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
251 251
 			else
252 252
 				$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>';
253 253
 
Please login to merge, or discard this patch.
Braces   +64 added lines, -45 removed lines patch added patch discarded remove patch
@@ -67,8 +67,9 @@  discard block
 block discarded – undo
67 67
 	foreach ($context['categories'] as $category)
68 68
 	{
69 69
 		// If theres no parent boards we can see, avoid showing an empty category (unless its collapsed)
70
-		if (empty($category['boards']) && !$category['is_collapsed'])
71
-			continue;
70
+		if (empty($category['boards']) && !$category['is_collapsed']) {
71
+					continue;
72
+		}
72 73
 
73 74
 		echo '
74 75
 		<div class="main_container">
@@ -76,9 +77,10 @@  discard block
 block discarded – undo
76 77
 				<h3 class="catbg">';
77 78
 
78 79
 		// If this category even can collapse, show a link to collapse it.
79
-		if ($category['can_collapse'])
80
-			echo '
80
+		if ($category['can_collapse']) {
81
+					echo '
81 82
 					<span id="category_', $category['id'], '_upshrink" class="', $category['is_collapsed'] ? 'toggle_down' : 'toggle_up', ' floatright" data-collapsed="', (int) $category['is_collapsed'], '" title="', !$category['is_collapsed'] ? $txt['hide_category'] : $txt['show_category'], '" style="display: none;"></span>';
83
+		}
82 84
 
83 85
 		echo '
84 86
 					', $category['link'], '
@@ -108,10 +110,11 @@  discard block
 block discarded – undo
108 110
 					</div>';
109 111
 
110 112
 				// Won't somebody think of the children!
111
-				if (function_exists('template_bi_' . $board['type'] . '_children'))
112
-					call_user_func('template_bi_' . $board['type'] . '_children', $board);
113
-				else
114
-					template_bi_board_children($board);
113
+				if (function_exists('template_bi_' . $board['type'] . '_children')) {
114
+									call_user_func('template_bi_' . $board['type'] . '_children', $board);
115
+				} else {
116
+									template_bi_board_children($board);
117
+				}
115 118
 
116 119
 				echo '
117 120
 					</div>';
@@ -126,10 +129,11 @@  discard block
 block discarded – undo
126 129
 	</div>';
127 130
 
128 131
 	// Show the mark all as read button?
129
-	if ($context['user']['is_logged'] && !empty($context['categories']))
130
-		echo '
132
+	if ($context['user']['is_logged'] && !empty($context['categories'])) {
133
+			echo '
131 134
 		<div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>';
132
-}
135
+	}
136
+	}
133 137
 
134 138
 /**
135 139
  * Outputs the board icon for a standard board.
@@ -173,18 +177,20 @@  discard block
 block discarded – undo
173 177
 						</a>';
174 178
 
175 179
 	// Has it outstanding posts for approval?
176
-	if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics']))
177
-		echo '
180
+	if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) {
181
+			echo '
178 182
 						<a href="', $scripturl, '?action=moderate;area=postmod;sa=', ($board['unapproved_topics'] > 0 ? 'topics' : 'posts'), ';brd=', $board['id'], ';', $context['session_var'], '=', $context['session_id'], '" title="', sprintf($txt['unapproved_posts'], $board['unapproved_topics'], $board['unapproved_posts']), '" class="moderation_link">(!)</a>';
183
+	}
179 184
 
180 185
 	echo '
181 186
 						<p class="board_description">', $board['description'], '</p>';
182 187
 
183 188
 	// Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.)
184
-	if (!empty($board['link_moderators']))
185
-		echo '
189
+	if (!empty($board['link_moderators'])) {
190
+			echo '
186 191
 						<p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>';
187
-}
192
+	}
193
+	}
188 194
 
189 195
 /**
190 196
  * Outputs the board stats for a standard board.
@@ -223,10 +229,11 @@  discard block
 block discarded – undo
223 229
  */
224 230
 function template_bi_board_lastpost($board)
225 231
 {
226
-	if (!empty($board['last_post']['id']))
227
-		echo '
232
+	if (!empty($board['last_post']['id'])) {
233
+			echo '
228 234
 						<p>', $board['last_post']['last_post_message'], '</p>';
229
-}
235
+	}
236
+	}
230 237
 
231 238
 /**
232 239
  * Outputs the board children for a standard board.
@@ -246,14 +253,16 @@  discard block
 block discarded – undo
246 253
 				id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */
247 254
 		foreach ($board['children'] as $child)
248 255
 		{
249
-			if (!$child['is_redirect'])
250
-				$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
251
-			else
252
-				$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>';
256
+			if (!$child['is_redirect']) {
257
+							$child['link'] = ''. ($child['new'] ? '<a href="' . $scripturl . '?action=unread;board=' . $child['id'] . '" title="' . $txt['new_posts'] . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')"><span class="new_posts">' . $txt['new'] . '</span></a>' : '') . '<a href="' . $child['href'] . '" ' . ($child['new'] ? 'class="board_new_posts" ' : '') . 'title="' . ($child['new'] ? $txt['new_posts'] : $txt['old_posts']) . ' (' . $txt['board_topics'] . ': ' . comma_format($child['topics']) . ', ' . $txt['posts'] . ': ' . comma_format($child['posts']) . ')">' . $child['name'] . '</a>';
258
+			} else {
259
+							$child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>';
260
+			}
253 261
 
254 262
 			// Has it posts awaiting approval?
255
-			if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics']))
256
-				$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
263
+			if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) {
264
+							$child['link'] .= ' <a href="' . $scripturl . '?action=moderate;area=postmod;sa=' . ($child['unapproved_topics'] > 0 ? 'topics' : 'posts') . ';brd=' . $child['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" title="' . sprintf($txt['unapproved_posts'], $child['unapproved_topics'], $child['unapproved_posts']) . '" class="moderation_link">(!)</a>';
265
+			}
257 266
 
258 267
 			$children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>';
259 268
 		}
@@ -280,8 +289,9 @@  discard block
 block discarded – undo
280 289
 {
281 290
 	global $context, $options, $txt;
282 291
 
283
-	if (empty($context['info_center']))
284
-		return;
292
+	if (empty($context['info_center'])) {
293
+			return;
294
+	}
285 295
 
286 296
 	// Here's where the "Info Center" starts...
287 297
 	echo '
@@ -381,14 +391,15 @@  discard block
 block discarded – undo
381 391
 		/* Each post in latest_posts has:
382 392
 				board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
383 393
 				subject, short_subject (shortened with...), time, link, and href. */
384
-		foreach ($context['latest_posts'] as $post)
385
-			echo '
394
+		foreach ($context['latest_posts'] as $post) {
395
+					echo '
386 396
 					<tr class="windowbg">
387 397
 						<td class="recentpost"><strong>', $post['link'], '</strong></td>
388 398
 						<td class="recentposter">', $post['poster']['link'], '</td>
389 399
 						<td class="recentboard">', $post['board']['link'], '</td>
390 400
 						<td class="recenttime">', $post['time'], '</td>
391 401
 					</tr>';
402
+		}
392 403
 		echo '
393 404
 				</table>';
394 405
 	}
@@ -412,9 +423,10 @@  discard block
 block discarded – undo
412 423
 			</div>';
413 424
 
414 425
 	// Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P.
415
-	if (!empty($context['calendar_holidays']))
416
-		echo '
426
+	if (!empty($context['calendar_holidays'])) {
427
+			echo '
417 428
 				<p class="inline holiday"><span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), '</p>';
429
+	}
418 430
 
419 431
 	// People's birthdays. Like mine. And yours, I guess. Kidding.
420 432
 	if (!empty($context['calendar_birthdays']))
@@ -423,9 +435,10 @@  discard block
 block discarded – undo
423 435
 				<p class="inline">
424 436
 					<span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>';
425 437
 		// Each member in calendar_birthdays has: id, name (person), age (if they have one set?), is_last. (last in list?), and is_today (birthday is today?)
426
-		foreach ($context['calendar_birthdays'] as $member)
427
-			echo '
438
+		foreach ($context['calendar_birthdays'] as $member) {
439
+					echo '
428 440
 					<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['is_today'] ? '<strong class="fix_rtl_names">' : '', $member['name'], $member['is_today'] ? '</strong>' : '', isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', $member['is_last'] ? '' : ', ';
441
+		}
429 442
 		echo '
430 443
 				</p>';
431 444
 	}
@@ -439,9 +452,10 @@  discard block
 block discarded – undo
439 452
 
440 453
 		// Each event in calendar_events should have:
441 454
 		//		title, href, is_last, can_edit (are they allowed?), modify_href, and is_today.
442
-		foreach ($context['calendar_events'] as $event)
443
-			echo '
455
+		foreach ($context['calendar_events'] as $event) {
456
+					echo '
444 457
 					', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '" title="' . $txt['calendar_edit'] . '"><span class="generic_icons calendar_modify"></span></a> ' : '', $event['href'] == '' ? '' : '<a href="' . $event['href'] . '">', $event['is_today'] ? '<strong>' . $event['title'] . '</strong>' : $event['title'], $event['href'] == '' ? '' : '</a>', $event['is_last'] ? '<br>' : ', ';
458
+		}
445 459
 		echo '
446 460
 				</p>';
447 461
 	}
@@ -486,15 +500,19 @@  discard block
 block discarded – undo
486 500
 
487 501
 	// Handle hidden users and buddies.
488 502
 	$bracketList = array();
489
-	if ($context['show_buddies'])
490
-		$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
491
-	if (!empty($context['num_spiders']))
492
-		$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
493
-	if (!empty($context['num_users_hidden']))
494
-		$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']);
503
+	if ($context['show_buddies']) {
504
+			$bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
505
+	}
506
+	if (!empty($context['num_spiders'])) {
507
+			$bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
508
+	}
509
+	if (!empty($context['num_users_hidden'])) {
510
+			$bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']);
511
+	}
495 512
 
496
-	if (!empty($bracketList))
497
-		echo ' (' . implode(', ', $bracketList) . ')';
513
+	if (!empty($bracketList)) {
514
+			echo ' (' . implode(', ', $bracketList) . ')';
515
+	}
498 516
 
499 517
 	echo $context['show_who'] ? '</a>' : '', '
500 518
 
@@ -508,9 +526,10 @@  discard block
 block discarded – undo
508 526
 				', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']);
509 527
 
510 528
 		// Showing membergroups?
511
-		if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
512
-			echo '
529
+		if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) {
530
+					echo '
513 531
 				<span class="membergroups">' . implode(',&nbsp;', $context['membergroups']) . '</span>';
532
+		}
514 533
 	}
515 534
 
516 535
 	echo '
Please login to merge, or discard this patch.
Sources/MessageIndex.php 1 patch
Braces   +264 added lines, -197 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Show the list of topics in this board, along with any child boards.
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 	$context['name'] = $board_info['name'];
58 59
 	$context['description'] = $board_info['description'];
59
-	if (!empty($board_info['description']))
60
-		$context['meta_description'] = strip_tags($board_info['description']);
60
+	if (!empty($board_info['description'])) {
61
+			$context['meta_description'] = strip_tags($board_info['description']);
62
+	}
61 63
 
62 64
 	// How many topics do we have in total?
63 65
 	$board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
 		$session_name = session_name();
74 76
 		foreach ($_GET as $k => $v)
75 77
 		{
76
-			if (!in_array($k, array('board', 'start', $session_name)))
77
-				$context['robot_no_index'] = true;
78
+			if (!in_array($k, array('board', 'start', $session_name))) {
79
+							$context['robot_no_index'] = true;
80
+			}
78 81
 		}
79 82
 	}
80
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
81
-		$context['robot_no_index'] = true;
83
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
84
+			$context['robot_no_index'] = true;
85
+	}
82 86
 
83 87
 	// If we can view unapproved messages and there are some build up a list.
84 88
 	if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts']))
@@ -89,14 +93,16 @@  discard block
 block discarded – undo
89 93
 	}
90 94
 
91 95
 	// We only know these.
92
-	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
93
-		$_REQUEST['sort'] = 'last_post';
96
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) {
97
+			$_REQUEST['sort'] = 'last_post';
98
+	}
94 99
 
95 100
 	// Make sure the starting place makes sense and construct the page index.
96
-	if (isset($_REQUEST['sort']))
97
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
98
-	else
99
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
101
+	if (isset($_REQUEST['sort'])) {
102
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
103
+	} else {
104
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
105
+	}
100 106
 	$context['start'] = &$_REQUEST['start'];
101 107
 
102 108
 	// Set a canonical URL for this page.
@@ -132,14 +138,16 @@  discard block
 block discarded – undo
132 138
 	$context['link_moderators'] = array();
133 139
 	if (!empty($board_info['moderators']))
134 140
 	{
135
-		foreach ($board_info['moderators'] as $mod)
136
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
141
+		foreach ($board_info['moderators'] as $mod) {
142
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
143
+		}
137 144
 	}
138 145
 	if (!empty($board_info['moderator_groups']))
139 146
 	{
140 147
 		// By default just tack the moderator groups onto the end of the members
141
-		foreach ($board_info['moderator_groups'] as $mod_group)
142
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
148
+		foreach ($board_info['moderator_groups'] as $mod_group) {
149
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
150
+		}
143 151
 	}
144 152
 
145 153
 	// Now we tack the info onto the end of the linktree
@@ -191,20 +199,24 @@  discard block
 block discarded – undo
191 199
 		);
192 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
193 201
 		{
194
-			if (empty($row['id_member']))
195
-				continue;
202
+			if (empty($row['id_member'])) {
203
+							continue;
204
+			}
196 205
 
197
-			if (!empty($row['online_color']))
198
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
199
-			else
200
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
206
+			if (!empty($row['online_color'])) {
207
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
208
+			} else {
209
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
210
+			}
201 211
 
202 212
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
203
-			if ($is_buddy)
204
-				$link = '<strong>' . $link . '</strong>';
213
+			if ($is_buddy) {
214
+							$link = '<strong>' . $link . '</strong>';
215
+			}
205 216
 
206
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
207
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
217
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
218
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
219
+			}
208 220
 			// @todo why are we filling this array of data that are just counted (twice) and discarded? ???
209 221
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
210 222
 				'id' => $row['id_member'],
@@ -217,8 +229,9 @@  discard block
 block discarded – undo
217 229
 				'hidden' => empty($row['show_online']),
218 230
 			);
219 231
 
220
-			if (empty($row['show_online']))
221
-				$context['view_num_hidden']++;
232
+			if (empty($row['show_online'])) {
233
+							$context['view_num_hidden']++;
234
+			}
222 235
 		}
223 236
 		$context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
224 237
 		$smcFunc['db_free_result']($request);
@@ -260,8 +273,9 @@  discard block
 block discarded – undo
260 273
 	// Bring in any changes we want to make before the query.
261 274
 	call_integration_hook('integrate_pre_messageindex', array(&$sort_methods));
262 275
 
263
-	foreach ($sort_methods as $key => $val)
264
-		$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
276
+	foreach ($sort_methods as $key => $val) {
277
+			$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
278
+	}
265 279
 
266 280
 	// Calculate the fastest way to get the topics.
267 281
 	$start = (int) $_REQUEST['start'];
@@ -271,14 +285,15 @@  discard block
 block discarded – undo
271 285
 		$fake_ascending = true;
272 286
 		$context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex'];
273 287
 		$start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex'];
288
+	} else {
289
+			$fake_ascending = false;
274 290
 	}
275
-	else
276
-		$fake_ascending = false;
277 291
 
278 292
 	// Setup the default topic icons...
279 293
 	$context['icon_sources'] = array();
280
-	foreach ($context['stable_icons'] as $icon)
281
-		$context['icon_sources'][$icon] = 'images_url';
294
+	foreach ($context['stable_icons'] as $icon) {
295
+			$context['icon_sources'][$icon] = 'images_url';
296
+	}
282 297
 
283 298
 	$topic_ids = array();
284 299
 	$context['topics'] = array();
@@ -316,8 +331,9 @@  discard block
 block discarded – undo
316 331
 			$message_pre_index_parameters
317 332
 		);
318 333
 		$topic_ids = array();
319
-		while ($row = $smcFunc['db_fetch_assoc']($request))
320
-			$topic_ids[] = $row['id_topic'];
334
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
335
+					$topic_ids[] = $row['id_topic'];
336
+		}
321 337
 	}
322 338
 
323 339
 	// Grab the appropriate topic information...
@@ -375,11 +391,13 @@  discard block
 block discarded – undo
375 391
 		// Begin 'printing' the message index for current board.
376 392
 		while ($row = $smcFunc['db_fetch_assoc']($result))
377 393
 		{
378
-			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
379
-				continue;
394
+			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
395
+							continue;
396
+			}
380 397
 
381
-			if (!$pre_query)
382
-				$topic_ids[] = $row['id_topic'];
398
+			if (!$pre_query) {
399
+							$topic_ids[] = $row['id_topic'];
400
+			}
383 401
 
384 402
 			// Reference the main color class.
385 403
 			$colorClass = 'windowbg';
@@ -389,8 +407,9 @@  discard block
 block discarded – undo
389 407
 			{
390 408
 				// Limit them to $modSettings['preview_characters'] characters
391 409
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
392
-				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
393
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
410
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
411
+									$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
412
+				}
394 413
 
395 414
 				// Censor the subject and message preview.
396 415
 				censorText($row['first_subject']);
@@ -401,27 +420,27 @@  discard block
 block discarded – undo
401 420
 				{
402 421
 					$row['last_subject'] = $row['first_subject'];
403 422
 					$row['last_body'] = $row['first_body'];
404
-				}
405
-				else
423
+				} else
406 424
 				{
407 425
 					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
408
-					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
409
-						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
426
+					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
427
+											$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
428
+					}
410 429
 
411 430
 					censorText($row['last_subject']);
412 431
 					censorText($row['last_body']);
413 432
 				}
414
-			}
415
-			else
433
+			} else
416 434
 			{
417 435
 				$row['first_body'] = '';
418 436
 				$row['last_body'] = '';
419 437
 				censorText($row['first_subject']);
420 438
 
421
-				if ($row['id_first_msg'] == $row['id_last_msg'])
422
-					$row['last_subject'] = $row['first_subject'];
423
-				else
424
-					censorText($row['last_subject']);
439
+				if ($row['id_first_msg'] == $row['id_last_msg']) {
440
+									$row['last_subject'] = $row['first_subject'];
441
+				} else {
442
+									censorText($row['last_subject']);
443
+				}
425 444
 			}
426 445
 
427 446
 			// Decide how many pages the topic should have.
@@ -432,42 +451,50 @@  discard block
 block discarded – undo
432 451
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
433 452
 
434 453
 				// If we can use all, show all.
435
-				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages'])
436
-					$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
454
+				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
455
+									$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
456
+				}
457
+			} else {
458
+							$pages = '';
437 459
 			}
438
-			else
439
-				$pages = '';
440 460
 
441 461
 			// We need to check the topic icons exist...
442 462
 			if (!empty($modSettings['messageIconChecks_enable']))
443 463
 			{
444
-				if (!isset($context['icon_sources'][$row['first_icon']]))
445
-					$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
446
-				if (!isset($context['icon_sources'][$row['last_icon']]))
447
-					$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
448
-			}
449
-			else
464
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
465
+									$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
466
+				}
467
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
468
+									$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
469
+				}
470
+			} else
450 471
 			{
451
-				if (!isset($context['icon_sources'][$row['first_icon']]))
452
-					$context['icon_sources'][$row['first_icon']] = 'images_url';
453
-				if (!isset($context['icon_sources'][$row['last_icon']]))
454
-					$context['icon_sources'][$row['last_icon']] = 'images_url';
472
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
473
+									$context['icon_sources'][$row['first_icon']] = 'images_url';
474
+				}
475
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
476
+									$context['icon_sources'][$row['last_icon']] = 'images_url';
477
+				}
455 478
 			}
456 479
 
457
-			if (!empty($board_info['recycle']))
458
-				$row['first_icon'] = 'recycled';
480
+			if (!empty($board_info['recycle'])) {
481
+							$row['first_icon'] = 'recycled';
482
+			}
459 483
 
460 484
 			// Is this topic pending approval, or does it have any posts pending approval?
461
-			if ($context['can_approve_posts'] && $row['unapproved_posts'])
462
-				$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
485
+			if ($context['can_approve_posts'] && $row['unapproved_posts']) {
486
+							$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
487
+			}
463 488
 
464 489
 			// Sticky topics should get a different color, too.
465
-			if ($row['is_sticky'])
466
-				$colorClass .= ' sticky';
490
+			if ($row['is_sticky']) {
491
+							$colorClass .= ' sticky';
492
+			}
467 493
 
468 494
 			// Locked topics get special treatment as well.
469
-			if ($row['locked'])
470
-				$colorClass .= ' locked';
495
+			if ($row['locked']) {
496
+							$colorClass .= ' locked';
497
+			}
471 498
 
472 499
 			// 'Print' the topic info.
473 500
 			$context['topics'][$row['id_topic']] = array_merge($row, array(
@@ -548,8 +575,9 @@  discard block
 block discarded – undo
548 575
 		$smcFunc['db_free_result']($result);
549 576
 
550 577
 		// Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
551
-		if ($fake_ascending)
552
-			$context['topics'] = array_reverse($context['topics'], true);
578
+		if ($fake_ascending) {
579
+					$context['topics'] = array_reverse($context['topics'], true);
580
+		}
553 581
 
554 582
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids))
555 583
 		{
@@ -566,8 +594,9 @@  discard block
 block discarded – undo
566 594
 					'limit' => count($topic_ids),
567 595
 				)
568 596
 			);
569
-			while ($row = $smcFunc['db_fetch_assoc']($result))
570
-				$context['topics'][$row['id_topic']]['is_posted_in'] = true;
597
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
598
+							$context['topics'][$row['id_topic']]['is_posted_in'] = true;
599
+			}
571 600
 			$smcFunc['db_free_result']($result);
572 601
 		}
573 602
 	}
@@ -592,9 +621,9 @@  discard block
 block discarded – undo
592 621
 		// Can we restore topics?
593 622
 		$context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']);
594 623
 
595
-		if ($user_info['is_admin'] || $modSettings['topic_move_any'])
596
-			$context['can_move_any'] = true;
597
-		else
624
+		if ($user_info['is_admin'] || $modSettings['topic_move_any']) {
625
+					$context['can_move_any'] = true;
626
+		} else
598 627
 		{
599 628
 			// We'll use this in a minute
600 629
 			$boards_allowed = boardsAllowedTo('post_new');
@@ -621,11 +650,13 @@  discard block
 block discarded – undo
621 650
 		}
622 651
 
623 652
 		// Can we use quick moderation checkboxes?
624
-		if ($options['display_quick_mod'] == 1)
625
-			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
653
+		if ($options['display_quick_mod'] == 1) {
654
+					$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
655
+		}
626 656
 		// Or the icons?
627
-		else
628
-			$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
657
+		else {
658
+					$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
659
+		}
629 660
 	}
630 661
 
631 662
 	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
@@ -659,13 +690,15 @@  discard block
 block discarded – undo
659 690
 			);
660 691
 
661 692
 			// We've seen all these boards now!
662
-			foreach ($board_info['parent_boards'] as $k => $dummy)
663
-				if (isset($_SESSION['topicseen_cache'][$k]))
693
+			foreach ($board_info['parent_boards'] as $k => $dummy) {
694
+							if (isset($_SESSION['topicseen_cache'][$k]))
664 695
 					unset($_SESSION['topicseen_cache'][$k]);
696
+			}
665 697
 		}
666 698
 
667
-		if (isset($_SESSION['topicseen_cache'][$board]))
668
-			unset($_SESSION['topicseen_cache'][$board]);
699
+		if (isset($_SESSION['topicseen_cache'][$board])) {
700
+					unset($_SESSION['topicseen_cache'][$board]);
701
+		}
669 702
 
670 703
 		$request = $smcFunc['db_query']('', '
671 704
 			SELECT id_topic, id_board, sent
@@ -686,8 +719,9 @@  discard block
 block discarded – undo
686 719
 				$context['is_marked_notify'] = true;
687 720
 				$board_sent = $row['sent'];
688 721
 			}
689
-			if (!empty($row['id_topic']))
690
-				$context['topics'][$row['id_topic']]['is_watched'] = true;
722
+			if (!empty($row['id_topic'])) {
723
+							$context['topics'][$row['id_topic']]['is_watched'] = true;
724
+			}
691 725
 		}
692 726
 		$smcFunc['db_free_result']($request);
693 727
 
@@ -711,8 +745,7 @@  discard block
 block discarded – undo
711 745
 		$pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array();
712 746
 		$pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0);
713 747
 		$context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1));
714
-	}
715
-	else
748
+	} else
716 749
 	{
717 750
 		$context['is_marked_notify'] = false;
718 751
 		$context['board_notification_mode'] = 1;
@@ -725,23 +758,27 @@  discard block
 block discarded – undo
725 758
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
726 759
 
727 760
 	// Don't want to show this forever...
728
-	if ($context['becomesUnapproved'])
729
-		unset($_SESSION['becomesUnapproved']);
761
+	if ($context['becomesUnapproved']) {
762
+			unset($_SESSION['becomesUnapproved']);
763
+	}
730 764
 
731 765
 	// Build the message index button array.
732 766
 	$context['normal_buttons'] = array();
733 767
 
734
-	if ($context['can_post_new'])
735
-		$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
768
+	if ($context['can_post_new']) {
769
+			$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
770
+	}
736 771
 
737
-	if ($context['can_post_poll'])
738
-		$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
772
+	if ($context['can_post_poll']) {
773
+			$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
774
+	}
739 775
 
740
-	if (!$context['user']['is_logged'])
741
-		$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
776
+	if (!$context['user']['is_logged']) {
777
+			$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
778
+	}
742 779
 
743
-	if ($context['can_mark_notify'])
744
-		$context['normal_buttons']['notify'] = array(
780
+	if ($context['can_mark_notify']) {
781
+			$context['normal_buttons']['notify'] = array(
745 782
 			'lang' => true,
746 783
 			'text' => 'notify_board_' . $context['board_notification_mode'],
747 784
 			'sub_buttons' => array(
@@ -759,6 +796,7 @@  discard block
 block discarded – undo
759 796
 				),
760 797
 			),
761 798
 		);
799
+	}
762 800
 
763 801
 	// Javascript for inline editing.
764 802
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -780,18 +818,21 @@  discard block
 block discarded – undo
780 818
 	checkSession('request');
781 819
 
782 820
 	// Lets go straight to the restore area.
783
-	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics']))
784
-		redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
821
+	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) {
822
+			redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
823
+	}
785 824
 
786
-	if (isset($_SESSION['topicseen_cache']))
787
-		$_SESSION['topicseen_cache'] = array();
825
+	if (isset($_SESSION['topicseen_cache'])) {
826
+			$_SESSION['topicseen_cache'] = array();
827
+	}
788 828
 
789 829
 	// This is going to be needed to send off the notifications and for updateLastMessages().
790 830
 	require_once($sourcedir . '/Subs-Post.php');
791 831
 
792 832
 	// Remember the last board they moved things to.
793
-	if (isset($_REQUEST['move_to']))
794
-		$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
833
+	if (isset($_REQUEST['move_to'])) {
834
+			$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
835
+	}
795 836
 
796 837
 	// Only a few possible actions.
797 838
 	$possibleActions = array();
@@ -811,8 +852,7 @@  discard block
 block discarded – undo
811 852
 		);
812 853
 
813 854
 		$redirect_url = 'board=' . $board . '.' . $_REQUEST['start'];
814
-	}
815
-	else
855
+	} else
816 856
 	{
817 857
 		/**
818 858
 		 * @todo Ugly. There's no getting around this, is there?
@@ -830,8 +870,7 @@  discard block
 block discarded – undo
830 870
 		if (!empty($board))
831 871
 		{
832 872
 			$boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board));
833
-		}
834
-		else
873
+		} else
835 874
 		{
836 875
 			$boards_can['post_new'] = boardsAllowedTo('post_new');
837 876
 		}
@@ -842,55 +881,67 @@  discard block
 block discarded – undo
842 881
 		}
843 882
 	}
844 883
 
845
-	if (!$user_info['is_guest'])
846
-		$possibleActions[] = 'markread';
847
-	if (!empty($boards_can['make_sticky']))
848
-		$possibleActions[] = 'sticky';
849
-	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own']))
850
-		$possibleActions[] = 'move';
851
-	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own']))
852
-		$possibleActions[] = 'remove';
853
-	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own']))
854
-		$possibleActions[] = 'lock';
855
-	if (!empty($boards_can['merge_any']))
856
-		$possibleActions[] = 'merge';
857
-	if (!empty($boards_can['approve_posts']))
858
-		$possibleActions[] = 'approve';
884
+	if (!$user_info['is_guest']) {
885
+			$possibleActions[] = 'markread';
886
+	}
887
+	if (!empty($boards_can['make_sticky'])) {
888
+			$possibleActions[] = 'sticky';
889
+	}
890
+	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) {
891
+			$possibleActions[] = 'move';
892
+	}
893
+	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) {
894
+			$possibleActions[] = 'remove';
895
+	}
896
+	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) {
897
+			$possibleActions[] = 'lock';
898
+	}
899
+	if (!empty($boards_can['merge_any'])) {
900
+			$possibleActions[] = 'merge';
901
+	}
902
+	if (!empty($boards_can['approve_posts'])) {
903
+			$possibleActions[] = 'approve';
904
+	}
859 905
 
860 906
 	// Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction'].
861 907
 	// (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.)
862 908
 	if (!empty($_REQUEST['topics']))
863 909
 	{
864 910
 		// If the action isn't valid, just quit now.
865
-		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions))
866
-			redirectexit($redirect_url);
911
+		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) {
912
+					redirectexit($redirect_url);
913
+		}
867 914
 
868 915
 		// Merge requires all topics as one parameter and can be done at once.
869 916
 		if ($_REQUEST['qaction'] == 'merge')
870 917
 		{
871 918
 			// Merge requires at least two topics.
872
-			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2)
873
-				redirectexit($redirect_url);
919
+			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) {
920
+							redirectexit($redirect_url);
921
+			}
874 922
 
875 923
 			require_once($sourcedir . '/SplitTopics.php');
876 924
 			return MergeExecute($_REQUEST['topics']);
877 925
 		}
878 926
 
879 927
 		// Just convert to the other method, to make it easier.
880
-		foreach ($_REQUEST['topics'] as $topic)
881
-			$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
928
+		foreach ($_REQUEST['topics'] as $topic) {
929
+					$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
930
+		}
882 931
 	}
883 932
 
884 933
 	// Weird... how'd you get here?
885
-	if (empty($_REQUEST['actions']))
886
-		redirectexit($redirect_url);
934
+	if (empty($_REQUEST['actions'])) {
935
+			redirectexit($redirect_url);
936
+	}
887 937
 
888 938
 	// Validate each action.
889 939
 	$temp = array();
890 940
 	foreach ($_REQUEST['actions'] as $topic => $action)
891 941
 	{
892
-		if (in_array($action, $possibleActions))
893
-			$temp[(int) $topic] = $action;
942
+		if (in_array($action, $possibleActions)) {
943
+					$temp[(int) $topic] = $action;
944
+		}
894 945
 	}
895 946
 	$_REQUEST['actions'] = $temp;
896 947
 
@@ -911,27 +962,31 @@  discard block
 block discarded – undo
911 962
 		{
912 963
 			if (!empty($board))
913 964
 			{
914
-				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts')))
915
-					unset($_REQUEST['actions'][$row['id_topic']]);
916
-			}
917
-			else
965
+				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) {
966
+									unset($_REQUEST['actions'][$row['id_topic']]);
967
+				}
968
+			} else
918 969
 			{
919 970
 				// Don't allow them to act on unapproved posts they can't see...
920
-				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))
921
-					unset($_REQUEST['actions'][$row['id_topic']]);
971
+				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) {
972
+									unset($_REQUEST['actions'][$row['id_topic']]);
973
+				}
922 974
 				// Goodness, this is fun.  We need to validate the action.
923
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky']))
924
-					unset($_REQUEST['actions'][$row['id_topic']]);
925
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own']))))
926
-					unset($_REQUEST['actions'][$row['id_topic']]);
927
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own']))))
928
-					unset($_REQUEST['actions'][$row['id_topic']]);
975
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) {
976
+									unset($_REQUEST['actions'][$row['id_topic']]);
977
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) {
978
+									unset($_REQUEST['actions'][$row['id_topic']]);
979
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) {
980
+									unset($_REQUEST['actions'][$row['id_topic']]);
981
+				}
929 982
 				// @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked'])
930
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own']))))
931
-					unset($_REQUEST['actions'][$row['id_topic']]);
983
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) {
984
+									unset($_REQUEST['actions'][$row['id_topic']]);
985
+				}
932 986
 				// If the topic is approved then you need permission to approve the posts within.
933
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))))
934
-					unset($_REQUEST['actions'][$row['id_topic']]);
987
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) {
988
+									unset($_REQUEST['actions'][$row['id_topic']]);
989
+				}
935 990
 			}
936 991
 		}
937 992
 		$smcFunc['db_free_result']($request);
@@ -949,11 +1004,11 @@  discard block
 block discarded – undo
949 1004
 	{
950 1005
 		$topic = (int) $topic;
951 1006
 
952
-		if ($action == 'markread')
953
-			$markCache[] = $topic;
954
-		elseif ($action == 'sticky')
955
-			$stickyCache[] = $topic;
956
-		elseif ($action == 'move')
1007
+		if ($action == 'markread') {
1008
+					$markCache[] = $topic;
1009
+		} elseif ($action == 'sticky') {
1010
+					$stickyCache[] = $topic;
1011
+		} elseif ($action == 'move')
957 1012
 		{
958 1013
 			require_once($sourcedir . '/MoveTopic.php');
959 1014
 			moveTopicConcurrence();
@@ -961,23 +1016,25 @@  discard block
 block discarded – undo
961 1016
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
962 1017
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
963 1018
 
964
-			if (empty($moveCache[1][$topic]))
965
-				continue;
1019
+			if (empty($moveCache[1][$topic])) {
1020
+							continue;
1021
+			}
966 1022
 
967 1023
 			$moveCache[0][] = $topic;
1024
+		} elseif ($action == 'remove') {
1025
+					$removeCache[] = $topic;
1026
+		} elseif ($action == 'lock') {
1027
+					$lockCache[] = $topic;
1028
+		} elseif ($action == 'approve') {
1029
+					$approveCache[] = $topic;
968 1030
 		}
969
-		elseif ($action == 'remove')
970
-			$removeCache[] = $topic;
971
-		elseif ($action == 'lock')
972
-			$lockCache[] = $topic;
973
-		elseif ($action == 'approve')
974
-			$approveCache[] = $topic;
975 1031
 	}
976 1032
 
977
-	if (empty($board))
978
-		$affectedBoards = array();
979
-	else
980
-		$affectedBoards = array($board => array(0, 0));
1033
+	if (empty($board)) {
1034
+			$affectedBoards = array();
1035
+	} else {
1036
+			$affectedBoards = array($board => array(0, 0));
1037
+	}
981 1038
 
982 1039
 	// Do all the stickies...
983 1040
 	if (!empty($stickyCache))
@@ -1037,14 +1094,16 @@  discard block
 block discarded – undo
1037 1094
 		{
1038 1095
 			$to = $moveCache[1][$row['id_topic']];
1039 1096
 
1040
-			if (empty($to))
1041
-				continue;
1097
+			if (empty($to)) {
1098
+							continue;
1099
+			}
1042 1100
 
1043 1101
 			// Does this topic's board count the posts or not?
1044 1102
 			$countPosts[$row['id_topic']] = empty($row['count_posts']);
1045 1103
 
1046
-			if (!isset($moveTos[$to]))
1047
-				$moveTos[$to] = array();
1104
+			if (!isset($moveTos[$to])) {
1105
+							$moveTos[$to] = array();
1106
+			}
1048 1107
 
1049 1108
 			$moveTos[$to][] = $row['id_topic'];
1050 1109
 
@@ -1058,8 +1117,9 @@  discard block
 block discarded – undo
1058 1117
 		require_once($sourcedir . '/MoveTopic.php');
1059 1118
 
1060 1119
 		// Do the actual moves...
1061
-		foreach ($moveTos as $to => $topics)
1062
-			moveTopics($topics, $to);
1120
+		foreach ($moveTos as $to => $topics) {
1121
+					moveTopics($topics, $to);
1122
+		}
1063 1123
 
1064 1124
 		// Does the post counts need to be updated?
1065 1125
 		if (!empty($moveTos))
@@ -1108,20 +1168,23 @@  discard block
 block discarded – undo
1108 1168
 
1109 1169
 				while ($row = $smcFunc['db_fetch_assoc']($request))
1110 1170
 				{
1111
-					if (!isset($members[$row['id_member']]))
1112
-						$members[$row['id_member']] = 0;
1171
+					if (!isset($members[$row['id_member']])) {
1172
+											$members[$row['id_member']] = 0;
1173
+					}
1113 1174
 
1114
-					if ($topicRecounts[$row['id_topic']] === '+')
1115
-						$members[$row['id_member']] += 1;
1116
-					else
1117
-						$members[$row['id_member']] -= 1;
1175
+					if ($topicRecounts[$row['id_topic']] === '+') {
1176
+											$members[$row['id_member']] += 1;
1177
+					} else {
1178
+											$members[$row['id_member']] -= 1;
1179
+					}
1118 1180
 				}
1119 1181
 
1120 1182
 				$smcFunc['db_free_result']($request);
1121 1183
 
1122 1184
 				// And now update them member's post counts
1123
-				foreach ($members as $id_member => $post_adj)
1124
-					updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1185
+				foreach ($members as $id_member => $post_adj) {
1186
+									updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1187
+				}
1125 1188
 
1126 1189
 			}
1127 1190
 		}
@@ -1201,8 +1264,9 @@  discard block
 block discarded – undo
1201 1264
 			approveTopics($approveCache);
1202 1265
 
1203 1266
 			// Time for some logging!
1204
-			foreach ($approveCache as $topic)
1205
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1267
+			foreach ($approveCache as $topic) {
1268
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1269
+			}
1206 1270
 		}
1207 1271
 	}
1208 1272
 
@@ -1237,8 +1301,7 @@  discard block
 block discarded – undo
1237 1301
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1238 1302
 			}
1239 1303
 			$smcFunc['db_free_result']($result);
1240
-		}
1241
-		else
1304
+		} else
1242 1305
 		{
1243 1306
 			$result = $smcFunc['db_query']('', '
1244 1307
 				SELECT id_topic, locked, id_board
@@ -1288,13 +1351,15 @@  discard block
 block discarded – undo
1288 1351
 			)
1289 1352
 		);
1290 1353
 		$logged_topics = array();
1291
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1292
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1354
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1355
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1356
+		}
1293 1357
 		$smcFunc['db_free_result']($request);
1294 1358
 
1295 1359
 		$markArray = array();
1296
-		foreach ($markCache as $topic)
1297
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1360
+		foreach ($markCache as $topic) {
1361
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1362
+		}
1298 1363
 
1299 1364
 		$smcFunc['db_insert']('replace',
1300 1365
 			'{db_prefix}log_topics',
@@ -1307,8 +1372,9 @@  discard block
 block discarded – undo
1307 1372
 	foreach ($moveCache as $topic)
1308 1373
 	{
1309 1374
 		// Didn't actually move anything!
1310
-		if (!isset($topic[0]))
1311
-			break;
1375
+		if (!isset($topic[0])) {
1376
+					break;
1377
+		}
1312 1378
 
1313 1379
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1314 1380
 		sendNotifications($topic[0], 'move');
@@ -1330,8 +1396,9 @@  discard block
 block discarded – undo
1330 1396
 		'calendar_updated' => time(),
1331 1397
 	));
1332 1398
 
1333
-	if (!empty($affectedBoards))
1334
-		updateLastMessages(array_keys($affectedBoards));
1399
+	if (!empty($affectedBoards)) {
1400
+			updateLastMessages(array_keys($affectedBoards));
1401
+	}
1335 1402
 
1336 1403
 	redirectexit($redirect_url);
1337 1404
 }
Please login to merge, or discard this patch.
Sources/ManageMail.php 1 patch
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * Main dispatcher. This function checks permissions and passes control through to the relevant section.
@@ -245,8 +246,9 @@  discard block
 block discarded – undo
245 246
 	while ($row = $smcFunc['db_fetch_assoc']($request))
246 247
 	{
247 248
 		// Private PM/email subjects and similar shouldn't be shown in the mailbox area.
248
-		if (!empty($row['private']))
249
-			$row['subject'] = $txt['personal_message'];
249
+		if (!empty($row['private'])) {
250
+					$row['subject'] = $txt['personal_message'];
251
+		}
250 252
 
251 253
 		$mails[] = $row;
252 254
 	}
@@ -300,8 +302,9 @@  discard block
 block discarded – undo
300 302
 		$element = substr($key, strrpos($key, '_') + 1);
301 303
 		$processedBirthdayEmails[$index][$element] = $value;
302 304
 	}
303
-	foreach ($processedBirthdayEmails as $index => $dummy)
304
-		$emails[$index] = $index;
305
+	foreach ($processedBirthdayEmails as $index => $dummy) {
306
+			$emails[$index] = $index;
307
+	}
305 308
 
306 309
 	$config_vars = array(
307 310
 			// Mail queue stuff, this rocks ;)
@@ -322,8 +325,9 @@  discard block
 block discarded – undo
322 325
 
323 326
 	call_integration_hook('integrate_modify_mail_settings', array(&$config_vars));
324 327
 
325
-	if ($return_config)
326
-		return $config_vars;
328
+	if ($return_config) {
329
+			return $config_vars;
330
+	}
327 331
 
328 332
 	// Saving?
329 333
 	if (isset($_GET['save']))
@@ -398,9 +402,9 @@  discard block
 block discarded – undo
398 402
 		);
399 403
 		list ($_GET['te']) = $smcFunc['db_fetch_row']($request);
400 404
 		$smcFunc['db_free_result']($request);
405
+	} else {
406
+			$_GET['te'] = (int) $_GET['te'];
401 407
 	}
402
-	else
403
-		$_GET['te'] = (int) $_GET['te'];
404 408
 
405 409
 	$_GET['sent'] = isset($_GET['sent']) ? (int) $_GET['sent'] : 0;
406 410
 
@@ -424,12 +428,14 @@  discard block
 block discarded – undo
424 428
 
425 429
 	// Try get more time...
426 430
 	@set_time_limit(600);
427
-	if (function_exists('apache_reset_timeout'))
428
-		@apache_reset_timeout();
431
+	if (function_exists('apache_reset_timeout')) {
432
+			@apache_reset_timeout();
433
+	}
429 434
 
430 435
 	// Have we already used our maximum time?
431
-	if ((time() - $time_start) < 5)
432
-		return;
436
+	if ((time() - $time_start) < 5) {
437
+			return;
438
+	}
433 439
 
434 440
 	$context['continue_get_data'] = '?action=admin;area=mailqueue;sa=clear;te=' . $_GET['te'] . ';sent=' . $_GET['sent'] . ';' . $context['session_var'] . '=' . $context['session_id'];
435 441
 	$context['page_title'] = $txt['not_done_title'];
@@ -459,8 +465,9 @@  discard block
 block discarded – undo
459 465
 {
460 466
 	global $txt;
461 467
 
462
-	if ($time_diff < 0)
463
-		$time_diff = 0;
468
+	if ($time_diff < 0) {
469
+			$time_diff = 0;
470
+	}
464 471
 
465 472
 	// Just do a bit of an if fest...
466 473
 	if ($time_diff > 86400)
@@ -481,8 +488,9 @@  discard block
 block discarded – undo
481 488
 		return sprintf($minutes == 1 ? $txt['mq_minute'] : $txt['mq_minutes'], $minutes);
482 489
 	}
483 490
 	// Otherwise must be second
484
-	else
485
-		return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
486
-}
491
+	else {
492
+			return sprintf($time_diff == 1 ? $txt['mq_second'] : $txt['mq_seconds'], $time_diff);
493
+	}
494
+	}
487 495
 
488 496
 ?>
489 497
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/DbExtra-postgresql.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$table = str_replace('{db_prefix}', $db_prefix, $table);
93 93
 
94
-	$pg_tables = array('pg_catalog','information_schema');
94
+	$pg_tables = array('pg_catalog', 'information_schema');
95 95
 
96 96
 	$request = $smcFunc['db_query']('', '
97 97
 		SELECT pg_relation_size(C.oid) AS "size"
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	global $db_connection;
291 291
 	static $ver;
292 292
 
293
-	if(!empty($ver))
293
+	if (!empty($ver))
294 294
 		return $ver;
295 295
 
296 296
 	$ver = pg_version($db_connection)['server'];
Please login to merge, or discard this patch.
Braces   +37 added lines, -27 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
  * Add the functions implemented in this file to the $smcFunc array.
@@ -23,8 +24,8 @@  discard block
 block discarded – undo
23 24
 {
24 25
 	global $smcFunc;
25 26
 
26
-	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table')
27
-		$smcFunc += array(
27
+	if (!isset($smcFunc['db_backup_table']) || $smcFunc['db_backup_table'] != 'smf_db_backup_table') {
28
+			$smcFunc += array(
28 29
 			'db_backup_table' => 'smf_db_backup_table',
29 30
 			'db_optimize_table' => 'smf_db_optimize_table',
30 31
 			'db_table_sql' => 'smf_db_table_sql',
@@ -32,7 +33,8 @@  discard block
 block discarded – undo
32 33
 			'db_get_version' => 'smf_db_get_version',
33 34
 			'db_get_engine' => 'smf_db_get_engine',
34 35
 		);
35
-}
36
+	}
37
+	}
36 38
 
37 39
 /**
38 40
  * Backup $table to $backup_table.
@@ -48,13 +50,14 @@  discard block
 block discarded – undo
48 50
 
49 51
 	// Do we need to drop it first?
50 52
 	$tables = smf_db_list_tables(false, $backup_table);
51
-	if (!empty($tables))
52
-		$smcFunc['db_query']('', '
53
+	if (!empty($tables)) {
54
+			$smcFunc['db_query']('', '
53 55
 			DROP TABLE {raw:backup_table}',
54 56
 			array(
55 57
 				'backup_table' => $backup_table,
56 58
 			)
57 59
 		);
60
+	}
58 61
 
59 62
 	/**
60 63
 	 * @todo Should we create backups of sequences as well?
@@ -117,8 +120,9 @@  discard block
 block discarded – undo
117 120
 			)
118 121
 		);
119 122
 
120
-	if (!$request)
121
-		return -1;
123
+	if (!$request) {
124
+			return -1;
125
+	}
122 126
 
123 127
 	$request = $smcFunc['db_query']('', '
124 128
 		SELECT pg_relation_size(C.oid) AS "size"
@@ -136,11 +140,12 @@  discard block
 block discarded – undo
136 140
 	$row = $smcFunc['db_fetch_assoc']($request);
137 141
 	$smcFunc['db_free_result']($request);
138 142
 
139
-	if (isset($row['size']))
140
-			return ($old_size - $row['size']) / 1024;
141
-	else
142
-		return 0;
143
-}
143
+	if (isset($row['size'])) {
144
+				return ($old_size - $row['size']) / 1024;
145
+	} else {
146
+			return 0;
147
+	}
148
+	}
144 149
 
145 150
 /**
146 151
  * This function lists all tables in the database.
@@ -167,8 +172,9 @@  discard block
 block discarded – undo
167 172
 	);
168 173
 
169 174
 	$tables = array();
170
-	while ($row = $smcFunc['db_fetch_row']($request))
171
-		$tables[] = $row[0];
175
+	while ($row = $smcFunc['db_fetch_row']($request)) {
176
+			$tables[] = $row[0];
177
+	}
172 178
 	$smcFunc['db_free_result']($request);
173 179
 
174 180
 	return $tables;
@@ -209,12 +215,14 @@  discard block
 block discarded – undo
209 215
 	);
210 216
 	while ($row = $smcFunc['db_fetch_assoc']($result))
211 217
 	{
212
-		if ($row['data_type'] == 'character varying')
213
-			$row['data_type'] = 'varchar';
214
-		elseif ($row['data_type'] == 'character')
215
-			$row['data_type'] = 'char';
216
-		if ($row['character_maximum_length'])
217
-			$row['data_type'] .= '(' . $row['character_maximum_length'] . ')';
218
+		if ($row['data_type'] == 'character varying') {
219
+					$row['data_type'] = 'varchar';
220
+		} elseif ($row['data_type'] == 'character') {
221
+					$row['data_type'] = 'char';
222
+		}
223
+		if ($row['character_maximum_length']) {
224
+					$row['data_type'] .= '(' . $row['character_maximum_length'] . ')';
225
+		}
218 226
 
219 227
 		// Make the CREATE for this column.
220 228
 		$schema_create .= ' "' . $row['column_name'] . '" ' . $row['data_type'] . ($row['is_nullable'] != 'YES' ? ' NOT NULL' : '');
@@ -265,13 +273,14 @@  discard block
 block discarded – undo
265 273
 	{
266 274
 		if ($row['is_primary'])
267 275
 		{
268
-			if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0)
269
-				continue;
276
+			if (preg_match('~\(([^\)]+?)\)~i', $row['inddef'], $matches) == 0) {
277
+							continue;
278
+			}
270 279
 
271 280
 			$index_create .= $crlf . 'ALTER TABLE ' . $tableName . ' ADD PRIMARY KEY ("' . $matches[1] . '");';
281
+		} else {
282
+					$index_create .= $crlf . $row['inddef'] . ';';
272 283
 		}
273
-		else
274
-			$index_create .= $crlf . $row['inddef'] . ';';
275 284
 	}
276 285
 	$smcFunc['db_free_result']($result);
277 286
 
@@ -290,8 +299,9 @@  discard block
 block discarded – undo
290 299
 	global $db_connection;
291 300
 	static $ver;
292 301
 
293
-	if(!empty($ver))
294
-		return $ver;
302
+	if(!empty($ver)) {
303
+			return $ver;
304
+	}
295 305
 
296 306
 	$ver = pg_version($db_connection)['server'];
297 307
 
Please login to merge, or discard this patch.
Themes/default/ManageSmileys.template.php 1 patch
Braces   +55 added lines, -41 removed lines patch added patch discarded remove patch
@@ -63,18 +63,19 @@  discard block
 block discarded – undo
63 63
 					</dt>
64 64
 					<dd>
65 65
 						', $modSettings['smileys_url'], '/';
66
-		if ($context['current_set']['id'] == 'default')
67
-			echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
68
-		elseif (empty($context['smiley_set_dirs']))
69
-			echo '
66
+		if ($context['current_set']['id'] == 'default') {
67
+					echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
68
+		} elseif (empty($context['smiley_set_dirs'])) {
69
+					echo '
70 70
 						<input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '"> ';
71
-		else
71
+		} else
72 72
 		{
73 73
 			echo '
74 74
 						<select name="smiley_sets_path" id="smiley_sets_path">';
75
-			foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
76
-				echo '
75
+			foreach ($context['smiley_set_dirs'] as $smiley_set_dir) {
76
+							echo '
77 77
 							<option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
78
+			}
78 79
 			echo '
79 80
 						</select> ';
80 81
 		}
@@ -89,14 +90,15 @@  discard block
 block discarded – undo
89 90
 					</dd>';
90 91
 
91 92
 		// If this is a new smiley set they have the option to import smileys already in the directory.
92
-		if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
93
-			echo '
93
+		if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable'])) {
94
+					echo '
94 95
 					<dt>
95 96
 						<strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
96 97
 					</dt>
97 98
 					<dd>
98 99
 						<input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1">
99 100
 					</dd>';
101
+		}
100 102
 
101 103
 		echo '
102 104
 				</dl>
@@ -130,9 +132,10 @@  discard block
 block discarded – undo
130 132
 					<dd>
131 133
 						<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'], '" id="preview" alt=""> (', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();">';
132 134
 
133
-		foreach ($context['smiley_sets'] as $smiley_set)
134
-			echo '
135
+		foreach ($context['smiley_sets'] as $smiley_set) {
136
+					echo '
135 137
 						<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
138
+		}
136 139
 
137 140
 		echo '
138 141
 						</select>)
@@ -147,16 +150,17 @@  discard block
 block discarded – undo
147 150
 						<strong><label for="smiley_filename">', $txt['smileys_filename'], '</label>: </strong>
148 151
 					</dt>
149 152
 					<dd>';
150
-			if (empty($context['filenames']))
151
-				echo '
153
+			if (empty($context['filenames'])) {
154
+							echo '
152 155
 						<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '">';
153
-			else
156
+			} else
154 157
 			{
155 158
 				echo '
156 159
 						<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
157
-				foreach ($context['filenames'] as $filename)
158
-					echo '
160
+				foreach ($context['filenames'] as $filename) {
161
+									echo '
159 162
 							<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
163
+				}
160 164
 				echo '
161 165
 						</select>';
162 166
 			}
@@ -225,9 +229,10 @@  discard block
 block discarded – undo
225 229
 						<dd>
226 230
 							', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();selectMethod(\'existing\');">';
227 231
 
228
-		foreach ($context['smiley_sets'] as $smiley_set)
229
-			echo '
232
+		foreach ($context['smiley_sets'] as $smiley_set) {
233
+					echo '
230 234
 							<option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
235
+		}
231 236
 
232 237
 		echo '
233 238
 							</select>
@@ -236,16 +241,17 @@  discard block
 block discarded – undo
236 241
 							<strong><label for="smiley_filename">', $txt['smileys_filename'], '</label>: </strong>
237 242
 						</dt>
238 243
 						<dd>';
239
-	if (empty($context['filenames']))
240
-		echo '
244
+	if (empty($context['filenames'])) {
245
+			echo '
241 246
 							<input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');">';
242
-	else
247
+	} else
243 248
 	{
244 249
 		echo '
245 250
 								<select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
246
-		foreach ($context['filenames'] as $filename)
247
-			echo '
251
+		foreach ($context['filenames'] as $filename) {
252
+					echo '
248 253
 								<option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
254
+		}
249 255
 		echo '
250 256
 							</select>';
251 257
 	}
@@ -273,14 +279,15 @@  discard block
 block discarded – undo
273 279
 				</fieldset>
274 280
 
275 281
 				<dl id="uploadMore" style="display: none;" class="settings">';
276
-	foreach ($context['smiley_sets'] as $smiley_set)
277
-		echo '
282
+	foreach ($context['smiley_sets'] as $smiley_set) {
283
+			echo '
278 284
 					<dt>
279 285
 						', sprintf($txt['smileys_add_upload_for'], '<strong>' . $smiley_set['name'] . '</strong>'), ':
280 286
 					</dt>
281 287
 					<dd>
282 288
 						<input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');">
283 289
 					</dd>';
290
+	}
284 291
 	echo '
285 292
 				</dl>
286 293
 			</div>
@@ -349,24 +356,27 @@  discard block
 block discarded – undo
349 356
 				<strong>', empty($context['move_smiley']) ? $txt['smileys_move_select_smiley'] : $txt['smileys_move_select_destination'], '...</strong><br>';
350 357
 		foreach ($location['rows'] as $row)
351 358
 		{
352
-			if (!empty($context['move_smiley']))
353
-				echo '
359
+			if (!empty($context['move_smiley'])) {
360
+							echo '
354 361
 					<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
362
+			}
355 363
 
356 364
 			foreach ($row as $smiley)
357 365
 			{
358
-				if (empty($context['move_smiley']))
359
-					echo '<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px; border: 0px solid black;" alt="', $smiley['description'], '"></a>';
360
-				else
361
-					echo '<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px;', $smiley['selected'] ? ' border: 2px solid red' : '', ';" alt="', $smiley['description'], '"><a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
366
+				if (empty($context['move_smiley'])) {
367
+									echo '<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px; border: 0px solid black;" alt="', $smiley['description'], '"></a>';
368
+				} else {
369
+									echo '<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px;', $smiley['selected'] ? ' border: 2px solid red' : '', ';" alt="', $smiley['description'], '"><a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
370
+				}
362 371
 			}
363 372
 
364 373
 			echo '
365 374
 				<br>';
366 375
 		}
367
-		if (!empty($context['move_smiley']))
368
-			echo '
376
+		if (!empty($context['move_smiley'])) {
377
+					echo '
369 378
 				<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons select_below" title="', $txt['smileys_move_here'], '"></span></a>';
379
+		}
370 380
 		echo '
371 381
 			</div>
372 382
 		<input type="hidden" name="reorder" value="1">
@@ -402,14 +412,15 @@  discard block
 block discarded – undo
402 412
 			</div>
403 413
 			<div class="windowbg2">
404 414
 				<dl class="settings">';
405
-	if (!$context['new_icon'])
406
-		echo '
415
+	if (!$context['new_icon']) {
416
+			echo '
407 417
 					<dt>
408 418
 						<strong>', $txt['smiley_preview'], ': </strong>
409 419
 					</dt>
410 420
 					<dd>
411 421
 						<img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
412 422
 					</dd>';
423
+	}
413 424
 	echo '
414 425
 					<dt>
415 426
 						<strong><label for="icon_filename">', $txt['smileys_filename'], '</label>: </strong><br><span class="smalltext">', $txt['icons_filename_all_png'], '</span>
@@ -434,9 +445,10 @@  discard block
 block discarded – undo
434 445
 	{
435 446
 		echo '
436 447
 							<optgroup label="', $category['name'], '">';
437
-		foreach ($category['boards'] as $board)
438
-			echo '
448
+		foreach ($category['boards'] as $board) {
449
+					echo '
439 450
 								<option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
451
+		}
440 452
 		echo '
441 453
 							</optgroup>';
442 454
 	}
@@ -451,19 +463,21 @@  discard block
 block discarded – undo
451 463
 							<option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
452 464
 
453 465
 	// Print the list of all the icons it can be put after...
454
-	foreach ($context['icons'] as $id => $data)
455
-		if (empty($context['icon']['id']) || $id != $context['icon']['id'])
466
+	foreach ($context['icons'] as $id => $data) {
467
+			if (empty($context['icon']['id']) || $id != $context['icon']['id'])
456 468
 			echo '
457 469
 							<option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
470
+	}
458 471
 
459 472
 	echo '
460 473
 						</select>
461 474
 					</dd>
462 475
 				</dl>';
463 476
 
464
-	if (!$context['new_icon'])
465
-		echo '
477
+	if (!$context['new_icon']) {
478
+			echo '
466 479
 				<input type="hidden" name="icon" value="', $context['icon']['id'], '">';
480
+	}
467 481
 
468 482
 	echo '
469 483
 				<input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button">
Please login to merge, or discard this patch.