@@ -18,11 +18,12 @@ discard block |
||
18 | 18 | global $context, $settings, $options, $scripturl, $modSettings, $txt; |
19 | 19 | |
20 | 20 | // Let them know why their message became unapproved. |
21 | - if ($context['becomesUnapproved']) |
|
22 | - echo ' |
|
21 | + if ($context['becomesUnapproved']) { |
|
22 | + echo ' |
|
23 | 23 | <div class="noticebox"> |
24 | 24 | ', $txt['post_becomesUnapproved'], ' |
25 | 25 | </div>'; |
26 | + } |
|
26 | 27 | |
27 | 28 | if (!empty($context['boards']) && (!empty($options['show_children']) || $context['start'] == 0)) |
28 | 29 | { |
@@ -46,17 +47,19 @@ discard block |
||
46 | 47 | </a>'; |
47 | 48 | |
48 | 49 | // Has it outstanding posts for approval? |
49 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
50 | - echo ' |
|
50 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
51 | + echo ' |
|
51 | 52 | <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>'; |
53 | + } |
|
52 | 54 | |
53 | 55 | echo ' |
54 | 56 | <p class="board_description">', $board['description'], '</p>'; |
55 | 57 | |
56 | 58 | // Show the "Moderators: ". Each has name, href, link, and id. (but we're gonna use link_moderators.) |
57 | - if (!empty($board['moderators']) || !empty($board['moderator_groups'])) |
|
58 | - echo ' |
|
59 | + if (!empty($board['moderators']) || !empty($board['moderator_groups'])) { |
|
60 | + echo ' |
|
59 | 61 | <p class="moderators">', count($board['link_moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
62 | + } |
|
60 | 63 | |
61 | 64 | // Show some basic information about the number of posts, etc. |
62 | 65 | echo ' |
@@ -68,9 +71,10 @@ discard block |
||
68 | 71 | </div> |
69 | 72 | <div class="lastpost lpr_border">'; |
70 | 73 | |
71 | - if (!empty($board['last_post']['id'])) |
|
72 | - echo ' |
|
74 | + if (!empty($board['last_post']['id'])) { |
|
75 | + echo ' |
|
73 | 76 | <p>', $board['last_post']['last_post_message'], '</p>'; |
77 | + } |
|
74 | 78 | |
75 | 79 | echo ' |
76 | 80 | </div>'; |
@@ -84,14 +88,16 @@ discard block |
||
84 | 88 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
85 | 89 | foreach ($board['children'] as $child) |
86 | 90 | { |
87 | - if (!$child['is_redirect']) |
|
88 | - $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>'; |
|
89 | - else |
|
90 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
91 | + if (!$child['is_redirect']) { |
|
92 | + $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>'; |
|
93 | + } else { |
|
94 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . '">' . $child['name'] . '</a>'; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | // Has it posts awaiting approval? |
93 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) |
|
94 | - $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>'; |
|
98 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] | $child['unapproved_topics'])) { |
|
99 | + $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>'; |
|
100 | + } |
|
95 | 101 | |
96 | 102 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
97 | 103 | } |
@@ -111,8 +117,9 @@ discard block |
||
111 | 117 | } |
112 | 118 | |
113 | 119 | // They can only mark read if they are logged in and it's enabled! |
114 | - if (!$context['user']['is_logged']) |
|
115 | - unset($context['normal_buttons']['markread']); |
|
120 | + if (!$context['user']['is_logged']) { |
|
121 | + unset($context['normal_buttons']['markread']); |
|
122 | + } |
|
116 | 123 | |
117 | 124 | if (!$context['no_topic_listing']) |
118 | 125 | { |
@@ -139,13 +146,15 @@ discard block |
||
139 | 146 | <h3>', $context['name'], '</h3> |
140 | 147 | <p>'; |
141 | 148 | |
142 | - if ($context['description'] != '') |
|
143 | - echo ' |
|
149 | + if ($context['description'] != '') { |
|
150 | + echo ' |
|
144 | 151 | ', $context['description']; |
152 | + } |
|
145 | 153 | |
146 | - if (!empty($context['moderators'])) |
|
147 | - echo ' |
|
154 | + if (!empty($context['moderators'])) { |
|
155 | + echo ' |
|
148 | 156 | ', count($context['moderators']) === 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $context['link_moderators']), '.'; |
157 | + } |
|
149 | 158 | |
150 | 159 | echo ' |
151 | 160 | </p> |
@@ -153,9 +162,10 @@ discard block |
||
153 | 162 | } |
154 | 163 | |
155 | 164 | // If Quick Moderation is enabled start the form. |
156 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
157 | - echo ' |
|
165 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
166 | + echo ' |
|
158 | 167 | <form action="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" class="clear" name="quickModForm" id="quickModForm">'; |
168 | + } |
|
159 | 169 | |
160 | 170 | echo ' |
161 | 171 | <div id="messageindex">'; |
@@ -165,11 +175,11 @@ discard block |
||
165 | 175 | echo ' |
166 | 176 | <div class="information">'; |
167 | 177 | |
168 | - if ($settings['display_who_viewing'] == 1) |
|
169 | - echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
170 | - |
|
171 | - else |
|
172 | - echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
178 | + if ($settings['display_who_viewing'] == 1) { |
|
179 | + echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members']; |
|
180 | + } else { |
|
181 | + echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')'); |
|
182 | + } |
|
173 | 183 | echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_board']; |
174 | 184 | |
175 | 185 | echo ' |
@@ -189,32 +199,36 @@ discard block |
||
189 | 199 | <div class="lastpost">', $context['topics_headers']['last_post'], '</div>'; |
190 | 200 | |
191 | 201 | // Show a "select all" box for quick moderation? |
192 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
|
193 | - echo ' |
|
202 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
203 | + echo ' |
|
194 | 204 | <div class="moderation"> |
195 | 205 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');"> |
196 | 206 | </div>'; |
207 | + } |
|
197 | 208 | |
198 | 209 | // If it's on in "image" mode, don't show anything but the column. |
199 | - elseif (!empty($context['can_quick_mod'])) |
|
200 | - echo ' |
|
210 | + elseif (!empty($context['can_quick_mod'])) { |
|
211 | + echo ' |
|
201 | 212 | <div class="moderation"></div>'; |
213 | + } |
|
202 | 214 | } |
203 | 215 | |
204 | 216 | // No topics... just say, "sorry bub". |
205 | - else |
|
206 | - echo ' |
|
217 | + else { |
|
218 | + echo ' |
|
207 | 219 | <h3 class="titlebg">', $txt['topic_alert_none'], '</h3>'; |
220 | + } |
|
208 | 221 | |
209 | 222 | echo ' |
210 | 223 | </div><!-- #topic_header -->'; |
211 | 224 | |
212 | 225 | // If this person can approve items and we have some awaiting approval tell them. |
213 | - if (!empty($context['unapproved_posts_message'])) |
|
214 | - echo ' |
|
226 | + if (!empty($context['unapproved_posts_message'])) { |
|
227 | + echo ' |
|
215 | 228 | <div class="information"> |
216 | 229 | <span class="alert">!</span> ', $context['unapproved_posts_message'], ' |
217 | 230 | </div>'; |
231 | + } |
|
218 | 232 | |
219 | 233 | // Contain the topic list |
220 | 234 | echo ' |
@@ -235,25 +249,30 @@ discard block |
||
235 | 249 | echo ' |
236 | 250 | <div class="icons floatright">'; |
237 | 251 | |
238 | - if ($topic['is_watched']) |
|
239 | - echo ' |
|
252 | + if ($topic['is_watched']) { |
|
253 | + echo ' |
|
240 | 254 | <span class="generic_icons watch" title="', $txt['watching_this_topic'], '"></span>'; |
255 | + } |
|
241 | 256 | |
242 | - if ($topic['is_locked']) |
|
243 | - echo ' |
|
257 | + if ($topic['is_locked']) { |
|
258 | + echo ' |
|
244 | 259 | <span class="generic_icons lock"></span>'; |
260 | + } |
|
245 | 261 | |
246 | - if ($topic['is_sticky']) |
|
247 | - echo ' |
|
262 | + if ($topic['is_sticky']) { |
|
263 | + echo ' |
|
248 | 264 | <span class="generic_icons sticky"></span>'; |
265 | + } |
|
249 | 266 | |
250 | - if ($topic['is_redirect']) |
|
251 | - echo ' |
|
267 | + if ($topic['is_redirect']) { |
|
268 | + echo ' |
|
252 | 269 | <span class="generic_icons move"></span>'; |
270 | + } |
|
253 | 271 | |
254 | - if ($topic['is_poll']) |
|
255 | - echo ' |
|
272 | + if ($topic['is_poll']) { |
|
273 | + echo ' |
|
256 | 274 | <span class="generic_icons poll"></span>'; |
275 | + } |
|
257 | 276 | |
258 | 277 | echo ' |
259 | 278 | </div>'; |
@@ -285,26 +304,31 @@ discard block |
||
285 | 304 | echo ' |
286 | 305 | <div class="moderation">'; |
287 | 306 | |
288 | - if ($options['display_quick_mod'] == 1) |
|
289 | - echo ' |
|
307 | + if ($options['display_quick_mod'] == 1) { |
|
308 | + echo ' |
|
290 | 309 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
291 | - else |
|
310 | + } else |
|
292 | 311 | { |
293 | 312 | // Check permissions on each and show only the ones they are allowed to use. |
294 | - if ($topic['quick_mod']['remove']) |
|
295 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
313 | + if ($topic['quick_mod']['remove']) { |
|
314 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
|
315 | + } |
|
296 | 316 | |
297 | - if ($topic['quick_mod']['lock']) |
|
298 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
317 | + if ($topic['quick_mod']['lock']) { |
|
318 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
|
319 | + } |
|
299 | 320 | |
300 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
301 | - echo '<br>'; |
|
321 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
322 | + echo '<br>'; |
|
323 | + } |
|
302 | 324 | |
303 | - if ($topic['quick_mod']['sticky']) |
|
304 | - echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
325 | + if ($topic['quick_mod']['sticky']) { |
|
326 | + echo '<a href="', $scripturl, '?action=quickmod;board=', $context['current_board'], '.', $context['start'], ';actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
|
327 | + } |
|
305 | 328 | |
306 | - if ($topic['quick_mod']['move']) |
|
307 | - echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
329 | + if ($topic['quick_mod']['move']) { |
|
330 | + echo '<a href="', $scripturl, '?action=movetopic;current_board=', $context['current_board'], ';board=', $context['current_board'], '.', $context['start'], ';topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
|
331 | + } |
|
308 | 332 | } |
309 | 333 | echo ' |
310 | 334 | </div><!-- .moderation -->'; |
@@ -322,18 +346,20 @@ discard block |
||
322 | 346 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
323 | 347 | <option value="">--------</option>'; |
324 | 348 | |
325 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
326 | - if ($context['can_' . $qmod_action]) |
|
349 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
350 | + if ($context['can_' . $qmod_action]) |
|
327 | 351 | echo ' |
328 | 352 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
353 | + } |
|
329 | 354 | |
330 | 355 | echo ' |
331 | 356 | </select>'; |
332 | 357 | |
333 | 358 | // Show a list of boards they can move the topic to. |
334 | - if ($context['can_move']) |
|
335 | - echo ' |
|
359 | + if ($context['can_move']) { |
|
360 | + echo ' |
|
336 | 361 | <span id="quick_mod_jump_to"></span>'; |
362 | + } |
|
337 | 363 | |
338 | 364 | echo ' |
339 | 365 | <input type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.quickModForm.qaction.value != \'\' && confirm(\'', $txt['quickmod_confirm'], '\');" class="button qaction"> |
@@ -344,10 +370,11 @@ discard block |
||
344 | 370 | </div><!-- #messageindex -->'; |
345 | 371 | |
346 | 372 | // Finish off the form - again. |
347 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) |
|
348 | - echo ' |
|
373 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] > 0 && !empty($context['topics'])) { |
|
374 | + echo ' |
|
349 | 375 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
350 | 376 | </form>'; |
377 | + } |
|
351 | 378 | |
352 | 379 | // Mobile action buttons (bottom) |
353 | 380 | echo ' |
@@ -369,8 +396,8 @@ discard block |
||
369 | 396 | // Show breadcrumbs at the bottom too. |
370 | 397 | theme_linktree(); |
371 | 398 | |
372 | - if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
373 | - echo ' |
|
399 | + if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
400 | + echo ' |
|
374 | 401 | <script> |
375 | 402 | if (typeof(window.XMLHttpRequest) != "undefined") |
376 | 403 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -389,6 +416,7 @@ discard block |
||
389 | 416 | sCustomName: "move_to" |
390 | 417 | }); |
391 | 418 | </script>'; |
419 | + } |
|
392 | 420 | |
393 | 421 | // Javascript for inline editing. |
394 | 422 | echo ' |
@@ -425,8 +453,8 @@ discard block |
||
425 | 453 | <div class="information"> |
426 | 454 | <p class="floatright" id="message_index_jump_to"></p>'; |
427 | 455 | |
428 | - if (empty($context['no_topic_listing'])) |
|
429 | - echo ' |
|
456 | + if (empty($context['no_topic_listing'])) { |
|
457 | + echo ' |
|
430 | 458 | <p class="floatleft">', !empty($modSettings['enableParticipation']) && $context['user']['is_logged'] ? ' |
431 | 459 | <img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="" class="centericon"> ' . $txt['participation_caption'] . '<br>' : '', ' |
432 | 460 | '. ($modSettings['pollMode'] == '1' ? '<span class="generic_icons poll centericon"></span> ' . $txt['poll'] : '') . '<br> |
@@ -436,9 +464,10 @@ discard block |
||
436 | 464 | <span class="generic_icons lock centericon"></span> ' . $txt['locked_topic'] . '<br> |
437 | 465 | <span class="generic_icons sticky centericon"></span> ' . $txt['sticky_topic'] . '<br> |
438 | 466 | </p>'; |
467 | + } |
|
439 | 468 | |
440 | - if (!empty($context['jump_to'])) |
|
441 | - echo ' |
|
469 | + if (!empty($context['jump_to'])) { |
|
470 | + echo ' |
|
442 | 471 | <script> |
443 | 472 | if (typeof(window.XMLHttpRequest) != "undefined") |
444 | 473 | aJumpTo[aJumpTo.length] = new JumpTo({ |
@@ -454,6 +483,7 @@ discard block |
||
454 | 483 | sGoButtonLabel: "', $txt['quick_mod_go'], '" |
455 | 484 | }); |
456 | 485 | </script>'; |
486 | + } |
|
457 | 487 | |
458 | 488 | echo ' |
459 | 489 | <br class="clear"> |
@@ -40,9 +40,10 @@ discard block |
||
40 | 40 | <option value="0000"', $context['holiday']['year'] == '0000' ? ' selected' : '', '>', $txt['every_year'], '</option>'; |
41 | 41 | |
42 | 42 | // Show a list of all the years we allow... |
43 | - for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) |
|
44 | - echo ' |
|
43 | + for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++) { |
|
44 | + echo ' |
|
45 | 45 | <option value="', $year, '"', $year == $context['holiday']['year'] ? ' selected' : '', '>', $year, '</option>'; |
46 | + } |
|
46 | 47 | |
47 | 48 | echo ' |
48 | 49 | </select> |
@@ -50,9 +51,10 @@ discard block |
||
50 | 51 | <select name="month" id="month" onchange="generateDays();">'; |
51 | 52 | |
52 | 53 | // There are 12 months per year - ensure that they all get listed. |
53 | - for ($month = 1; $month <= 12; $month++) |
|
54 | - echo ' |
|
54 | + for ($month = 1; $month <= 12; $month++) { |
|
55 | + echo ' |
|
55 | 56 | <option value="', $month, '"', $month == $context['holiday']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
57 | + } |
|
56 | 58 | |
57 | 59 | echo ' |
58 | 60 | </select> |
@@ -60,23 +62,25 @@ discard block |
||
60 | 62 | <select name="day" id="day" onchange="generateDays();">'; |
61 | 63 | |
62 | 64 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
63 | - for ($day = 1; $day <= $context['holiday']['last_day']; $day++) |
|
64 | - echo ' |
|
65 | + for ($day = 1; $day <= $context['holiday']['last_day']; $day++) { |
|
66 | + echo ' |
|
65 | 67 | <option value="', $day, '"', $day == $context['holiday']['day'] ? ' selected' : '', '>', $day, '</option>'; |
68 | + } |
|
66 | 69 | |
67 | 70 | echo ' |
68 | 71 | </select> |
69 | 72 | </dd> |
70 | 73 | </dl>'; |
71 | 74 | |
72 | - if ($context['is_new']) |
|
73 | - echo ' |
|
75 | + if ($context['is_new']) { |
|
76 | + echo ' |
|
74 | 77 | <input type="submit" value="', $txt['holidays_button_add'], '" class="button">'; |
75 | - else |
|
76 | - echo ' |
|
78 | + } else { |
|
79 | + echo ' |
|
77 | 80 | <input type="submit" name="edit" value="', $txt['holidays_button_edit'], '" class="button"> |
78 | 81 | <input type="submit" name="delete" value="', $txt['holidays_button_remove'], '" class="button"> |
79 | 82 | <input type="hidden" name="holiday" value="', $context['holiday']['id'], '">'; |
83 | + } |
|
80 | 84 | echo ' |
81 | 85 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
82 | 86 | </div><!-- .windowbg2 --> |
@@ -24,11 +24,12 @@ discard block |
||
24 | 24 | <h3 class="catbg">', $txt['paid_' . $context['action_type'] . '_subscription'], '</h3> |
25 | 25 | </div>'; |
26 | 26 | |
27 | - if (!empty($context['disable_groups'])) |
|
28 | - echo ' |
|
27 | + if (!empty($context['disable_groups'])) { |
|
28 | + echo ' |
|
29 | 29 | <div class="information"> |
30 | 30 | <span class="alert">', $txt['paid_mod_edit_note'], '</span> |
31 | 31 | </div>'; |
32 | + } |
|
32 | 33 | |
33 | 34 | echo ' |
34 | 35 | <div class="windowbg2"> |
@@ -69,9 +70,10 @@ discard block |
||
69 | 70 | <option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>'; |
70 | 71 | |
71 | 72 | // Put each group into the box. |
72 | - foreach ($context['groups'] as $id => $name) |
|
73 | - echo ' |
|
73 | + foreach ($context['groups'] as $id => $name) { |
|
74 | + echo ' |
|
74 | 75 | <option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>'; |
76 | + } |
|
75 | 77 | |
76 | 78 | echo ' |
77 | 79 | </select> |
@@ -83,12 +85,13 @@ discard block |
||
83 | 85 | <dd>'; |
84 | 86 | |
85 | 87 | // Put a checkbox in for each group |
86 | - foreach ($context['groups'] as $id => $name) |
|
87 | - echo ' |
|
88 | + foreach ($context['groups'] as $id => $name) { |
|
89 | + echo ' |
|
88 | 90 | <label for="addgroup_', $id, '"> |
89 | 91 | <input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '> |
90 | 92 | <span class="smalltext">', $name, '</span> |
91 | 93 | </label><br>'; |
94 | + } |
|
92 | 95 | |
93 | 96 | echo ' |
94 | 97 | </dd> |
@@ -142,8 +145,8 @@ discard block |
||
142 | 145 | <fieldset>'; |
143 | 146 | |
144 | 147 | //!! Removed until implemented |
145 | - if (!empty($sdflsdhglsdjgs)) |
|
146 | - echo ' |
|
148 | + if (!empty($sdflsdhglsdjgs)) { |
|
149 | + echo ' |
|
147 | 150 | <dl class="settings"> |
148 | 151 | <dt> |
149 | 152 | <label for="allow_partial_check">', $txt['paid_mod_allow_partial'], '</label>:<br><span class="smalltext">', $txt['paid_mod_allow_partial_desc'], '</span> |
@@ -152,6 +155,7 @@ discard block |
||
152 | 155 | <input type="checkbox" name="allow_partial" id="allow_partial_check"', empty($context['sub']['allow_partial']) ? '' : ' checked', '> |
153 | 156 | </dd> |
154 | 157 | </dl>'; |
158 | + } |
|
155 | 159 | |
156 | 160 | echo ' |
157 | 161 | <div class="information"> |
@@ -250,8 +254,8 @@ discard block |
||
250 | 254 | <dl class="settings">'; |
251 | 255 | |
252 | 256 | // Do we need a username? |
253 | - if ($context['action_type'] == 'add') |
|
254 | - echo ' |
|
257 | + if ($context['action_type'] == 'add') { |
|
258 | + echo ' |
|
255 | 259 | <dt> |
256 | 260 | <strong>', $txt['paid_username'], ':</strong><br> |
257 | 261 | <span class="smalltext">', $txt['one_username'], '</span> |
@@ -259,6 +263,7 @@ discard block |
||
259 | 263 | <dd> |
260 | 264 | <input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30"> |
261 | 265 | </dd>'; |
266 | + } |
|
262 | 267 | |
263 | 268 | echo ' |
264 | 269 | <dt> |
@@ -276,9 +281,10 @@ discard block |
||
276 | 281 | <select name="year" id="year" onchange="generateDays();">'; |
277 | 282 | |
278 | 283 | // Show a list of all the years we allow... |
279 | - for ($year = 2005; $year <= 2030; $year++) |
|
280 | - echo ' |
|
284 | + for ($year = 2005; $year <= 2030; $year++) { |
|
285 | + echo ' |
|
281 | 286 | <option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>'; |
287 | + } |
|
282 | 288 | |
283 | 289 | echo ' |
284 | 290 | </select> |
@@ -286,9 +292,10 @@ discard block |
||
286 | 292 | <select name="month" id="month" onchange="generateDays();">'; |
287 | 293 | |
288 | 294 | // There are 12 months per year - ensure that they all get listed. |
289 | - for ($month = 1; $month <= 12; $month++) |
|
290 | - echo ' |
|
295 | + for ($month = 1; $month <= 12; $month++) { |
|
296 | + echo ' |
|
291 | 297 | <option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
298 | + } |
|
292 | 299 | |
293 | 300 | echo ' |
294 | 301 | </select> |
@@ -296,9 +303,10 @@ discard block |
||
296 | 303 | <select name="day" id="day">'; |
297 | 304 | |
298 | 305 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
299 | - for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) |
|
300 | - echo ' |
|
306 | + for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) { |
|
307 | + echo ' |
|
301 | 308 | <option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>'; |
309 | + } |
|
302 | 310 | |
303 | 311 | echo ' |
304 | 312 | </select> |
@@ -310,9 +318,10 @@ discard block |
||
310 | 318 | <select name="yearend" id="yearend" onchange="generateDays(\'end\');">'; |
311 | 319 | |
312 | 320 | // Show a list of all the years we allow... |
313 | - for ($year = 2005; $year <= 2030; $year++) |
|
314 | - echo ' |
|
321 | + for ($year = 2005; $year <= 2030; $year++) { |
|
322 | + echo ' |
|
315 | 323 | <option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>'; |
324 | + } |
|
316 | 325 | |
317 | 326 | echo ' |
318 | 327 | </select> |
@@ -320,9 +329,10 @@ discard block |
||
320 | 329 | <select name="monthend" id="monthend" onchange="generateDays(\'end\');">'; |
321 | 330 | |
322 | 331 | // There are 12 months per year - ensure that they all get listed. |
323 | - for ($month = 1; $month <= 12; $month++) |
|
324 | - echo ' |
|
332 | + for ($month = 1; $month <= 12; $month++) { |
|
333 | + echo ' |
|
325 | 334 | <option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>'; |
335 | + } |
|
326 | 336 | |
327 | 337 | echo ' |
328 | 338 | </select> |
@@ -330,9 +340,10 @@ discard block |
||
330 | 340 | <select name="dayend" id="dayend">'; |
331 | 341 | |
332 | 342 | // This prints out all the days in the current month - this changes dynamically as we switch months. |
333 | - for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) |
|
334 | - echo ' |
|
343 | + for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) { |
|
344 | + echo ' |
|
335 | 345 | <option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>'; |
346 | + } |
|
336 | 347 | |
337 | 348 | echo ' |
338 | 349 | </select> |
@@ -371,8 +382,8 @@ discard block |
||
371 | 382 | <div class="windowbg"> |
372 | 383 | <ul>'; |
373 | 384 | |
374 | - foreach ($context['pending_payments'] as $id => $payment) |
|
375 | - echo ' |
|
385 | + foreach ($context['pending_payments'] as $id => $payment) { |
|
386 | + echo ' |
|
376 | 387 | <li> |
377 | 388 | ', $payment['desc'], ' |
378 | 389 | <span class="floatleft"> |
@@ -382,6 +393,7 @@ discard block |
||
382 | 393 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a> |
383 | 394 | </span> |
384 | 395 | </li>'; |
396 | + } |
|
385 | 397 | |
386 | 398 | echo ' |
387 | 399 | </ul> |
@@ -406,12 +418,12 @@ discard block |
||
406 | 418 | <h3 class="catbg">', $txt['subscriptions'], '</h3> |
407 | 419 | </div>'; |
408 | 420 | |
409 | - if (empty($context['subscriptions'])) |
|
410 | - echo ' |
|
421 | + if (empty($context['subscriptions'])) { |
|
422 | + echo ' |
|
411 | 423 | <div class="information"> |
412 | 424 | ', $txt['paid_subs_none'], ' |
413 | 425 | </div>'; |
414 | - else |
|
426 | + } else |
|
415 | 427 | { |
416 | 428 | echo ' |
417 | 429 | <div class="information"> |
@@ -423,8 +435,9 @@ discard block |
||
423 | 435 | { |
424 | 436 | |
425 | 437 | // Ignore the inactive ones... |
426 | - if (empty($subscription['active'])) |
|
427 | - continue; |
|
438 | + if (empty($subscription['active'])) { |
|
439 | + continue; |
|
440 | + } |
|
428 | 441 | |
429 | 442 | echo ' |
430 | 443 | <div class="cat_bar"> |
@@ -434,9 +447,10 @@ discard block |
||
434 | 447 | <p><strong>', $subscription['name'], '</strong></p> |
435 | 448 | <p class="smalltext">', $subscription['desc'], '</p>'; |
436 | 449 | |
437 | - if (!$subscription['flexible']) |
|
438 | - echo ' |
|
450 | + if (!$subscription['flexible']) { |
|
451 | + echo ' |
|
439 | 452 | <div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>'; |
453 | + } |
|
440 | 454 | |
441 | 455 | if ($context['user']['is_owner']) |
442 | 456 | { |
@@ -449,24 +463,25 @@ discard block |
||
449 | 463 | <select name="cur[', $subscription['id'], ']">'; |
450 | 464 | |
451 | 465 | // Print out the costs for this one. |
452 | - foreach ($subscription['costs'] as $duration => $value) |
|
453 | - echo ' |
|
466 | + foreach ($subscription['costs'] as $duration => $value) { |
|
467 | + echo ' |
|
454 | 468 | <option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>'; |
469 | + } |
|
455 | 470 | |
456 | 471 | echo ' |
457 | 472 | </select>'; |
458 | - } |
|
459 | - else |
|
460 | - echo ' |
|
473 | + } else { |
|
474 | + echo ' |
|
461 | 475 | ', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']); |
476 | + } |
|
462 | 477 | |
463 | 478 | echo ' |
464 | 479 | <hr> |
465 | 480 | <input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">'; |
466 | - } |
|
467 | - else |
|
468 | - echo ' |
|
481 | + } else { |
|
482 | + echo ' |
|
469 | 483 | <a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>'; |
484 | + } |
|
470 | 485 | |
471 | 486 | echo ' |
472 | 487 | </div><!-- .windowbg -->'; |
@@ -493,19 +508,20 @@ discard block |
||
493 | 508 | </thead> |
494 | 509 | <tbody>'; |
495 | 510 | |
496 | - if (empty($context['current'])) |
|
497 | - echo ' |
|
511 | + if (empty($context['current'])) { |
|
512 | + echo ' |
|
498 | 513 | <tr class="windowbg"> |
499 | 514 | <td colspan="4"> |
500 | 515 | ', $txt['paid_none_yet'], ' |
501 | 516 | </td> |
502 | 517 | </tr>'; |
518 | + } |
|
503 | 519 | |
504 | 520 | foreach ($context['current'] as $sub) |
505 | 521 | { |
506 | 522 | |
507 | - if (!$sub['hide']) |
|
508 | - echo ' |
|
523 | + if (!$sub['hide']) { |
|
524 | + echo ' |
|
509 | 525 | <tr class="windowbg"> |
510 | 526 | <td> |
511 | 527 | ', (allowedTo('admin_forum') ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), ' |
@@ -516,6 +532,7 @@ discard block |
||
516 | 532 | <td>', $sub['start'], '</td> |
517 | 533 | <td>', $sub['end'], '</td> |
518 | 534 | </tr>'; |
535 | + } |
|
519 | 536 | } |
520 | 537 | |
521 | 538 | echo ' |
@@ -567,15 +584,17 @@ discard block |
||
567 | 584 | ', $gateway['desc'], '<br> |
568 | 585 | <form action="', $gateway['form'], '" method="post">'; |
569 | 586 | |
570 | - if (!empty($gateway['javascript'])) |
|
571 | - echo ' |
|
587 | + if (!empty($gateway['javascript'])) { |
|
588 | + echo ' |
|
572 | 589 | <script> |
573 | 590 | ', $gateway['javascript'], ' |
574 | 591 | </script>'; |
592 | + } |
|
575 | 593 | |
576 | - foreach ($gateway['hidden'] as $name => $value) |
|
577 | - echo ' |
|
594 | + foreach ($gateway['hidden'] as $name => $value) { |
|
595 | + echo ' |
|
578 | 596 | <input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">'; |
597 | + } |
|
579 | 598 | |
580 | 599 | echo ' |
581 | 600 | <br> |
@@ -65,9 +65,10 @@ discard block |
||
65 | 65 | ', implode(', ', $context['administrators']); |
66 | 66 | |
67 | 67 | // If we have lots of admins... don't show them all. |
68 | - if (!empty($context['more_admins_link'])) |
|
69 | - echo ' |
|
68 | + if (!empty($context['more_admins_link'])) { |
|
69 | + echo ' |
|
70 | 70 | (', $context['more_admins_link'], ')'; |
71 | + } |
|
71 | 72 | |
72 | 73 | echo ' |
73 | 74 | </div><!-- #version_details --> |
@@ -84,17 +85,19 @@ discard block |
||
84 | 85 | foreach ($area['areas'] as $item_id => $item) |
85 | 86 | { |
86 | 87 | // No point showing the 'home' page here, we're already on it! |
87 | - if ($area_id == 'forum' && $item_id == 'index') |
|
88 | - continue; |
|
88 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
89 | + continue; |
|
90 | + } |
|
89 | 91 | |
90 | 92 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
91 | 93 | |
92 | - if (!empty($item['icon_file'])) |
|
93 | - echo ' |
|
94 | + if (!empty($item['icon_file'])) { |
|
95 | + echo ' |
|
94 | 96 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
95 | - else |
|
96 | - echo ' |
|
97 | + } else { |
|
98 | + echo ' |
|
97 | 99 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
100 | + } |
|
98 | 101 | } |
99 | 102 | |
100 | 103 | echo ' |
@@ -105,10 +108,11 @@ discard block |
||
105 | 108 | </div><!-- #admincenter -->'; |
106 | 109 | |
107 | 110 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
108 | - if (empty($modSettings['disable_smf_js'])) |
|
109 | - echo ' |
|
111 | + if (empty($modSettings['disable_smf_js'])) { |
|
112 | + echo ' |
|
110 | 113 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
111 | 114 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
115 | + } |
|
112 | 116 | |
113 | 117 | // This sets the announcements and current versions themselves ;). |
114 | 118 | echo ' |
@@ -187,9 +191,10 @@ discard block |
||
187 | 191 | <em>', $version['version'], '</em>'; |
188 | 192 | |
189 | 193 | // more details for this item, show them a link |
190 | - if ($context['can_admin'] && isset($version['more'])) |
|
191 | - echo |
|
194 | + if ($context['can_admin'] && isset($version['more'])) { |
|
195 | + echo |
|
192 | 196 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
197 | + } |
|
193 | 198 | echo ' |
194 | 199 | <br>'; |
195 | 200 | } |
@@ -220,21 +225,23 @@ discard block |
||
220 | 225 | |
221 | 226 | foreach ($context['credits'] as $section) |
222 | 227 | { |
223 | - if (isset($section['pretext'])) |
|
224 | - echo ' |
|
228 | + if (isset($section['pretext'])) { |
|
229 | + echo ' |
|
225 | 230 | <p>', $section['pretext'], '</p> |
226 | 231 | <hr>'; |
232 | + } |
|
227 | 233 | |
228 | 234 | echo ' |
229 | 235 | <dl>'; |
230 | 236 | |
231 | 237 | foreach ($section['groups'] as $group) |
232 | 238 | { |
233 | - if (isset($group['title'])) |
|
234 | - echo ' |
|
239 | + if (isset($group['title'])) { |
|
240 | + echo ' |
|
235 | 241 | <dt> |
236 | 242 | <strong>', $group['title'], ':</strong> |
237 | 243 | </dt>'; |
244 | + } |
|
238 | 245 | |
239 | 246 | echo ' |
240 | 247 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -243,10 +250,11 @@ discard block |
||
243 | 250 | echo ' |
244 | 251 | </dl>'; |
245 | 252 | |
246 | - if (isset($section['posttext'])) |
|
247 | - echo ' |
|
253 | + if (isset($section['posttext'])) { |
|
254 | + echo ' |
|
248 | 255 | <hr> |
249 | 256 | <p>', $section['posttext'], '</p>'; |
257 | + } |
|
250 | 258 | } |
251 | 259 | |
252 | 260 | echo ' |
@@ -262,9 +270,10 @@ discard block |
||
262 | 270 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
263 | 271 | |
264 | 272 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
265 | - foreach ($context['current_versions'] as $variable => $version) |
|
266 | - echo ' |
|
273 | + foreach ($context['current_versions'] as $variable => $version) { |
|
274 | + echo ' |
|
267 | 275 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
276 | + } |
|
268 | 277 | |
269 | 278 | // Now we just have to include the script and wait ;). |
270 | 279 | echo ' |
@@ -361,8 +370,8 @@ discard block |
||
361 | 370 | <tbody>'; |
362 | 371 | |
363 | 372 | // Loop through every source file displaying its version - using javascript. |
364 | - foreach ($context['file_versions'] as $filename => $version) |
|
365 | - echo ' |
|
373 | + foreach ($context['file_versions'] as $filename => $version) { |
|
374 | + echo ' |
|
366 | 375 | <tr class="windowbg"> |
367 | 376 | <td class="half_table"> |
368 | 377 | ', $filename, ' |
@@ -374,6 +383,7 @@ discard block |
||
374 | 383 | <em id="currentSources', $filename, '">??</em> |
375 | 384 | </td> |
376 | 385 | </tr>'; |
386 | + } |
|
377 | 387 | |
378 | 388 | // Default template files. |
379 | 389 | echo ' |
@@ -399,8 +409,8 @@ discard block |
||
399 | 409 | <table id="Default" class="table_grid"> |
400 | 410 | <tbody>'; |
401 | 411 | |
402 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
403 | - echo ' |
|
412 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
413 | + echo ' |
|
404 | 414 | <tr class="windowbg"> |
405 | 415 | <td class="half_table"> |
406 | 416 | ', $filename, ' |
@@ -412,6 +422,7 @@ discard block |
||
412 | 422 | <em id="currentDefault', $filename, '">??</em> |
413 | 423 | </td> |
414 | 424 | </tr>'; |
425 | + } |
|
415 | 426 | |
416 | 427 | // Now the language files... |
417 | 428 | echo ' |
@@ -439,8 +450,8 @@ discard block |
||
439 | 450 | |
440 | 451 | foreach ($context['default_language_versions'] as $language => $files) |
441 | 452 | { |
442 | - foreach ($files as $filename => $version) |
|
443 | - echo ' |
|
453 | + foreach ($files as $filename => $version) { |
|
454 | + echo ' |
|
444 | 455 | <tr class="windowbg"> |
445 | 456 | <td class="half_table"> |
446 | 457 | ', $filename, '.<em>', $language, '</em>.php |
@@ -452,6 +463,7 @@ discard block |
||
452 | 463 | <em id="current', $filename, '.', $language, '">??</em> |
453 | 464 | </td> |
454 | 465 | </tr>'; |
466 | + } |
|
455 | 467 | } |
456 | 468 | |
457 | 469 | echo ' |
@@ -481,8 +493,8 @@ discard block |
||
481 | 493 | <table id="Templates" class="table_grid"> |
482 | 494 | <tbody>'; |
483 | 495 | |
484 | - foreach ($context['template_versions'] as $filename => $version) |
|
485 | - echo ' |
|
496 | + foreach ($context['template_versions'] as $filename => $version) { |
|
497 | + echo ' |
|
486 | 498 | <tr class="windowbg"> |
487 | 499 | <td class="half_table"> |
488 | 500 | ', $filename, ' |
@@ -494,6 +506,7 @@ discard block |
||
494 | 506 | <em id="currentTemplates', $filename, '">??</em> |
495 | 507 | </td> |
496 | 508 | </tr>'; |
509 | + } |
|
497 | 510 | |
498 | 511 | echo ' |
499 | 512 | </tbody> |
@@ -523,8 +536,8 @@ discard block |
||
523 | 536 | <table id="Tasks" class="table_grid"> |
524 | 537 | <tbody>'; |
525 | 538 | |
526 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
527 | - echo ' |
|
539 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
540 | + echo ' |
|
528 | 541 | <tr class="windowbg"> |
529 | 542 | <td class="half_table"> |
530 | 543 | ', $filename, ' |
@@ -536,6 +549,7 @@ discard block |
||
536 | 549 | <em id="currentTasks', $filename, '">??</em> |
537 | 550 | </td> |
538 | 551 | </tr>'; |
552 | + } |
|
539 | 553 | |
540 | 554 | echo ' |
541 | 555 | </tbody> |
@@ -577,9 +591,10 @@ discard block |
||
577 | 591 | { |
578 | 592 | global $context, $scripturl, $txt, $modSettings; |
579 | 593 | |
580 | - if (!empty($context['saved_successful'])) |
|
581 | - echo ' |
|
594 | + if (!empty($context['saved_successful'])) { |
|
595 | + echo ' |
|
582 | 596 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
597 | + } |
|
583 | 598 | |
584 | 599 | // First section is for adding/removing words from the censored list. |
585 | 600 | echo ' |
@@ -594,11 +609,12 @@ discard block |
||
594 | 609 | <p>', $txt['admin_censored_where'], '</p>'; |
595 | 610 | |
596 | 611 | // Show text boxes for censoring [bad ] => [good ]. |
597 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
598 | - echo ' |
|
612 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
613 | + echo ' |
|
599 | 614 | <div class="block"> |
600 | 615 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
601 | 616 | </div>'; |
617 | + } |
|
602 | 618 | |
603 | 619 | // Now provide a way to censor more words. |
604 | 620 | echo ' |
@@ -673,19 +689,21 @@ discard block |
||
673 | 689 | <div class="windowbg2 noup"> |
674 | 690 | ', $txt['not_done_reason']; |
675 | 691 | |
676 | - if (!empty($context['continue_percent'])) |
|
677 | - echo ' |
|
692 | + if (!empty($context['continue_percent'])) { |
|
693 | + echo ' |
|
678 | 694 | <div class="progress_bar"> |
679 | 695 | <div class="full_bar">', $context['continue_percent'], '%</div> |
680 | 696 | <div class="green_percent" style="width: ', $context['continue_percent'], '%;"></div> |
681 | 697 | </div>'; |
698 | + } |
|
682 | 699 | |
683 | - if (!empty($context['substep_enabled'])) |
|
684 | - echo ' |
|
700 | + if (!empty($context['substep_enabled'])) { |
|
701 | + echo ' |
|
685 | 702 | <div class="progress_bar"> |
686 | 703 | <div class="full_bar">', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</div> |
687 | 704 | <div class="blue_percent" style="width: ', $context['substep_continue_percent'], '%;"></div> |
688 | 705 | </div>'; |
706 | + } |
|
689 | 707 | |
690 | 708 | echo ' |
691 | 709 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit"> |
@@ -720,35 +738,40 @@ discard block |
||
720 | 738 | { |
721 | 739 | global $context, $txt, $scripturl; |
722 | 740 | |
723 | - if (!empty($context['saved_successful'])) |
|
724 | - echo ' |
|
741 | + if (!empty($context['saved_successful'])) { |
|
742 | + echo ' |
|
725 | 743 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
726 | - elseif (!empty($context['saved_failed'])) |
|
727 | - echo ' |
|
744 | + } elseif (!empty($context['saved_failed'])) { |
|
745 | + echo ' |
|
728 | 746 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
747 | + } |
|
729 | 748 | |
730 | - if (!empty($context['settings_pre_javascript'])) |
|
731 | - echo ' |
|
749 | + if (!empty($context['settings_pre_javascript'])) { |
|
750 | + echo ' |
|
732 | 751 | <script>', $context['settings_pre_javascript'], '</script>'; |
752 | + } |
|
733 | 753 | |
734 | - if (!empty($context['settings_insert_above'])) |
|
735 | - echo $context['settings_insert_above']; |
|
754 | + if (!empty($context['settings_insert_above'])) { |
|
755 | + echo $context['settings_insert_above']; |
|
756 | + } |
|
736 | 757 | |
737 | 758 | echo ' |
738 | 759 | <div id="admincenter"> |
739 | 760 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
740 | 761 | |
741 | 762 | // Is there a custom title? |
742 | - if (isset($context['settings_title'])) |
|
743 | - echo ' |
|
763 | + if (isset($context['settings_title'])) { |
|
764 | + echo ' |
|
744 | 765 | <div class="cat_bar"> |
745 | 766 | <h3 class="catbg">', $context['settings_title'], '</h3> |
746 | 767 | </div>'; |
768 | + } |
|
747 | 769 | |
748 | 770 | // Have we got a message to display? |
749 | - if (!empty($context['settings_message'])) |
|
750 | - echo ' |
|
771 | + if (!empty($context['settings_message'])) { |
|
772 | + echo ' |
|
751 | 773 | <div class="information">', $context['settings_message'], '</div>'; |
774 | + } |
|
752 | 775 | |
753 | 776 | // Now actually loop through all the variables. |
754 | 777 | $is_open = false; |
@@ -801,8 +824,9 @@ discard block |
||
801 | 824 | // Hang about? Are you pulling my leg - a callback?! |
802 | 825 | if (is_array($config_var) && $config_var['type'] == 'callback') |
803 | 826 | { |
804 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
805 | - call_user_func('template_callback_' . $config_var['name']); |
|
827 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
828 | + call_user_func('template_callback_' . $config_var['name']); |
|
829 | + } |
|
806 | 830 | |
807 | 831 | continue; |
808 | 832 | } |
@@ -832,9 +856,10 @@ discard block |
||
832 | 856 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
833 | 857 | |
834 | 858 | // Show the [?] button. |
835 | - if ($config_var['help']) |
|
836 | - echo ' |
|
859 | + if ($config_var['help']) { |
|
860 | + echo ' |
|
837 | 861 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
862 | + } |
|
838 | 863 | |
839 | 864 | echo ' |
840 | 865 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -843,23 +868,26 @@ discard block |
||
843 | 868 | $config_var['preinput']; |
844 | 869 | |
845 | 870 | // Show a check box. |
846 | - if ($config_var['type'] == 'check') |
|
847 | - echo ' |
|
871 | + if ($config_var['type'] == 'check') { |
|
872 | + echo ' |
|
848 | 873 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
874 | + } |
|
849 | 875 | // Escape (via htmlspecialchars.) the text box. |
850 | - elseif ($config_var['type'] == 'password') |
|
851 | - echo ' |
|
876 | + elseif ($config_var['type'] == 'password') { |
|
877 | + echo ' |
|
852 | 878 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
853 | 879 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
880 | + } |
|
854 | 881 | // Show a selection box. |
855 | 882 | elseif ($config_var['type'] == 'select') |
856 | 883 | { |
857 | 884 | echo ' |
858 | 885 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
859 | 886 | |
860 | - foreach ($config_var['data'] as $option) |
|
861 | - echo ' |
|
887 | + foreach ($config_var['data'] as $option) { |
|
888 | + echo ' |
|
862 | 889 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
890 | + } |
|
863 | 891 | echo ' |
864 | 892 | </select>'; |
865 | 893 | } |
@@ -876,16 +904,18 @@ discard block |
||
876 | 904 | |
877 | 905 | foreach ($context['board_list'] as $id_cat => $cat) |
878 | 906 | { |
879 | - if (!$first) |
|
880 | - echo ' |
|
907 | + if (!$first) { |
|
908 | + echo ' |
|
881 | 909 | <hr>'; |
910 | + } |
|
882 | 911 | echo ' |
883 | 912 | <strong>', $cat['name'], '</strong> |
884 | 913 | <ul>'; |
885 | 914 | |
886 | - foreach ($cat['boards'] as $id_board => $brd) |
|
887 | - echo ' |
|
915 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
916 | + echo ' |
|
888 | 917 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
918 | + } |
|
889 | 919 | |
890 | 920 | echo ' |
891 | 921 | </ul>'; |
@@ -895,12 +925,14 @@ discard block |
||
895 | 925 | </fieldset>'; |
896 | 926 | } |
897 | 927 | // Text area? |
898 | - elseif ($config_var['type'] == 'large_text') |
|
899 | - echo ' |
|
928 | + elseif ($config_var['type'] == 'large_text') { |
|
929 | + echo ' |
|
900 | 930 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
931 | + } |
|
901 | 932 | // Permission group? |
902 | - elseif ($config_var['type'] == 'permissions') |
|
903 | - theme_inline_permissions($config_var['name']); |
|
933 | + elseif ($config_var['type'] == 'permissions') { |
|
934 | + theme_inline_permissions($config_var['name']); |
|
935 | + } |
|
904 | 936 | |
905 | 937 | // BBC selection? |
906 | 938 | elseif ($config_var['type'] == 'bbc') |
@@ -912,22 +944,24 @@ discard block |
||
912 | 944 | |
913 | 945 | foreach ($context['bbc_columns'] as $bbcColumn) |
914 | 946 | { |
915 | - foreach ($bbcColumn as $bbcTag) |
|
916 | - echo ' |
|
947 | + foreach ($bbcColumn as $bbcTag) { |
|
948 | + echo ' |
|
917 | 949 | <li class="list_bbc floatleft"> |
918 | 950 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
919 | 951 | </li>'; |
952 | + } |
|
920 | 953 | } |
921 | 954 | echo ' </ul> |
922 | 955 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
923 | 956 | </fieldset>'; |
924 | 957 | } |
925 | 958 | // A simple message? |
926 | - elseif ($config_var['type'] == 'var_message') |
|
927 | - echo ' |
|
959 | + elseif ($config_var['type'] == 'var_message') { |
|
960 | + echo ' |
|
928 | 961 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
929 | 962 | ', $config_var['var_message'], ' |
930 | 963 | </div>'; |
964 | + } |
|
931 | 965 | // Assume it must be a text box |
932 | 966 | else |
933 | 967 | { |
@@ -952,62 +986,70 @@ discard block |
||
952 | 986 | ' . $config_var['postinput'] : '',' |
953 | 987 | </dd>'; |
954 | 988 | } |
955 | - } |
|
956 | - else |
|
989 | + } else |
|
957 | 990 | { |
958 | 991 | // Just show a separator. |
959 | - if ($config_var == '') |
|
960 | - echo ' |
|
992 | + if ($config_var == '') { |
|
993 | + echo ' |
|
961 | 994 | </dl> |
962 | 995 | <hr> |
963 | 996 | <dl class="settings">'; |
964 | - else |
|
965 | - echo ' |
|
997 | + } else { |
|
998 | + echo ' |
|
966 | 999 | <dd> |
967 | 1000 | <strong>' . $config_var . '</strong> |
968 | 1001 | </dd>'; |
1002 | + } |
|
969 | 1003 | } |
970 | 1004 | } |
971 | 1005 | |
972 | - if ($is_open) |
|
973 | - echo ' |
|
1006 | + if ($is_open) { |
|
1007 | + echo ' |
|
974 | 1008 | </dl>'; |
1009 | + } |
|
975 | 1010 | |
976 | - if (empty($context['settings_save_dont_show'])) |
|
977 | - echo ' |
|
1011 | + if (empty($context['settings_save_dont_show'])) { |
|
1012 | + echo ' |
|
978 | 1013 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
1014 | + } |
|
979 | 1015 | |
980 | - if ($is_open) |
|
981 | - echo ' |
|
1016 | + if ($is_open) { |
|
1017 | + echo ' |
|
982 | 1018 | </div><!-- .windowbg2 -->'; |
1019 | + } |
|
983 | 1020 | |
984 | 1021 | |
985 | 1022 | // At least one token has to be used! |
986 | - if (isset($context['admin-ssc_token'])) |
|
987 | - echo ' |
|
1023 | + if (isset($context['admin-ssc_token'])) { |
|
1024 | + echo ' |
|
988 | 1025 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1026 | + } |
|
989 | 1027 | |
990 | - if (isset($context['admin-dbsc_token'])) |
|
991 | - echo ' |
|
1028 | + if (isset($context['admin-dbsc_token'])) { |
|
1029 | + echo ' |
|
992 | 1030 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1031 | + } |
|
993 | 1032 | |
994 | - if (isset($context['admin-mp_token'])) |
|
995 | - echo ' |
|
1033 | + if (isset($context['admin-mp_token'])) { |
|
1034 | + echo ' |
|
996 | 1035 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1036 | + } |
|
997 | 1037 | |
998 | 1038 | echo ' |
999 | 1039 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1000 | 1040 | </form> |
1001 | 1041 | </div><!-- #admincenter -->'; |
1002 | 1042 | |
1003 | - if (!empty($context['settings_post_javascript'])) |
|
1004 | - echo ' |
|
1043 | + if (!empty($context['settings_post_javascript'])) { |
|
1044 | + echo ' |
|
1005 | 1045 | <script> |
1006 | 1046 | ', $context['settings_post_javascript'], ' |
1007 | 1047 | </script>'; |
1048 | + } |
|
1008 | 1049 | |
1009 | - if (!empty($context['settings_insert_below'])) |
|
1010 | - echo $context['settings_insert_below']; |
|
1050 | + if (!empty($context['settings_insert_below'])) { |
|
1051 | + echo $context['settings_insert_below']; |
|
1052 | + } |
|
1011 | 1053 | |
1012 | 1054 | // We may have added a board listing. If we did, we need to make it work. |
1013 | 1055 | addInlineJavascript(' |
@@ -1030,9 +1072,10 @@ discard block |
||
1030 | 1072 | { |
1031 | 1073 | global $context, $txt; |
1032 | 1074 | |
1033 | - if (!empty($context['saved_successful'])) |
|
1034 | - echo ' |
|
1075 | + if (!empty($context['saved_successful'])) { |
|
1076 | + echo ' |
|
1035 | 1077 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1078 | + } |
|
1036 | 1079 | |
1037 | 1080 | // Standard fields. |
1038 | 1081 | template_show_list('standard_profile_fields'); |
@@ -1066,11 +1109,12 @@ discard block |
||
1066 | 1109 | { |
1067 | 1110 | loadLanguage('Errors'); |
1068 | 1111 | |
1069 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1070 | - echo ' |
|
1112 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1113 | + echo ' |
|
1071 | 1114 | <div class="errorbox">', |
1072 | 1115 | $txt['custom_option_' . $_GET['msg']], ' |
1073 | 1116 | </div>'; |
1117 | + } |
|
1074 | 1118 | } |
1075 | 1119 | |
1076 | 1120 | echo ' |
@@ -1137,9 +1181,10 @@ discard block |
||
1137 | 1181 | <dd> |
1138 | 1182 | <select name="placement" id="placement">'; |
1139 | 1183 | |
1140 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1141 | - echo ' |
|
1184 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1185 | + echo ' |
|
1142 | 1186 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1187 | + } |
|
1143 | 1188 | |
1144 | 1189 | echo ' |
1145 | 1190 | </select> |
@@ -1163,9 +1208,10 @@ discard block |
||
1163 | 1208 | <dd> |
1164 | 1209 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1165 | 1210 | |
1166 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1167 | - echo ' |
|
1211 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1212 | + echo ' |
|
1168 | 1213 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1214 | + } |
|
1169 | 1215 | |
1170 | 1216 | echo ' |
1171 | 1217 | </select> |
@@ -1197,9 +1243,10 @@ discard block |
||
1197 | 1243 | </dt> |
1198 | 1244 | <dd id="options_dd">'; |
1199 | 1245 | |
1200 | - foreach ($context['field']['options'] as $k => $option) |
|
1201 | - echo ' |
|
1246 | + foreach ($context['field']['options'] as $k => $option) { |
|
1247 | + echo ' |
|
1202 | 1248 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
1249 | + } |
|
1203 | 1250 | |
1204 | 1251 | echo ' |
1205 | 1252 | <span id="addopt"></span> |
@@ -1263,9 +1310,10 @@ discard block |
||
1263 | 1310 | </fieldset> |
1264 | 1311 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
1265 | 1312 | |
1266 | - if ($context['fid']) |
|
1267 | - echo ' |
|
1313 | + if ($context['fid']) { |
|
1314 | + echo ' |
|
1268 | 1315 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
1316 | + } |
|
1269 | 1317 | |
1270 | 1318 | echo ' |
1271 | 1319 | </div><!-- .windowbg2 --> |
@@ -1312,8 +1360,7 @@ discard block |
||
1312 | 1360 | <p class="centertext"> |
1313 | 1361 | <strong>', $txt['admin_search_results_none'], '</strong> |
1314 | 1362 | </p>'; |
1315 | - } |
|
1316 | - else |
|
1363 | + } else |
|
1317 | 1364 | { |
1318 | 1365 | echo ' |
1319 | 1366 | <ol class="search_results">'; |
@@ -1340,9 +1387,10 @@ discard block |
||
1340 | 1387 | <li> |
1341 | 1388 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1342 | 1389 | |
1343 | - if ($result['help']) |
|
1344 | - echo ' |
|
1390 | + if ($result['help']) { |
|
1391 | + echo ' |
|
1345 | 1392 | <p class="double_height">', $result['help'], '</p>'; |
1393 | + } |
|
1346 | 1394 | |
1347 | 1395 | echo ' |
1348 | 1396 | </li>'; |
@@ -1382,10 +1430,11 @@ discard block |
||
1382 | 1430 | <strong>', $txt['setup_verification_answer'], '</strong> |
1383 | 1431 | </dd>'; |
1384 | 1432 | |
1385 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1386 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1433 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1434 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1387 | 1435 | { |
1388 | 1436 | $question = $context['question_answers'][$q_id]; |
1437 | + } |
|
1389 | 1438 | |
1390 | 1439 | echo ' |
1391 | 1440 | <dt> |
@@ -1393,9 +1442,10 @@ discard block |
||
1393 | 1442 | </dt> |
1394 | 1443 | <dd>'; |
1395 | 1444 | |
1396 | - foreach ($question['answers'] as $answer) |
|
1397 | - echo ' |
|
1445 | + foreach ($question['answers'] as $answer) { |
|
1446 | + echo ' |
|
1398 | 1447 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
1448 | + } |
|
1399 | 1449 | |
1400 | 1450 | echo ' |
1401 | 1451 | <div class="qa_add_answer"><a href="javascript:void(0);" onclick="return addAnswer(this);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1434,11 +1484,12 @@ discard block |
||
1434 | 1484 | ', $txt['errors_found'], ': |
1435 | 1485 | <ul>'; |
1436 | 1486 | |
1437 | - foreach ($context['repair_errors'] as $error) |
|
1438 | - echo ' |
|
1487 | + foreach ($context['repair_errors'] as $error) { |
|
1488 | + echo ' |
|
1439 | 1489 | <li> |
1440 | 1490 | ', $error, ' |
1441 | 1491 | </li>'; |
1492 | + } |
|
1442 | 1493 | |
1443 | 1494 | echo ' |
1444 | 1495 | </ul> |
@@ -1448,16 +1499,15 @@ discard block |
||
1448 | 1499 | <p class="padding"> |
1449 | 1500 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1450 | 1501 | </p>'; |
1451 | - } |
|
1452 | - else |
|
1453 | - echo ' |
|
1502 | + } else { |
|
1503 | + echo ' |
|
1454 | 1504 | <p>', $txt['maintain_no_errors'], '</p> |
1455 | 1505 | <p class="padding"> |
1456 | 1506 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1457 | 1507 | </p>'; |
1508 | + } |
|
1458 | 1509 | |
1459 | - } |
|
1460 | - else |
|
1510 | + } else |
|
1461 | 1511 | { |
1462 | 1512 | if (!empty($context['redirect_to_recount'])) |
1463 | 1513 | { |
@@ -1469,8 +1519,7 @@ discard block |
||
1469 | 1519 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1470 | 1520 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1471 | 1521 | </form>'; |
1472 | - } |
|
1473 | - else |
|
1522 | + } else |
|
1474 | 1523 | { |
1475 | 1524 | echo ' |
1476 | 1525 | <p>', $txt['errors_fixed'], '</p> |
@@ -1561,9 +1610,10 @@ discard block |
||
1561 | 1610 | <tr class="windowbg"> |
1562 | 1611 | <td class="equal_table">', $key, '</td>'; |
1563 | 1612 | |
1564 | - foreach ($setting as $key_lm => $value) |
|
1565 | - echo ' |
|
1613 | + foreach ($setting as $key_lm => $value) { |
|
1614 | + echo ' |
|
1566 | 1615 | <td class="equal_table">', $value, '</td>'; |
1616 | + } |
|
1567 | 1617 | |
1568 | 1618 | echo ' |
1569 | 1619 | </tr>'; |
@@ -1623,8 +1673,8 @@ discard block |
||
1623 | 1673 | { |
1624 | 1674 | global $context, $txt; |
1625 | 1675 | |
1626 | - if ($context['user']['is_admin']) |
|
1627 | - echo ' |
|
1676 | + if ($context['user']['is_admin']) { |
|
1677 | + echo ' |
|
1628 | 1678 | <span class="floatright admin_search"> |
1629 | 1679 | <span class="generic_icons filter centericon"></span> |
1630 | 1680 | <input type="search" name="search_term" value="', $txt['admin_search'], '" onclick="if (this.value == \'', $txt['admin_search'], '\') this.value = \'\';"> |
@@ -1635,6 +1685,7 @@ discard block |
||
1635 | 1685 | </select> |
1636 | 1686 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
1637 | 1687 | </span>'; |
1638 | -} |
|
1688 | + } |
|
1689 | + } |
|
1639 | 1690 | |
1640 | 1691 | ?> |
1641 | 1692 | \ No newline at end of file |
@@ -31,9 +31,10 @@ discard block |
||
31 | 31 | echo ' |
32 | 32 | <ul id="smf_slider" class="roundframe">'; |
33 | 33 | |
34 | - foreach ($context['news_lines'] as $news) |
|
35 | - echo ' |
|
34 | + foreach ($context['news_lines'] as $news) { |
|
35 | + echo ' |
|
36 | 36 | <li>', $news, '</li>'; |
37 | + } |
|
37 | 38 | |
38 | 39 | echo ' |
39 | 40 | </ul> |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | foreach ($context['categories'] as $category) |
66 | 67 | { |
67 | 68 | // If theres no parent boards we can see, avoid showing an empty category (unless its collapsed) |
68 | - if (empty($category['boards']) && !$category['is_collapsed']) |
|
69 | - continue; |
|
69 | + if (empty($category['boards']) && !$category['is_collapsed']) { |
|
70 | + continue; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | echo ' |
72 | 74 | <div class="main_container"> |
@@ -74,9 +76,10 @@ discard block |
||
74 | 76 | <h3 class="catbg">'; |
75 | 77 | |
76 | 78 | // If this category even can collapse, show a link to collapse it. |
77 | - if ($category['can_collapse']) |
|
78 | - echo ' |
|
79 | + if ($category['can_collapse']) { |
|
80 | + echo ' |
|
79 | 81 | <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>'; |
82 | + } |
|
80 | 83 | |
81 | 84 | echo ' |
82 | 85 | ', $category['link'], ' |
@@ -106,10 +109,11 @@ discard block |
||
106 | 109 | </div>'; |
107 | 110 | |
108 | 111 | // Won't somebody think of the children! |
109 | - if (function_exists('template_bi_' . $board['type'] . '_children')) |
|
110 | - call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
111 | - else |
|
112 | - template_bi_board_children($board); |
|
112 | + if (function_exists('template_bi_' . $board['type'] . '_children')) { |
|
113 | + call_user_func('template_bi_' . $board['type'] . '_children', $board); |
|
114 | + } else { |
|
115 | + template_bi_board_children($board); |
|
116 | + } |
|
113 | 117 | |
114 | 118 | echo ' |
115 | 119 | </div><!-- #board_[id] -->'; |
@@ -124,12 +128,13 @@ discard block |
||
124 | 128 | </div><!-- #boardindex_table -->'; |
125 | 129 | |
126 | 130 | // Show the mark all as read button? |
127 | - if ($context['user']['is_logged'] && !empty($context['categories'])) |
|
128 | - echo ' |
|
131 | + if ($context['user']['is_logged'] && !empty($context['categories'])) { |
|
132 | + echo ' |
|
129 | 133 | <div class="mark_read"> |
130 | 134 | ', template_button_strip($context['mark_read_button'], 'right'), ' |
131 | 135 | </div>'; |
132 | -} |
|
136 | + } |
|
137 | + } |
|
133 | 138 | |
134 | 139 | /** |
135 | 140 | * Outputs the board icon for a standard board. |
@@ -173,18 +178,20 @@ discard block |
||
173 | 178 | </a>'; |
174 | 179 | |
175 | 180 | // Has it outstanding posts for approval? |
176 | - if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) |
|
177 | - echo ' |
|
181 | + if ($board['can_approve_posts'] && ($board['unapproved_posts'] || $board['unapproved_topics'])) { |
|
182 | + echo ' |
|
178 | 183 | <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>'; |
184 | + } |
|
179 | 185 | |
180 | 186 | echo ' |
181 | 187 | <p class="board_description">', $board['description'], '</p>'; |
182 | 188 | |
183 | 189 | // 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 ' |
|
190 | + if (!empty($board['link_moderators'])) { |
|
191 | + echo ' |
|
186 | 192 | <p class="moderators">', count($board['link_moderators']) == 1 ? $txt['moderator'] : $txt['moderators'], ': ', implode(', ', $board['link_moderators']), '</p>'; |
187 | -} |
|
193 | + } |
|
194 | + } |
|
188 | 195 | |
189 | 196 | /** |
190 | 197 | * Outputs the board stats for a standard board. |
@@ -225,10 +232,11 @@ discard block |
||
225 | 232 | */ |
226 | 233 | function template_bi_board_lastpost($board) |
227 | 234 | { |
228 | - if (!empty($board['last_post']['id'])) |
|
229 | - echo ' |
|
235 | + if (!empty($board['last_post']['id'])) { |
|
236 | + echo ' |
|
230 | 237 | <p>', $board['last_post']['last_post_message'], '</p>'; |
231 | -} |
|
238 | + } |
|
239 | + } |
|
232 | 240 | |
233 | 241 | /** |
234 | 242 | * Outputs the board children for a standard board. |
@@ -248,14 +256,16 @@ discard block |
||
248 | 256 | id, name, description, new (is it new?), topics (#), posts (#), href, link, and last_post. */ |
249 | 257 | foreach ($board['children'] as $child) |
250 | 258 | { |
251 | - if (!$child['is_redirect']) |
|
252 | - $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>'; |
|
253 | - else |
|
254 | - $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
259 | + if (!$child['is_redirect']) { |
|
260 | + $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>'; |
|
261 | + } else { |
|
262 | + $child['link'] = '<a href="' . $child['href'] . '" title="' . comma_format($child['posts']) . ' ' . $txt['redirects'] . ' - ' . $child['short_description'] . '">' . $child['name'] . '</a>'; |
|
263 | + } |
|
255 | 264 | |
256 | 265 | // Has it posts awaiting approval? |
257 | - if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) |
|
258 | - $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>'; |
|
266 | + if ($child['can_approve_posts'] && ($child['unapproved_posts'] || $child['unapproved_topics'])) { |
|
267 | + $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>'; |
|
268 | + } |
|
259 | 269 | |
260 | 270 | $children[] = $child['new'] ? '<span class="strong">' . $child['link'] . '</span>' : '<span>' . $child['link'] . '</span>'; |
261 | 271 | } |
@@ -282,8 +292,9 @@ discard block |
||
282 | 292 | { |
283 | 293 | global $context, $options, $txt; |
284 | 294 | |
285 | - if (empty($context['info_center'])) |
|
286 | - return; |
|
295 | + if (empty($context['info_center'])) { |
|
296 | + return; |
|
297 | + } |
|
287 | 298 | |
288 | 299 | // Here's where the "Info Center" starts... |
289 | 300 | echo ' |
@@ -383,14 +394,15 @@ discard block |
||
383 | 394 | /* Each post in latest_posts has: |
384 | 395 | board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.), |
385 | 396 | subject, short_subject (shortened with...), time, link, and href. */ |
386 | - foreach ($context['latest_posts'] as $post) |
|
387 | - echo ' |
|
397 | + foreach ($context['latest_posts'] as $post) { |
|
398 | + echo ' |
|
388 | 399 | <tr class="windowbg"> |
389 | 400 | <td class="recentpost"><strong>', $post['link'], '</strong></td> |
390 | 401 | <td class="recentposter">', $post['poster']['link'], '</td> |
391 | 402 | <td class="recentboard">', $post['board']['link'], '</td> |
392 | 403 | <td class="recenttime">', $post['time'], '</td> |
393 | 404 | </tr>'; |
405 | + } |
|
394 | 406 | echo ' |
395 | 407 | </table>'; |
396 | 408 | } |
@@ -414,11 +426,12 @@ discard block |
||
414 | 426 | </div>'; |
415 | 427 | |
416 | 428 | // Holidays like "Christmas", "Chanukah", and "We Love [Unknown] Day" :P |
417 | - if (!empty($context['calendar_holidays'])) |
|
418 | - echo ' |
|
429 | + if (!empty($context['calendar_holidays'])) { |
|
430 | + echo ' |
|
419 | 431 | <p class="inline holiday"> |
420 | 432 | <span>', $txt['calendar_prompt'], '</span> ', implode(', ', $context['calendar_holidays']), ' |
421 | 433 | </p>'; |
434 | + } |
|
422 | 435 | |
423 | 436 | // People's birthdays. Like mine. And yours, I guess. Kidding. |
424 | 437 | if (!empty($context['calendar_birthdays'])) |
@@ -428,9 +441,10 @@ discard block |
||
428 | 441 | <span class="birthday">', $context['calendar_only_today'] ? $txt['birthdays'] : $txt['birthdays_upcoming'], '</span>'; |
429 | 442 | |
430 | 443 | // 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?) |
431 | - foreach ($context['calendar_birthdays'] as $member) |
|
432 | - echo ' |
|
444 | + foreach ($context['calendar_birthdays'] as $member) { |
|
445 | + echo ' |
|
433 | 446 | <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'] ? '' : ', '; |
447 | + } |
|
434 | 448 | |
435 | 449 | echo ' |
436 | 450 | </p>'; |
@@ -445,9 +459,10 @@ discard block |
||
445 | 459 | |
446 | 460 | // Each event in calendar_events should have: |
447 | 461 | // title, href, is_last, can_edit (are they allowed?), modify_href, and is_today. |
448 | - foreach ($context['calendar_events'] as $event) |
|
449 | - echo ' |
|
462 | + foreach ($context['calendar_events'] as $event) { |
|
463 | + echo ' |
|
450 | 464 | ', $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>' : ', '; |
465 | + } |
|
451 | 466 | echo ' |
452 | 467 | </p>'; |
453 | 468 | } |
@@ -493,17 +508,21 @@ discard block |
||
493 | 508 | // Handle hidden users and buddies. |
494 | 509 | $bracketList = array(); |
495 | 510 | |
496 | - if ($context['show_buddies']) |
|
497 | - $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
511 | + if ($context['show_buddies']) { |
|
512 | + $bracketList[] = comma_format($context['num_buddies']) . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']); |
|
513 | + } |
|
498 | 514 | |
499 | - if (!empty($context['num_spiders'])) |
|
500 | - $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
515 | + if (!empty($context['num_spiders'])) { |
|
516 | + $bracketList[] = comma_format($context['num_spiders']) . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']); |
|
517 | + } |
|
501 | 518 | |
502 | - if (!empty($context['num_users_hidden'])) |
|
503 | - $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
519 | + if (!empty($context['num_users_hidden'])) { |
|
520 | + $bracketList[] = comma_format($context['num_users_hidden']) . ' ' . ($context['num_spiders'] == 1 ? $txt['hidden'] : $txt['hidden_s']); |
|
521 | + } |
|
504 | 522 | |
505 | - if (!empty($bracketList)) |
|
506 | - echo ' (' . implode(', ', $bracketList) . ')'; |
|
523 | + if (!empty($bracketList)) { |
|
524 | + echo ' (' . implode(', ', $bracketList) . ')'; |
|
525 | + } |
|
507 | 526 | |
508 | 527 | echo $context['show_who'] ? '</a>' : '', ' |
509 | 528 | |
@@ -517,9 +536,10 @@ discard block |
||
517 | 536 | ', sprintf($txt['users_active'], $modSettings['lastActive']), ': ', implode(', ', $context['list_users_online']); |
518 | 537 | |
519 | 538 | // Showing membergroups? |
520 | - if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) |
|
521 | - echo ' |
|
539 | + if (!empty($settings['show_group_key']) && !empty($context['membergroups'])) { |
|
540 | + echo ' |
|
522 | 541 | <span class="membergroups">' . implode(', ', $context['membergroups']) . '</span>'; |
542 | + } |
|
523 | 543 | } |
524 | 544 | |
525 | 545 | echo ' |
@@ -22,27 +22,31 @@ discard block |
||
22 | 22 | // Get a shortcut to the current list. |
23 | 23 | $list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id; |
24 | 24 | |
25 | - if (empty($list_id) || empty($context[$list_id])) |
|
26 | - return; |
|
25 | + if (empty($list_id) || empty($context[$list_id])) { |
|
26 | + return; |
|
27 | + } |
|
27 | 28 | |
28 | 29 | $cur_list = &$context[$list_id]; |
29 | 30 | |
30 | 31 | // These are the main tabs that is used all around the template. |
31 | - if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) |
|
32 | - template_create_list_menu($cur_list['list_menu'], 'top'); |
|
32 | + if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top')) { |
|
33 | + template_create_list_menu($cur_list['list_menu'], 'top'); |
|
34 | + } |
|
33 | 35 | |
34 | - if (isset($cur_list['form'])) |
|
35 | - echo ' |
|
36 | + if (isset($cur_list['form'])) { |
|
37 | + echo ' |
|
36 | 38 | <form action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">'; |
39 | + } |
|
37 | 40 | |
38 | 41 | // Show the title of the table (if any). |
39 | - if (!empty($cur_list['title'])) |
|
40 | - echo ' |
|
42 | + if (!empty($cur_list['title'])) { |
|
43 | + echo ' |
|
41 | 44 | <div class="cat_bar"> |
42 | 45 | <h3 class="catbg"> |
43 | 46 | ', $cur_list['title'], ' |
44 | 47 | </h3> |
45 | 48 | </div>'; |
49 | + } |
|
46 | 50 | |
47 | 51 | if (isset($cur_list['additional_rows']['after_title'])) |
48 | 52 | { |
@@ -55,20 +59,23 @@ discard block |
||
55 | 59 | </div>'; |
56 | 60 | } |
57 | 61 | |
58 | - if (isset($cur_list['additional_rows']['top_of_list'])) |
|
59 | - template_additional_rows('top_of_list', $cur_list); |
|
62 | + if (isset($cur_list['additional_rows']['top_of_list'])) { |
|
63 | + template_additional_rows('top_of_list', $cur_list); |
|
64 | + } |
|
60 | 65 | |
61 | 66 | if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers'])) |
62 | 67 | { |
63 | 68 | // Show the page index (if this list doesn't intend to show all items). |
64 | - if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
|
65 | - echo ' |
|
69 | + if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) { |
|
70 | + echo ' |
|
66 | 71 | <div class="floatleft"> |
67 | 72 | <div class="pagesection">', $cur_list['page_index'], '</div> |
68 | 73 | </div>'; |
74 | + } |
|
69 | 75 | |
70 | - if (isset($cur_list['additional_rows']['above_column_headers'])) |
|
71 | - template_additional_rows('above_column_headers', $cur_list); |
|
76 | + if (isset($cur_list['additional_rows']['above_column_headers'])) { |
|
77 | + template_additional_rows('above_column_headers', $cur_list); |
|
78 | + } |
|
72 | 79 | } |
73 | 80 | |
74 | 81 | echo ' |
@@ -83,11 +90,12 @@ discard block |
||
83 | 90 | <tr class="title_bar">'; |
84 | 91 | |
85 | 92 | // Loop through each column and add a table header. |
86 | - foreach ($cur_list['headers'] as $col_header) |
|
87 | - echo ' |
|
93 | + foreach ($cur_list['headers'] as $col_header) { |
|
94 | + echo ' |
|
88 | 95 | <th scope="col" id="header_', $list_id, '_', $col_header['id'], '"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '> |
89 | 96 | ', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? '' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="generic_icons sort_' . $col_header['sort_image'] . '"></span></a>'), ' |
90 | 97 | </th>'; |
98 | + } |
|
91 | 99 | |
92 | 100 | echo ' |
93 | 101 | </tr> |
@@ -98,13 +106,14 @@ discard block |
||
98 | 106 | <tbody>'; |
99 | 107 | |
100 | 108 | // Show a nice message informing there are no items in this list. |
101 | - if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) |
|
102 | - echo ' |
|
109 | + if (empty($cur_list['rows']) && !empty($cur_list['no_items_label'])) { |
|
110 | + echo ' |
|
103 | 111 | <tr class="windowbg"> |
104 | 112 | <td colspan="', $cur_list['num_columns'], '" class="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'centertext', '"> |
105 | 113 | ', $cur_list['no_items_label'], ' |
106 | 114 | </td> |
107 | 115 | </tr>'; |
116 | + } |
|
108 | 117 | |
109 | 118 | // Show the list rows. |
110 | 119 | elseif (!empty($cur_list['rows'])) |
@@ -114,12 +123,13 @@ discard block |
||
114 | 123 | echo ' |
115 | 124 | <tr class="windowbg', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', ' id="list_', $list_id, '_', $id, '">'; |
116 | 125 | |
117 | - if (!empty($row['data'])) |
|
118 | - foreach ($row['data'] as $row_data) |
|
126 | + if (!empty($row['data'])) { |
|
127 | + foreach ($row['data'] as $row_data) |
|
119 | 128 | echo ' |
120 | 129 | <td', empty($row_data['class']) ? '' : ' class="' . $row_data['class'] . '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '> |
121 | 130 | ', $row_data['value'], ' |
122 | 131 | </td>'; |
132 | + } |
|
123 | 133 | |
124 | 134 | echo ' |
125 | 135 | </tr>'; |
@@ -136,46 +146,53 @@ discard block |
||
136 | 146 | <div class="flow_auto">'; |
137 | 147 | |
138 | 148 | // Show the page index (if this list doesn't intend to show all items). |
139 | - if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) |
|
140 | - echo ' |
|
149 | + if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) { |
|
150 | + echo ' |
|
141 | 151 | <div class="floatleft"> |
142 | 152 | <div class="pagesection">', $cur_list['page_index'], '</div> |
143 | 153 | </div>'; |
154 | + } |
|
144 | 155 | |
145 | - if (isset($cur_list['additional_rows']['below_table_data'])) |
|
146 | - template_additional_rows('below_table_data', $cur_list); |
|
156 | + if (isset($cur_list['additional_rows']['below_table_data'])) { |
|
157 | + template_additional_rows('below_table_data', $cur_list); |
|
158 | + } |
|
147 | 159 | |
148 | 160 | echo ' |
149 | 161 | </div>'; |
150 | 162 | } |
151 | 163 | |
152 | - if (isset($cur_list['additional_rows']['bottom_of_list'])) |
|
153 | - template_additional_rows('bottom_of_list', $cur_list); |
|
164 | + if (isset($cur_list['additional_rows']['bottom_of_list'])) { |
|
165 | + template_additional_rows('bottom_of_list', $cur_list); |
|
166 | + } |
|
154 | 167 | |
155 | 168 | if (isset($cur_list['form'])) |
156 | 169 | { |
157 | - foreach ($cur_list['form']['hidden_fields'] as $name => $value) |
|
158 | - echo ' |
|
170 | + foreach ($cur_list['form']['hidden_fields'] as $name => $value) { |
|
171 | + echo ' |
|
159 | 172 | <input type="hidden" name="', $name, '" value="', $value, '">'; |
173 | + } |
|
160 | 174 | |
161 | - if (isset($cur_list['form']['token'])) |
|
162 | - echo ' |
|
175 | + if (isset($cur_list['form']['token'])) { |
|
176 | + echo ' |
|
163 | 177 | <input type="hidden" name="', $context[$cur_list['form']['token'] . '_token_var'], '" value="', $context[$cur_list['form']['token'] . '_token'], '">'; |
178 | + } |
|
164 | 179 | |
165 | 180 | echo ' |
166 | 181 | </form>'; |
167 | 182 | } |
168 | 183 | |
169 | 184 | // Tabs at the bottom. Usually bottom aligned. |
170 | - if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) |
|
171 | - template_create_list_menu($cur_list['list_menu'], 'bottom'); |
|
185 | + if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom')) { |
|
186 | + template_create_list_menu($cur_list['list_menu'], 'bottom'); |
|
187 | + } |
|
172 | 188 | |
173 | - if (isset($cur_list['javascript'])) |
|
174 | - echo ' |
|
189 | + if (isset($cur_list['javascript'])) { |
|
190 | + echo ' |
|
175 | 191 | <script> |
176 | 192 | ', $cur_list['javascript'], ' |
177 | 193 | </script>'; |
178 | -} |
|
194 | + } |
|
195 | + } |
|
179 | 196 | |
180 | 197 | /** |
181 | 198 | * This template displays additional rows above or below the list. |
@@ -185,12 +202,13 @@ discard block |
||
185 | 202 | */ |
186 | 203 | function template_additional_rows($row_position, $cur_list) |
187 | 204 | { |
188 | - foreach ($cur_list['additional_rows'][$row_position] as $row) |
|
189 | - echo ' |
|
205 | + foreach ($cur_list['additional_rows'][$row_position] as $row) { |
|
206 | + echo ' |
|
190 | 207 | <div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '> |
191 | 208 | ', $row['value'], ' |
192 | 209 | </div>'; |
193 | -} |
|
210 | + } |
|
211 | + } |
|
194 | 212 | |
195 | 213 | /** |
196 | 214 | * This function creates a menu |
@@ -249,18 +267,19 @@ discard block |
||
249 | 267 | |
250 | 268 | foreach ($list_menu['links'] as $link) |
251 | 269 | { |
252 | - if ($link['is_selected']) |
|
253 | - echo ' |
|
270 | + if ($link['is_selected']) { |
|
271 | + echo ' |
|
254 | 272 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"></td> |
255 | 273 | <td class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back"> |
256 | 274 | <a href="', $link['href'], '">', $link['label'], '</a> |
257 | 275 | </td> |
258 | 276 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"></td>'; |
259 | - else |
|
260 | - echo ' |
|
277 | + } else { |
|
278 | + echo ' |
|
261 | 279 | <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back"> |
262 | 280 | <a href="', $link['href'], '">', $link['label'], '</a> |
263 | 281 | </td>'; |
282 | + } |
|
264 | 283 | } |
265 | 284 | |
266 | 285 | echo ' |
@@ -271,12 +290,12 @@ discard block |
||
271 | 290 | <td></td>' : '', ' |
272 | 291 | </tr> |
273 | 292 | </table>'; |
274 | - } |
|
275 | - elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons') |
|
293 | + } elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons') |
|
276 | 294 | { |
277 | 295 | $links = array(); |
278 | - foreach ($list_menu['links'] as $link) |
|
279 | - $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; |
|
296 | + foreach ($list_menu['links'] as $link) { |
|
297 | + $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>'; |
|
298 | + } |
|
280 | 299 | |
281 | 300 | echo ' |
282 | 301 | <table style="margin-', $list_menu['position'], ': 10px; width: 100%;"> |
@@ -15,8 +15,9 @@ discard block |
||
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 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
37 | 38 | |
38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
39 | 40 | |
40 | - if (!isset($_REQUEST['xml'])) |
|
41 | - loadTemplate('PersonalMessage'); |
|
41 | + if (!isset($_REQUEST['xml'])) { |
|
42 | + loadTemplate('PersonalMessage'); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Load up the members maximum message capacity. |
44 | - if ($user_info['is_admin']) |
|
45 | - $context['message_limit'] = 0; |
|
46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
46 | + if ($user_info['is_admin']) { |
|
47 | + $context['message_limit'] = 0; |
|
48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
47 | 49 | { |
48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | } |
79 | 81 | |
80 | 82 | // a previous message was sent successfully? show a small indication. |
81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
82 | - $context['pm_sent'] = true; |
|
83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
84 | + $context['pm_sent'] = true; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | $context['labels'] = array(); |
85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
210 | 213 | { |
211 | 214 | $_REQUEST['sa'] = ''; |
212 | 215 | MessageFolder(); |
213 | - } |
|
214 | - else |
|
216 | + } else |
|
215 | 217 | { |
216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
217 | - messageIndexBar($_REQUEST['sa']); |
|
218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
219 | + messageIndexBar($_REQUEST['sa']); |
|
220 | + } |
|
218 | 221 | |
219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
291 | 294 | ); |
292 | 295 | |
293 | 296 | // Handle labels. |
294 | - if (empty($context['currently_using_labels'])) |
|
295 | - unset($pm_areas['labels']); |
|
296 | - else |
|
297 | + if (empty($context['currently_using_labels'])) { |
|
298 | + unset($pm_areas['labels']); |
|
299 | + } else |
|
297 | 300 | { |
298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
299 | 302 | $unread_in_labels = 0; |
300 | 303 | foreach ($context['labels'] as $label) |
301 | 304 | { |
302 | - if ($label['id'] == -1) |
|
303 | - continue; |
|
305 | + if ($label['id'] == -1) { |
|
306 | + continue; |
|
307 | + } |
|
304 | 308 | |
305 | 309 | // Count the amount of unread items in labels. |
306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
314 | 318 | ); |
315 | 319 | } |
316 | 320 | |
317 | - if (!empty($unread_in_labels)) |
|
318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
321 | + if (!empty($unread_in_labels)) { |
|
322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
323 | + } |
|
319 | 324 | } |
320 | 325 | |
321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
353 | 358 | unset($pm_areas); |
354 | 359 | |
355 | 360 | // No menu means no access. |
356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
357 | - fatal_lang_error('no_access', false); |
|
361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
362 | + fatal_lang_error('no_access', false); |
|
363 | + } |
|
358 | 364 | |
359 | 365 | // Make a note of the Unique ID for this menu. |
360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
365 | 371 | $context['menu_item_selected'] = $current_area; |
366 | 372 | |
367 | 373 | // Set the template for this area and add the profile layer. |
368 | - if (!isset($_REQUEST['xml'])) |
|
369 | - $context['template_layers'][] = 'pm'; |
|
370 | -} |
|
374 | + if (!isset($_REQUEST['xml'])) { |
|
375 | + $context['template_layers'][] = 'pm'; |
|
376 | + } |
|
377 | + } |
|
371 | 378 | |
372 | 379 | /** |
373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
399 | 406 | ) |
400 | 407 | ); |
401 | 408 | $pms = array(); |
402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
403 | - $pms[] = $row[0]; |
|
409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
410 | + $pms[] = $row[0]; |
|
411 | + } |
|
404 | 412 | $smcFunc['db_free_result']($request); |
405 | 413 | |
406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
428 | 436 | ); |
429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
430 | 438 | { |
431 | - if (!empty($row['id_member_from'])) |
|
432 | - $senders[] = $row['id_member_from']; |
|
439 | + if (!empty($row['id_member_from'])) { |
|
440 | + $senders[] = $row['id_member_from']; |
|
441 | + } |
|
433 | 442 | |
434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
439 | 448 | $smcFunc['db_free_result']($request); |
440 | 449 | |
441 | 450 | $senders = loadMemberData($senders); |
442 | - foreach ($senders as $member) |
|
443 | - loadMemberContext($member); |
|
451 | + foreach ($senders as $member) { |
|
452 | + loadMemberContext($member); |
|
453 | + } |
|
444 | 454 | |
445 | 455 | // Having loaded everyone, attach them to the PMs. |
446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
459 | + } |
|
449 | 460 | } |
450 | 461 | } |
451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
465 | 476 | } |
466 | 477 | |
467 | 478 | // Make sure the starting location is valid. |
468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
469 | - $_GET['start'] = (int) $_GET['start']; |
|
470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
471 | - $_GET['start'] = 0; |
|
472 | - else |
|
473 | - $_GET['start'] = 'new'; |
|
479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
480 | + $_GET['start'] = (int) $_GET['start']; |
|
481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
482 | + $_GET['start'] = 0; |
|
483 | + } else { |
|
484 | + $_GET['start'] = 'new'; |
|
485 | + } |
|
474 | 486 | |
475 | 487 | // Set up some basic theme stuff. |
476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
487 | 499 | { |
488 | 500 | $labelQuery = ' |
489 | 501 | AND pmr.in_inbox = 1'; |
490 | - } |
|
491 | - elseif ($context['folder'] != 'sent') |
|
502 | + } elseif ($context['folder'] != 'sent') |
|
492 | 503 | { |
493 | 504 | $labelJoin = ' |
494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
531 | 542 | |
532 | 543 | // Now, build the link tree! |
533 | - if ($context['current_label_id'] == -1) |
|
534 | - $context['linktree'][] = array( |
|
544 | + if ($context['current_label_id'] == -1) { |
|
545 | + $context['linktree'][] = array( |
|
535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
536 | 547 | 'name' => $pmbox |
537 | 548 | ); |
549 | + } |
|
538 | 550 | |
539 | 551 | // Build it further for a label. |
540 | - if ($context['current_label_id'] != -1) |
|
541 | - $context['linktree'][] = array( |
|
552 | + if ($context['current_label_id'] != -1) { |
|
553 | + $context['linktree'][] = array( |
|
542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
544 | 556 | ); |
557 | + } |
|
545 | 558 | |
546 | 559 | // Figure out how many messages there are. |
547 | - if ($context['folder'] == 'sent') |
|
548 | - $request = $smcFunc['db_query']('', ' |
|
560 | + if ($context['folder'] == 'sent') { |
|
561 | + $request = $smcFunc['db_query']('', ' |
|
549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
550 | 563 | FROM {db_prefix}personal_messages AS pm |
551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
555 | 568 | 'not_deleted' => 0, |
556 | 569 | ) |
557 | 570 | ); |
558 | - else |
|
559 | - $request = $smcFunc['db_query']('', ' |
|
571 | + } else { |
|
572 | + $request = $smcFunc['db_query']('', ' |
|
560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
567 | 580 | 'not_deleted' => 0, |
568 | 581 | ) |
569 | 582 | ); |
583 | + } |
|
570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
571 | 585 | $smcFunc['db_free_result']($request); |
572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
576 | 590 | |
577 | 591 | // Start on the last page. |
578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
580 | - elseif ($_GET['start'] < 0) |
|
581 | - $_GET['start'] = 0; |
|
592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
594 | + } elseif ($_GET['start'] < 0) { |
|
595 | + $_GET['start'] = 0; |
|
596 | + } |
|
582 | 597 | |
583 | 598 | // ... but wait - what if we want to start from a specific message? |
584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
586 | 601 | $pmID = (int) $_GET['pmid']; |
587 | 602 | |
588 | 603 | // Make sure you have access to this PM. |
589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
590 | - fatal_lang_error('no_access', false); |
|
604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
605 | + fatal_lang_error('no_access', false); |
|
606 | + } |
|
591 | 607 | |
592 | 608 | $context['current_pm'] = $pmID; |
593 | 609 | |
594 | 610 | // With only one page of PM's we're gonna want page 1. |
595 | - if ($max_messages <= $maxPerPage) |
|
596 | - $_GET['start'] = 0; |
|
611 | + if ($max_messages <= $maxPerPage) { |
|
612 | + $_GET['start'] = 0; |
|
613 | + } |
|
597 | 614 | // If we pass kstart we assume we're in the right place. |
598 | 615 | elseif (!isset($_GET['kstart'])) |
599 | 616 | { |
600 | - if ($context['folder'] == 'sent') |
|
601 | - $request = $smcFunc['db_query']('', ' |
|
617 | + if ($context['folder'] == 'sent') { |
|
618 | + $request = $smcFunc['db_query']('', ' |
|
602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
603 | 620 | FROM {db_prefix}personal_messages |
604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
610 | 627 | 'id_pm' => $pmID, |
611 | 628 | ) |
612 | 629 | ); |
613 | - else |
|
614 | - $request = $smcFunc['db_query']('', ' |
|
630 | + } else { |
|
631 | + $request = $smcFunc['db_query']('', ' |
|
615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
624 | 641 | 'id_pm' => $pmID, |
625 | 642 | ) |
626 | 643 | ); |
644 | + } |
|
627 | 645 | |
628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | { |
639 | 657 | $pmsg = (int) $_GET['pmsg']; |
640 | 658 | |
641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
642 | - fatal_lang_error('no_access', false); |
|
659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
660 | + fatal_lang_error('no_access', false); |
|
661 | + } |
|
643 | 662 | } |
644 | 663 | |
645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
734 | 753 | { |
735 | 754 | if (!isset($recipients[$row['id_pm']])) |
736 | 755 | { |
737 | - if (isset($row['id_member_from'])) |
|
738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
756 | + if (isset($row['id_member_from'])) { |
|
757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
758 | + } |
|
739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
740 | 760 | $recipients[$row['id_pm']] = array( |
741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
744 | 764 | } |
745 | 765 | |
746 | 766 | // Keep track of the last message so we know what the head is without another query! |
747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
748 | - $lastData = array( |
|
767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
768 | + $lastData = array( |
|
749 | 769 | 'id' => $row['id_pm'], |
750 | 770 | 'head' => $row['id_pm_head'], |
751 | 771 | ); |
772 | + } |
|
752 | 773 | } |
753 | 774 | $smcFunc['db_free_result']($request); |
754 | 775 | |
755 | 776 | // Make sure that we have been given a correct head pm id! |
756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
757 | - fatal_lang_error('no_access', false); |
|
777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
778 | + fatal_lang_error('no_access', false); |
|
779 | + } |
|
758 | 780 | |
759 | 781 | if (!empty($pms)) |
760 | 782 | { |
761 | 783 | // Select the correct current message. |
762 | - if (empty($pmID)) |
|
763 | - $context['current_pm'] = $lastData['id']; |
|
784 | + if (empty($pmID)) { |
|
785 | + $context['current_pm'] = $lastData['id']; |
|
786 | + } |
|
764 | 787 | |
765 | 788 | // This is a list of the pm's that are used for "full" display. |
766 | - if ($context['display_mode'] == 0) |
|
767 | - $display_pms = $pms; |
|
768 | - else |
|
769 | - $display_pms = array($context['current_pm']); |
|
789 | + if ($context['display_mode'] == 0) { |
|
790 | + $display_pms = $pms; |
|
791 | + } else { |
|
792 | + $display_pms = array($context['current_pm']); |
|
793 | + } |
|
770 | 794 | |
771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
789 | 813 | { |
790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
792 | - continue; |
|
793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
794 | - continue; |
|
815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
816 | + continue; |
|
817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
818 | + continue; |
|
819 | + } |
|
795 | 820 | |
796 | - if (!isset($recipients[$row['id_pm']])) |
|
797 | - $recipients[$row['id_pm']] = array( |
|
821 | + if (!isset($recipients[$row['id_pm']])) { |
|
822 | + $recipients[$row['id_pm']] = array( |
|
798 | 823 | 'to' => array(), |
799 | 824 | 'bcc' => array() |
800 | 825 | ); |
826 | + } |
|
801 | 827 | $display_pms[] = $row['id_pm']; |
802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
849 | 875 | { |
850 | 876 | $l_id = $row2['id_label']; |
851 | - if (isset($context['labels'][$l_id])) |
|
852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
877 | + if (isset($context['labels'][$l_id])) { |
|
878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
879 | + } |
|
853 | 880 | } |
854 | 881 | |
855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
866 | 893 | // Make sure we don't load unnecessary data. |
867 | 894 | if ($context['display_mode'] == 1) |
868 | 895 | { |
869 | - foreach ($posters as $k => $v) |
|
870 | - if (!in_array($k, $display_pms)) |
|
896 | + foreach ($posters as $k => $v) { |
|
897 | + if (!in_array($k, $display_pms)) |
|
871 | 898 | unset($posters[$k]); |
899 | + } |
|
872 | 900 | } |
873 | 901 | |
874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
879 | 907 | { |
880 | 908 | // Get the order right. |
881 | 909 | $orderBy = array(); |
882 | - foreach (array_reverse($pms) as $pm) |
|
883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
910 | + foreach (array_reverse($pms) as $pm) { |
|
911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
912 | + } |
|
884 | 913 | |
885 | 914 | // Seperate query for these bits! |
886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
926 | 955 | // Allow mods to add additional buttons here |
927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
928 | 957 | } |
958 | + } else { |
|
959 | + $messages_request = false; |
|
929 | 960 | } |
930 | - else |
|
931 | - $messages_request = false; |
|
932 | 961 | |
933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
940 | 969 | { |
941 | 970 | // If the display mode is "old sk00l" do them all... |
942 | - if ($context['display_mode'] == 0) |
|
943 | - markMessages(null, $context['current_label_id']); |
|
971 | + if ($context['display_mode'] == 0) { |
|
972 | + markMessages(null, $context['current_label_id']); |
|
973 | + } |
|
944 | 974 | // Otherwise do just the current one! |
945 | - elseif (!empty($context['current_pm'])) |
|
946 | - markMessages($display_pms, $context['current_label_id']); |
|
975 | + elseif (!empty($context['current_pm'])) { |
|
976 | + markMessages($display_pms, $context['current_label_id']); |
|
977 | + } |
|
947 | 978 | } |
948 | 979 | } |
949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
961 | 992 | |
962 | 993 | // Count the current message number.... |
963 | 994 | static $counter = null; |
964 | - if ($counter === null || $reset) |
|
965 | - $counter = $context['start']; |
|
995 | + if ($counter === null || $reset) { |
|
996 | + $counter = $context['start']; |
|
997 | + } |
|
966 | 998 | |
967 | 999 | static $temp_pm_selected = null; |
968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
1007 | 1039 | } |
1008 | 1040 | |
1009 | 1041 | // Bail if it's false, ie. no messages. |
1010 | - if ($messages_request == false) |
|
1011 | - return false; |
|
1042 | + if ($messages_request == false) { |
|
1043 | + return false; |
|
1044 | + } |
|
1012 | 1045 | |
1013 | 1046 | // Reset the data? |
1014 | - if ($reset == true) |
|
1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1047 | + if ($reset == true) { |
|
1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1049 | + } |
|
1016 | 1050 | |
1017 | 1051 | // Get the next one... bail if anything goes wrong. |
1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1019 | 1053 | if (!$message) |
1020 | 1054 | { |
1021 | - if ($type != 'subject') |
|
1022 | - $smcFunc['db_free_result']($messages_request); |
|
1055 | + if ($type != 'subject') { |
|
1056 | + $smcFunc['db_free_result']($messages_request); |
|
1057 | + } |
|
1023 | 1058 | |
1024 | 1059 | return false; |
1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
1042 | - } |
|
1043 | - else |
|
1077 | + } else |
|
1044 | 1078 | { |
1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,9 +1115,10 @@ discard block |
||
1081 | 1115 | $counter++; |
1082 | 1116 | |
1083 | 1117 | // Any custom profile fields? |
1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1086 | 1120 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1121 | + } |
|
1087 | 1122 | |
1088 | 1123 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
1089 | 1124 | |
@@ -1107,22 +1142,28 @@ discard block |
||
1107 | 1142 | $context['search_params'][$k] = $v; |
1108 | 1143 | } |
1109 | 1144 | } |
1110 | - if (isset($_REQUEST['search'])) |
|
1111 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1145 | + if (isset($_REQUEST['search'])) { |
|
1146 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1147 | + } |
|
1112 | 1148 | |
1113 | - if (isset($context['search_params']['search'])) |
|
1114 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1115 | - if (isset($context['search_params']['userspec'])) |
|
1116 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1149 | + if (isset($context['search_params']['search'])) { |
|
1150 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1151 | + } |
|
1152 | + if (isset($context['search_params']['userspec'])) { |
|
1153 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1154 | + } |
|
1117 | 1155 | |
1118 | - if (!empty($context['search_params']['searchtype'])) |
|
1119 | - $context['search_params']['searchtype'] = 2; |
|
1156 | + if (!empty($context['search_params']['searchtype'])) { |
|
1157 | + $context['search_params']['searchtype'] = 2; |
|
1158 | + } |
|
1120 | 1159 | |
1121 | - if (!empty($context['search_params']['minage'])) |
|
1122 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1160 | + if (!empty($context['search_params']['minage'])) { |
|
1161 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1162 | + } |
|
1123 | 1163 | |
1124 | - if (!empty($context['search_params']['maxage'])) |
|
1125 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1164 | + if (!empty($context['search_params']['maxage'])) { |
|
1165 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1166 | + } |
|
1126 | 1167 | |
1127 | 1168 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
1128 | 1169 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1149,8 +1190,9 @@ discard block |
||
1149 | 1190 | $context['search_errors']['messages'] = array(); |
1150 | 1191 | foreach ($context['search_errors'] as $search_error => $dummy) |
1151 | 1192 | { |
1152 | - if ($search_error == 'messages') |
|
1153 | - continue; |
|
1193 | + if ($search_error == 'messages') { |
|
1194 | + continue; |
|
1195 | + } |
|
1154 | 1196 | |
1155 | 1197 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
1156 | 1198 | } |
@@ -1172,8 +1214,9 @@ discard block |
||
1172 | 1214 | global $scripturl, $modSettings, $user_info, $context, $txt; |
1173 | 1215 | global $memberContext, $smcFunc; |
1174 | 1216 | |
1175 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
1176 | - fatal_lang_error('loadavg_search_disabled', false); |
|
1217 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
1218 | + fatal_lang_error('loadavg_search_disabled', false); |
|
1219 | + } |
|
1177 | 1220 | |
1178 | 1221 | /** |
1179 | 1222 | * @todo For the moment force the folder to the inbox. |
@@ -1202,35 +1245,40 @@ discard block |
||
1202 | 1245 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
1203 | 1246 | |
1204 | 1247 | // Store whether simple search was used (needed if the user wants to do another query). |
1205 | - if (!isset($search_params['advanced'])) |
|
1206 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1248 | + if (!isset($search_params['advanced'])) { |
|
1249 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1250 | + } |
|
1207 | 1251 | |
1208 | 1252 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
1209 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
1210 | - $search_params['searchtype'] = 2; |
|
1253 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
1254 | + $search_params['searchtype'] = 2; |
|
1255 | + } |
|
1211 | 1256 | |
1212 | 1257 | // Minimum age of messages. Default to zero (don't set param in that case). |
1213 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
1214 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1258 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
1259 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1260 | + } |
|
1215 | 1261 | |
1216 | 1262 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
1217 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
1218 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1263 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
1264 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1265 | + } |
|
1219 | 1266 | |
1220 | 1267 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
1221 | 1268 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
1222 | 1269 | |
1223 | 1270 | // Default the user name to a wildcard matching every user (*). |
1224 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
1225 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1271 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
1272 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1273 | + } |
|
1226 | 1274 | |
1227 | 1275 | // This will be full of all kinds of parameters! |
1228 | 1276 | $searchq_parameters = array(); |
1229 | 1277 | |
1230 | 1278 | // If there's no specific user, then don't mention it in the main query. |
1231 | - if (empty($search_params['userspec'])) |
|
1232 | - $userQuery = ''; |
|
1233 | - else |
|
1279 | + if (empty($search_params['userspec'])) { |
|
1280 | + $userQuery = ''; |
|
1281 | + } else |
|
1234 | 1282 | { |
1235 | 1283 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
1236 | 1284 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1242,8 +1290,9 @@ discard block |
||
1242 | 1290 | { |
1243 | 1291 | $possible_users[$k] = trim($possible_users[$k]); |
1244 | 1292 | |
1245 | - if (strlen($possible_users[$k]) == 0) |
|
1246 | - unset($possible_users[$k]); |
|
1293 | + if (strlen($possible_users[$k]) == 0) { |
|
1294 | + unset($possible_users[$k]); |
|
1295 | + } |
|
1247 | 1296 | } |
1248 | 1297 | |
1249 | 1298 | if (!empty($possible_users)) |
@@ -1255,8 +1304,9 @@ discard block |
||
1255 | 1304 | { |
1256 | 1305 | $where_params['name_' . $k] = $v; |
1257 | 1306 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
1258 | - if (!isset($where_params['real_name'])) |
|
1259 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1307 | + if (!isset($where_params['real_name'])) { |
|
1308 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1309 | + } |
|
1260 | 1310 | } |
1261 | 1311 | |
1262 | 1312 | // Who matches those criteria? |
@@ -1269,28 +1319,28 @@ discard block |
||
1269 | 1319 | ); |
1270 | 1320 | |
1271 | 1321 | // Simply do nothing if there're too many members matching the criteria. |
1272 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
1273 | - $userQuery = ''; |
|
1274 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1322 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
1323 | + $userQuery = ''; |
|
1324 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1275 | 1325 | { |
1276 | 1326 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
1277 | 1327 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1278 | 1328 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1279 | - } |
|
1280 | - else |
|
1329 | + } else |
|
1281 | 1330 | { |
1282 | 1331 | $memberlist = array(); |
1283 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1284 | - $memberlist[] = $row['id_member']; |
|
1332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1333 | + $memberlist[] = $row['id_member']; |
|
1334 | + } |
|
1285 | 1335 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
1286 | 1336 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1287 | 1337 | $searchq_parameters['member_list'] = $memberlist; |
1288 | 1338 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1289 | 1339 | } |
1290 | 1340 | $smcFunc['db_free_result']($request); |
1341 | + } else { |
|
1342 | + $userQuery = ''; |
|
1291 | 1343 | } |
1292 | - else |
|
1293 | - $userQuery = ''; |
|
1294 | 1344 | } |
1295 | 1345 | |
1296 | 1346 | // Setup the sorting variables... |
@@ -1298,8 +1348,9 @@ discard block |
||
1298 | 1348 | $sort_columns = array( |
1299 | 1349 | 'pm.id_pm', |
1300 | 1350 | ); |
1301 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
1302 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1351 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
1352 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1353 | + } |
|
1303 | 1354 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
1304 | 1355 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
1305 | 1356 | |
@@ -1309,24 +1360,27 @@ discard block |
||
1309 | 1360 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
1310 | 1361 | { |
1311 | 1362 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
1312 | - if (isset($search_params['labels'])) |
|
1313 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1363 | + if (isset($search_params['labels'])) { |
|
1364 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1365 | + } |
|
1314 | 1366 | |
1315 | 1367 | // Assuming we have some labels - make them all integers. |
1316 | 1368 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
1317 | 1369 | { |
1318 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
1319 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1370 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
1371 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1372 | + } |
|
1373 | + } else { |
|
1374 | + $_REQUEST['searchlabel'] = array(); |
|
1320 | 1375 | } |
1321 | - else |
|
1322 | - $_REQUEST['searchlabel'] = array(); |
|
1323 | 1376 | |
1324 | 1377 | // Now that everything is cleaned up a bit, make the labels a param. |
1325 | 1378 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
1326 | 1379 | |
1327 | 1380 | // No labels selected? That must be an error! |
1328 | - if (empty($_REQUEST['searchlabel'])) |
|
1329 | - $context['search_errors']['no_labels_selected'] = true; |
|
1381 | + if (empty($_REQUEST['searchlabel'])) { |
|
1382 | + $context['search_errors']['no_labels_selected'] = true; |
|
1383 | + } |
|
1330 | 1384 | // Otherwise prepare the query! |
1331 | 1385 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
1332 | 1386 | { |
@@ -1349,8 +1403,7 @@ discard block |
||
1349 | 1403 | // Not searching the inbox - PM must be labeled |
1350 | 1404 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
1351 | 1405 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
1352 | - } |
|
1353 | - else |
|
1406 | + } else |
|
1354 | 1407 | { |
1355 | 1408 | // Searching the inbox - PM doesn't have to be labeled |
1356 | 1409 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1365,8 +1418,9 @@ discard block |
||
1365 | 1418 | // What are we actually searching for? |
1366 | 1419 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
1367 | 1420 | // If we ain't got nothing - we should error! |
1368 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
1369 | - $context['search_errors']['invalid_search_string'] = true; |
|
1421 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
1422 | + $context['search_errors']['invalid_search_string'] = true; |
|
1423 | + } |
|
1370 | 1424 | |
1371 | 1425 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
1372 | 1426 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1379,12 +1433,14 @@ discard block |
||
1379 | 1433 | $excludedWords = array(); |
1380 | 1434 | |
1381 | 1435 | // .. first, we check for things like -"some words", but not "-some words". |
1382 | - foreach ($matches[1] as $index => $word) |
|
1383 | - if ($word == '-') |
|
1436 | + foreach ($matches[1] as $index => $word) { |
|
1437 | + if ($word == '-') |
|
1384 | 1438 | { |
1385 | 1439 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
1386 | - if (strlen($word) > 0) |
|
1387 | - $excludedWords[] = $word; |
|
1440 | + } |
|
1441 | + if (strlen($word) > 0) { |
|
1442 | + $excludedWords[] = $word; |
|
1443 | + } |
|
1388 | 1444 | unset($searchArray[$index]); |
1389 | 1445 | } |
1390 | 1446 | |
@@ -1394,8 +1450,9 @@ discard block |
||
1394 | 1450 | if (strpos(trim($word), '-') === 0) |
1395 | 1451 | { |
1396 | 1452 | $word = substr($smcFunc['strtolower']($word), 1); |
1397 | - if (strlen($word) > 0) |
|
1398 | - $excludedWords[] = $word; |
|
1453 | + if (strlen($word) > 0) { |
|
1454 | + $excludedWords[] = $word; |
|
1455 | + } |
|
1399 | 1456 | unset($tempSearch[$index]); |
1400 | 1457 | } |
1401 | 1458 | } |
@@ -1406,9 +1463,9 @@ discard block |
||
1406 | 1463 | foreach ($searchArray as $index => $value) |
1407 | 1464 | { |
1408 | 1465 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
1409 | - if ($searchArray[$index] == '') |
|
1410 | - unset($searchArray[$index]); |
|
1411 | - else |
|
1466 | + if ($searchArray[$index] == '') { |
|
1467 | + unset($searchArray[$index]); |
|
1468 | + } else |
|
1412 | 1469 | { |
1413 | 1470 | // Sort out entities first. |
1414 | 1471 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1418,27 +1475,32 @@ discard block |
||
1418 | 1475 | |
1419 | 1476 | // Create an array of replacements for highlighting. |
1420 | 1477 | $context['mark'] = array(); |
1421 | - foreach ($searchArray as $word) |
|
1422 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1478 | + foreach ($searchArray as $word) { |
|
1479 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1480 | + } |
|
1423 | 1481 | |
1424 | 1482 | // This contains *everything* |
1425 | 1483 | $searchWords = array_merge($searchArray, $excludedWords); |
1426 | 1484 | |
1427 | 1485 | // Make sure at least one word is being searched for. |
1428 | - if (empty($searchArray)) |
|
1429 | - $context['search_errors']['invalid_search_string'] = true; |
|
1486 | + if (empty($searchArray)) { |
|
1487 | + $context['search_errors']['invalid_search_string'] = true; |
|
1488 | + } |
|
1430 | 1489 | |
1431 | 1490 | // Sort out the search query so the user can edit it - if they want. |
1432 | 1491 | $context['search_params'] = $search_params; |
1433 | - if (isset($context['search_params']['search'])) |
|
1434 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1435 | - if (isset($context['search_params']['userspec'])) |
|
1436 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1492 | + if (isset($context['search_params']['search'])) { |
|
1493 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1494 | + } |
|
1495 | + if (isset($context['search_params']['userspec'])) { |
|
1496 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1497 | + } |
|
1437 | 1498 | |
1438 | 1499 | // Now we have all the parameters, combine them together for pagination and the like... |
1439 | 1500 | $context['params'] = array(); |
1440 | - foreach ($search_params as $k => $v) |
|
1441 | - $context['params'][] = $k . '|\'|' . $v; |
|
1501 | + foreach ($search_params as $k => $v) { |
|
1502 | + $context['params'][] = $k . '|\'|' . $v; |
|
1503 | + } |
|
1442 | 1504 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
1443 | 1505 | |
1444 | 1506 | // Compile the subject query part. |
@@ -1446,26 +1508,31 @@ discard block |
||
1446 | 1508 | |
1447 | 1509 | foreach ($searchWords as $index => $word) |
1448 | 1510 | { |
1449 | - if ($word == '') |
|
1450 | - continue; |
|
1511 | + if ($word == '') { |
|
1512 | + continue; |
|
1513 | + } |
|
1451 | 1514 | |
1452 | - if ($search_params['subject_only']) |
|
1453 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1454 | - else |
|
1455 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1515 | + if ($search_params['subject_only']) { |
|
1516 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1517 | + } else { |
|
1518 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1519 | + } |
|
1456 | 1520 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
1457 | 1521 | } |
1458 | 1522 | |
1459 | 1523 | $searchQuery = ' 1=1'; |
1460 | - if (!empty($andQueryParts)) |
|
1461 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1524 | + if (!empty($andQueryParts)) { |
|
1525 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1526 | + } |
|
1462 | 1527 | |
1463 | 1528 | // Age limits? |
1464 | 1529 | $timeQuery = ''; |
1465 | - if (!empty($search_params['minage'])) |
|
1466 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1467 | - if (!empty($search_params['maxage'])) |
|
1468 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1530 | + if (!empty($search_params['minage'])) { |
|
1531 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1532 | + } |
|
1533 | + if (!empty($search_params['maxage'])) { |
|
1534 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1535 | + } |
|
1469 | 1536 | |
1470 | 1537 | // If we have errors - return back to the first screen... |
1471 | 1538 | if (!empty($context['search_errors'])) |
@@ -1551,8 +1618,9 @@ discard block |
||
1551 | 1618 | ) |
1552 | 1619 | ); |
1553 | 1620 | $real_pm_ids = array(); |
1554 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1555 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1622 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1623 | + } |
|
1556 | 1624 | $smcFunc['db_free_result']($request); |
1557 | 1625 | } |
1558 | 1626 | |
@@ -1582,8 +1650,9 @@ discard block |
||
1582 | 1650 | ); |
1583 | 1651 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1584 | 1652 | { |
1585 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
1586 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1653 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
1654 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1655 | + } |
|
1587 | 1656 | |
1588 | 1657 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
1589 | 1658 | { |
@@ -1604,12 +1673,14 @@ discard block |
||
1604 | 1673 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
1605 | 1674 | { |
1606 | 1675 | $l_id = $row2['id_label']; |
1607 | - if (isset($context['labels'][$l_id])) |
|
1608 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1676 | + if (isset($context['labels'][$l_id])) { |
|
1677 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1678 | + } |
|
1609 | 1679 | |
1610 | 1680 | // Here we find the first label on a message - for linking to posts in results |
1611 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
1612 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
1681 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
1682 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
1683 | + } |
|
1613 | 1684 | } |
1614 | 1685 | |
1615 | 1686 | $smcFunc['db_free_result']($request2); |
@@ -1736,8 +1807,9 @@ discard block |
||
1736 | 1807 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
1737 | 1808 | $smcFunc['db_free_result']($request); |
1738 | 1809 | |
1739 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
1740 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1810 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
1811 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1812 | + } |
|
1741 | 1813 | } |
1742 | 1814 | |
1743 | 1815 | // Quoting/Replying to a message? |
@@ -1746,8 +1818,9 @@ discard block |
||
1746 | 1818 | $pmsg = (int) $_REQUEST['pmsg']; |
1747 | 1819 | |
1748 | 1820 | // Make sure this is yours. |
1749 | - if (!isAccessiblePM($pmsg)) |
|
1750 | - fatal_lang_error('no_access', false); |
|
1821 | + if (!isAccessiblePM($pmsg)) { |
|
1822 | + fatal_lang_error('no_access', false); |
|
1823 | + } |
|
1751 | 1824 | |
1752 | 1825 | // Work out whether this is one you've received? |
1753 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1784,8 +1857,9 @@ discard block |
||
1784 | 1857 | 'id_pm' => $pmsg, |
1785 | 1858 | ) |
1786 | 1859 | ); |
1787 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1788 | - fatal_lang_error('pm_not_yours', false); |
|
1860 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1861 | + fatal_lang_error('pm_not_yours', false); |
|
1862 | + } |
|
1789 | 1863 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
1790 | 1864 | $smcFunc['db_free_result']($request); |
1791 | 1865 | |
@@ -1796,9 +1870,9 @@ discard block |
||
1796 | 1870 | // Add 'Re: ' to it.... |
1797 | 1871 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
1798 | 1872 | { |
1799 | - if ($language === $user_info['language']) |
|
1800 | - $context['response_prefix'] = $txt['response_prefix']; |
|
1801 | - else |
|
1873 | + if ($language === $user_info['language']) { |
|
1874 | + $context['response_prefix'] = $txt['response_prefix']; |
|
1875 | + } else |
|
1802 | 1876 | { |
1803 | 1877 | loadLanguage('index', $language, false); |
1804 | 1878 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1807,22 +1881,25 @@ discard block |
||
1807 | 1881 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
1808 | 1882 | } |
1809 | 1883 | $form_subject = $row_quoted['subject']; |
1810 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
1811 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
1884 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
1885 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
1886 | + } |
|
1812 | 1887 | |
1813 | 1888 | if (isset($_REQUEST['quote'])) |
1814 | 1889 | { |
1815 | 1890 | // Remove any nested quotes and <br>... |
1816 | 1891 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
1817 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
1818 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1819 | - if (empty($row_quoted['id_member'])) |
|
1820 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1821 | - else |
|
1822 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1892 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
1893 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1894 | + } |
|
1895 | + if (empty($row_quoted['id_member'])) { |
|
1896 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1897 | + } else { |
|
1898 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1899 | + } |
|
1900 | + } else { |
|
1901 | + $form_message = ''; |
|
1823 | 1902 | } |
1824 | - else |
|
1825 | - $form_message = ''; |
|
1826 | 1903 | |
1827 | 1904 | // Do the BBC thang on the message. |
1828 | 1905 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1843,8 +1920,7 @@ discard block |
||
1843 | 1920 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
1844 | 1921 | 'body' => $row_quoted['body'] |
1845 | 1922 | ); |
1846 | - } |
|
1847 | - else |
|
1923 | + } else |
|
1848 | 1924 | { |
1849 | 1925 | $context['quoted_message'] = false; |
1850 | 1926 | $form_subject = ''; |
@@ -1863,11 +1939,12 @@ discard block |
||
1863 | 1939 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
1864 | 1940 | { |
1865 | 1941 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
1866 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
1867 | - $context['recipients']['to'][] = array( |
|
1942 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
1943 | + $context['recipients']['to'][] = array( |
|
1868 | 1944 | 'id' => $row_quoted['id_member'], |
1869 | 1945 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
1870 | 1946 | ); |
1947 | + } |
|
1871 | 1948 | |
1872 | 1949 | // Now to get the others. |
1873 | 1950 | $request = $smcFunc['db_query']('', ' |
@@ -1883,18 +1960,19 @@ discard block |
||
1883 | 1960 | 'not_bcc' => 0, |
1884 | 1961 | ) |
1885 | 1962 | ); |
1886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1887 | - $context['recipients']['to'][] = array( |
|
1963 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1964 | + $context['recipients']['to'][] = array( |
|
1888 | 1965 | 'id' => $row['id_member'], |
1889 | 1966 | 'name' => $row['real_name'], |
1890 | 1967 | ); |
1968 | + } |
|
1891 | 1969 | $smcFunc['db_free_result']($request); |
1892 | - } |
|
1893 | - else |
|
1970 | + } else |
|
1894 | 1971 | { |
1895 | 1972 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
1896 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
1897 | - $_REQUEST['u'][$key] = (int) $uID; |
|
1973 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
1974 | + $_REQUEST['u'][$key] = (int) $uID; |
|
1975 | + } |
|
1898 | 1976 | |
1899 | 1977 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
1900 | 1978 | |
@@ -1908,22 +1986,24 @@ discard block |
||
1908 | 1986 | 'limit' => count($_REQUEST['u']), |
1909 | 1987 | ) |
1910 | 1988 | ); |
1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1912 | - $context['recipients']['to'][] = array( |
|
1989 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1990 | + $context['recipients']['to'][] = array( |
|
1913 | 1991 | 'id' => $row['id_member'], |
1914 | 1992 | 'name' => $row['real_name'], |
1915 | 1993 | ); |
1994 | + } |
|
1916 | 1995 | $smcFunc['db_free_result']($request); |
1917 | 1996 | } |
1918 | 1997 | |
1919 | 1998 | // Get a literal name list in case the user has JavaScript disabled. |
1920 | 1999 | $names = array(); |
1921 | - foreach ($context['recipients']['to'] as $to) |
|
1922 | - $names[] = $to['name']; |
|
2000 | + foreach ($context['recipients']['to'] as $to) { |
|
2001 | + $names[] = $to['name']; |
|
2002 | + } |
|
1923 | 2003 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
2004 | + } else { |
|
2005 | + $context['to_value'] = ''; |
|
1924 | 2006 | } |
1925 | - else |
|
1926 | - $context['to_value'] = ''; |
|
1927 | 2007 | |
1928 | 2008 | // Set the defaults... |
1929 | 2009 | $context['subject'] = $form_subject; |
@@ -1993,8 +2073,9 @@ discard block |
||
1993 | 2073 | |
1994 | 2074 | // validate with loadMemberData() |
1995 | 2075 | $memberResult = loadMemberData($user_info['id'], false); |
1996 | - if (!$memberResult) |
|
1997 | - fatal_lang_error('not_a_user', false); |
|
2076 | + if (!$memberResult) { |
|
2077 | + fatal_lang_error('not_a_user', false); |
|
2078 | + } |
|
1998 | 2079 | list ($memID) = $memberResult; |
1999 | 2080 | |
2000 | 2081 | // drafts is where the functions reside |
@@ -2020,9 +2101,9 @@ discard block |
||
2020 | 2101 | $context['sub_template'] = 'send'; |
2021 | 2102 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
2022 | 2103 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
2104 | + } else { |
|
2105 | + $context['sub_template'] = 'pm'; |
|
2023 | 2106 | } |
2024 | - else |
|
2025 | - $context['sub_template'] = 'pm'; |
|
2026 | 2107 | |
2027 | 2108 | $context['page_title'] = $txt['send_message']; |
2028 | 2109 | |
@@ -2083,10 +2164,11 @@ discard block |
||
2083 | 2164 | ); |
2084 | 2165 | if ($smcFunc['db_num_rows']($request) == 0) |
2085 | 2166 | { |
2086 | - if (!isset($_REQUEST['xml'])) |
|
2087 | - fatal_lang_error('pm_not_yours', false); |
|
2088 | - else |
|
2089 | - $error_types[] = 'pm_not_yours'; |
|
2167 | + if (!isset($_REQUEST['xml'])) { |
|
2168 | + fatal_lang_error('pm_not_yours', false); |
|
2169 | + } else { |
|
2170 | + $error_types[] = 'pm_not_yours'; |
|
2171 | + } |
|
2090 | 2172 | } |
2091 | 2173 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
2092 | 2174 | $smcFunc['db_free_result']($request); |
@@ -2133,14 +2215,16 @@ discard block |
||
2133 | 2215 | $context['post_error'][$error_type] = true; |
2134 | 2216 | if (isset($txt['error_' . $error_type])) |
2135 | 2217 | { |
2136 | - if ($error_type == 'long_message') |
|
2137 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2218 | + if ($error_type == 'long_message') { |
|
2219 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2220 | + } |
|
2138 | 2221 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
2139 | 2222 | } |
2140 | 2223 | |
2141 | 2224 | // If it's not a minor error flag it as such. |
2142 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
2143 | - $context['error_type'] = 'serious'; |
|
2225 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
2226 | + $context['error_type'] = 'serious'; |
|
2227 | + } |
|
2144 | 2228 | } |
2145 | 2229 | |
2146 | 2230 | // We need to load the editor once more. |
@@ -2198,8 +2282,9 @@ discard block |
||
2198 | 2282 | require_once($sourcedir . '/Subs-Auth.php'); |
2199 | 2283 | |
2200 | 2284 | // PM Drafts enabled and needed? |
2201 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
2202 | - require_once($sourcedir . '/Drafts.php'); |
|
2285 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
2286 | + require_once($sourcedir . '/Drafts.php'); |
|
2287 | + } |
|
2203 | 2288 | |
2204 | 2289 | loadLanguage('PersonalMessage', '', false); |
2205 | 2290 | |
@@ -2229,24 +2314,27 @@ discard block |
||
2229 | 2314 | |
2230 | 2315 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
2231 | 2316 | { |
2232 | - if (!isset($_REQUEST['xml'])) |
|
2233 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2234 | - else |
|
2235 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
2317 | + if (!isset($_REQUEST['xml'])) { |
|
2318 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2319 | + } else { |
|
2320 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
2321 | + } |
|
2236 | 2322 | } |
2237 | 2323 | } |
2238 | 2324 | |
2239 | 2325 | // If your session timed out, show an error, but do allow to re-submit. |
2240 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
2241 | - $post_errors[] = 'session_timeout'; |
|
2326 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
2327 | + $post_errors[] = 'session_timeout'; |
|
2328 | + } |
|
2242 | 2329 | |
2243 | 2330 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
2244 | 2331 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
2245 | 2332 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
2246 | 2333 | |
2247 | 2334 | // Route the input from the 'u' parameter to the 'to'-list. |
2248 | - if (!empty($_POST['u'])) |
|
2249 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2335 | + if (!empty($_POST['u'])) { |
|
2336 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2337 | + } |
|
2250 | 2338 | |
2251 | 2339 | // Construct the list of recipients. |
2252 | 2340 | $recipientList = array(); |
@@ -2258,8 +2346,9 @@ discard block |
||
2258 | 2346 | $recipientList[$recipientType] = array(); |
2259 | 2347 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
2260 | 2348 | { |
2261 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
2262 | - $recipientList[$recipientType][] = (int) $recipient; |
|
2349 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
2350 | + $recipientList[$recipientType][] = (int) $recipient; |
|
2351 | + } |
|
2263 | 2352 | } |
2264 | 2353 | |
2265 | 2354 | // Are there also literal names set? |
@@ -2273,10 +2362,11 @@ discard block |
||
2273 | 2362 | |
2274 | 2363 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
2275 | 2364 | { |
2276 | - if (strlen(trim($recipient)) > 0) |
|
2277 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2278 | - else |
|
2279 | - unset($namedRecipientList[$recipientType][$index]); |
|
2365 | + if (strlen(trim($recipient)) > 0) { |
|
2366 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2367 | + } else { |
|
2368 | + unset($namedRecipientList[$recipientType][$index]); |
|
2369 | + } |
|
2280 | 2370 | } |
2281 | 2371 | |
2282 | 2372 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2306,8 +2396,9 @@ discard block |
||
2306 | 2396 | } |
2307 | 2397 | |
2308 | 2398 | // Selected a recipient to be deleted? Remove them now. |
2309 | - if (!empty($_POST['delete_recipient'])) |
|
2310 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2399 | + if (!empty($_POST['delete_recipient'])) { |
|
2400 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2401 | + } |
|
2311 | 2402 | |
2312 | 2403 | // Make sure we don't include the same name twice |
2313 | 2404 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2317,8 +2408,9 @@ discard block |
||
2317 | 2408 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
2318 | 2409 | |
2319 | 2410 | // Check if there's at least one recipient. |
2320 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
2321 | - $post_errors[] = 'no_to'; |
|
2411 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
2412 | + $post_errors[] = 'no_to'; |
|
2413 | + } |
|
2322 | 2414 | |
2323 | 2415 | // Make sure that we remove the members who did get it from the screen. |
2324 | 2416 | if (!$is_recipient_change) |
@@ -2332,28 +2424,31 @@ discard block |
||
2332 | 2424 | // Since we already have a post error, remove the previous one. |
2333 | 2425 | $post_errors = array_diff($post_errors, array('no_to')); |
2334 | 2426 | |
2335 | - foreach ($namesNotFound[$recipientType] as $name) |
|
2336 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2427 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
2428 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2429 | + } |
|
2337 | 2430 | } |
2338 | 2431 | } |
2339 | 2432 | } |
2340 | 2433 | |
2341 | 2434 | // Did they make any mistakes? |
2342 | - if ($_REQUEST['subject'] == '') |
|
2343 | - $post_errors[] = 'no_subject'; |
|
2344 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
2345 | - $post_errors[] = 'no_message'; |
|
2346 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
2347 | - $post_errors[] = 'long_message'; |
|
2348 | - else |
|
2435 | + if ($_REQUEST['subject'] == '') { |
|
2436 | + $post_errors[] = 'no_subject'; |
|
2437 | + } |
|
2438 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
2439 | + $post_errors[] = 'no_message'; |
|
2440 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
2441 | + $post_errors[] = 'long_message'; |
|
2442 | + } else |
|
2349 | 2443 | { |
2350 | 2444 | // Preparse the message. |
2351 | 2445 | $message = $_REQUEST['message']; |
2352 | 2446 | preparsecode($message); |
2353 | 2447 | |
2354 | 2448 | // Make sure there's still some content left without the tags. |
2355 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
2356 | - $post_errors[] = 'no_message'; |
|
2449 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
2450 | + $post_errors[] = 'no_message'; |
|
2451 | + } |
|
2357 | 2452 | } |
2358 | 2453 | |
2359 | 2454 | // Wrong verification code? |
@@ -2365,13 +2460,15 @@ discard block |
||
2365 | 2460 | ); |
2366 | 2461 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
2367 | 2462 | |
2368 | - if (is_array($context['require_verification'])) |
|
2369 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2463 | + if (is_array($context['require_verification'])) { |
|
2464 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2465 | + } |
|
2370 | 2466 | } |
2371 | 2467 | |
2372 | 2468 | // If they did, give a chance to make ammends. |
2373 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
2374 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2469 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
2470 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2471 | + } |
|
2375 | 2472 | |
2376 | 2473 | // Want to take a second glance before you send? |
2377 | 2474 | if (isset($_REQUEST['preview'])) |
@@ -2402,8 +2499,9 @@ discard block |
||
2402 | 2499 | foreach ($namesNotFound as $recipientType => $names) |
2403 | 2500 | { |
2404 | 2501 | $post_errors[] = 'bad_' . $recipientType; |
2405 | - foreach ($names as $name) |
|
2406 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2502 | + foreach ($names as $name) { |
|
2503 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2504 | + } |
|
2407 | 2505 | } |
2408 | 2506 | |
2409 | 2507 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2433,13 +2531,14 @@ discard block |
||
2433 | 2531 | checkSubmitOnce('check'); |
2434 | 2532 | |
2435 | 2533 | // Do the actual sending of the PM. |
2436 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
2437 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2438 | - else |
|
2439 | - $context['send_log'] = array( |
|
2534 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
2535 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2536 | + } else { |
|
2537 | + $context['send_log'] = array( |
|
2440 | 2538 | 'sent' => array(), |
2441 | 2539 | 'failed' => array() |
2442 | 2540 | ); |
2541 | + } |
|
2443 | 2542 | |
2444 | 2543 | // Mark the message as "replied to". |
2445 | 2544 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2457,11 +2556,12 @@ discard block |
||
2457 | 2556 | } |
2458 | 2557 | |
2459 | 2558 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
2460 | - if (!empty($context['send_log']['failed'])) |
|
2461 | - return messagePostError($post_errors, $namesNotFound, array( |
|
2559 | + if (!empty($context['send_log']['failed'])) { |
|
2560 | + return messagePostError($post_errors, $namesNotFound, array( |
|
2462 | 2561 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
2463 | 2562 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
2464 | 2563 | )); |
2564 | + } |
|
2465 | 2565 | |
2466 | 2566 | // Message sent successfully? |
2467 | 2567 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2469,8 +2569,9 @@ discard block |
||
2469 | 2569 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
2470 | 2570 | |
2471 | 2571 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
2472 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
2473 | - DeleteDraft($_POST['id_pm_draft']); |
|
2572 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
2573 | + DeleteDraft($_POST['id_pm_draft']); |
|
2574 | + } |
|
2474 | 2575 | } |
2475 | 2576 | |
2476 | 2577 | // Go back to the where they sent from, if possible... |
@@ -2485,24 +2586,28 @@ discard block |
||
2485 | 2586 | |
2486 | 2587 | checkSession('request'); |
2487 | 2588 | |
2488 | - if (isset($_REQUEST['del_selected'])) |
|
2489 | - $_REQUEST['pm_action'] = 'delete'; |
|
2589 | + if (isset($_REQUEST['del_selected'])) { |
|
2590 | + $_REQUEST['pm_action'] = 'delete'; |
|
2591 | + } |
|
2490 | 2592 | |
2491 | 2593 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
2492 | 2594 | { |
2493 | - foreach ($_REQUEST['pms'] as $pm) |
|
2494 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2595 | + foreach ($_REQUEST['pms'] as $pm) { |
|
2596 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2597 | + } |
|
2495 | 2598 | } |
2496 | 2599 | |
2497 | - if (empty($_REQUEST['pm_actions'])) |
|
2498 | - redirectexit($context['current_label_redirect']); |
|
2600 | + if (empty($_REQUEST['pm_actions'])) { |
|
2601 | + redirectexit($context['current_label_redirect']); |
|
2602 | + } |
|
2499 | 2603 | |
2500 | 2604 | // If we are in conversation, we may need to apply this to every message in the conversation. |
2501 | 2605 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
2502 | 2606 | { |
2503 | 2607 | $id_pms = array(); |
2504 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
2505 | - $id_pms[] = (int) $pm; |
|
2608 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
2609 | + $id_pms[] = (int) $pm; |
|
2610 | + } |
|
2506 | 2611 | |
2507 | 2612 | $request = $smcFunc['db_query']('', ' |
2508 | 2613 | SELECT id_pm_head, id_pm |
@@ -2513,8 +2618,9 @@ discard block |
||
2513 | 2618 | ) |
2514 | 2619 | ); |
2515 | 2620 | $pm_heads = array(); |
2516 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2517 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2622 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2623 | + } |
|
2518 | 2624 | $smcFunc['db_free_result']($request); |
2519 | 2625 | |
2520 | 2626 | $request = $smcFunc['db_query']('', ' |
@@ -2528,8 +2634,9 @@ discard block |
||
2528 | 2634 | // Copy the action from the single to PM to the others. |
2529 | 2635 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2530 | 2636 | { |
2531 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
2532 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2637 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
2638 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2639 | + } |
|
2533 | 2640 | } |
2534 | 2641 | $smcFunc['db_free_result']($request); |
2535 | 2642 | } |
@@ -2540,22 +2647,21 @@ discard block |
||
2540 | 2647 | $labels = array(); |
2541 | 2648 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
2542 | 2649 | { |
2543 | - if ($action === 'delete') |
|
2544 | - $to_delete[] = (int) $pm; |
|
2545 | - else |
|
2650 | + if ($action === 'delete') { |
|
2651 | + $to_delete[] = (int) $pm; |
|
2652 | + } else |
|
2546 | 2653 | { |
2547 | 2654 | if (substr($action, 0, 4) == 'add_') |
2548 | 2655 | { |
2549 | 2656 | $type = 'add'; |
2550 | 2657 | $action = substr($action, 4); |
2551 | - } |
|
2552 | - elseif (substr($action, 0, 4) == 'rem_') |
|
2658 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
2553 | 2659 | { |
2554 | 2660 | $type = 'rem'; |
2555 | 2661 | $action = substr($action, 4); |
2662 | + } else { |
|
2663 | + $type = 'unk'; |
|
2556 | 2664 | } |
2557 | - else |
|
2558 | - $type = 'unk'; |
|
2559 | 2665 | |
2560 | 2666 | if ($action == '-1' || (int) $action > 0) |
2561 | 2667 | { |
@@ -2566,8 +2672,9 @@ discard block |
||
2566 | 2672 | } |
2567 | 2673 | |
2568 | 2674 | // Deleting, it looks like? |
2569 | - if (!empty($to_delete)) |
|
2570 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2675 | + if (!empty($to_delete)) { |
|
2676 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2677 | + } |
|
2571 | 2678 | |
2572 | 2679 | // Are we labeling anything? |
2573 | 2680 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2633,8 +2740,7 @@ discard block |
||
2633 | 2740 | } |
2634 | 2741 | |
2635 | 2742 | $smcFunc['db_free_result']($request2); |
2636 | - } |
|
2637 | - elseif ($type == 'rem') |
|
2743 | + } elseif ($type == 'rem') |
|
2638 | 2744 | { |
2639 | 2745 | // If we're removing from the inbox, see if we have at least one other label. |
2640 | 2746 | // This query is faster than the one above |
@@ -2666,21 +2772,25 @@ discard block |
||
2666 | 2772 | if ($to_label[$row['id_pm']] != '-1') |
2667 | 2773 | { |
2668 | 2774 | // If this label is in the list and we're not adding it, remove it |
2669 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
2670 | - unset($labels[$to_label[$row['id_pm']]]); |
|
2671 | - else if ($type !== 'rem') |
|
2672 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2775 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
2776 | + unset($labels[$to_label[$row['id_pm']]]); |
|
2777 | + } else if ($type !== 'rem') { |
|
2778 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2779 | + } |
|
2673 | 2780 | } |
2674 | 2781 | |
2675 | 2782 | // Removing all labels or just removing the inbox label |
2676 | - if ($type == 'rem' && empty($labels)) |
|
2677 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2783 | + if ($type == 'rem' && empty($labels)) { |
|
2784 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2785 | + } |
|
2678 | 2786 | // Adding new labels, but removing inbox and applying new ones |
2679 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
2680 | - $in_inbox = 0; |
|
2787 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
2788 | + $in_inbox = 0; |
|
2789 | + } |
|
2681 | 2790 | // Just adding it to the inbox |
2682 | - else |
|
2683 | - $in_inbox = 1; |
|
2791 | + else { |
|
2792 | + $in_inbox = 1; |
|
2793 | + } |
|
2684 | 2794 | |
2685 | 2795 | // Are we adding it to or removing it from the inbox? |
2686 | 2796 | if ($in_inbox != $row['in_inbox']) |
@@ -2722,8 +2832,9 @@ discard block |
||
2722 | 2832 | if (!empty($labels_to_apply)) |
2723 | 2833 | { |
2724 | 2834 | $inserts = array(); |
2725 | - foreach ($labels_to_apply as $label) |
|
2726 | - $inserts[] = array($row['id_pm'], $label); |
|
2835 | + foreach ($labels_to_apply as $label) { |
|
2836 | + $inserts[] = array($row['id_pm'], $label); |
|
2837 | + } |
|
2727 | 2838 | |
2728 | 2839 | $smcFunc['db_insert']('', |
2729 | 2840 | '{db_prefix}pm_labeled_messages', |
@@ -2767,11 +2878,13 @@ discard block |
||
2767 | 2878 | checkSession('get'); |
2768 | 2879 | |
2769 | 2880 | // If all then delete all messages the user has. |
2770 | - if ($_REQUEST['f'] == 'all') |
|
2771 | - deleteMessages(null, null); |
|
2881 | + if ($_REQUEST['f'] == 'all') { |
|
2882 | + deleteMessages(null, null); |
|
2883 | + } |
|
2772 | 2884 | // Otherwise just the selected folder. |
2773 | - else |
|
2774 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2885 | + else { |
|
2886 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2887 | + } |
|
2775 | 2888 | |
2776 | 2889 | // Done... all gone. |
2777 | 2890 | redirectexit($context['current_label_redirect']); |
@@ -2808,8 +2921,9 @@ discard block |
||
2808 | 2921 | 'msgtime' => $deleteTime, |
2809 | 2922 | ) |
2810 | 2923 | ); |
2811 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2812 | - $toDelete[] = $row[0]; |
|
2924 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2925 | + $toDelete[] = $row[0]; |
|
2926 | + } |
|
2813 | 2927 | $smcFunc['db_free_result']($request); |
2814 | 2928 | |
2815 | 2929 | // Select all messages in their inbox older than $deleteTime. |
@@ -2826,8 +2940,9 @@ discard block |
||
2826 | 2940 | 'msgtime' => $deleteTime, |
2827 | 2941 | ) |
2828 | 2942 | ); |
2829 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2830 | - $toDelete[] = $row['id_pm']; |
|
2943 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2944 | + $toDelete[] = $row['id_pm']; |
|
2945 | + } |
|
2831 | 2946 | $smcFunc['db_free_result']($request); |
2832 | 2947 | |
2833 | 2948 | // Delete the actual messages. |
@@ -2858,26 +2973,29 @@ discard block |
||
2858 | 2973 | { |
2859 | 2974 | global $user_info, $smcFunc; |
2860 | 2975 | |
2861 | - if ($owner === null) |
|
2862 | - $owner = array($user_info['id']); |
|
2863 | - elseif (empty($owner)) |
|
2864 | - return; |
|
2865 | - elseif (!is_array($owner)) |
|
2866 | - $owner = array($owner); |
|
2976 | + if ($owner === null) { |
|
2977 | + $owner = array($user_info['id']); |
|
2978 | + } elseif (empty($owner)) { |
|
2979 | + return; |
|
2980 | + } elseif (!is_array($owner)) { |
|
2981 | + $owner = array($owner); |
|
2982 | + } |
|
2867 | 2983 | |
2868 | 2984 | if ($personal_messages !== null) |
2869 | 2985 | { |
2870 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
2871 | - return; |
|
2986 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
2987 | + return; |
|
2988 | + } |
|
2872 | 2989 | |
2873 | - foreach ($personal_messages as $index => $delete_id) |
|
2874 | - $personal_messages[$index] = (int) $delete_id; |
|
2990 | + foreach ($personal_messages as $index => $delete_id) { |
|
2991 | + $personal_messages[$index] = (int) $delete_id; |
|
2992 | + } |
|
2875 | 2993 | |
2876 | 2994 | $where = ' |
2877 | 2995 | AND id_pm IN ({array_int:pm_list})'; |
2996 | + } else { |
|
2997 | + $where = ''; |
|
2878 | 2998 | } |
2879 | - else |
|
2880 | - $where = ''; |
|
2881 | 2999 | |
2882 | 3000 | if ($folder == 'sent' || $folder === null) |
2883 | 3001 | { |
@@ -2912,17 +3030,19 @@ discard block |
||
2912 | 3030 | // ...And update the statistics accordingly - now including unread messages!. |
2913 | 3031 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2914 | 3032 | { |
2915 | - if ($row['is_read']) |
|
2916 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
2917 | - else |
|
2918 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3033 | + if ($row['is_read']) { |
|
3034 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
3035 | + } else { |
|
3036 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3037 | + } |
|
2919 | 3038 | |
2920 | 3039 | // If this is the current member we need to make their message count correct. |
2921 | 3040 | if ($user_info['id'] == $row['id_member']) |
2922 | 3041 | { |
2923 | 3042 | $user_info['messages'] -= $row['num_deleted_messages']; |
2924 | - if (!($row['is_read'])) |
|
2925 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3043 | + if (!($row['is_read'])) { |
|
3044 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3045 | + } |
|
2926 | 3046 | } |
2927 | 3047 | } |
2928 | 3048 | $smcFunc['db_free_result']($request); |
@@ -2990,8 +3110,9 @@ discard block |
||
2990 | 3110 | ) |
2991 | 3111 | ); |
2992 | 3112 | $remove_pms = array(); |
2993 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2994 | - $remove_pms[] = $row['sender']; |
|
3113 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3114 | + $remove_pms[] = $row['sender']; |
|
3115 | + } |
|
2995 | 3116 | $smcFunc['db_free_result']($request); |
2996 | 3117 | |
2997 | 3118 | if (!empty($remove_pms)) |
@@ -3036,8 +3157,9 @@ discard block |
||
3036 | 3157 | { |
3037 | 3158 | global $user_info, $context, $smcFunc; |
3038 | 3159 | |
3039 | - if ($owner === null) |
|
3040 | - $owner = $user_info['id']; |
|
3160 | + if ($owner === null) { |
|
3161 | + $owner = $user_info['id']; |
|
3162 | + } |
|
3041 | 3163 | |
3042 | 3164 | $in_inbox = ''; |
3043 | 3165 | |
@@ -3061,8 +3183,7 @@ discard block |
||
3061 | 3183 | } |
3062 | 3184 | |
3063 | 3185 | $smcFunc['db_free_result']($get_messages); |
3064 | - } |
|
3065 | - elseif ($label = '-1') |
|
3186 | + } elseif ($label = '-1') |
|
3066 | 3187 | { |
3067 | 3188 | // Marking all PMs in your inbox read |
3068 | 3189 | $in_inbox = ' |
@@ -3087,8 +3208,9 @@ discard block |
||
3087 | 3208 | { |
3088 | 3209 | if ($owner == $user_info['id']) |
3089 | 3210 | { |
3090 | - foreach ($context['labels'] as $label) |
|
3091 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3211 | + foreach ($context['labels'] as $label) { |
|
3212 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3213 | + } |
|
3092 | 3214 | } |
3093 | 3215 | |
3094 | 3216 | $result = $smcFunc['db_query']('', ' |
@@ -3108,8 +3230,9 @@ discard block |
||
3108 | 3230 | { |
3109 | 3231 | $total_unread += $row['num']; |
3110 | 3232 | |
3111 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
3112 | - continue; |
|
3233 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
3234 | + continue; |
|
3235 | + } |
|
3113 | 3236 | |
3114 | 3237 | $this_labels = array(); |
3115 | 3238 | |
@@ -3133,11 +3256,13 @@ discard block |
||
3133 | 3256 | |
3134 | 3257 | $smcFunc['db_free_result']($result2); |
3135 | 3258 | |
3136 | - foreach ($this_labels as $this_label) |
|
3137 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3259 | + foreach ($this_labels as $this_label) { |
|
3260 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3261 | + } |
|
3138 | 3262 | |
3139 | - if ($row['in_inbox'] == 1) |
|
3140 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3263 | + if ($row['in_inbox'] == 1) { |
|
3264 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3265 | + } |
|
3141 | 3266 | } |
3142 | 3267 | $smcFunc['db_free_result']($result); |
3143 | 3268 | |
@@ -3146,8 +3271,9 @@ discard block |
||
3146 | 3271 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
3147 | 3272 | |
3148 | 3273 | // If it was for the current member, reflect this in the $user_info array too. |
3149 | - if ($owner == $user_info['id']) |
|
3150 | - $user_info['unread_messages'] = $total_unread; |
|
3274 | + if ($owner == $user_info['id']) { |
|
3275 | + $user_info['unread_messages'] = $total_unread; |
|
3276 | + } |
|
3151 | 3277 | } |
3152 | 3278 | } |
3153 | 3279 | |
@@ -3175,8 +3301,9 @@ discard block |
||
3175 | 3301 | // Add all existing labels to the array to save, slashing them as necessary... |
3176 | 3302 | foreach ($context['labels'] as $label) |
3177 | 3303 | { |
3178 | - if ($label['id'] != -1) |
|
3179 | - $the_labels[$label['id']] = $label['name']; |
|
3304 | + if ($label['id'] != -1) { |
|
3305 | + $the_labels[$label['id']] = $label['name']; |
|
3306 | + } |
|
3180 | 3307 | } |
3181 | 3308 | |
3182 | 3309 | if (isset($_POST[$context['session_var']])) |
@@ -3195,8 +3322,9 @@ discard block |
||
3195 | 3322 | { |
3196 | 3323 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
3197 | 3324 | |
3198 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
3199 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3325 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
3326 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3327 | + } |
|
3200 | 3328 | if ($_POST['label'] != '') |
3201 | 3329 | { |
3202 | 3330 | $the_labels[] = $_POST['label']; |
@@ -3217,24 +3345,25 @@ discard block |
||
3217 | 3345 | { |
3218 | 3346 | foreach ($the_labels as $id => $name) |
3219 | 3347 | { |
3220 | - if ($id == -1) |
|
3221 | - continue; |
|
3222 | - elseif (isset($_POST['label_name'][$id])) |
|
3348 | + if ($id == -1) { |
|
3349 | + continue; |
|
3350 | + } elseif (isset($_POST['label_name'][$id])) |
|
3223 | 3351 | { |
3224 | 3352 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
3225 | 3353 | |
3226 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
3227 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3354 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
3355 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3356 | + } |
|
3228 | 3357 | if ($_POST['label_name'][$id] != '') |
3229 | 3358 | { |
3230 | 3359 | // Changing the name of this label? |
3231 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
3232 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
3360 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
3361 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
3362 | + } |
|
3233 | 3363 | |
3234 | 3364 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
3235 | 3365 | |
3236 | - } |
|
3237 | - else |
|
3366 | + } else |
|
3238 | 3367 | { |
3239 | 3368 | unset($the_labels[(int) $id]); |
3240 | 3369 | $labels_to_remove[] = $id; |
@@ -3248,8 +3377,9 @@ discard block |
||
3248 | 3377 | if (!empty($labels_to_add)) |
3249 | 3378 | { |
3250 | 3379 | $inserts = array(); |
3251 | - foreach ($labels_to_add AS $label) |
|
3252 | - $inserts[] = array($user_info['id'], $label); |
|
3380 | + foreach ($labels_to_add AS $label) { |
|
3381 | + $inserts[] = array($user_info['id'], $label); |
|
3382 | + } |
|
3253 | 3383 | |
3254 | 3384 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
3255 | 3385 | } |
@@ -3339,8 +3469,9 @@ discard block |
||
3339 | 3469 | // Each action... |
3340 | 3470 | foreach ($rule['actions'] as $k2 => $action) |
3341 | 3471 | { |
3342 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
3343 | - continue; |
|
3472 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
3473 | + continue; |
|
3474 | + } |
|
3344 | 3475 | |
3345 | 3476 | $rule_changes[] = $rule['id']; |
3346 | 3477 | |
@@ -3355,8 +3486,8 @@ discard block |
||
3355 | 3486 | { |
3356 | 3487 | $rule_changes = array_unique($rule_changes); |
3357 | 3488 | // Update/delete as appropriate. |
3358 | - foreach ($rule_changes as $k => $id) |
|
3359 | - if (!empty($context['rules'][$id]['actions'])) |
|
3489 | + foreach ($rule_changes as $k => $id) { |
|
3490 | + if (!empty($context['rules'][$id]['actions'])) |
|
3360 | 3491 | { |
3361 | 3492 | $smcFunc['db_query']('', ' |
3362 | 3493 | UPDATE {db_prefix}pm_rules |
@@ -3369,12 +3500,13 @@ discard block |
||
3369 | 3500 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
3370 | 3501 | ) |
3371 | 3502 | ); |
3503 | + } |
|
3372 | 3504 | unset($rule_changes[$k]); |
3373 | 3505 | } |
3374 | 3506 | |
3375 | 3507 | // Anything left here means it's lost all actions... |
3376 | - if (!empty($rule_changes)) |
|
3377 | - $smcFunc['db_query']('', ' |
|
3508 | + if (!empty($rule_changes)) { |
|
3509 | + $smcFunc['db_query']('', ' |
|
3378 | 3510 | DELETE FROM {db_prefix}pm_rules |
3379 | 3511 | WHERE id_rule IN ({array_int:rule_list}) |
3380 | 3512 | AND id_member = {int:current_member}', |
@@ -3383,6 +3515,7 @@ discard block |
||
3383 | 3515 | 'rule_list' => $rule_changes, |
3384 | 3516 | ) |
3385 | 3517 | ); |
3518 | + } |
|
3386 | 3519 | } |
3387 | 3520 | |
3388 | 3521 | // Make sure we're not caching this! |
@@ -3452,8 +3585,9 @@ discard block |
||
3452 | 3585 | // Save the fields. |
3453 | 3586 | saveProfileFields(); |
3454 | 3587 | |
3455 | - if (!empty($profile_vars)) |
|
3456 | - updateMemberData($user_info['id'], $profile_vars); |
|
3588 | + if (!empty($profile_vars)) { |
|
3589 | + updateMemberData($user_info['id'], $profile_vars); |
|
3590 | + } |
|
3457 | 3591 | } |
3458 | 3592 | |
3459 | 3593 | setupProfileContext( |
@@ -3478,13 +3612,15 @@ discard block |
||
3478 | 3612 | global $user_info, $language, $modSettings, $smcFunc; |
3479 | 3613 | |
3480 | 3614 | // Check that this feature is even enabled! |
3481 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
3482 | - fatal_lang_error('no_access', false); |
|
3615 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
3616 | + fatal_lang_error('no_access', false); |
|
3617 | + } |
|
3483 | 3618 | |
3484 | 3619 | $pmsg = (int) $_REQUEST['pmsg']; |
3485 | 3620 | |
3486 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
3487 | - fatal_lang_error('no_access', false); |
|
3621 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
3622 | + fatal_lang_error('no_access', false); |
|
3623 | + } |
|
3488 | 3624 | |
3489 | 3625 | $context['pm_id'] = $pmsg; |
3490 | 3626 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3506,8 +3642,9 @@ discard block |
||
3506 | 3642 | ) |
3507 | 3643 | ); |
3508 | 3644 | $context['admins'] = array(); |
3509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3510 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
3645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3646 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
3647 | + } |
|
3511 | 3648 | $smcFunc['db_free_result']($request); |
3512 | 3649 | |
3513 | 3650 | // How many admins in total? |
@@ -3536,8 +3673,9 @@ discard block |
||
3536 | 3673 | ) |
3537 | 3674 | ); |
3538 | 3675 | // Can only be a hacker here! |
3539 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3540 | - fatal_lang_error('no_access', false); |
|
3676 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3677 | + fatal_lang_error('no_access', false); |
|
3678 | + } |
|
3541 | 3679 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
3542 | 3680 | $smcFunc['db_free_result']($request); |
3543 | 3681 | |
@@ -3561,15 +3699,17 @@ discard block |
||
3561 | 3699 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3562 | 3700 | { |
3563 | 3701 | // If it's hidden still don't reveal their names - privacy after all ;) |
3564 | - if ($row['bcc']) |
|
3565 | - $hidden_recipients++; |
|
3566 | - else |
|
3567 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3702 | + if ($row['bcc']) { |
|
3703 | + $hidden_recipients++; |
|
3704 | + } else { |
|
3705 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3706 | + } |
|
3568 | 3707 | } |
3569 | 3708 | $smcFunc['db_free_result']($request); |
3570 | 3709 | |
3571 | - if ($hidden_recipients) |
|
3572 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3710 | + if ($hidden_recipients) { |
|
3711 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3712 | + } |
|
3573 | 3713 | |
3574 | 3714 | // Now let's get out and loop through the admins. |
3575 | 3715 | $request = $smcFunc['db_query']('', ' |
@@ -3585,8 +3725,9 @@ discard block |
||
3585 | 3725 | ); |
3586 | 3726 | |
3587 | 3727 | // Maybe we shouldn't advertise this? |
3588 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3589 | - fatal_lang_error('no_access', false); |
|
3728 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3729 | + fatal_lang_error('no_access', false); |
|
3730 | + } |
|
3590 | 3731 | |
3591 | 3732 | $memberFromName = un_htmlspecialchars($memberFromName); |
3592 | 3733 | |
@@ -3605,8 +3746,9 @@ discard block |
||
3605 | 3746 | // Make the body. |
3606 | 3747 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
3607 | 3748 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
3608 | - if (!empty($recipients)) |
|
3609 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3749 | + if (!empty($recipients)) { |
|
3750 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3751 | + } |
|
3610 | 3752 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
3611 | 3753 | |
3612 | 3754 | // Plonk it in the array ;) |
@@ -3626,12 +3768,14 @@ discard block |
||
3626 | 3768 | $smcFunc['db_free_result']($request); |
3627 | 3769 | |
3628 | 3770 | // Send a different email for each language. |
3629 | - foreach ($messagesToSend as $lang => $message) |
|
3630 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3771 | + foreach ($messagesToSend as $lang => $message) { |
|
3772 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3773 | + } |
|
3631 | 3774 | |
3632 | 3775 | // Give the user their own language back! |
3633 | - if (!empty($modSettings['userLanguage'])) |
|
3634 | - loadLanguage('PersonalMessage', '', false); |
|
3776 | + if (!empty($modSettings['userLanguage'])) { |
|
3777 | + loadLanguage('PersonalMessage', '', false); |
|
3778 | + } |
|
3635 | 3779 | |
3636 | 3780 | // Leave them with a template. |
3637 | 3781 | $context['sub_template'] = 'report_message_complete'; |
@@ -3677,8 +3821,9 @@ discard block |
||
3677 | 3821 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3678 | 3822 | { |
3679 | 3823 | // Hide hidden groups! |
3680 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
3681 | - continue; |
|
3824 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
3825 | + continue; |
|
3826 | + } |
|
3682 | 3827 | |
3683 | 3828 | $context['groups'][$row['id_group']] = $row['group_name']; |
3684 | 3829 | } |
@@ -3704,9 +3849,10 @@ discard block |
||
3704 | 3849 | $context['rule'] = $context['rules'][$context['rid']]; |
3705 | 3850 | $members = array(); |
3706 | 3851 | // Need to get member names! |
3707 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
3708 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3852 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
3853 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3709 | 3854 | $members[(int) $criteria['v']] = $k; |
3855 | + } |
|
3710 | 3856 | |
3711 | 3857 | if (!empty($members)) |
3712 | 3858 | { |
@@ -3718,19 +3864,20 @@ discard block |
||
3718 | 3864 | 'member_list' => array_keys($members), |
3719 | 3865 | ) |
3720 | 3866 | ); |
3721 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3722 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3868 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3869 | + } |
|
3723 | 3870 | $smcFunc['db_free_result']($request); |
3724 | 3871 | } |
3725 | - } |
|
3726 | - else |
|
3727 | - $context['rule'] = array( |
|
3872 | + } else { |
|
3873 | + $context['rule'] = array( |
|
3728 | 3874 | 'id' => '', |
3729 | 3875 | 'name' => '', |
3730 | 3876 | 'criteria' => array(), |
3731 | 3877 | 'actions' => array(), |
3732 | 3878 | 'logic' => 'and', |
3733 | 3879 | ); |
3880 | + } |
|
3734 | 3881 | } |
3735 | 3882 | // Saving? |
3736 | 3883 | elseif (isset($_GET['save'])) |
@@ -3740,22 +3887,25 @@ discard block |
||
3740 | 3887 | |
3741 | 3888 | // Name is easy! |
3742 | 3889 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
3743 | - if (empty($ruleName)) |
|
3744 | - fatal_lang_error('pm_rule_no_name', false); |
|
3890 | + if (empty($ruleName)) { |
|
3891 | + fatal_lang_error('pm_rule_no_name', false); |
|
3892 | + } |
|
3745 | 3893 | |
3746 | 3894 | // Sanity check... |
3747 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
3748 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3895 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
3896 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3897 | + } |
|
3749 | 3898 | |
3750 | 3899 | // Let's do the criteria first - it's also hardest! |
3751 | 3900 | $criteria = array(); |
3752 | 3901 | foreach ($_POST['ruletype'] as $ind => $type) |
3753 | 3902 | { |
3754 | 3903 | // Check everything is here... |
3755 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
3756 | - continue; |
|
3757 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
3758 | - continue; |
|
3904 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
3905 | + continue; |
|
3906 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
3907 | + continue; |
|
3908 | + } |
|
3759 | 3909 | |
3760 | 3910 | // Members need to be found. |
3761 | 3911 | if ($type == 'mid') |
@@ -3779,13 +3929,13 @@ discard block |
||
3779 | 3929 | $smcFunc['db_free_result']($request); |
3780 | 3930 | |
3781 | 3931 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
3932 | + } elseif ($type == 'bud') { |
|
3933 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3934 | + } elseif ($type == 'gid') { |
|
3935 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3936 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
3937 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3782 | 3938 | } |
3783 | - elseif ($type == 'bud') |
|
3784 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3785 | - elseif ($type == 'gid') |
|
3786 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3787 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
3788 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3789 | 3939 | } |
3790 | 3940 | |
3791 | 3941 | // Also do the actions! |
@@ -3795,26 +3945,29 @@ discard block |
||
3795 | 3945 | foreach ($_POST['acttype'] as $ind => $type) |
3796 | 3946 | { |
3797 | 3947 | // Picking a valid label? |
3798 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
3799 | - continue; |
|
3948 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
3949 | + continue; |
|
3950 | + } |
|
3800 | 3951 | |
3801 | 3952 | // Record what we're doing. |
3802 | - if ($type == 'del') |
|
3803 | - $doDelete = 1; |
|
3804 | - elseif ($type == 'lab') |
|
3805 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3953 | + if ($type == 'del') { |
|
3954 | + $doDelete = 1; |
|
3955 | + } elseif ($type == 'lab') { |
|
3956 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3957 | + } |
|
3806 | 3958 | } |
3807 | 3959 | |
3808 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
3809 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3960 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
3961 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3962 | + } |
|
3810 | 3963 | |
3811 | 3964 | // What are we storing? |
3812 | 3965 | $criteria = $smcFunc['json_encode']($criteria); |
3813 | 3966 | $actions = $smcFunc['json_encode']($actions); |
3814 | 3967 | |
3815 | 3968 | // Create the rule? |
3816 | - if (empty($context['rid'])) |
|
3817 | - $smcFunc['db_insert']('', |
|
3969 | + if (empty($context['rid'])) { |
|
3970 | + $smcFunc['db_insert']('', |
|
3818 | 3971 | '{db_prefix}pm_rules', |
3819 | 3972 | array( |
3820 | 3973 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3825,8 +3978,8 @@ discard block |
||
3825 | 3978 | ), |
3826 | 3979 | array('id_rule') |
3827 | 3980 | ); |
3828 | - else |
|
3829 | - $smcFunc['db_query']('', ' |
|
3981 | + } else { |
|
3982 | + $smcFunc['db_query']('', ' |
|
3830 | 3983 | UPDATE {db_prefix}pm_rules |
3831 | 3984 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
3832 | 3985 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3842,6 +3995,7 @@ discard block |
||
3842 | 3995 | 'actions' => $actions, |
3843 | 3996 | ) |
3844 | 3997 | ); |
3998 | + } |
|
3845 | 3999 | |
3846 | 4000 | redirectexit('action=pm;sa=manrules'); |
3847 | 4001 | } |
@@ -3850,11 +4004,12 @@ discard block |
||
3850 | 4004 | { |
3851 | 4005 | checkSession(); |
3852 | 4006 | $toDelete = array(); |
3853 | - foreach ($_POST['delrule'] as $k => $v) |
|
3854 | - $toDelete[] = (int) $k; |
|
4007 | + foreach ($_POST['delrule'] as $k => $v) { |
|
4008 | + $toDelete[] = (int) $k; |
|
4009 | + } |
|
3855 | 4010 | |
3856 | - if (!empty($toDelete)) |
|
3857 | - $smcFunc['db_query']('', ' |
|
4011 | + if (!empty($toDelete)) { |
|
4012 | + $smcFunc['db_query']('', ' |
|
3858 | 4013 | DELETE FROM {db_prefix}pm_rules |
3859 | 4014 | WHERE id_rule IN ({array_int:delete_list}) |
3860 | 4015 | AND id_member = {int:current_member}', |
@@ -3863,6 +4018,7 @@ discard block |
||
3863 | 4018 | 'delete_list' => $toDelete, |
3864 | 4019 | ) |
3865 | 4020 | ); |
4021 | + } |
|
3866 | 4022 | |
3867 | 4023 | redirectexit('action=pm;sa=manrules'); |
3868 | 4024 | } |
@@ -3881,8 +4037,9 @@ discard block |
||
3881 | 4037 | loadRules(); |
3882 | 4038 | |
3883 | 4039 | // No rules? |
3884 | - if (empty($context['rules'])) |
|
3885 | - return; |
|
4040 | + if (empty($context['rules'])) { |
|
4041 | + return; |
|
4042 | + } |
|
3886 | 4043 | |
3887 | 4044 | // Just unread ones? |
3888 | 4045 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3912,8 +4069,9 @@ discard block |
||
3912 | 4069 | // Loop through all the criteria hoping to make a match. |
3913 | 4070 | foreach ($rule['criteria'] as $criterium) |
3914 | 4071 | { |
3915 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
3916 | - $match = true; |
|
4072 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
4073 | + $match = true; |
|
4074 | + } |
|
3917 | 4075 | // If we're adding and one criteria don't match then we stop! |
3918 | 4076 | elseif ($rule['logic'] == 'and') |
3919 | 4077 | { |
@@ -3925,17 +4083,18 @@ discard block |
||
3925 | 4083 | // If we have a match the rule must be true - act! |
3926 | 4084 | if ($match) |
3927 | 4085 | { |
3928 | - if ($rule['delete']) |
|
3929 | - $actions['deletes'][] = $row['id_pm']; |
|
3930 | - else |
|
4086 | + if ($rule['delete']) { |
|
4087 | + $actions['deletes'][] = $row['id_pm']; |
|
4088 | + } else |
|
3931 | 4089 | { |
3932 | 4090 | foreach ($rule['actions'] as $ruleAction) |
3933 | 4091 | { |
3934 | 4092 | if ($ruleAction['t'] == 'lab') |
3935 | 4093 | { |
3936 | 4094 | // Get a basic pot started! |
3937 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
3938 | - $actions['labels'][$row['id_pm']] = array(); |
|
4095 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
4096 | + $actions['labels'][$row['id_pm']] = array(); |
|
4097 | + } |
|
3939 | 4098 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
3940 | 4099 | } |
3941 | 4100 | } |
@@ -3946,8 +4105,9 @@ discard block |
||
3946 | 4105 | $smcFunc['db_free_result']($request); |
3947 | 4106 | |
3948 | 4107 | // Deletes are easy! |
3949 | - if (!empty($actions['deletes'])) |
|
3950 | - deleteMessages($actions['deletes']); |
|
4108 | + if (!empty($actions['deletes'])) { |
|
4109 | + deleteMessages($actions['deletes']); |
|
4110 | + } |
|
3951 | 4111 | |
3952 | 4112 | // Relabel? |
3953 | 4113 | if (!empty($actions['labels'])) |
@@ -3974,8 +4134,7 @@ discard block |
||
3974 | 4134 | 'current_member' => $user_info['id'], |
3975 | 4135 | ) |
3976 | 4136 | ); |
3977 | - } |
|
3978 | - else |
|
4137 | + } else |
|
3979 | 4138 | { |
3980 | 4139 | $realLabels[] = $label['id']; |
3981 | 4140 | } |
@@ -3984,8 +4143,9 @@ discard block |
||
3984 | 4143 | |
3985 | 4144 | $inserts = array(); |
3986 | 4145 | // Now we insert the label info |
3987 | - foreach ($realLabels as $a_label) |
|
3988 | - $inserts[] = array($pm, $a_label); |
|
4146 | + foreach ($realLabels as $a_label) { |
|
4147 | + $inserts[] = array($pm, $a_label); |
|
4148 | + } |
|
3989 | 4149 | |
3990 | 4150 | $smcFunc['db_insert']('ignore', |
3991 | 4151 | '{db_prefix}pm_labeled_messages', |
@@ -4006,8 +4166,9 @@ discard block |
||
4006 | 4166 | { |
4007 | 4167 | global $user_info, $context, $smcFunc; |
4008 | 4168 | |
4009 | - if (isset($context['rules']) && !$reload) |
|
4010 | - return; |
|
4169 | + if (isset($context['rules']) && !$reload) { |
|
4170 | + return; |
|
4171 | + } |
|
4011 | 4172 | |
4012 | 4173 | $request = $smcFunc['db_query']('', ' |
4013 | 4174 | SELECT |
@@ -4031,8 +4192,9 @@ discard block |
||
4031 | 4192 | 'logic' => $row['is_or'] ? 'or' : 'and', |
4032 | 4193 | ); |
4033 | 4194 | |
4034 | - if ($row['delete_pm']) |
|
4035 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4195 | + if ($row['delete_pm']) { |
|
4196 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4197 | + } |
|
4036 | 4198 | } |
4037 | 4199 | $smcFunc['db_free_result']($request); |
4038 | 4200 | } |
@@ -14,8 +14,9 @@ discard block |
||
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 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
74 | 76 | ); |
75 | 77 | |
76 | 78 | // Start with an empty array. |
77 | - if ($boardIndexOptions['include_categories']) |
|
78 | - $categories = array(); |
|
79 | - else |
|
80 | - $this_category = array(); |
|
79 | + if ($boardIndexOptions['include_categories']) { |
|
80 | + $categories = array(); |
|
81 | + } else { |
|
82 | + $this_category = array(); |
|
83 | + } |
|
81 | 84 | $boards = array(); |
82 | 85 | |
83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
89 | 92 | |
90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
92 | - $boards[] = $row_board['id_board']; |
|
94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
95 | + $boards[] = $row_board['id_board']; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ($boardIndexOptions['include_categories']) |
95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -161,14 +166,12 @@ discard block |
||
161 | 166 | { |
162 | 167 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
163 | 168 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
164 | - } |
|
165 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
169 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
166 | 170 | { |
167 | 171 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
168 | 172 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
169 | 173 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
170 | - } |
|
171 | - else |
|
174 | + } else |
|
172 | 175 | { |
173 | 176 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
174 | 177 | } |
@@ -219,14 +222,16 @@ discard block |
||
219 | 222 | // Child of a child... just add it on... |
220 | 223 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
221 | 224 | { |
222 | - if (!isset($parent_map)) |
|
223 | - $parent_map = array(); |
|
225 | + if (!isset($parent_map)) { |
|
226 | + $parent_map = array(); |
|
227 | + } |
|
224 | 228 | |
225 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
226 | - foreach ($this_category as $id => $board) |
|
229 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
230 | + foreach ($this_category as $id => $board) |
|
227 | 231 | { |
228 | 232 | if (!isset($board['children'][$row_board['id_parent']])) |
229 | 233 | continue; |
234 | + } |
|
230 | 235 | |
231 | 236 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
232 | 237 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -247,8 +252,9 @@ discard block |
||
247 | 252 | continue; |
248 | 253 | } |
249 | 254 | // Found a child of a child - skip. |
250 | - else |
|
251 | - continue; |
|
255 | + else { |
|
256 | + continue; |
|
257 | + } |
|
252 | 258 | |
253 | 259 | // Prepare the subject, and make sure it's not too long. |
254 | 260 | censorText($row_board['subject']); |
@@ -269,12 +275,13 @@ discard block |
||
269 | 275 | 'topic' => $row_board['id_topic'] |
270 | 276 | ); |
271 | 277 | |
272 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
273 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
278 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
279 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
274 | 280 | 'avatar' => $row_board['avatar'], |
275 | 281 | 'email' => $row_board['email_address'], |
276 | 282 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
277 | 283 | )); |
284 | + } |
|
278 | 285 | |
279 | 286 | // Provide the href and link. |
280 | 287 | if ($row_board['subject'] != '') |
@@ -286,8 +293,7 @@ discard block |
||
286 | 293 | link, href, subject, start (where they should go for the first unread post.), |
287 | 294 | and member. (which has id, name, link, href, username in it.) */ |
288 | 295 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
289 | - } |
|
290 | - else |
|
296 | + } else |
|
291 | 297 | { |
292 | 298 | $this_last_post['href'] = ''; |
293 | 299 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -295,8 +301,9 @@ discard block |
||
295 | 301 | } |
296 | 302 | |
297 | 303 | // Set the last post in the parent board. |
298 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
299 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
304 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
305 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
306 | + } |
|
300 | 307 | // Just in the child...? |
301 | 308 | if ($isChild) |
302 | 309 | { |
@@ -306,15 +313,17 @@ discard block |
||
306 | 313 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
307 | 314 | } |
308 | 315 | // No last post for this board? It's not new then, is it..? |
309 | - elseif ($row_board['poster_name'] == '') |
|
310 | - $this_category[$row_board['id_board']]['new'] = false; |
|
316 | + elseif ($row_board['poster_name'] == '') { |
|
317 | + $this_category[$row_board['id_board']]['new'] = false; |
|
318 | + } |
|
311 | 319 | |
312 | 320 | // Determine a global most recent topic. |
313 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
314 | - $latest_post = array( |
|
321 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
322 | + $latest_post = array( |
|
315 | 323 | 'timestamp' => $row_board['poster_time'], |
316 | 324 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
317 | 325 | ); |
326 | + } |
|
318 | 327 | } |
319 | 328 | $smcFunc['db_free_result']($result_boards); |
320 | 329 | |
@@ -331,8 +340,9 @@ discard block |
||
331 | 340 | if (!empty($moderators[$board['id']])) |
332 | 341 | { |
333 | 342 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
334 | - foreach ($moderators[$board['id']] as $moderator) |
|
335 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
343 | + foreach ($moderators[$board['id']] as $moderator) { |
|
344 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
345 | + } |
|
336 | 346 | } |
337 | 347 | if (!empty($groups[$board['id']])) |
338 | 348 | { |
@@ -345,16 +355,16 @@ discard block |
||
345 | 355 | } |
346 | 356 | } |
347 | 357 | } |
348 | - } |
|
349 | - else |
|
358 | + } else |
|
350 | 359 | { |
351 | 360 | foreach ($this_category as $k => $board) |
352 | 361 | { |
353 | 362 | if (!empty($moderators[$board['id']])) |
354 | 363 | { |
355 | 364 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
356 | - foreach ($moderators[$board['id']] as $moderator) |
|
357 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
365 | + foreach ($moderators[$board['id']] as $moderator) { |
|
366 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
367 | + } |
|
358 | 368 | } |
359 | 369 | if (!empty($groups[$board['id']])) |
360 | 370 | { |
@@ -368,20 +378,23 @@ discard block |
||
368 | 378 | } |
369 | 379 | } |
370 | 380 | |
371 | - if ($boardIndexOptions['include_categories']) |
|
372 | - sortCategories($categories); |
|
373 | - else |
|
374 | - sortBoards($this_category); |
|
381 | + if ($boardIndexOptions['include_categories']) { |
|
382 | + sortCategories($categories); |
|
383 | + } else { |
|
384 | + sortBoards($this_category); |
|
385 | + } |
|
375 | 386 | |
376 | 387 | // By now we should know the most recent post...if we wanna know it that is. |
377 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
378 | - $context['latest_post'] = $latest_post['ref']; |
|
388 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
389 | + $context['latest_post'] = $latest_post['ref']; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
381 | - if ($boardIndexOptions['include_categories']) |
|
382 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
383 | - else |
|
384 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
393 | + if ($boardIndexOptions['include_categories']) { |
|
394 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
395 | + } else { |
|
396 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
397 | + } |
|
385 | 398 | |
386 | 399 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
387 | 400 | } |
@@ -13,8 +13,9 @@ discard block |
||
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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
240 | 248 | 'language' => $language_ftx |
241 | 249 | ) |
242 | 250 | ); |
243 | - } |
|
244 | - else |
|
251 | + } else |
|
245 | 252 | { |
246 | 253 | // Make sure it's gone before creating it. |
247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
259 | 266 | ) |
260 | 267 | ); |
261 | 268 | } |
262 | - } |
|
263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
264 | 270 | { |
265 | 271 | checkSession('get'); |
266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
277 | 283 | $context['fulltext_index'] = array(); |
278 | 284 | |
279 | 285 | // Go back to the default search method. |
280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
281 | - updateSettings(array( |
|
286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
287 | + updateSettings(array( |
|
282 | 288 | 'search_index' => '', |
283 | 289 | )); |
284 | - } |
|
285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
290 | + } |
|
291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
286 | 292 | { |
287 | 293 | checkSession('get'); |
288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
304 | 310 | )); |
305 | 311 | |
306 | 312 | // Go back to the default search method. |
307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
308 | - updateSettings(array( |
|
313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
314 | + updateSettings(array( |
|
309 | 315 | 'search_index' => '', |
310 | 316 | )); |
311 | - } |
|
312 | - elseif (isset($_POST['save'])) |
|
317 | + } |
|
318 | + } elseif (isset($_POST['save'])) |
|
313 | 319 | { |
314 | 320 | checkSession(); |
315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
331 | 337 | // Get some info about the messages table, to show its size and index size. |
332 | 338 | if ($db_type == 'mysql') |
333 | 339 | { |
334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
335 | - $request = $smcFunc['db_query']('', ' |
|
340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
341 | + $request = $smcFunc['db_query']('', ' |
|
336 | 342 | SHOW TABLE STATUS |
337 | 343 | FROM {string:database_name} |
338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
342 | 348 | ) |
343 | 349 | ); |
344 | - else |
|
345 | - $request = $smcFunc['db_query']('', ' |
|
350 | + } else { |
|
351 | + $request = $smcFunc['db_query']('', ' |
|
346 | 352 | SHOW TABLE STATUS |
347 | 353 | LIKE {string:table_name}', |
348 | 354 | array( |
349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
350 | 356 | ) |
351 | 357 | ); |
358 | + } |
|
352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
353 | 360 | { |
354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
360 | 367 | } |
361 | 368 | |
362 | 369 | // Now check the custom index table, if it exists at all. |
363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
364 | - $request = $smcFunc['db_query']('', ' |
|
370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
371 | + $request = $smcFunc['db_query']('', ' |
|
365 | 372 | SHOW TABLE STATUS |
366 | 373 | FROM {string:database_name} |
367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
371 | 378 | ) |
372 | 379 | ); |
373 | - else |
|
374 | - $request = $smcFunc['db_query']('', ' |
|
380 | + } else { |
|
381 | + $request = $smcFunc['db_query']('', ' |
|
375 | 382 | SHOW TABLE STATUS |
376 | 383 | LIKE {string:table_name}', |
377 | 384 | array( |
378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
379 | 386 | ) |
380 | 387 | ); |
388 | + } |
|
381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
382 | 390 | { |
383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
387 | 395 | $smcFunc['db_free_result']($request); |
388 | 396 | } |
389 | - } |
|
390 | - elseif ($db_type == 'postgresql') |
|
397 | + } elseif ($db_type == 'postgresql') |
|
391 | 398 | { |
392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
432 | - } |
|
433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
434 | 440 | { |
435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
437 | 443 | } |
438 | 444 | } |
439 | 445 | $smcFunc['db_free_result']($request); |
440 | - } |
|
441 | - else |
|
442 | - // Didn't work for some reason... |
|
446 | + } else { |
|
447 | + // Didn't work for some reason... |
|
443 | 448 | $context['table_info'] = array( |
444 | 449 | 'data_length' => $txt['not_applicable'], |
445 | 450 | 'index_length' => $txt['not_applicable'], |
446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
448 | 453 | ); |
449 | - } |
|
450 | - else |
|
451 | - $context['table_info'] = array( |
|
454 | + } |
|
455 | + } else { |
|
456 | + $context['table_info'] = array( |
|
452 | 457 | 'data_length' => $txt['not_applicable'], |
453 | 458 | 'index_length' => $txt['not_applicable'], |
454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
456 | 461 | ); |
462 | + } |
|
457 | 463 | |
458 | 464 | // Format the data and index length in kilobytes. |
459 | 465 | foreach ($context['table_info'] as $type => $size) |
460 | 466 | { |
461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
462 | - if (!is_numeric($size)) |
|
463 | - break; |
|
468 | + if (!is_numeric($size)) { |
|
469 | + break; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
489 | 496 | |
490 | 497 | // Scotty, we need more time... |
491 | 498 | @set_time_limit(600); |
492 | - if (function_exists('apache_reset_timeout')) |
|
493 | - @apache_reset_timeout(); |
|
499 | + if (function_exists('apache_reset_timeout')) { |
|
500 | + @apache_reset_timeout(); |
|
501 | + } |
|
494 | 502 | |
495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
521 | 529 | unset($context['index_settings']['resume_at']); |
522 | 530 | $context['step'] = 1; |
523 | - } |
|
524 | - else |
|
531 | + } else |
|
525 | 532 | { |
526 | 533 | $context['index_settings'] = array( |
527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
531 | 538 | |
532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
534 | - $_SESSION['admin_time'] = time(); |
|
540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
541 | + $_SESSION['admin_time'] = time(); |
|
542 | + } |
|
535 | 543 | } |
536 | 544 | |
537 | - if ($context['step'] !== 0) |
|
538 | - checkSession('request'); |
|
545 | + if ($context['step'] !== 0) { |
|
546 | + checkSession('request'); |
|
547 | + } |
|
539 | 548 | |
540 | 549 | // Step 0: let the user determine how they like their index. |
541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
565 | 574 | |
566 | 575 | // Temporarily switch back to not using a search index. |
567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
568 | - updateSettings(array('search_index' => '')); |
|
576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
577 | + updateSettings(array('search_index' => '')); |
|
578 | + } |
|
569 | 579 | |
570 | 580 | // Don't let simultanious processes be updating the search index. |
571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
572 | - updateSettings(array('search_custom_index_config' => '')); |
|
581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
582 | + updateSettings(array('search_custom_index_config' => '')); |
|
583 | + } |
|
573 | 584 | } |
574 | 585 | |
575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
585 | 596 | 'starting_id' => $context['start'], |
586 | 597 | ) |
587 | 598 | ); |
588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
601 | + } |
|
590 | 602 | |
591 | 603 | if (empty($num_messages['todo'])) |
592 | 604 | { |
593 | 605 | $context['step'] = 2; |
594 | 606 | $context['percentage'] = 80; |
595 | 607 | $context['start'] = 0; |
596 | - } |
|
597 | - else |
|
608 | + } else |
|
598 | 609 | { |
599 | 610 | // Number of seconds before the next step. |
600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
635 | 646 | |
636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
637 | 648 | |
638 | - if (!empty($inserts)) |
|
639 | - $smcFunc['db_insert']('ignore', |
|
649 | + if (!empty($inserts)) { |
|
650 | + $smcFunc['db_insert']('ignore', |
|
640 | 651 | '{db_prefix}log_search_words', |
641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
642 | 653 | $inserts, |
643 | 654 | array('id_word', 'id_msg') |
644 | 655 | ); |
656 | + } |
|
645 | 657 | if ($num_messages['todo'] === 0) |
646 | 658 | { |
647 | 659 | $context['step'] = 2; |
648 | 660 | $context['start'] = 0; |
649 | 661 | break; |
662 | + } else { |
|
663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
650 | 664 | } |
651 | - else |
|
652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
653 | 665 | } |
654 | 666 | |
655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
661 | 673 | elseif ($context['step'] === 2) |
662 | 674 | { |
663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
664 | - $context['step'] = 3; |
|
665 | - else |
|
675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
676 | + $context['step'] = 3; |
|
677 | + } else |
|
666 | 678 | { |
667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
683 | 695 | 'minimum_messages' => $max_messages, |
684 | 696 | ) |
685 | 697 | ); |
686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
687 | - $stop_words[] = $row['id_word']; |
|
698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
699 | + $stop_words[] = $row['id_word']; |
|
700 | + } |
|
688 | 701 | $smcFunc['db_free_result']($request); |
689 | 702 | |
690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
691 | 704 | |
692 | - if (!empty($stop_words)) |
|
693 | - $smcFunc['db_query']('', ' |
|
705 | + if (!empty($stop_words)) { |
|
706 | + $smcFunc['db_query']('', ' |
|
694 | 707 | DELETE FROM {db_prefix}log_search_words |
695 | 708 | WHERE id_word in ({array_int:stop_words})', |
696 | 709 | array( |
697 | 710 | 'stop_words' => $stop_words, |
698 | 711 | ) |
699 | 712 | ); |
713 | + } |
|
700 | 714 | |
701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
757 | 771 | $searchAPI = new $search_class_name(); |
758 | 772 | |
759 | 773 | // No Support? NEXT! |
760 | - if (!$searchAPI->is_supported) |
|
761 | - continue; |
|
774 | + if (!$searchAPI->is_supported) { |
|
775 | + continue; |
|
776 | + } |
|
762 | 777 | |
763 | 778 | $apis[$index_name] = array( |
764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
806 | 821 | ) |
807 | 822 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
809 | - $context['fulltext_index'][] = $row['indexname']; |
|
810 | - } |
|
811 | - else |
|
823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
824 | + $context['fulltext_index'][] = $row['indexname']; |
|
825 | + } |
|
826 | + } else |
|
812 | 827 | { |
813 | 828 | $request = $smcFunc['db_query']('', ' |
814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
819 | 834 | $context['fulltext_index'] = array(); |
820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
821 | 836 | { |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
840 | + } |
|
825 | 841 | $smcFunc['db_free_result']($request); |
826 | 842 | |
827 | - if (is_array($context['fulltext_index'])) |
|
828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
843 | + if (is_array($context['fulltext_index'])) { |
|
844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
845 | + } |
|
829 | 846 | } |
830 | 847 | |
831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
832 | - $request = $smcFunc['db_query']('', ' |
|
848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
849 | + $request = $smcFunc['db_query']('', ' |
|
833 | 850 | SHOW TABLE STATUS |
834 | 851 | FROM {string:database_name} |
835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
839 | 856 | ) |
840 | 857 | ); |
841 | - else |
|
842 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
843 | 860 | SHOW TABLE STATUS |
844 | 861 | LIKE {string:table_name}', |
845 | 862 | array( |
846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
847 | 864 | ) |
848 | 865 | ); |
866 | + } |
|
849 | 867 | |
850 | 868 | if ($request !== false) |
851 | 869 | { |
852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
854 | 872 | $context['cannot_create_fulltext'] = true; |
873 | + } |
|
855 | 874 | $smcFunc['db_free_result']($request); |
856 | 875 | } |
857 | 876 | } |