@@ -88,7 +88,9 @@ discard block |
||
88 | 88 | |
89 | 89 | // If it's not enabled, die. |
90 | 90 | if (empty($modSettings['xmlnews_enable'])) |
91 | - obExit(false); |
|
91 | + { |
|
92 | + obExit(false); |
|
93 | + } |
|
92 | 94 | |
93 | 95 | loadLanguage('Stats'); |
94 | 96 | $txt['xml_rss_desc'] = replaceBasicActionUrl($txt['xml_rss_desc']); |
@@ -121,11 +123,15 @@ discard block |
||
121 | 123 | $boards = array_keys($boards_posts); |
122 | 124 | |
123 | 125 | if (!empty($boards)) |
124 | - $this->_query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
126 | + { |
|
127 | + $this->_query_this_board = 'b.id_board IN (' . implode(', ', $boards) . ')'; |
|
128 | + } |
|
125 | 129 | |
126 | 130 | // Try to limit the number of messages we look through. |
127 | 131 | if ($total_cat_posts > 100 && $total_cat_posts > $modSettings['totalMessages'] / 15) |
128 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $this->_limit * 5); |
|
132 | + { |
|
133 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 400 - $this->_limit * 5); |
|
134 | + } |
|
129 | 135 | } |
130 | 136 | // Maybe they only want to see feeds form some certain boards? |
131 | 137 | elseif (!empty($this->_req->query->boards)) |
@@ -138,14 +144,18 @@ discard block |
||
138 | 144 | // Either the board specified doesn't exist or you have no access. |
139 | 145 | $num_boards = count($boards_data); |
140 | 146 | if ($num_boards == 0) |
141 | - throw new Elk_Exception('no_board'); |
|
147 | + { |
|
148 | + throw new Elk_Exception('no_board'); |
|
149 | + } |
|
142 | 150 | |
143 | 151 | $total_posts = 0; |
144 | 152 | $boards = array_keys($boards_data); |
145 | 153 | foreach ($boards_data as $row) |
146 | 154 | { |
147 | 155 | if ($num_boards == 1) |
148 | - $feed_title = ' - ' . strip_tags($row['name']); |
|
156 | + { |
|
157 | + $feed_title = ' - ' . strip_tags($row['name']); |
|
158 | + } |
|
149 | 159 | |
150 | 160 | $total_posts += $row['num_posts']; |
151 | 161 | } |
@@ -154,7 +164,9 @@ discard block |
||
154 | 164 | |
155 | 165 | // The more boards, the more we're going to look through... |
156 | 166 | if ($total_posts > 100 && $total_posts > $modSettings['totalMessages'] / 12) |
157 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $this->_limit * 5); |
|
167 | + { |
|
168 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 500 - $this->_limit * 5); |
|
169 | + } |
|
158 | 170 | } |
159 | 171 | // Just a single board |
160 | 172 | elseif (!empty($board)) |
@@ -168,7 +180,9 @@ discard block |
||
168 | 180 | |
169 | 181 | // Try to look through just a few messages, if at all possible. |
170 | 182 | if ($boards_data[(int) $board]['num_posts'] > 80 && $boards_data[(int) $board]['num_posts'] > $modSettings['totalMessages'] / 10) |
171 | - $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $this->_limit * 5); |
|
183 | + { |
|
184 | + $context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 600 - $this->_limit * 5); |
|
185 | + } |
|
172 | 186 | } |
173 | 187 | else |
174 | 188 | { |
@@ -180,7 +194,9 @@ discard block |
||
180 | 194 | // If format isn't set, or is wrong, rss2 is default |
181 | 195 | $xml_format = $this->_req->getQuery('type', 'trim', 'rss2'); |
182 | 196 | if (!in_array($xml_format, array('rss', 'rss2', 'atom', 'rdf'))) |
183 | - $xml_format = 'rss2'; |
|
197 | + { |
|
198 | + $xml_format = 'rss2'; |
|
199 | + } |
|
184 | 200 | |
185 | 201 | // List all the different types of data they can pull. |
186 | 202 | $subActions = array( |
@@ -201,7 +217,9 @@ discard block |
||
201 | 217 | foreach (array('board', 'boards', 'c') as $var) |
202 | 218 | { |
203 | 219 | if (isset($this->_req->query->{$var})) |
204 | - $cachekey[] = $this->_req->query->{$var}; |
|
220 | + { |
|
221 | + $cachekey[] = $this->_req->query->{$var}; |
|
222 | + } |
|
205 | 223 | } |
206 | 224 | |
207 | 225 | $cachekey = md5(serialize($cachekey) . (!empty($this->_query_this_board) ? $this->_query_this_board : '')); |
@@ -210,14 +228,18 @@ discard block |
||
210 | 228 | |
211 | 229 | // Get the associative array representing the xml. |
212 | 230 | if (!$user_info['is_guest'] || $cache->levelHigherThan(2)) |
213 | - $xml = $cache->get('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
231 | + { |
|
232 | + $xml = $cache->get('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, 240); |
|
233 | + } |
|
214 | 234 | |
215 | 235 | if (empty($xml)) |
216 | 236 | { |
217 | 237 | $xml = $this->{$subActions[$subAction][0]}($xml_format); |
218 | 238 | |
219 | 239 | if ($cache->isEnabled() && (($user_info['is_guest'] && $cache->levelHigherThan(2)) || (!$user_info['is_guest'] && (microtime(true) - $cache_t > 0.2)))) |
220 | - $cache->put('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
240 | + { |
|
241 | + $cache->put('xmlfeed-' . $xml_format . ':' . ($user_info['is_guest'] ? '' : $user_info['id'] . '-') . $cachekey, $xml, 240); |
|
242 | + } |
|
221 | 243 | } |
222 | 244 | |
223 | 245 | $context['feed_title'] = encode_special(strip_tags(un_htmlspecialchars($context['forum_name']) . (isset($feed_title) ? $feed_title : ''))); |
@@ -230,13 +252,21 @@ discard block |
||
230 | 252 | |
231 | 253 | // This is an xml file.... |
232 | 254 | if (isset($this->_req->query->debug)) |
233 | - header('Content-Type: text/xml; charset=UTF-8'); |
|
255 | + { |
|
256 | + header('Content-Type: text/xml; charset=UTF-8'); |
|
257 | + } |
|
234 | 258 | elseif ($xml_format === 'rss' || $xml_format === 'rss2') |
235 | - header('Content-Type: application/rss+xml; charset=UTF-8'); |
|
259 | + { |
|
260 | + header('Content-Type: application/rss+xml; charset=UTF-8'); |
|
261 | + } |
|
236 | 262 | elseif ($xml_format === 'atom') |
237 | - header('Content-Type: application/atom+xml; charset=UTF-8'); |
|
263 | + { |
|
264 | + header('Content-Type: application/atom+xml; charset=UTF-8'); |
|
265 | + } |
|
238 | 266 | elseif ($xml_format === 'rdf') |
239 | - header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=UTF-8'); |
|
267 | + { |
|
268 | + header('Content-Type: ' . (isBrowser('ie') ? 'text/xml' : 'application/rdf+xml') . '; charset=UTF-8'); |
|
269 | + } |
|
240 | 270 | |
241 | 271 | loadTemplate('Xml'); |
242 | 272 | Template_Layers::instance()->removeAll(); |
@@ -280,7 +310,9 @@ discard block |
||
280 | 310 | |
281 | 311 | // Not allowed, then you get nothing |
282 | 312 | if (!allowedTo('view_mlist')) |
283 | - return array(); |
|
313 | + { |
|
314 | + return array(); |
|
315 | + } |
|
284 | 316 | |
285 | 317 | // Find the most recent members. |
286 | 318 | require_once(SUBSDIR . '/Members.subs.php'); |
@@ -293,34 +325,41 @@ discard block |
||
293 | 325 | { |
294 | 326 | // Make the data look rss-ish. |
295 | 327 | if ($xml_format === 'rss' || $xml_format === 'rss2') |
296 | - $data[] = array( |
|
328 | + { |
|
329 | + $data[] = array( |
|
297 | 330 | 'title' => cdata_parse($member['real_name']), |
298 | 331 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
299 | 332 | 'comments' => $scripturl . '?action=pm;sa=send;u=' . $member['id_member'], |
300 | 333 | 'pubDate' => gmdate('D, d M Y H:i:s \G\M\T', $member['date_registered']), |
301 | 334 | 'guid' => $scripturl . '?action=profile;u=' . $member['id_member'], |
302 | 335 | ); |
336 | + } |
|
303 | 337 | elseif ($xml_format === 'rdf') |
304 | - $data[] = array( |
|
338 | + { |
|
339 | + $data[] = array( |
|
305 | 340 | 'title' => cdata_parse($member['real_name']), |
306 | 341 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
307 | 342 | ); |
343 | + } |
|
308 | 344 | elseif ($xml_format === 'atom') |
309 | - $data[] = array( |
|
345 | + { |
|
346 | + $data[] = array( |
|
310 | 347 | 'title' => cdata_parse($member['real_name']), |
311 | 348 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'], |
312 | 349 | 'published' => Util::gmstrftime('%Y-%m-%dT%H:%M:%SZ', $member['date_registered']), |
313 | 350 | 'updated' => Util::gmstrftime('%Y-%m-%dT%H:%M:%SZ', $member['last_login']), |
314 | 351 | 'id' => $scripturl . '?action=profile;u=' . $member['id_member'], |
315 | 352 | ); |
353 | + } |
|
316 | 354 | // More logical format for the data, but harder to apply. |
317 | - else |
|
318 | - $data[] = array( |
|
355 | + else { |
|
356 | + $data[] = array( |
|
319 | 357 | 'name' => cdata_parse($member['real_name']), |
320 | 358 | 'time' => htmlspecialchars(strip_tags(standardTime($member['date_registered'])), ENT_COMPAT, 'UTF-8'), |
321 | 359 | 'id' => $member['id_member'], |
322 | 360 | 'link' => $scripturl . '?action=profile;u=' . $member['id_member'] |
323 | 361 | ); |
362 | + } |
|
324 | 363 | } |
325 | 364 | |
326 | 365 | return $data; |
@@ -349,7 +388,9 @@ discard block |
||
349 | 388 | { |
350 | 389 | // Limit the length of the message, if the option is set. |
351 | 390 | if (!empty($modSettings['xmlnews_maxlen']) && Util::strlen(str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
352 | - $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
391 | + { |
|
392 | + $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
393 | + } |
|
353 | 394 | |
354 | 395 | $row['body'] = $bbc_parser->parseMessage($row['body'], $row['smileys_enabled']); |
355 | 396 | |
@@ -455,7 +496,9 @@ discard block |
||
455 | 496 | { |
456 | 497 | // Limit the length of the message, if the option is set. |
457 | 498 | if (!empty($modSettings['xmlnews_maxlen']) && Util::strlen(str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) |
458 | - $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
499 | + { |
|
500 | + $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />')); |
|
501 | + } |
|
459 | 502 | |
460 | 503 | $row['body'] = $bbc_parser->parseMessage($row['body'], $row['smileys_enabled']); |
461 | 504 | |
@@ -558,14 +601,18 @@ discard block |
||
558 | 601 | |
559 | 602 | // You must input a valid user.... |
560 | 603 | if (empty($this->_req->query->u) || loadMemberData((int) $this->_req->query->u) === false) |
561 | - return array(); |
|
604 | + { |
|
605 | + return array(); |
|
606 | + } |
|
562 | 607 | |
563 | 608 | // Make sure the id is a number and not "I like trying to hack the database". |
564 | 609 | $uid = (int) $this->_req->query->u; |
565 | 610 | |
566 | 611 | // Load the member's contextual information! |
567 | 612 | if (!loadMemberContext($uid) || !allowedTo('profile_view_any')) |
568 | - return array(); |
|
613 | + { |
|
614 | + return array(); |
|
615 | + } |
|
569 | 616 | |
570 | 617 | $profile = &$memberContext[$uid]; |
571 | 618 | |
@@ -623,35 +670,51 @@ discard block |
||
623 | 670 | |
624 | 671 | // Everything below here might not be set, and thus maybe shouldn't be displayed. |
625 | 672 | if ($profile['avatar']['name'] != '') |
626 | - $data['avatar'] = $profile['avatar']['url']; |
|
673 | + { |
|
674 | + $data['avatar'] = $profile['avatar']['url']; |
|
675 | + } |
|
627 | 676 | |
628 | 677 | // If they are online, show an empty tag... no reason to put anything inside it. |
629 | 678 | if ($profile['online']['is_online']) |
630 | - $data['online'] = ''; |
|
679 | + { |
|
680 | + $data['online'] = ''; |
|
681 | + } |
|
631 | 682 | |
632 | 683 | if ($profile['signature'] != '') |
633 | - $data['signature'] = cdata_parse($profile['signature']); |
|
684 | + { |
|
685 | + $data['signature'] = cdata_parse($profile['signature']); |
|
686 | + } |
|
634 | 687 | |
635 | 688 | if ($profile['title'] != '') |
636 | - $data['title'] = cdata_parse($profile['title']); |
|
689 | + { |
|
690 | + $data['title'] = cdata_parse($profile['title']); |
|
691 | + } |
|
637 | 692 | |
638 | 693 | if ($profile['website']['title'] != '') |
639 | - $data['website'] = array( |
|
694 | + { |
|
695 | + $data['website'] = array( |
|
640 | 696 | 'title' => cdata_parse($profile['website']['title']), |
641 | 697 | 'link' => $profile['website']['url'] |
642 | 698 | ); |
699 | + } |
|
643 | 700 | |
644 | 701 | if ($profile['group'] != '') |
645 | - $data['position'] = cdata_parse($profile['group']); |
|
702 | + { |
|
703 | + $data['position'] = cdata_parse($profile['group']); |
|
704 | + } |
|
646 | 705 | |
647 | 706 | if (!empty($modSettings['karmaMode'])) |
648 | - $data['karma'] = array( |
|
707 | + { |
|
708 | + $data['karma'] = array( |
|
649 | 709 | 'good' => $profile['karma']['good'], |
650 | 710 | 'bad' => $profile['karma']['bad'] |
651 | 711 | ); |
712 | + } |
|
652 | 713 | |
653 | 714 | if (in_array($profile['show_email'], array('yes', 'yes_permission_override'))) |
654 | - $data['email'] = $profile['email']; |
|
715 | + { |
|
716 | + $data['email'] = $profile['email']; |
|
717 | + } |
|
655 | 718 | |
656 | 719 | if (!empty($profile['birth_date']) && substr($profile['birth_date'], 0, 4) != '0000') |
657 | 720 | { |
@@ -679,7 +742,9 @@ discard block |
||
679 | 742 | global $modSettings, $scripturl; |
680 | 743 | |
681 | 744 | if (substr($val, 0, strlen($scripturl)) != $scripturl) |
682 | - return $val; |
|
745 | + { |
|
746 | + return $val; |
|
747 | + } |
|
683 | 748 | |
684 | 749 | call_integration_hook('integrate_fix_url', array(&$val)); |
685 | 750 | |
@@ -730,7 +795,9 @@ discard block |
||
730 | 795 | |
731 | 796 | // Are we not doing it? |
732 | 797 | if (!empty($cdata_override)) |
733 | - return $data; |
|
798 | + { |
|
799 | + return $data; |
|
800 | + } |
|
734 | 801 | |
735 | 802 | $cdata = '<![CDATA['; |
736 | 803 | |
@@ -742,33 +809,46 @@ discard block |
||
742 | 809 | ); |
743 | 810 | |
744 | 811 | if ($ns != '') |
745 | - $positions[] = Util::strpos($data, '<', $pos); |
|
812 | + { |
|
813 | + $positions[] = Util::strpos($data, '<', $pos); |
|
814 | + } |
|
746 | 815 | |
747 | 816 | foreach ($positions as $k => $dummy) |
748 | 817 | { |
749 | 818 | if ($dummy === false) |
750 | - unset($positions[$k]); |
|
819 | + { |
|
820 | + unset($positions[$k]); |
|
821 | + } |
|
751 | 822 | } |
752 | 823 | |
753 | 824 | $old = $pos; |
754 | 825 | $pos = empty($positions) ? $n : min($positions); |
755 | 826 | |
756 | 827 | if ($pos - $old > 0) |
757 | - $cdata .= Util::substr($data, $old, $pos - $old); |
|
828 | + { |
|
829 | + $cdata .= Util::substr($data, $old, $pos - $old); |
|
830 | + } |
|
758 | 831 | |
759 | 832 | if ($pos >= $n) |
760 | - break; |
|
833 | + { |
|
834 | + break; |
|
835 | + } |
|
761 | 836 | |
762 | 837 | if (Util::substr($data, $pos, 1) === '<') |
763 | 838 | { |
764 | 839 | $pos2 = Util::strpos($data, '>', $pos); |
765 | 840 | if ($pos2 === false) |
766 | - $pos2 = $n; |
|
841 | + { |
|
842 | + $pos2 = $n; |
|
843 | + } |
|
767 | 844 | |
768 | 845 | if (Util::substr($data, $pos + 1, 1) === '/') |
769 | - $cdata .= ']]></' . $ns . ':' . Util::substr($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
770 | - else |
|
771 | - $cdata .= ']]><' . $ns . ':' . Util::substr($data, $pos + 1, $pos2 - $pos) . '<![CDATA['; |
|
846 | + { |
|
847 | + $cdata .= ']]></' . $ns . ':' . Util::substr($data, $pos + 2, $pos2 - $pos - 1) . '<![CDATA['; |
|
848 | + } |
|
849 | + else { |
|
850 | + $cdata .= ']]><' . $ns . ':' . Util::substr($data, $pos + 1, $pos2 - $pos) . '<![CDATA['; |
|
851 | + } |
|
772 | 852 | |
773 | 853 | $pos = $pos2 + 1; |
774 | 854 | } |
@@ -782,14 +862,20 @@ discard block |
||
782 | 862 | $pos2 = Util::strpos($data, ';', $pos); |
783 | 863 | |
784 | 864 | if ($pos2 === false) |
785 | - $pos2 = $n; |
|
865 | + { |
|
866 | + $pos2 = $n; |
|
867 | + } |
|
786 | 868 | |
787 | 869 | $ent = Util::substr($data, $pos + 1, $pos2 - $pos - 1); |
788 | 870 | |
789 | 871 | if (Util::substr($data, $pos + 1, 1) === '#') |
790 | - $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
872 | + { |
|
873 | + $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
874 | + } |
|
791 | 875 | elseif (in_array($ent, array('amp', 'lt', 'gt', 'quot'))) |
792 | - $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
876 | + { |
|
877 | + $cdata .= ']]>' . Util::substr($data, $pos, $pos2 - $pos + 1) . '<![CDATA['; |
|
878 | + } |
|
793 | 879 | |
794 | 880 | $pos = $pos2 + 1; |
795 | 881 | } |
@@ -59,10 +59,14 @@ discard block |
||
59 | 59 | $attachments = attachmentsOfMessage($id_msg); |
60 | 60 | } |
61 | 61 | elseif (!empty($this->_req->query->aid)) |
62 | - $attachments[] = (int) $this->_req->query->aid; |
|
62 | + { |
|
63 | + $attachments[] = (int) $this->_req->query->aid; |
|
64 | + } |
|
63 | 65 | |
64 | 66 | if (empty($attachments)) |
65 | - throw new Elk_Exception('no_access', false); |
|
67 | + { |
|
68 | + throw new Elk_Exception('no_access', false); |
|
69 | + } |
|
66 | 70 | |
67 | 71 | // @todo nb: this requires permission to approve posts, not manage attachments |
68 | 72 | // Now we have some ID's cleaned and ready to approve, but first - let's check we have permission! |
@@ -89,7 +93,9 @@ discard block |
||
89 | 93 | $redirect = 'topic=' . $attach_home['id_topic'] . '.msg' . $attach_home['id_msg'] . '#msg' . $attach_home['id_msg']; |
90 | 94 | |
91 | 95 | if (empty($attachments)) |
92 | - throw new Elk_Exception('no_access', false); |
|
96 | + { |
|
97 | + throw new Elk_Exception('no_access', false); |
|
98 | + } |
|
93 | 99 | |
94 | 100 | // Finally, we are there. Follow through! |
95 | 101 | if ($is_approve) |
@@ -97,8 +103,9 @@ discard block |
||
97 | 103 | // Checked and deemed worthy. |
98 | 104 | approveAttachments($attachments); |
99 | 105 | } |
100 | - else |
|
101 | - removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
106 | + else { |
|
107 | + removeAttachments(array('id_attach' => $attachments, 'do_logging' => true)); |
|
108 | + } |
|
102 | 109 | |
103 | 110 | // We approved or removed, either way we reset those numbers |
104 | 111 | Cache::instance()->remove('num_menu_errors'); |
@@ -55,7 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | // Page disabled - redirect them out |
57 | 57 | if (empty($modSettings['trackStats'])) |
58 | - throw new Elk_Exception('feature_disabled', true); |
|
58 | + { |
|
59 | + throw new Elk_Exception('feature_disabled', true); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | // Expanding out the history summary |
61 | 63 | list($year, $month) = $this->_expandedStats(); |
@@ -73,7 +75,9 @@ discard block |
||
73 | 75 | |
74 | 76 | // Collapsing stats only needs adjustments of the session variables. |
75 | 77 | if (!empty($this->_req->query->collapse)) |
76 | - obExit(false); |
|
78 | + { |
|
79 | + obExit(false); |
|
80 | + } |
|
77 | 81 | |
78 | 82 | $context['sub_template'] = 'stats'; |
79 | 83 | getDailyStats('YEAR(date) = {int:year} AND MONTH(date) = {int:month}', array('year' => $year, 'month' => $month)); |
@@ -148,9 +152,11 @@ discard block |
||
148 | 152 | ); |
149 | 153 | |
150 | 154 | if (!empty($modSettings['hitStats'])) |
151 | - $context['general_statistics']['left'] += array( |
|
155 | + { |
|
156 | + $context['general_statistics']['left'] += array( |
|
152 | 157 | 'num_hits' => comma_format($averages['hits'], 0) |
153 | 158 | ); |
159 | + } |
|
154 | 160 | |
155 | 161 | $context['general_statistics']['right'] = array( |
156 | 162 | 'average_members' => comma_format(round($averages['registers'] / $total_days_up, 2)), |
@@ -164,9 +170,11 @@ discard block |
||
164 | 170 | ); |
165 | 171 | |
166 | 172 | if (!empty($modSettings['hitStats'])) |
167 | - $context['general_statistics']['right'] += array( |
|
173 | + { |
|
174 | + $context['general_statistics']['right'] += array( |
|
168 | 175 | 'average_hits' => comma_format(round($averages['hits'] / $total_days_up, 2)), |
169 | 176 | ); |
177 | + } |
|
170 | 178 | } |
171 | 179 | |
172 | 180 | /** |
@@ -226,12 +234,16 @@ discard block |
||
226 | 234 | |
227 | 235 | // Keep a list of collapsed years. |
228 | 236 | if (!$data['expanded'] && !$data['current_year']) |
229 | - $context['collapsed_years'][] = $year; |
|
237 | + { |
|
238 | + $context['collapsed_years'][] = $year; |
|
239 | + } |
|
230 | 240 | } |
231 | 241 | |
232 | 242 | // Want to expand out the yearly stats |
233 | 243 | if (empty($_SESSION['expanded_stats'])) |
234 | - return false; |
|
244 | + { |
|
245 | + return false; |
|
246 | + } |
|
235 | 247 | |
236 | 248 | $condition_text = array(); |
237 | 249 | $condition_params = array(); |
@@ -247,7 +259,9 @@ discard block |
||
247 | 259 | |
248 | 260 | // No daily stats to even look at? |
249 | 261 | if (empty($condition_text)) |
250 | - return false; |
|
262 | + { |
|
263 | + return false; |
|
264 | + } |
|
251 | 265 | |
252 | 266 | getDailyStats(implode(' OR ', $condition_text), $condition_params); |
253 | 267 | |
@@ -273,7 +287,9 @@ discard block |
||
273 | 287 | $month = (int) substr($this->_req->query->expand, 4); |
274 | 288 | $year = (int) substr($this->_req->query->expand, 0, 4); |
275 | 289 | if ($year > 1900 && $year < 2200 && $month >= 1 && $month <= 12) |
276 | - $_SESSION['expanded_stats'][$year][] = $month; |
|
290 | + { |
|
291 | + $_SESSION['expanded_stats'][$year][] = $month; |
|
292 | + } |
|
277 | 293 | } |
278 | 294 | // Done looking at the details and want to fold it back up |
279 | 295 | elseif (!empty($this->_req->query->collapse)) |
@@ -283,7 +299,9 @@ discard block |
||
283 | 299 | $month = (int) substr($this->_req->query->collapse, 4); |
284 | 300 | $year = (int) substr($this->_req->query->collapse, 0, 4); |
285 | 301 | if (!empty($_SESSION['expanded_stats'][$year])) |
286 | - $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
302 | + { |
|
303 | + $_SESSION['expanded_stats'][$year] = array_diff($_SESSION['expanded_stats'][$year], array($month)); |
|
304 | + } |
|
287 | 305 | } |
288 | 306 | |
289 | 307 | return array($year, $month); |
@@ -82,7 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | // Do we have a file to include? |
84 | 84 | if (!empty($currentSearch['file']) && file_exists($currentSearch['file'])) |
85 | - require_once($currentSearch['file']); |
|
85 | + { |
|
86 | + require_once($currentSearch['file']); |
|
87 | + } |
|
86 | 88 | |
87 | 89 | // If it is a class, let's instantiate it |
88 | 90 | if (!empty($currentSearch['class']) && class_exists($currentSearch['class'])) |
@@ -101,7 +103,9 @@ discard block |
||
101 | 103 | |
102 | 104 | // If we have data, return it |
103 | 105 | if (!empty($context['xml_data'])) |
104 | - $context['sub_template'] = 'generic_xml'; |
|
106 | + { |
|
107 | + $context['sub_template'] = 'generic_xml'; |
|
108 | + } |
|
105 | 109 | } |
106 | 110 | } |
107 | 111 | } |
@@ -57,7 +57,9 @@ discard block |
||
57 | 57 | |
58 | 58 | // You can't do anything if the calendar is off. |
59 | 59 | if (empty($modSettings['cal_enabled'])) |
60 | - throw new Elk_Exception('calendar_off', false); |
|
60 | + { |
|
61 | + throw new Elk_Exception('calendar_off', false); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // Set the page title to mention the calendar ;). |
63 | 65 | $context['page_title'] = $txt['calendar']; |
@@ -70,7 +72,9 @@ discard block |
||
70 | 72 | |
71 | 73 | // Don't let search engines index weekly calendar pages. |
72 | 74 | if ($context['view_week']) |
73 | - $context['robot_no_index'] = true; |
|
75 | + { |
|
76 | + $context['robot_no_index'] = true; |
|
77 | + } |
|
74 | 78 | |
75 | 79 | // Get the current day of month... |
76 | 80 | require_once(SUBSDIR . '/Calendar.subs.php'); |
@@ -85,16 +89,22 @@ discard block |
||
85 | 89 | |
86 | 90 | // Make sure the year and month are in valid ranges. |
87 | 91 | if ($curPage['month'] < 1 || $curPage['month'] > 12) |
88 | - throw new Elk_Exception('invalid_month', false); |
|
92 | + { |
|
93 | + throw new Elk_Exception('invalid_month', false); |
|
94 | + } |
|
89 | 95 | |
90 | 96 | if ($curPage['year'] < $context['cal_minyear'] || $curPage['year'] > $context['cal_maxyear']) |
91 | - throw new Elk_Exception('invalid_year', false); |
|
97 | + { |
|
98 | + throw new Elk_Exception('invalid_year', false); |
|
99 | + } |
|
92 | 100 | |
93 | 101 | // If we have a day clean that too. |
94 | 102 | if ($context['view_week']) |
95 | 103 | { |
96 | 104 | if ($curPage['day'] > 31 || !mktime(0, 0, 0, $curPage['month'], $curPage['day'], $curPage['year'])) |
97 | - throw new Elk_Exception('invalid_day', false); |
|
105 | + { |
|
106 | + throw new Elk_Exception('invalid_day', false); |
|
107 | + } |
|
98 | 108 | } |
99 | 109 | |
100 | 110 | // Load all the context information needed to show the calendar grid. |
@@ -112,9 +122,12 @@ discard block |
||
112 | 122 | |
113 | 123 | // Load up the main view. |
114 | 124 | if ($context['view_week']) |
115 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
116 | - else |
|
117 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
125 | + { |
|
126 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
127 | + } |
|
128 | + else { |
|
129 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
130 | + } |
|
118 | 131 | |
119 | 132 | // Load up the previous and next months. |
120 | 133 | $calendarOptions['show_birthdays'] = $calendarOptions['show_events'] = $calendarOptions['show_holidays'] = false; |
@@ -126,11 +139,15 @@ discard block |
||
126 | 139 | |
127 | 140 | // Only show previous month if it isn't pre-January of the min-year |
128 | 141 | if ($context['calendar_grid_current']['previous_calendar']['year'] > $context['cal_minyear'] || $curPage['month'] != 1) |
129 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions); |
|
142 | + { |
|
143 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions); |
|
144 | + } |
|
130 | 145 | |
131 | 146 | // Only show next month if it isn't post-December of the max-year |
132 | 147 | if ($context['calendar_grid_current']['next_calendar']['year'] < $context['cal_maxyear'] || $curPage['month'] != 12) |
133 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
148 | + { |
|
149 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
150 | + } |
|
134 | 151 | |
135 | 152 | // Basic template stuff. |
136 | 153 | $context['can_post'] = allowedTo('calendar_post'); |
@@ -156,10 +173,12 @@ discard block |
||
156 | 173 | |
157 | 174 | // If applicable, add the current week to the linktree. |
158 | 175 | if ($context['view_week']) |
159 | - $context['linktree'][] = array( |
|
176 | + { |
|
177 | + $context['linktree'][] = array( |
|
160 | 178 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
161 | 179 | 'name' => $txt['calendar_week'] . ' ' . $context['calendar_grid_main']['week_number'] |
162 | 180 | ); |
181 | + } |
|
163 | 182 | |
164 | 183 | // Build the calendar button array. |
165 | 184 | $context['calendar_buttons'] = array( |
@@ -220,7 +239,9 @@ discard block |
||
220 | 239 | // Get list of boards that can be posted in. |
221 | 240 | $boards = boardsAllowedTo('post_new'); |
222 | 241 | if (empty($boards)) |
223 | - throw new Elk_Exception('cannot_post_new', 'permission'); |
|
242 | + { |
|
243 | + throw new Elk_Exception('cannot_post_new', 'permission'); |
|
244 | + } |
|
224 | 245 | |
225 | 246 | // Load the list of boards and categories in the context. |
226 | 247 | require_once(SUBSDIR . '/Boards.subs.php'); |
@@ -275,7 +296,9 @@ discard block |
||
275 | 296 | |
276 | 297 | // If you're not allowed to edit any events, you have to be the poster. |
277 | 298 | if (!$event->isNew() && !allowedTo('calendar_edit_any')) |
278 | - isAllowedTo('calendar_edit_' . ($event->isStarter($user_info['id']) ? 'own' : 'any')); |
|
299 | + { |
|
300 | + isAllowedTo('calendar_edit_' . ($event->isStarter($user_info['id']) ? 'own' : 'any')); |
|
301 | + } |
|
279 | 302 | |
280 | 303 | // New - and directing? |
281 | 304 | if ($event->isNew() && isset($_POST['link_to_board'])) |
@@ -351,11 +374,15 @@ discard block |
||
351 | 374 | |
352 | 375 | // You can't export if the calendar export feature is off. |
353 | 376 | if (empty($modSettings['cal_export'])) |
354 | - throw new Elk_Exception('calendar_export_off', false); |
|
377 | + { |
|
378 | + throw new Elk_Exception('calendar_export_off', false); |
|
379 | + } |
|
355 | 380 | |
356 | 381 | // Goes without saying that this is required. |
357 | 382 | if (!isset($_REQUEST['eventid'])) |
358 | - throw new Elk_Exception('no_access', false); |
|
383 | + { |
|
384 | + throw new Elk_Exception('no_access', false); |
|
385 | + } |
|
359 | 386 | |
360 | 387 | // This is kinda wanted. |
361 | 388 | require_once(SUBSDIR . '/Calendar.subs.php'); |
@@ -364,7 +391,9 @@ discard block |
||
364 | 391 | $event = getEventProperties($_REQUEST['eventid']); |
365 | 392 | |
366 | 393 | if ($event === false) |
367 | - throw new Elk_Exception('no_access', false); |
|
394 | + { |
|
395 | + throw new Elk_Exception('no_access', false); |
|
396 | + } |
|
368 | 397 | |
369 | 398 | $filecontents = build_ical_content($event); |
370 | 399 | |
@@ -380,7 +409,9 @@ discard block |
||
380 | 409 | header('Connection: close'); |
381 | 410 | header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"'); |
382 | 411 | if (empty($modSettings['enableCompressedOutput'])) |
383 | - header('Content-Length: ' . Util::strlen($filecontents)); |
|
412 | + { |
|
413 | + header('Content-Length: ' . Util::strlen($filecontents)); |
|
414 | + } |
|
384 | 415 | |
385 | 416 | // This is a calendar item! |
386 | 417 | header('Content-Type: text/calendar'); |
@@ -121,7 +121,9 @@ discard block |
||
121 | 121 | |
122 | 122 | // Is the load average too high to allow searching just now? |
123 | 123 | if (!empty($modSettings['loadavg_search']) && $modSettings['current_load'] >= $modSettings['loadavg_search']) |
124 | - throw new Elk_Exception('loadavg_search_disabled', false); |
|
124 | + { |
|
125 | + throw new Elk_Exception('loadavg_search_disabled', false); |
|
126 | + } |
|
125 | 127 | |
126 | 128 | loadLanguage('Search'); |
127 | 129 | |
@@ -169,17 +171,29 @@ discard block |
||
169 | 171 | } |
170 | 172 | |
171 | 173 | if (isset($_REQUEST['search'])) |
172 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
174 | + { |
|
175 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
176 | + } |
|
173 | 177 | if (isset($context['search_params']['search'])) |
174 | - $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
178 | + { |
|
179 | + $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
180 | + } |
|
175 | 181 | if (isset($context['search_params']['userspec'])) |
176 | - $context['search_params']['userspec'] = htmlspecialchars($context['search_params']['userspec'], ENT_COMPAT, 'UTF-8'); |
|
182 | + { |
|
183 | + $context['search_params']['userspec'] = htmlspecialchars($context['search_params']['userspec'], ENT_COMPAT, 'UTF-8'); |
|
184 | + } |
|
177 | 185 | if (!empty($context['search_params']['searchtype'])) |
178 | - $context['search_params']['searchtype'] = 2; |
|
186 | + { |
|
187 | + $context['search_params']['searchtype'] = 2; |
|
188 | + } |
|
179 | 189 | if (!empty($context['search_params']['minage'])) |
180 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
190 | + { |
|
191 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
192 | + } |
|
181 | 193 | if (!empty($context['search_params']['maxage'])) |
182 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
194 | + { |
|
195 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
196 | + } |
|
183 | 197 | |
184 | 198 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
185 | 199 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
@@ -192,10 +206,14 @@ discard block |
||
192 | 206 | foreach ($context['search_errors'] as $search_error => $dummy) |
193 | 207 | { |
194 | 208 | if ($search_error === 'messages') |
195 | - continue; |
|
209 | + { |
|
210 | + continue; |
|
211 | + } |
|
196 | 212 | |
197 | 213 | if ($search_error === 'string_too_long') |
198 | - $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
214 | + { |
|
215 | + $txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']); |
|
216 | + } |
|
199 | 217 | |
200 | 218 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
201 | 219 | } |
@@ -210,7 +228,9 @@ discard block |
||
210 | 228 | $context['boards_in_category'][$cat] = count($category['boards']); |
211 | 229 | $category['child_ids'] = array_keys($category['boards']); |
212 | 230 | foreach ($category['boards'] as &$board) |
213 | - $board['selected'] = (empty($context['search_params']['brd']) && (empty($modSettings['recycle_enable']) || $board['id'] != $modSettings['recycle_board']) && !in_array($board['id'], $user_info['ignoreboards'])) || (!empty($context['search_params']['brd']) && in_array($board['id'], $context['search_params']['brd'])); |
|
231 | + { |
|
232 | + $board['selected'] = (empty($context['search_params']['brd']) && (empty($modSettings['recycle_enable']) || $board['id'] != $modSettings['recycle_board']) && !in_array($board['id'], $user_info['ignoreboards'])) || (!empty($context['search_params']['brd']) && in_array($board['id'], $context['search_params']['brd'])); |
|
233 | + } |
|
214 | 234 | } |
215 | 235 | |
216 | 236 | if (!empty($_REQUEST['topic'])) |
@@ -238,7 +258,9 @@ discard block |
||
238 | 258 | |
239 | 259 | // Start guest off collapsed |
240 | 260 | if ($context['user']['is_guest'] && !isset($context['minmax_preferences']['asearch'])) |
241 | - $context['minmax_preferences']['asearch'] = 1; |
|
261 | + { |
|
262 | + $context['minmax_preferences']['asearch'] = 1; |
|
263 | + } |
|
242 | 264 | |
243 | 265 | call_integration_hook('integrate_search'); |
244 | 266 | } |
@@ -284,10 +306,13 @@ discard block |
||
284 | 306 | |
285 | 307 | loadLanguage('Search'); |
286 | 308 | if (!isset($_REQUEST['xml'])) |
287 | - loadTemplate('Search'); |
|
309 | + { |
|
310 | + loadTemplate('Search'); |
|
311 | + } |
|
288 | 312 | // If we're doing XML we need to use the results template regardless really. |
289 | - else |
|
290 | - $context['sub_template'] = 'results'; |
|
313 | + else { |
|
314 | + $context['sub_template'] = 'results'; |
|
315 | + } |
|
291 | 316 | |
292 | 317 | // Are you allowed? |
293 | 318 | isAllowedTo('search_posts'); |
@@ -299,17 +324,23 @@ discard block |
||
299 | 324 | $searchAPI = $this->_search->findSearchAPI(); |
300 | 325 | |
301 | 326 | if (isset($_REQUEST['params'])) |
302 | - $this->_search->searchParamsFromString($_REQUEST['params']); |
|
327 | + { |
|
328 | + $this->_search->searchParamsFromString($_REQUEST['params']); |
|
329 | + } |
|
303 | 330 | |
304 | 331 | $this->_search->mergeSearchParams($_REQUEST, $recentPercentage, $maxMembersToSearch); |
305 | 332 | $context['compact'] = $this->_search->isCompact(); |
306 | 333 | |
307 | 334 | // Nothing?? |
308 | 335 | if ($this->_search->param('search') === false || $this->_search->param('search') === '') |
309 | - $context['search_errors']['invalid_search_string'] = true; |
|
336 | + { |
|
337 | + $context['search_errors']['invalid_search_string'] = true; |
|
338 | + } |
|
310 | 339 | // Too long? |
311 | 340 | elseif (Util::strlen($this->_search->param('search')) > $context['search_string_limit']) |
312 | - $context['search_errors']['string_too_long'] = true; |
|
341 | + { |
|
342 | + $context['search_errors']['string_too_long'] = true; |
|
343 | + } |
|
313 | 344 | |
314 | 345 | // Build the search array |
315 | 346 | // $modSettings ['search_simple_fulltext'] is an hidden setting that will |
@@ -323,13 +354,18 @@ discard block |
||
323 | 354 | if (empty($searchArray)) |
324 | 355 | { |
325 | 356 | if (!empty($context['search_ignored'])) |
326 | - $context['search_errors']['search_string_small_words'] = true; |
|
327 | - else |
|
328 | - $context['search_errors']['invalid_search_string' . ($this->_search->foundBlackListedWords() ? '_blacklist' : '')] = true; |
|
357 | + { |
|
358 | + $context['search_errors']['search_string_small_words'] = true; |
|
359 | + } |
|
360 | + else { |
|
361 | + $context['search_errors']['invalid_search_string' . ($this->_search->foundBlackListedWords() ? '_blacklist' : '')] = true; |
|
362 | + } |
|
329 | 363 | |
330 | 364 | // Don't allow duplicate error messages if one string is too short. |
331 | 365 | if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) |
332 | - unset($context['search_errors']['invalid_search_string']); |
|
366 | + { |
|
367 | + unset($context['search_errors']['invalid_search_string']); |
|
368 | + } |
|
333 | 369 | } |
334 | 370 | |
335 | 371 | $searchWords = $this->_search->searchWords(); |
@@ -346,13 +382,21 @@ discard block |
||
346 | 382 | // Let the user adjust the search query, should they wish? |
347 | 383 | $context['search_params'] = $this->_search->getParams(); |
348 | 384 | if (isset($context['search_params']['search'])) |
349 | - $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
385 | + { |
|
386 | + $context['search_params']['search'] = Util::htmlspecialchars($context['search_params']['search']); |
|
387 | + } |
|
350 | 388 | if (isset($context['search_params']['userspec'])) |
351 | - $context['search_params']['userspec'] = Util::htmlspecialchars($context['search_params']['userspec']); |
|
389 | + { |
|
390 | + $context['search_params']['userspec'] = Util::htmlspecialchars($context['search_params']['userspec']); |
|
391 | + } |
|
352 | 392 | if (empty($context['search_params']['minage'])) |
353 | - $context['search_params']['minage'] = 0; |
|
393 | + { |
|
394 | + $context['search_params']['minage'] = 0; |
|
395 | + } |
|
354 | 396 | if (empty($context['search_params']['maxage'])) |
355 | - $context['search_params']['maxage'] = 9999; |
|
397 | + { |
|
398 | + $context['search_params']['maxage'] = 9999; |
|
399 | + } |
|
356 | 400 | |
357 | 401 | $context['search_params'] = $this->_fill_default_search_params($context['search_params']); |
358 | 402 | |
@@ -361,7 +405,9 @@ discard block |
||
361 | 405 | { |
362 | 406 | // If we come from another search box tone down the error... |
363 | 407 | if (!isset($_REQUEST['search_vv'])) |
364 | - $context['search_errors']['need_verification_code'] = true; |
|
408 | + { |
|
409 | + $context['search_errors']['need_verification_code'] = true; |
|
410 | + } |
|
365 | 411 | else |
366 | 412 | { |
367 | 413 | require_once(SUBSDIR . '/VerificationControls.class.php'); |
@@ -373,11 +419,14 @@ discard block |
||
373 | 419 | if (is_array($context['require_verification'])) |
374 | 420 | { |
375 | 421 | foreach ($context['require_verification'] as $error) |
376 | - $context['search_errors'][$error] = true; |
|
422 | + { |
|
423 | + $context['search_errors'][$error] = true; |
|
424 | + } |
|
377 | 425 | } |
378 | 426 | // Don't keep asking for it - they've proven themselves worthy. |
379 | - else |
|
380 | - $_SESSION['ss_vv_passed'] = true; |
|
427 | + else { |
|
428 | + $_SESSION['ss_vv_passed'] = true; |
|
429 | + } |
|
381 | 430 | } |
382 | 431 | } |
383 | 432 | |
@@ -396,18 +445,24 @@ discard block |
||
396 | 445 | |
397 | 446 | // Start guest off collapsed |
398 | 447 | if ($context['user']['is_guest'] && !isset($context['minmax_preferences']['asearch'])) |
399 | - $context['minmax_preferences']['asearch'] = 1; |
|
448 | + { |
|
449 | + $context['minmax_preferences']['asearch'] = 1; |
|
450 | + } |
|
400 | 451 | |
401 | 452 | // *** A last error check |
402 | 453 | call_integration_hook('integrate_search_errors'); |
403 | 454 | |
404 | 455 | // One or more search errors? Go back to the first search screen. |
405 | 456 | if (!empty($context['search_errors'])) |
406 | - return $this->action_search(); |
|
457 | + { |
|
458 | + return $this->action_search(); |
|
459 | + } |
|
407 | 460 | |
408 | 461 | // Spam me not, Spam-a-lot? |
409 | 462 | if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $this->_search->param('search')) |
410 | - spamProtection('search'); |
|
463 | + { |
|
464 | + spamProtection('search'); |
|
465 | + } |
|
411 | 466 | |
412 | 467 | // Store the last search string to allow pages of results to be browsed. |
413 | 468 | $_SESSION['last_ss'] = $this->_search->param('search'); |
@@ -434,7 +489,9 @@ discard block |
||
434 | 489 | $this->_search->clearCacheResults($_SESSION['search_cache']['id_search']); |
435 | 490 | |
436 | 491 | if ($this->_search->param('subject_only')) |
437 | - $_SESSION['search_cache']['num_results'] = $this->_search->getSubjectResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
|
492 | + { |
|
493 | + $_SESSION['search_cache']['num_results'] = $this->_search->getSubjectResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
|
494 | + } |
|
438 | 495 | else |
439 | 496 | { |
440 | 497 | $num_res = $this->_search->getResults($_SESSION['search_cache']['id_search'], $humungousTopicPosts, $maxMessageResults); |
@@ -478,14 +535,18 @@ discard block |
||
478 | 535 | call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters)); |
479 | 536 | |
480 | 537 | if (!empty($posters)) |
481 | - loadMemberData(array_unique($posters)); |
|
538 | + { |
|
539 | + loadMemberData(array_unique($posters)); |
|
540 | + } |
|
482 | 541 | |
483 | 542 | // Get the messages out for the callback - select enough that it can be made to look just like Display. |
484 | 543 | $messages_request = $this->_search->loadMessagesRequest($msg_list, count($context['topics'])); |
485 | 544 | |
486 | 545 | // If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore. |
487 | 546 | if ($this->_search->noMessages($messages_request)) |
488 | - $context['topics'] = array(); |
|
547 | + { |
|
548 | + $context['topics'] = array(); |
|
549 | + } |
|
489 | 550 | |
490 | 551 | // If we want to know who participated in what then load this now. |
491 | 552 | if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
@@ -494,7 +555,9 @@ discard block |
||
494 | 555 | $topics_participated_in = topicsParticipation($user_info['id'], array_keys($participants)); |
495 | 556 | |
496 | 557 | foreach ($topics_participated_in as $topic) |
497 | - $participants[$topic['id_topic']] = true; |
|
558 | + { |
|
559 | + $participants[$topic['id_topic']] = true; |
|
560 | + } |
|
498 | 561 | } |
499 | 562 | } |
500 | 563 | |
@@ -541,16 +604,22 @@ discard block |
||
541 | 604 | // Remember which message this is. (ie. reply #83) |
542 | 605 | static $counter = null; |
543 | 606 | if ($counter === null || $reset) |
544 | - $counter = $_REQUEST['start'] + 1; |
|
607 | + { |
|
608 | + $counter = $_REQUEST['start'] + 1; |
|
609 | + } |
|
545 | 610 | |
546 | 611 | // Start from the beginning... |
547 | 612 | if ($reset) |
548 | - return currentContext($messages_request, $reset); |
|
613 | + { |
|
614 | + return currentContext($messages_request, $reset); |
|
615 | + } |
|
549 | 616 | |
550 | 617 | // Attempt to get the next in line |
551 | 618 | $message = currentContext($messages_request); |
552 | 619 | if (!$message) |
553 | - return false; |
|
620 | + { |
|
621 | + return false; |
|
622 | + } |
|
554 | 623 | |
555 | 624 | // Can't have an empty subject can we? |
556 | 625 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -590,7 +659,9 @@ discard block |
||
590 | 659 | if (Util::strlen($message['body']) > $charLimit) |
591 | 660 | { |
592 | 661 | if (empty($context['key_words'])) |
593 | - $message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
662 | + { |
|
663 | + $message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>'; |
|
664 | + } |
|
594 | 665 | else |
595 | 666 | { |
596 | 667 | $matchString = ''; |
@@ -600,7 +671,9 @@ discard block |
||
600 | 671 | $keyword = un_htmlspecialchars($keyword); |
601 | 672 | $keyword = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&'))); |
602 | 673 | if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) |
603 | - $force_partial_word = true; |
|
674 | + { |
|
675 | + $force_partial_word = true; |
|
676 | + } |
|
604 | 677 | $matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|'; |
605 | 678 | } |
606 | 679 | $matchString = un_htmlspecialchars(substr($matchString, 0, -1)); |
@@ -608,9 +681,12 @@ discard block |
||
608 | 681 | $message['body'] = un_htmlspecialchars(strtr($message['body'], array(' ' => ' ', '<br />' => "\n", '[' => '[', ']' => ']', ':' => ':', '@' => '@'))); |
609 | 682 | |
610 | 683 | if (empty($modSettings['search_method']) || $force_partial_word) |
611 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
612 | - else |
|
613 | - preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
684 | + { |
|
685 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
686 | + } |
|
687 | + else { |
|
688 | + preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/isu', $message['body'], $matches); |
|
689 | + } |
|
614 | 690 | |
615 | 691 | $message['body'] = ''; |
616 | 692 | foreach ($matches[0] as $match) |
@@ -703,7 +779,9 @@ discard block |
||
703 | 779 | determineTopicClass($output); |
704 | 780 | |
705 | 781 | if ($output['posted_in']) |
706 | - $output['class'] = 'my_' . $output['class']; |
|
782 | + { |
|
783 | + $output['class'] = 'my_' . $output['class']; |
|
784 | + } |
|
707 | 785 | |
708 | 786 | $body_highlighted = $message['body']; |
709 | 787 | $subject_highlighted = $message['subject']; |
@@ -878,7 +956,9 @@ discard block |
||
878 | 956 | { |
879 | 957 | // Admins can be bothered with a failure |
880 | 958 | if ($user_info['is_admin']) |
881 | - throw new Elk_Exception('search_invalid_weights'); |
|
959 | + { |
|
960 | + throw new Elk_Exception('search_invalid_weights'); |
|
961 | + } |
|
882 | 962 | |
883 | 963 | // Even if users will get an answer, the admin should know something is broken |
884 | 964 | Errors::instance()->log_lang_error('search_invalid_weights'); |
@@ -917,28 +997,46 @@ discard block |
||
917 | 997 | private function _fill_default_search_params($array) |
918 | 998 | { |
919 | 999 | if (empty($array['search'])) |
920 | - $array['search'] = ''; |
|
1000 | + { |
|
1001 | + $array['search'] = ''; |
|
1002 | + } |
|
921 | 1003 | if (empty($array['userspec'])) |
922 | - $array['userspec'] = '*'; |
|
1004 | + { |
|
1005 | + $array['userspec'] = '*'; |
|
1006 | + } |
|
923 | 1007 | if (empty($array['searchtype'])) |
924 | - $array['searchtype'] = 0; |
|
1008 | + { |
|
1009 | + $array['searchtype'] = 0; |
|
1010 | + } |
|
925 | 1011 | |
926 | 1012 | if (!isset($array['show_complete'])) |
927 | - $array['show_complete'] = 0; |
|
928 | - else |
|
929 | - $array['show_complete'] = (int) $array['show_complete']; |
|
1013 | + { |
|
1014 | + $array['show_complete'] = 0; |
|
1015 | + } |
|
1016 | + else { |
|
1017 | + $array['show_complete'] = (int) $array['show_complete']; |
|
1018 | + } |
|
930 | 1019 | |
931 | 1020 | if (!isset($array['subject_only'])) |
932 | - $array['subject_only'] = 0; |
|
933 | - else |
|
934 | - $array['subject_only'] = (int) $array['subject_only']; |
|
1021 | + { |
|
1022 | + $array['subject_only'] = 0; |
|
1023 | + } |
|
1024 | + else { |
|
1025 | + $array['subject_only'] = (int) $array['subject_only']; |
|
1026 | + } |
|
935 | 1027 | |
936 | 1028 | if (empty($array['minage'])) |
937 | - $array['minage'] = 0; |
|
1029 | + { |
|
1030 | + $array['minage'] = 0; |
|
1031 | + } |
|
938 | 1032 | if (empty($array['maxage'])) |
939 | - $array['maxage'] = 9999; |
|
1033 | + { |
|
1034 | + $array['maxage'] = 9999; |
|
1035 | + } |
|
940 | 1036 | if (empty($array['sort'])) |
941 | - $array['sort'] = 'relevance'; |
|
1037 | + { |
|
1038 | + $array['sort'] = 'relevance'; |
|
1039 | + } |
|
942 | 1040 | |
943 | 1041 | return $array; |
944 | 1042 | } |
@@ -738,7 +738,7 @@ |
||
738 | 738 | $query = strtr(Util::htmlspecialchars($query), array('\\\'' => '\'')); |
739 | 739 | |
740 | 740 | $search_highlight = preg_quote(strtr($query, array('\'' => ''')), '/'); |
741 | - $body_highlighted = preg_replace_callback('/((<[^>]*)|(\b' . $search_highlight . '\b)|'. $search_highlight . ')/iu', array($this, '_highlighted_callback'), $body_highlighted); |
|
741 | + $body_highlighted = preg_replace_callback('/((<[^>]*)|(\b' . $search_highlight . '\b)|' . $search_highlight . ')/iu', array($this, '_highlighted_callback'), $body_highlighted); |
|
742 | 742 | $subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/iu', '<strong class="highlight">$1</strong>', $subject_highlighted); |
743 | 743 | } |
744 | 744 |
@@ -42,9 +42,12 @@ discard block |
||
42 | 42 | |
43 | 43 | // Without anything it throws an error, so redirect somewhere |
44 | 44 | if (!empty($topic)) |
45 | - redirectexit('topic=' . $topic . '.0'); |
|
46 | - else |
|
47 | - redirectexit(); |
|
45 | + { |
|
46 | + redirectexit('topic=' . $topic . '.0'); |
|
47 | + } |
|
48 | + else { |
|
49 | + redirectexit(); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | /** |
@@ -64,7 +67,9 @@ discard block |
||
64 | 67 | |
65 | 68 | // Just quit if there's no topic to lock. |
66 | 69 | if (empty($topic)) |
67 | - throw new Elk_Exception('not_a_topic', false); |
|
70 | + { |
|
71 | + throw new Elk_Exception('not_a_topic', false); |
|
72 | + } |
|
68 | 73 | |
69 | 74 | checkSession('get'); |
70 | 75 | |
@@ -79,29 +84,41 @@ discard block |
||
79 | 84 | $user_lock = !allowedTo('lock_any'); |
80 | 85 | |
81 | 86 | if ($user_lock && $starter == $user_info['id']) |
82 | - isAllowedTo('lock_own'); |
|
83 | - else |
|
84 | - isAllowedTo('lock_any'); |
|
87 | + { |
|
88 | + isAllowedTo('lock_own'); |
|
89 | + } |
|
90 | + else { |
|
91 | + isAllowedTo('lock_any'); |
|
92 | + } |
|
85 | 93 | |
86 | 94 | // Locking with high privileges. |
87 | 95 | if ($locked == '0' && !$user_lock) |
88 | - $locked = '1'; |
|
96 | + { |
|
97 | + $locked = '1'; |
|
98 | + } |
|
89 | 99 | // Locking with low privileges. |
90 | 100 | elseif ($locked == '0') |
91 | - $locked = '2'; |
|
101 | + { |
|
102 | + $locked = '2'; |
|
103 | + } |
|
92 | 104 | // Unlocking - make sure you don't unlock what you can't. |
93 | 105 | elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
94 | - $locked = '0'; |
|
106 | + { |
|
107 | + $locked = '0'; |
|
108 | + } |
|
95 | 109 | // You cannot unlock this! |
96 | - else |
|
97 | - throw new Elk_Exception('locked_by_admin', 'user'); |
|
110 | + else { |
|
111 | + throw new Elk_Exception('locked_by_admin', 'user'); |
|
112 | + } |
|
98 | 113 | |
99 | 114 | // Lock the topic! |
100 | 115 | setTopicAttribute($topic, array('locked' => $locked)); |
101 | 116 | |
102 | 117 | // If they are allowed a "moderator" permission, log it in the moderator log. |
103 | 118 | if (!$user_lock) |
104 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
119 | + { |
|
120 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
121 | + } |
|
105 | 122 | |
106 | 123 | // Notify people that this topic has been locked? |
107 | 124 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
@@ -131,7 +148,9 @@ discard block |
||
131 | 148 | |
132 | 149 | // You can't sticky a board or something! |
133 | 150 | if (empty($topic)) |
134 | - throw new Elk_Exception('not_a_topic', false); |
|
151 | + { |
|
152 | + throw new Elk_Exception('not_a_topic', false); |
|
153 | + } |
|
135 | 154 | |
136 | 155 | checkSession('get'); |
137 | 156 | |
@@ -153,7 +172,9 @@ discard block |
||
153 | 172 | |
154 | 173 | // Notify people that this topic has been stickied? |
155 | 174 | if (empty($is_sticky)) |
156 | - sendNotifications($topic, 'sticky'); |
|
175 | + { |
|
176 | + sendNotifications($topic, 'sticky'); |
|
177 | + } |
|
157 | 178 | |
158 | 179 | // Take them back to the now stickied topic. |
159 | 180 | redirectexit('topic=' . $topic . '.' . $this->_req->post->start); |
@@ -176,7 +197,9 @@ discard block |
||
176 | 197 | |
177 | 198 | // Redirect to the boardindex if no valid topic id is provided. |
178 | 199 | if (empty($topic)) |
179 | - redirectexit(); |
|
200 | + { |
|
201 | + redirectexit(); |
|
202 | + } |
|
180 | 203 | |
181 | 204 | // Its not enabled, give them the boot |
182 | 205 | if (!empty($modSettings['disable_print_topic'])) |
@@ -196,7 +219,9 @@ discard block |
||
196 | 219 | |
197 | 220 | // Redirect to the boardindex if no valid topic id is provided. |
198 | 221 | if (empty($topicinfo)) |
199 | - redirectexit(); |
|
222 | + { |
|
223 | + redirectexit(); |
|
224 | + } |
|
200 | 225 | |
201 | 226 | $context['user']['started'] = $user_info['id'] == $topicinfo['id_member'] && !$user_info['is_guest']; |
202 | 227 | |
@@ -233,7 +258,9 @@ discard block |
||
233 | 258 | $posts_id = array_keys($context['posts']); |
234 | 259 | |
235 | 260 | if (!isset($context['topic_subject'])) |
236 | - $context['topic_subject'] = $context['posts'][min($posts_id)]['subject']; |
|
261 | + { |
|
262 | + $context['topic_subject'] = $context['posts'][min($posts_id)]['subject']; |
|
263 | + } |
|
237 | 264 | |
238 | 265 | // Fetch attachments so we can print them if asked, enabled and allowed |
239 | 266 | if (isset($this->_req->query->images) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
@@ -171,7 +171,9 @@ discard block |
||
171 | 171 | |
172 | 172 | // You must be posting to *some* board. |
173 | 173 | if (empty($board) && !$context['make_event']) |
174 | - throw new Elk_Exception('no_board', false); |
|
174 | + { |
|
175 | + throw new Elk_Exception('no_board', false); |
|
176 | + } |
|
175 | 177 | |
176 | 178 | // All those wonderful modifiers and attachments |
177 | 179 | $this->_template_layers->add('additional_options', 200); |
@@ -190,7 +192,9 @@ discard block |
||
190 | 192 | { |
191 | 193 | $topic = associatedTopic((int) $_REQUEST['msg']); |
192 | 194 | if (empty($topic)) |
193 | - unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
195 | + { |
|
196 | + unset($_REQUEST['msg'], $_POST['msg'], $_GET['msg']); |
|
197 | + } |
|
194 | 198 | } |
195 | 199 | |
196 | 200 | // Check if it's locked. It isn't locked if no topic is specified. |
@@ -203,35 +207,47 @@ discard block |
||
203 | 207 | if (empty($_REQUEST['msg'])) |
204 | 208 | { |
205 | 209 | if ($user_info['is_guest'] && !allowedTo('post_reply_any') && (!$modSettings['postmod_active'] || !allowedTo('post_unapproved_replies_any'))) |
206 | - is_not_guest(); |
|
210 | + { |
|
211 | + is_not_guest(); |
|
212 | + } |
|
207 | 213 | |
208 | 214 | // By default the reply will be approved... |
209 | 215 | $context['becomes_approved'] = true; |
210 | 216 | if ($this->_topic_attributes['id_member'] != $user_info['id']) |
211 | 217 | { |
212 | 218 | if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
213 | - $context['becomes_approved'] = false; |
|
214 | - else |
|
215 | - isAllowedTo('post_reply_any'); |
|
219 | + { |
|
220 | + $context['becomes_approved'] = false; |
|
221 | + } |
|
222 | + else { |
|
223 | + isAllowedTo('post_reply_any'); |
|
224 | + } |
|
216 | 225 | } |
217 | 226 | elseif (!allowedTo('post_reply_any')) |
218 | 227 | { |
219 | 228 | if ($modSettings['postmod_active']) |
220 | 229 | { |
221 | 230 | if (allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
222 | - $context['becomes_approved'] = false; |
|
231 | + { |
|
232 | + $context['becomes_approved'] = false; |
|
233 | + } |
|
223 | 234 | // Guests do not have post_unapproved_replies_own permission, so it's always post_unapproved_replies_any |
224 | 235 | elseif ($user_info['is_guest'] && allowedTo('post_unapproved_replies_any')) |
225 | - $context['becomes_approved'] = false; |
|
226 | - else |
|
227 | - isAllowedTo('post_reply_own'); |
|
236 | + { |
|
237 | + $context['becomes_approved'] = false; |
|
238 | + } |
|
239 | + else { |
|
240 | + isAllowedTo('post_reply_own'); |
|
241 | + } |
|
242 | + } |
|
243 | + else { |
|
244 | + isAllowedTo('post_reply_own'); |
|
228 | 245 | } |
229 | - else |
|
230 | - isAllowedTo('post_reply_own'); |
|
231 | 246 | } |
232 | 247 | } |
233 | - else |
|
234 | - $context['becomes_approved'] = true; |
|
248 | + else { |
|
249 | + $context['becomes_approved'] = true; |
|
250 | + } |
|
235 | 251 | |
236 | 252 | $context['can_lock'] = allowedTo('lock_any') || ($user_info['id'] == $this->_topic_attributes['id_member'] && allowedTo('lock_own')); |
237 | 253 | $context['can_sticky'] = allowedTo('make_sticky'); |
@@ -245,9 +261,12 @@ discard block |
||
245 | 261 | if (empty($context['make_event']) || !empty($board)) |
246 | 262 | { |
247 | 263 | if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
248 | - $context['becomes_approved'] = false; |
|
249 | - else |
|
250 | - isAllowedTo('post_new'); |
|
264 | + { |
|
265 | + $context['becomes_approved'] = false; |
|
266 | + } |
|
267 | + else { |
|
268 | + isAllowedTo('post_new'); |
|
269 | + } |
|
251 | 270 | } |
252 | 271 | |
253 | 272 | $this->_topic_attributes['locked'] = 0; |
@@ -277,7 +296,9 @@ discard block |
||
277 | 296 | |
278 | 297 | // Don't allow a post if it's locked and you aren't all powerful. |
279 | 298 | if ($this->_topic_attributes['locked'] && !allowedTo('moderate_board')) |
280 | - throw new Elk_Exception('topic_locked', false); |
|
299 | + { |
|
300 | + throw new Elk_Exception('topic_locked', false); |
|
301 | + } |
|
281 | 302 | } |
282 | 303 | |
283 | 304 | protected function _generating_message() |
@@ -294,9 +315,12 @@ discard block |
||
294 | 315 | if (!empty($context['new_replies'])) |
295 | 316 | { |
296 | 317 | if ($context['new_replies'] == 1) |
297 | - $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
298 | - else |
|
299 | - $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
318 | + { |
|
319 | + $txt['error_new_replies'] = isset($_GET['last_msg']) ? $txt['error_new_reply_reading'] : $txt['error_new_reply']; |
|
320 | + } |
|
321 | + else { |
|
322 | + $txt['error_new_replies'] = sprintf(isset($_GET['last_msg']) ? $txt['error_new_replies_reading'] : $txt['error_new_replies'], $context['new_replies']); |
|
323 | + } |
|
300 | 324 | |
301 | 325 | $this->_post_errors->addError('new_replies', 0); |
302 | 326 | |
@@ -322,13 +346,19 @@ discard block |
||
322 | 346 | else |
323 | 347 | { |
324 | 348 | if (!isset($_REQUEST['subject'])) |
325 | - $_REQUEST['subject'] = ''; |
|
349 | + { |
|
350 | + $_REQUEST['subject'] = ''; |
|
351 | + } |
|
326 | 352 | |
327 | 353 | if (!isset($_REQUEST['message'])) |
328 | - $_REQUEST['message'] = ''; |
|
354 | + { |
|
355 | + $_REQUEST['message'] = ''; |
|
356 | + } |
|
329 | 357 | |
330 | 358 | if (!isset($_REQUEST['icon'])) |
331 | - $_REQUEST['icon'] = 'xx'; |
|
359 | + { |
|
360 | + $_REQUEST['icon'] = 'xx'; |
|
361 | + } |
|
332 | 362 | |
333 | 363 | // They are previewing if they asked to preview (i.e. came from quick reply). |
334 | 364 | $really_previewing = !empty($_REQUEST['preview']) || isset($_REQUEST['xml']); |
@@ -348,7 +378,9 @@ discard block |
||
348 | 378 | |
349 | 379 | // Make sure the subject isn't too long - taking into account special characters. |
350 | 380 | if (Util::strlen($this->_form_subject) > 100) |
351 | - $this->_form_subject = Util::substr($this->_form_subject, 0, 100); |
|
381 | + { |
|
382 | + $this->_form_subject = Util::substr($this->_form_subject, 0, 100); |
|
383 | + } |
|
352 | 384 | |
353 | 385 | // Are you... a guest? |
354 | 386 | if ($user_info['is_guest']) |
@@ -382,13 +414,19 @@ discard block |
||
382 | 414 | } |
383 | 415 | |
384 | 416 | if ($context['preview_message'] === '') |
385 | - $this->_post_errors->addError('no_message'); |
|
417 | + { |
|
418 | + $this->_post_errors->addError('no_message'); |
|
419 | + } |
|
386 | 420 | elseif (!empty($modSettings['max_messageLength']) && Util::strlen($this->_form_message) > $modSettings['max_messageLength']) |
387 | - $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
421 | + { |
|
422 | + $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
423 | + } |
|
388 | 424 | |
389 | 425 | // Protect any CDATA blocks. |
390 | 426 | if (isset($_REQUEST['xml'])) |
391 | - $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
427 | + { |
|
428 | + $context['preview_message'] = strtr($context['preview_message'], array(']]>' => ']]]]><![CDATA[>')); |
|
429 | + } |
|
392 | 430 | } |
393 | 431 | |
394 | 432 | // Set up the checkboxes. |
@@ -411,12 +449,16 @@ discard block |
||
411 | 449 | // The message they were trying to edit was most likely deleted. |
412 | 450 | // @todo Change this error message? |
413 | 451 | if ($message === false) |
414 | - throw new Elk_Exception('no_board', false); |
|
452 | + { |
|
453 | + throw new Elk_Exception('no_board', false); |
|
454 | + } |
|
415 | 455 | |
416 | 456 | $errors = checkMessagePermissions($message['message']); |
417 | 457 | if (!empty($errors)) |
418 | - foreach ($errors as $error) |
|
458 | + { |
|
459 | + foreach ($errors as $error) |
|
419 | 460 | $this->_post_errors->addError($error); |
461 | + } |
|
420 | 462 | |
421 | 463 | prepareMessageContext($message); |
422 | 464 | } |
@@ -425,12 +467,17 @@ discard block |
||
425 | 467 | // @todo: sort out what kind of combinations are actually possible |
426 | 468 | // Posting a quoted reply? |
427 | 469 | if ((!empty($topic) && !empty($_REQUEST['quote'])) || (!empty($modSettings['enableFollowup']) && !empty($_REQUEST['followup']))) |
428 | - $case = 2; |
|
470 | + { |
|
471 | + $case = 2; |
|
472 | + } |
|
429 | 473 | // Posting a reply without a quote? |
430 | 474 | elseif (!empty($topic) && empty($_REQUEST['quote'])) |
431 | - $case = 3; |
|
432 | - else |
|
433 | - $case = 4; |
|
475 | + { |
|
476 | + $case = 3; |
|
477 | + } |
|
478 | + else { |
|
479 | + $case = 4; |
|
480 | + } |
|
434 | 481 | |
435 | 482 | list ($this->_form_subject,) = getFormMsgSubject($case, $topic, $this->_topic_attributes['subject']); |
436 | 483 | } |
@@ -447,14 +494,18 @@ discard block |
||
447 | 494 | |
448 | 495 | // The message they were trying to edit was most likely deleted. |
449 | 496 | if ($message === false) |
450 | - throw new Elk_Exception('no_message', false); |
|
497 | + { |
|
498 | + throw new Elk_Exception('no_message', false); |
|
499 | + } |
|
451 | 500 | |
452 | 501 | // Trigger the prepare_editing event |
453 | 502 | $this->_events->trigger('prepare_editing', array('topic' => $topic, 'message' => &$message)); |
454 | 503 | |
455 | 504 | if (!empty($message['errors'])) |
456 | - foreach ($message['errors'] as $error) |
|
505 | + { |
|
506 | + foreach ($message['errors'] as $error) |
|
457 | 507 | $this->_post_errors->addError($error); |
508 | + } |
|
458 | 509 | |
459 | 510 | // Get the stuff ready for the form. |
460 | 511 | $this->_form_subject = $message['message']['subject']; |
@@ -492,19 +543,26 @@ discard block |
||
492 | 543 | // @todo: sort out what kind of combinations are actually possible |
493 | 544 | // Posting a quoted reply? |
494 | 545 | if ((!empty($topic) && !empty($_REQUEST['quote'])) || (!empty($modSettings['enableFollowup']) && !empty($_REQUEST['followup']))) |
495 | - $case = 2; |
|
546 | + { |
|
547 | + $case = 2; |
|
548 | + } |
|
496 | 549 | // Posting a reply without a quote? |
497 | 550 | elseif (!empty($topic) && empty($_REQUEST['quote'])) |
498 | - $case = 3; |
|
499 | - else |
|
500 | - $case = 4; |
|
551 | + { |
|
552 | + $case = 3; |
|
553 | + } |
|
554 | + else { |
|
555 | + $case = 4; |
|
556 | + } |
|
501 | 557 | |
502 | 558 | list ($this->_form_subject, $this->_form_message) = getFormMsgSubject($case, $topic, $this->_topic_attributes['subject']); |
503 | 559 | } |
504 | 560 | |
505 | 561 | // Check whether this is a really old post being bumped... |
506 | 562 | if (!empty($topic) && !empty($modSettings['oldTopicDays']) && $this->_topic_attributes['last_post_time'] + $modSettings['oldTopicDays'] * 86400 < time() && empty($this->_topic_attributes['is_sticky']) && !isset($_REQUEST['subject'])) |
507 | - $this->_post_errors->addError(array('old_topic', array($modSettings['oldTopicDays'])), 0); |
|
563 | + { |
|
564 | + $this->_post_errors->addError(array('old_topic', array($modSettings['oldTopicDays'])), 0); |
|
565 | + } |
|
508 | 566 | } |
509 | 567 | |
510 | 568 | protected function _preparing_page() |
@@ -522,13 +580,20 @@ discard block |
||
522 | 580 | if (empty($context['page_title'])) |
523 | 581 | { |
524 | 582 | if (isset($_REQUEST['msg'])) |
525 | - $context['page_title'] = $txt['modify_msg']; |
|
583 | + { |
|
584 | + $context['page_title'] = $txt['modify_msg']; |
|
585 | + } |
|
526 | 586 | elseif (isset($_REQUEST['subject'], $context['preview_subject'])) |
527 | - $context['page_title'] = $txt['post_reply']; |
|
587 | + { |
|
588 | + $context['page_title'] = $txt['post_reply']; |
|
589 | + } |
|
528 | 590 | elseif (empty($topic)) |
529 | - $context['page_title'] = $txt['start_new_topic']; |
|
530 | - else |
|
531 | - $context['page_title'] = $txt['post_reply']; |
|
591 | + { |
|
592 | + $context['page_title'] = $txt['start_new_topic']; |
|
593 | + } |
|
594 | + else { |
|
595 | + $context['page_title'] = $txt['post_reply']; |
|
596 | + } |
|
532 | 597 | } |
533 | 598 | |
534 | 599 | // Update the topic summary, needed to show new posts in a preview |
@@ -537,9 +602,12 @@ discard block |
||
537 | 602 | $only_approved = $modSettings['postmod_active'] && !allowedTo('approve_posts'); |
538 | 603 | |
539 | 604 | if (isset($_REQUEST['xml'])) |
540 | - $limit = empty($context['new_replies']) ? 0 : (int) $context['new_replies']; |
|
541 | - else |
|
542 | - $limit = $modSettings['topicSummaryPosts']; |
|
605 | + { |
|
606 | + $limit = empty($context['new_replies']) ? 0 : (int) $context['new_replies']; |
|
607 | + } |
|
608 | + else { |
|
609 | + $limit = $modSettings['topicSummaryPosts']; |
|
610 | + } |
|
543 | 611 | |
544 | 612 | $before = isset($_REQUEST['msg']) ? array('before' => (int) $_REQUEST['msg']) : array(); |
545 | 613 | |
@@ -552,13 +620,17 @@ discard block |
||
552 | 620 | $post['is_ignored'] = !empty($modSettings['enable_buddylist']) && in_array($post['id_poster'], $user_info['ignoreusers']); |
553 | 621 | |
554 | 622 | if (!empty($context['new_replies'])) |
555 | - $context['new_replies']--; |
|
623 | + { |
|
624 | + $context['new_replies']--; |
|
625 | + } |
|
556 | 626 | } |
557 | 627 | } |
558 | 628 | |
559 | 629 | // Just ajax previewing then lets stop now |
560 | 630 | if (isset($_REQUEST['xml'])) |
561 | - obExit(); |
|
631 | + { |
|
632 | + obExit(); |
|
633 | + } |
|
562 | 634 | |
563 | 635 | $context['subject'] = addcslashes($this->_form_subject, '"'); |
564 | 636 | $context['message'] = str_replace(array('"', '<', '>', ' '), array('"', '<', '>', ' '), $this->_form_message); |
@@ -576,7 +648,9 @@ discard block |
||
576 | 648 | |
577 | 649 | // $context['icon'] is set when editing a message |
578 | 650 | if (!isset($context['icon'])) |
579 | - $context['icon'] = $context['icons'][0]['value']; |
|
651 | + { |
|
652 | + $context['icon'] = $context['icons'][0]['value']; |
|
653 | + } |
|
580 | 654 | $found = false; |
581 | 655 | foreach ($context['icons'] as $icon) |
582 | 656 | { |
@@ -658,12 +732,17 @@ discard block |
||
658 | 732 | if (empty($_POST) && empty($topic)) |
659 | 733 | { |
660 | 734 | if (empty($_SERVER['CONTENT_LENGTH'])) |
661 | - redirectexit('action=post;board=' . $board . '.0'); |
|
662 | - else |
|
663 | - throw new Elk_Exception('post_upload_error', false); |
|
735 | + { |
|
736 | + redirectexit('action=post;board=' . $board . '.0'); |
|
737 | + } |
|
738 | + else { |
|
739 | + throw new Elk_Exception('post_upload_error', false); |
|
740 | + } |
|
664 | 741 | } |
665 | 742 | elseif (empty($_POST) && !empty($topic)) |
666 | - redirectexit('action=post;topic=' . $topic . '.0'); |
|
743 | + { |
|
744 | + redirectexit('action=post;topic=' . $topic . '.0'); |
|
745 | + } |
|
667 | 746 | |
668 | 747 | // No need! |
669 | 748 | $context['robot_no_index'] = true; |
@@ -686,7 +765,9 @@ discard block |
||
686 | 765 | |
687 | 766 | // Previewing? Go back to start. |
688 | 767 | if (isset($_REQUEST['preview'])) |
689 | - return $this->action_post(); |
|
768 | + { |
|
769 | + return $this->action_post(); |
|
770 | + } |
|
690 | 771 | |
691 | 772 | require_once(SUBSDIR . '/Boards.subs.php'); |
692 | 773 | loadLanguage('Post'); |
@@ -704,11 +785,15 @@ discard block |
||
704 | 785 | |
705 | 786 | // Though the topic should be there, it might have vanished. |
706 | 787 | if (empty($topic_info)) |
707 | - throw new Elk_Exception('topic_doesnt_exist'); |
|
788 | + { |
|
789 | + throw new Elk_Exception('topic_doesnt_exist'); |
|
790 | + } |
|
708 | 791 | |
709 | 792 | // Did this topic suddenly move? Just checking... |
710 | 793 | if ($topic_info['id_board'] != $board) |
711 | - throw new Elk_Exception('not_a_topic'); |
|
794 | + { |
|
795 | + throw new Elk_Exception('not_a_topic'); |
|
796 | + } |
|
712 | 797 | } |
713 | 798 | |
714 | 799 | // Replying to a topic? |
@@ -716,28 +801,38 @@ discard block |
||
716 | 801 | { |
717 | 802 | // Don't allow a post if it's locked. |
718 | 803 | if ($topic_info['locked'] != 0 && !allowedTo('moderate_board')) |
719 | - throw new Elk_Exception('topic_locked', false); |
|
804 | + { |
|
805 | + throw new Elk_Exception('topic_locked', false); |
|
806 | + } |
|
720 | 807 | |
721 | 808 | // Do the permissions and approval stuff... |
722 | 809 | $becomesApproved = true; |
723 | 810 | if ($topic_info['id_member_started'] != $user_info['id']) |
724 | 811 | { |
725 | 812 | if ($modSettings['postmod_active'] && allowedTo('post_unapproved_replies_any') && !allowedTo('post_reply_any')) |
726 | - $becomesApproved = false; |
|
727 | - else |
|
728 | - isAllowedTo('post_reply_any'); |
|
813 | + { |
|
814 | + $becomesApproved = false; |
|
815 | + } |
|
816 | + else { |
|
817 | + isAllowedTo('post_reply_any'); |
|
818 | + } |
|
729 | 819 | } |
730 | 820 | elseif (!allowedTo('post_reply_any')) |
731 | 821 | { |
732 | 822 | if ($modSettings['postmod_active']) |
733 | 823 | { |
734 | 824 | if (allowedTo('post_unapproved_replies_own') && !allowedTo('post_reply_own')) |
735 | - $becomesApproved = false; |
|
825 | + { |
|
826 | + $becomesApproved = false; |
|
827 | + } |
|
736 | 828 | // Guests do not have post_unapproved_replies_own permission, so it's always post_unapproved_replies_any |
737 | 829 | elseif ($user_info['is_guest'] && allowedTo('post_unapproved_replies_any')) |
738 | - $becomesApproved = false; |
|
739 | - else |
|
740 | - isAllowedTo('post_reply_own'); |
|
830 | + { |
|
831 | + $becomesApproved = false; |
|
832 | + } |
|
833 | + else { |
|
834 | + isAllowedTo('post_reply_own'); |
|
835 | + } |
|
741 | 836 | } |
742 | 837 | } |
743 | 838 | |
@@ -748,7 +843,9 @@ discard block |
||
748 | 843 | |
749 | 844 | // So you wanna (un)sticky this...let's see. |
750 | 845 | if (isset($_POST['sticky']) && ($_POST['sticky'] == $topic_info['is_sticky'] || !allowedTo('make_sticky'))) |
751 | - unset($_POST['sticky']); |
|
846 | + { |
|
847 | + unset($_POST['sticky']); |
|
848 | + } |
|
752 | 849 | |
753 | 850 | // Trigger the save_replying event |
754 | 851 | $this->_events->trigger('save_replying', array('topic_info' => &$topic_info)); |
@@ -776,9 +873,12 @@ discard block |
||
776 | 873 | // Do like, the permissions, for safety and stuff... |
777 | 874 | $becomesApproved = true; |
778 | 875 | if ($modSettings['postmod_active'] && !allowedTo('post_new') && allowedTo('post_unapproved_topics')) |
779 | - $becomesApproved = false; |
|
780 | - else |
|
781 | - isAllowedTo('post_new'); |
|
876 | + { |
|
877 | + $becomesApproved = false; |
|
878 | + } |
|
879 | + else { |
|
880 | + isAllowedTo('post_new'); |
|
881 | + } |
|
782 | 882 | |
783 | 883 | // Trigger teh save new topic event |
784 | 884 | $this->_events->trigger('save_new_topic', array('becomesApproved' => &$becomesApproved)); |
@@ -789,7 +889,9 @@ discard block |
||
789 | 889 | } |
790 | 890 | |
791 | 891 | if (isset($_POST['sticky']) && (empty($_POST['sticky']) || !allowedTo('make_sticky'))) |
792 | - unset($_POST['sticky']); |
|
892 | + { |
|
893 | + unset($_POST['sticky']); |
|
894 | + } |
|
793 | 895 | |
794 | 896 | $posterIsGuest = $user_info['is_guest']; |
795 | 897 | } |
@@ -801,13 +903,17 @@ discard block |
||
801 | 903 | $msgInfo = basicMessageInfo($_REQUEST['msg'], true); |
802 | 904 | |
803 | 905 | if (empty($msgInfo)) |
804 | - throw new Elk_Exception('cant_find_messages', false); |
|
906 | + { |
|
907 | + throw new Elk_Exception('cant_find_messages', false); |
|
908 | + } |
|
805 | 909 | |
806 | 910 | // Trigger teh save_modify event |
807 | 911 | $this->_events->trigger('save_modify', array('msgInfo' => &$msgInfo)); |
808 | 912 | |
809 | 913 | if (!empty($topic_info['locked']) && !allowedTo('moderate_board')) |
810 | - throw new Elk_Exception('topic_locked', false); |
|
914 | + { |
|
915 | + throw new Elk_Exception('topic_locked', false); |
|
916 | + } |
|
811 | 917 | |
812 | 918 | if (isset($_POST['lock'])) |
813 | 919 | { |
@@ -816,16 +922,23 @@ discard block |
||
816 | 922 | |
817 | 923 | // Change the sticky status of this topic? |
818 | 924 | if (isset($_POST['sticky']) && (!allowedTo('make_sticky') || $_POST['sticky'] == $topic_info['is_sticky'])) |
819 | - unset($_POST['sticky']); |
|
925 | + { |
|
926 | + unset($_POST['sticky']); |
|
927 | + } |
|
820 | 928 | |
821 | 929 | if ($msgInfo['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
822 | 930 | { |
823 | 931 | if ((!$modSettings['postmod_active'] || $msgInfo['approved']) && !empty($modSettings['edit_disable_time']) && $msgInfo['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
824 | - throw new Elk_Exception('modify_post_time_passed', false); |
|
932 | + { |
|
933 | + throw new Elk_Exception('modify_post_time_passed', false); |
|
934 | + } |
|
825 | 935 | elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
826 | - isAllowedTo('modify_replies'); |
|
827 | - else |
|
828 | - isAllowedTo('modify_own'); |
|
936 | + { |
|
937 | + isAllowedTo('modify_replies'); |
|
938 | + } |
|
939 | + else { |
|
940 | + isAllowedTo('modify_own'); |
|
941 | + } |
|
829 | 942 | } |
830 | 943 | elseif ($topic_info['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
831 | 944 | { |
@@ -840,7 +953,9 @@ discard block |
||
840 | 953 | |
841 | 954 | // Log it, assuming you're not modifying your own post. |
842 | 955 | if ($msgInfo['id_member'] != $user_info['id']) |
843 | - $moderationAction = true; |
|
956 | + { |
|
957 | + $moderationAction = true; |
|
958 | + } |
|
844 | 959 | } |
845 | 960 | |
846 | 961 | $posterIsGuest = empty($msgInfo['id_member']); |
@@ -871,10 +986,14 @@ discard block |
||
871 | 986 | $_POST['email'] = !isset($_POST['email']) ? '' : Util::htmlspecialchars(trim($_POST['email'])); |
872 | 987 | |
873 | 988 | if ($_POST['guestname'] == '' || $_POST['guestname'] == '_') |
874 | - $this->_post_errors->addError('no_name'); |
|
989 | + { |
|
990 | + $this->_post_errors->addError('no_name'); |
|
991 | + } |
|
875 | 992 | |
876 | 993 | if (Util::strlen($_POST['guestname']) > 25) |
877 | - $this->_post_errors->addError('long_name'); |
|
994 | + { |
|
995 | + $this->_post_errors->addError('long_name'); |
|
996 | + } |
|
878 | 997 | |
879 | 998 | if (empty($modSettings['guest_post_no_email'])) |
880 | 999 | { |
@@ -882,7 +1001,9 @@ discard block |
||
882 | 1001 | if (!isset($msgInfo) || $msgInfo['poster_email'] != $_POST['email']) |
883 | 1002 | { |
884 | 1003 | if (!allowedTo('moderate_forum') && !Data_Validator::is_valid($_POST, array('email' => 'valid_email|required'), array('email' => 'trim'))) |
885 | - empty($_POST['email']) ? $this->_post_errors->addError('no_email') : $this->_post_errors->addError('bad_email'); |
|
1004 | + { |
|
1005 | + empty($_POST['email']) ? $this->_post_errors->addError('no_email') : $this->_post_errors->addError('bad_email'); |
|
1006 | + } |
|
886 | 1007 | } |
887 | 1008 | |
888 | 1009 | // Now make sure this email address is not banned from posting. |
@@ -909,12 +1030,18 @@ discard block |
||
909 | 1030 | |
910 | 1031 | // Check the subject and message. |
911 | 1032 | if (!isset($_POST['subject']) || Util::htmltrim(Util::htmlspecialchars($_POST['subject'])) === '') |
912 | - $this->_post_errors->addError('no_subject'); |
|
1033 | + { |
|
1034 | + $this->_post_errors->addError('no_subject'); |
|
1035 | + } |
|
913 | 1036 | |
914 | 1037 | if (!isset($_POST['message']) || Util::htmltrim(Util::htmlspecialchars($_POST['message'], ENT_QUOTES)) === '') |
915 | - $this->_post_errors->addError('no_message'); |
|
1038 | + { |
|
1039 | + $this->_post_errors->addError('no_message'); |
|
1040 | + } |
|
916 | 1041 | elseif (!empty($modSettings['max_messageLength']) && Util::strlen($_POST['message']) > $modSettings['max_messageLength']) |
917 | - $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
1042 | + { |
|
1043 | + $this->_post_errors->addError(array('long_message', array($modSettings['max_messageLength']))); |
|
1044 | + } |
|
918 | 1045 | else |
919 | 1046 | { |
920 | 1047 | // Prepare the message a bit for some additional testing. |
@@ -922,7 +1049,9 @@ discard block |
||
922 | 1049 | |
923 | 1050 | // Preparse code. (Zef) |
924 | 1051 | if ($user_info['is_guest']) |
925 | - $user_info['name'] = $_POST['guestname']; |
|
1052 | + { |
|
1053 | + $user_info['name'] = $_POST['guestname']; |
|
1054 | + } |
|
926 | 1055 | |
927 | 1056 | $this->preparse->preparsecode($_POST['message']); |
928 | 1057 | |
@@ -930,7 +1059,9 @@ discard block |
||
930 | 1059 | |
931 | 1060 | // Let's see if there's still some content left without the tags. |
932 | 1061 | if (Util::htmltrim(strip_tags($bbc_parser->parseMessage($_POST['message'], false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($_POST['message'], '[html]') === false)) |
933 | - $this->_post_errors->addError('no_message'); |
|
1062 | + { |
|
1063 | + $this->_post_errors->addError('no_message'); |
|
1064 | + } |
|
934 | 1065 | } |
935 | 1066 | |
936 | 1067 | if ($posterIsGuest) |
@@ -938,7 +1069,9 @@ discard block |
||
938 | 1069 | // If user is a guest, make sure the chosen name isn't taken. |
939 | 1070 | require_once(SUBSDIR . '/Members.subs.php'); |
940 | 1071 | if (isReservedName($_POST['guestname'], 0, true, false) && (!isset($msgInfo['poster_name']) || $_POST['guestname'] != $msgInfo['poster_name'])) |
941 | - $this->_post_errors->addError('bad_name'); |
|
1072 | + { |
|
1073 | + $this->_post_errors->addError('bad_name'); |
|
1074 | + } |
|
942 | 1075 | } |
943 | 1076 | // If the user isn't a guest, get his or her name and email. |
944 | 1077 | elseif (!isset($_REQUEST['msg'])) |
@@ -956,9 +1089,12 @@ discard block |
||
956 | 1089 | $post_in_board = boardInfo($new_board); |
957 | 1090 | |
958 | 1091 | if (!empty($post_in_board)) |
959 | - $this->_post_errors->addError(array('post_new_board', array($post_in_board['name']))); |
|
960 | - else |
|
961 | - $this->_post_errors->addError('post_new'); |
|
1092 | + { |
|
1093 | + $this->_post_errors->addError(array('post_new_board', array($post_in_board['name']))); |
|
1094 | + } |
|
1095 | + else { |
|
1096 | + $this->_post_errors->addError('post_new'); |
|
1097 | + } |
|
962 | 1098 | } |
963 | 1099 | } |
964 | 1100 | |
@@ -977,7 +1113,9 @@ discard block |
||
977 | 1113 | |
978 | 1114 | // Make sure the user isn't spamming the board. |
979 | 1115 | if (!isset($_REQUEST['msg'])) |
980 | - spamProtection('post'); |
|
1116 | + { |
|
1117 | + spamProtection('post'); |
|
1118 | + } |
|
981 | 1119 | |
982 | 1120 | // At about this point, we're posting and that's that. |
983 | 1121 | ignore_user_abort(true); |
@@ -990,7 +1128,9 @@ discard block |
||
990 | 1128 | |
991 | 1129 | // At this point, we want to make sure the subject isn't too long. |
992 | 1130 | if (Util::strlen($_POST['subject']) > 100) |
993 | - $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
1131 | + { |
|
1132 | + $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
1133 | + } |
|
994 | 1134 | |
995 | 1135 | // Creating a new topic? |
996 | 1136 | $newTopic = empty($_REQUEST['msg']) && empty($topic); |
@@ -1038,7 +1178,9 @@ discard block |
||
1038 | 1178 | |
1039 | 1179 | // This will save some time... |
1040 | 1180 | if (empty($approve_has_changed)) |
1041 | - unset($msgOptions['approved']); |
|
1181 | + { |
|
1182 | + unset($msgOptions['approved']); |
|
1183 | + } |
|
1042 | 1184 | |
1043 | 1185 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
1044 | 1186 | } |
@@ -1061,7 +1203,9 @@ discard block |
||
1061 | 1203 | createPost($msgOptions, $topicOptions, $posterOptions); |
1062 | 1204 | |
1063 | 1205 | if (isset($topicOptions['id'])) |
1064 | - $topic = $topicOptions['id']; |
|
1206 | + { |
|
1207 | + $topic = $topicOptions['id']; |
|
1208 | + } |
|
1065 | 1209 | } |
1066 | 1210 | |
1067 | 1211 | // Trigger the after_save_post event |
@@ -1075,27 +1219,41 @@ discard block |
||
1075 | 1219 | |
1076 | 1220 | // Returning to the topic? |
1077 | 1221 | if (!empty($_REQUEST['goback'])) |
1078 | - $board_list[] = $board; |
|
1222 | + { |
|
1223 | + $board_list[] = $board; |
|
1224 | + } |
|
1079 | 1225 | |
1080 | 1226 | if (!empty($board_list)) |
1081 | - markBoardsRead($board_list, false, false); |
|
1227 | + { |
|
1228 | + markBoardsRead($board_list, false, false); |
|
1229 | + } |
|
1082 | 1230 | } |
1083 | 1231 | |
1084 | 1232 | // Turn notification on or off. |
1085 | 1233 | if (!empty($_POST['notify']) && allowedTo('mark_any_notify')) |
1086 | - setTopicNotification($user_info['id'], $topic, true); |
|
1234 | + { |
|
1235 | + setTopicNotification($user_info['id'], $topic, true); |
|
1236 | + } |
|
1087 | 1237 | elseif (!$newTopic) |
1088 | - setTopicNotification($user_info['id'], $topic, false); |
|
1238 | + { |
|
1239 | + setTopicNotification($user_info['id'], $topic, false); |
|
1240 | + } |
|
1089 | 1241 | |
1090 | 1242 | // Log an act of moderation - modifying. |
1091 | 1243 | if (!empty($moderationAction)) |
1092 | - logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $msgInfo['id_member'], 'board' => $board)); |
|
1244 | + { |
|
1245 | + logAction('modify', array('topic' => $topic, 'message' => (int) $_REQUEST['msg'], 'member' => $msgInfo['id_member'], 'board' => $board)); |
|
1246 | + } |
|
1093 | 1247 | |
1094 | 1248 | if (isset($_POST['lock']) && $_POST['lock'] != 2) |
1095 | - logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
1249 | + { |
|
1250 | + logAction(empty($_POST['lock']) ? 'unlock' : 'lock', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
1251 | + } |
|
1096 | 1252 | |
1097 | 1253 | if (isset($_POST['sticky'])) |
1098 | - logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
1254 | + { |
|
1255 | + logAction(empty($_POST['sticky']) ? 'unsticky' : 'sticky', array('topic' => $topicOptions['id'], 'board' => $topicOptions['board'])); |
|
1256 | + } |
|
1099 | 1257 | |
1100 | 1258 | // Notify any members who have notification turned on for this topic/board - only do this if it's going to be approved(!) |
1101 | 1259 | if ($becomesApproved) |
@@ -1119,29 +1277,43 @@ discard block |
||
1119 | 1277 | { |
1120 | 1278 | // Only send it to everyone if the topic is approved, otherwise just to the topic starter if they want it. |
1121 | 1279 | if ($topic_info['approved']) |
1122 | - sendNotifications($topic, 'reply'); |
|
1123 | - else |
|
1124 | - sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']); |
|
1280 | + { |
|
1281 | + sendNotifications($topic, 'reply'); |
|
1282 | + } |
|
1283 | + else { |
|
1284 | + sendNotifications($topic, 'reply', array(), $topic_info['id_member_started']); |
|
1285 | + } |
|
1125 | 1286 | } |
1126 | 1287 | } |
1127 | 1288 | |
1128 | 1289 | if ($board_info['num_topics'] == 0) |
1129 | - Cache::instance()->remove('board-' . $board); |
|
1290 | + { |
|
1291 | + Cache::instance()->remove('board-' . $board); |
|
1292 | + } |
|
1130 | 1293 | |
1131 | 1294 | if (!empty($_POST['announce_topic'])) |
1132 | - redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
1295 | + { |
|
1296 | + redirectexit('action=announce;sa=selectgroup;topic=' . $topic . (!empty($_POST['move']) && allowedTo('move_any') ? ';move' : '') . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
1297 | + } |
|
1133 | 1298 | |
1134 | 1299 | if (!empty($_POST['move']) && allowedTo('move_any')) |
1135 | - redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
1300 | + { |
|
1301 | + redirectexit('action=movetopic;topic=' . $topic . '.0' . (empty($_REQUEST['goback']) ? '' : ';goback')); |
|
1302 | + } |
|
1136 | 1303 | |
1137 | 1304 | // Return to post if the mod is on. |
1138 | 1305 | if (isset($_REQUEST['msg']) && !empty($_REQUEST['goback'])) |
1139 | - redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
1306 | + { |
|
1307 | + redirectexit('topic=' . $topic . '.msg' . $_REQUEST['msg'] . '#msg' . $_REQUEST['msg'], isBrowser('ie')); |
|
1308 | + } |
|
1140 | 1309 | elseif (!empty($_REQUEST['goback'])) |
1141 | - redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
1310 | + { |
|
1311 | + redirectexit('topic=' . $topic . '.new#new', isBrowser('ie')); |
|
1312 | + } |
|
1142 | 1313 | // Dut-dut-duh-duh-DUH-duh-dut-duh-duh! *dances to the Final Fantasy Fanfare...* |
1143 | - else |
|
1144 | - redirectexit('board=' . $board . '.0'); |
|
1314 | + else { |
|
1315 | + redirectexit('board=' . $board . '.0'); |
|
1316 | + } |
|
1145 | 1317 | } |
1146 | 1318 | |
1147 | 1319 | /** |
@@ -1166,7 +1338,9 @@ discard block |
||
1166 | 1338 | |
1167 | 1339 | $context['sub_template'] = 'quotefast'; |
1168 | 1340 | if (!empty($row)) |
1169 | - $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
1341 | + { |
|
1342 | + $can_view_post = $row['approved'] || ($row['id_member'] != 0 && $row['id_member'] == $user_info['id']) || allowedTo('approve_posts', $row['id_board']); |
|
1343 | + } |
|
1170 | 1344 | |
1171 | 1345 | if (!empty($can_view_post)) |
1172 | 1346 | { |
@@ -1214,12 +1388,13 @@ discard block |
||
1214 | 1388 | 'subject' => '', |
1215 | 1389 | ); |
1216 | 1390 | } |
1217 | - else |
|
1218 | - $context['quote'] = array( |
|
1391 | + else { |
|
1392 | + $context['quote'] = array( |
|
1219 | 1393 | 'xml' => '', |
1220 | 1394 | 'mozilla' => '', |
1221 | 1395 | 'text' => '', |
1222 | 1396 | ); |
1397 | + } |
|
1223 | 1398 | } |
1224 | 1399 | |
1225 | 1400 | /** |
@@ -1233,35 +1408,49 @@ discard block |
||
1233 | 1408 | |
1234 | 1409 | // We have to have a topic! |
1235 | 1410 | if (empty($topic)) |
1236 | - obExit(false); |
|
1411 | + { |
|
1412 | + obExit(false); |
|
1413 | + } |
|
1237 | 1414 | |
1238 | 1415 | checkSession('get'); |
1239 | 1416 | |
1240 | 1417 | $row = getTopicInfoByMsg($topic, empty($_REQUEST['msg']) ? 0 : (int) $_REQUEST['msg']); |
1241 | 1418 | |
1242 | 1419 | if (empty($row)) |
1243 | - throw new Elk_Exception('no_board', false); |
|
1420 | + { |
|
1421 | + throw new Elk_Exception('no_board', false); |
|
1422 | + } |
|
1244 | 1423 | |
1245 | 1424 | // Change either body or subject requires permissions to modify messages. |
1246 | 1425 | if (isset($_POST['message']) || isset($_POST['subject']) || isset($_REQUEST['icon'])) |
1247 | 1426 | { |
1248 | 1427 | if (!empty($row['locked'])) |
1249 | - isAllowedTo('moderate_board'); |
|
1428 | + { |
|
1429 | + isAllowedTo('moderate_board'); |
|
1430 | + } |
|
1250 | 1431 | |
1251 | 1432 | if ($row['id_member'] == $user_info['id'] && !allowedTo('modify_any')) |
1252 | 1433 | { |
1253 | 1434 | if ((!$modSettings['postmod_active'] || $row['approved']) && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + ($modSettings['edit_disable_time'] + 5) * 60 < time()) |
1254 | - throw new Elk_Exception('modify_post_time_passed', false); |
|
1435 | + { |
|
1436 | + throw new Elk_Exception('modify_post_time_passed', false); |
|
1437 | + } |
|
1255 | 1438 | elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_own')) |
1256 | - isAllowedTo('modify_replies'); |
|
1257 | - else |
|
1258 | - isAllowedTo('modify_own'); |
|
1439 | + { |
|
1440 | + isAllowedTo('modify_replies'); |
|
1441 | + } |
|
1442 | + else { |
|
1443 | + isAllowedTo('modify_own'); |
|
1444 | + } |
|
1259 | 1445 | } |
1260 | 1446 | // Otherwise, they're locked out; someone who can modify the replies is needed. |
1261 | 1447 | elseif ($row['id_member_started'] == $user_info['id'] && !allowedTo('modify_any')) |
1262 | - isAllowedTo('modify_replies'); |
|
1263 | - else |
|
1264 | - isAllowedTo('modify_any'); |
|
1448 | + { |
|
1449 | + isAllowedTo('modify_replies'); |
|
1450 | + } |
|
1451 | + else { |
|
1452 | + isAllowedTo('modify_any'); |
|
1453 | + } |
|
1265 | 1454 | |
1266 | 1455 | // Only log this action if it wasn't your message. |
1267 | 1456 | $moderationAction = $row['id_member'] != $user_info['id']; |
@@ -1273,7 +1462,9 @@ discard block |
||
1273 | 1462 | |
1274 | 1463 | // Maximum number of characters. |
1275 | 1464 | if (Util::strlen($_POST['subject']) > 100) |
1276 | - $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
1465 | + { |
|
1466 | + $_POST['subject'] = Util::substr($_POST['subject'], 0, 100); |
|
1467 | + } |
|
1277 | 1468 | } |
1278 | 1469 | elseif (isset($_POST['subject'])) |
1279 | 1470 | { |
@@ -1314,7 +1505,9 @@ discard block |
||
1314 | 1505 | } |
1315 | 1506 | |
1316 | 1507 | if (isset($_POST['sticky']) && !allowedTo('make_sticky')) |
1317 | - unset($_POST['sticky']); |
|
1508 | + { |
|
1509 | + unset($_POST['sticky']); |
|
1510 | + } |
|
1318 | 1511 | |
1319 | 1512 | if (!$this->_post_errors->hasErrors()) |
1320 | 1513 | { |
@@ -1332,7 +1525,9 @@ discard block |
||
1332 | 1525 | { |
1333 | 1526 | $_POST['message'] = str_replace('@' . $member['real_name'], '[member=' . $member['id_member'] . ']' . $member['real_name'] . '[/member]', $_POST['message'], $replacements); |
1334 | 1527 | if ($replacements > 0) |
1335 | - $actually_mentioned[] = $member['id_member']; |
|
1528 | + { |
|
1529 | + $actually_mentioned[] = $member['id_member']; |
|
1530 | + } |
|
1336 | 1531 | } |
1337 | 1532 | } |
1338 | 1533 | |
@@ -1376,8 +1571,9 @@ discard block |
||
1376 | 1571 | } |
1377 | 1572 | } |
1378 | 1573 | // If nothing was changed there's no need to add an entry to the moderation log. |
1379 | - else |
|
1380 | - $moderationAction = false; |
|
1574 | + else { |
|
1575 | + $moderationAction = false; |
|
1576 | + } |
|
1381 | 1577 | |
1382 | 1578 | modifyPost($msgOptions, $topicOptions, $posterOptions); |
1383 | 1579 | |
@@ -1398,7 +1594,9 @@ discard block |
||
1398 | 1594 | } |
1399 | 1595 | |
1400 | 1596 | if (!empty($moderationAction)) |
1401 | - logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
1597 | + { |
|
1598 | + logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board)); |
|
1599 | + } |
|
1402 | 1600 | } |
1403 | 1601 | |
1404 | 1602 | if (isset($_REQUEST['xml'])) |
@@ -1454,8 +1652,9 @@ discard block |
||
1454 | 1652 | $context['message']['errors'] = $this->_post_errors->prepareErrors(); |
1455 | 1653 | } |
1456 | 1654 | } |
1457 | - else |
|
1458 | - obExit(false); |
|
1655 | + else { |
|
1656 | + obExit(false); |
|
1657 | + } |
|
1459 | 1658 | } |
1460 | 1659 | |
1461 | 1660 | /** |
@@ -1475,34 +1674,47 @@ discard block |
||
1475 | 1674 | { |
1476 | 1675 | // New topics are by default not locked. |
1477 | 1676 | if (empty($lock)) |
1478 | - return null; |
|
1677 | + { |
|
1678 | + return null; |
|
1679 | + } |
|
1479 | 1680 | // Besides, you need permission. |
1480 | 1681 | elseif (!allowedTo(array('lock_any', 'lock_own'))) |
1481 | - return null; |
|
1682 | + { |
|
1683 | + return null; |
|
1684 | + } |
|
1482 | 1685 | // A moderator-lock (1) can override a user-lock (2). |
1483 | - else |
|
1484 | - return allowedTo('lock_any') ? 1 : 2; |
|
1686 | + else { |
|
1687 | + return allowedTo('lock_any') ? 1 : 2; |
|
1688 | + } |
|
1485 | 1689 | } |
1486 | 1690 | |
1487 | 1691 | // Nothing changes to the lock status. |
1488 | 1692 | if ((empty($lock) && empty($topic_info['locked'])) || (!empty($lock) && !empty($topic_info['locked']))) |
1489 | - return null; |
|
1693 | + { |
|
1694 | + return null; |
|
1695 | + } |
|
1490 | 1696 | // You're simply not allowed to (un)lock this. |
1491 | 1697 | elseif (!allowedTo(array('lock_any', 'lock_own')) || (!allowedTo('lock_any') && $user_info['id'] != $topic_info['id_member_started'])) |
1492 | - return null; |
|
1698 | + { |
|
1699 | + return null; |
|
1700 | + } |
|
1493 | 1701 | // You're only allowed to lock your own topics. |
1494 | 1702 | elseif (!allowedTo('lock_any')) |
1495 | 1703 | { |
1496 | 1704 | // You're not allowed to break a moderator's lock. |
1497 | 1705 | if ($topic_info['locked'] == 1) |
1498 | - return null; |
|
1706 | + { |
|
1707 | + return null; |
|
1708 | + } |
|
1499 | 1709 | // Lock it with a soft lock or unlock it. |
1500 | - else |
|
1501 | - $lock = empty($lock) ? 0 : 2; |
|
1710 | + else { |
|
1711 | + $lock = empty($lock) ? 0 : 2; |
|
1712 | + } |
|
1502 | 1713 | } |
1503 | 1714 | // You must be the moderator. |
1504 | - else |
|
1505 | - $lock = empty($lock) ? 0 : 1; |
|
1715 | + else { |
|
1716 | + $lock = empty($lock) ? 0 : 1; |
|
1717 | + } |
|
1506 | 1718 | |
1507 | 1719 | return $lock; |
1508 | 1720 | } |
@@ -79,7 +79,9 @@ discard block |
||
79 | 79 | ); |
80 | 80 | |
81 | 81 | if (isset($replacements[$identifier])) |
82 | - $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
82 | + { |
|
83 | + $db_string = preg_replace(array_keys($replacements[$identifier]), array_values($replacements[$identifier]), $db_string); |
|
84 | + } |
|
83 | 85 | elseif (preg_match('~^\s*INSERT\sIGNORE~i', $db_string) != 0) |
84 | 86 | { |
85 | 87 | $db_string = preg_replace('~^\s*INSERT\sIGNORE~i', 'INSERT', $db_string); |
@@ -116,7 +118,9 @@ discard block |
||
116 | 118 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
117 | 119 | $db_table->optimize('{db_prefix}messages'); |
118 | 120 | if ($db_table->table_exists('{db_prefix}log_search_words')) |
119 | - $db_table->optimize('{db_prefix}log_search_words'); |
|
121 | + { |
|
122 | + $db_table->optimize('{db_prefix}log_search_words'); |
|
123 | + } |
|
120 | 124 | |
121 | 125 | // PostGreSql has some hidden sizes. |
122 | 126 | $request = $db->query('', ' |
@@ -149,14 +153,15 @@ discard block |
||
149 | 153 | } |
150 | 154 | $db->free_result($request); |
151 | 155 | } |
152 | - else |
|
153 | - // Didn't work for some reason... |
|
156 | + else { |
|
157 | + // Didn't work for some reason... |
|
154 | 158 | $table_info = array( |
155 | 159 | 'data_length' => $txt['not_applicable'], |
156 | 160 | 'index_length' => $txt['not_applicable'], |
157 | 161 | 'fulltext_length' => $txt['not_applicable'], |
158 | 162 | 'custom_index_length' => $txt['not_applicable'], |
159 | 163 | ); |
164 | + } |
|
160 | 165 | |
161 | 166 | return $table_info; |
162 | 167 | } |