@@ -233,11 +233,13 @@ |
||
233 | 233 | ); |
234 | 234 | |
235 | 235 | $id_searchs = array(); |
236 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
237 | - $id_searchs[] = $row['id_search']; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
237 | + $id_searchs[] = $row['id_search']; |
|
238 | + } |
|
238 | 239 | |
239 | - if (count($id_searchs) < 1) |
|
240 | - return; |
|
240 | + if (count($id_searchs) < 1) { |
|
241 | + return; |
|
242 | + } |
|
241 | 243 | |
242 | 244 | $smcFunc['db_query']('',' |
243 | 245 | DELETE FROM {db_prefix}log_search_results |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Standard non full index, non custom index search |
@@ -27,8 +28,9 @@ discard block |
||
27 | 28 | $return = false; |
28 | 29 | |
29 | 30 | // Maybe parent got support |
30 | - if (!$return) |
|
31 | - $return = parent::supportsMethod($methodName, $query_params); |
|
31 | + if (!$return) { |
|
32 | + $return = parent::supportsMethod($methodName, $query_params); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | return $return; |
34 | 36 | } |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Class fulltext_search |
@@ -75,8 +76,9 @@ discard block |
||
75 | 76 | } |
76 | 77 | |
77 | 78 | // Maybe parent got support |
78 | - if (!$return) |
|
79 | - $return = parent::supportsMethod($methodName, $query_params); |
|
79 | + if (!$return) { |
|
80 | + $return = parent::supportsMethod($methodName, $query_params); |
|
81 | + } |
|
80 | 82 | |
81 | 83 | return $return; |
82 | 84 | } |
@@ -92,8 +94,9 @@ discard block |
||
92 | 94 | { |
93 | 95 | global $smcFunc, $db_type; |
94 | 96 | |
95 | - if ($db_type == 'postgresql') |
|
96 | - return 0; |
|
97 | + if ($db_type == 'postgresql') { |
|
98 | + return 0; |
|
99 | + } |
|
97 | 100 | // Try to determine the minimum number of letters for a fulltext search. |
98 | 101 | $request = $smcFunc['db_search_query']('max_fulltext_length', ' |
99 | 102 | SHOW VARIABLES |
@@ -108,8 +111,9 @@ discard block |
||
108 | 111 | $smcFunc['db_free_result']($request); |
109 | 112 | } |
110 | 113 | // 4 is the MySQL default... |
111 | - else |
|
112 | - $min_word_length = 4; |
|
114 | + else { |
|
115 | + $min_word_length = 4; |
|
116 | + } |
|
113 | 117 | |
114 | 118 | return $min_word_length; |
115 | 119 | } |
@@ -148,8 +152,7 @@ discard block |
||
148 | 152 | $wordsSearch['words'][] = trim($word, "/*- "); |
149 | 153 | $wordsSearch['complex_words'][] = count($subwords) === 1 ? $word : '"' . $word . '"'; |
150 | 154 | } |
151 | - } |
|
152 | - elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
155 | + } elseif ($smcFunc['strlen'](trim($word, "/*- ")) < $this->min_word_length) |
|
153 | 156 | { |
154 | 157 | // short words have feelings too |
155 | 158 | $wordsSearch['words'][] = trim($word, "/*- "); |
@@ -159,8 +162,9 @@ discard block |
||
159 | 162 | |
160 | 163 | $fulltextWord = count($subwords) === 1 ? $word : '"' . $word . '"'; |
161 | 164 | $wordsSearch['indexed_words'][] = $fulltextWord; |
162 | - if ($isExcluded) |
|
163 | - $wordsExclude[] = $fulltextWord; |
|
165 | + if ($isExcluded) { |
|
166 | + $wordsExclude[] = $fulltextWord; |
|
167 | + } |
|
164 | 168 | } |
165 | 169 | |
166 | 170 | /** |
@@ -176,44 +180,54 @@ discard block |
||
176 | 180 | $query_where = array(); |
177 | 181 | $query_params = $search_data['params']; |
178 | 182 | |
179 | - if( $smcFunc['db_title'] == "PostgreSQL") |
|
180 | - $modSettings['search_simple_fulltext'] = true; |
|
183 | + if( $smcFunc['db_title'] == "PostgreSQL") { |
|
184 | + $modSettings['search_simple_fulltext'] = true; |
|
185 | + } |
|
181 | 186 | |
182 | - if ($query_params['id_search']) |
|
183 | - $query_select['id_search'] = '{int:id_search}'; |
|
187 | + if ($query_params['id_search']) { |
|
188 | + $query_select['id_search'] = '{int:id_search}'; |
|
189 | + } |
|
184 | 190 | |
185 | 191 | $count = 0; |
186 | - if (empty($modSettings['search_simple_fulltext'])) |
|
187 | - foreach ($words['words'] as $regularWord) |
|
192 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
193 | + foreach ($words['words'] as $regularWord) |
|
188 | 194 | { |
189 | 195 | $query_where[] = 'm.body' . (in_array($regularWord, $query_params['excluded_words']) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:complex_body_' . $count . '}'; |
196 | + } |
|
190 | 197 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
191 | 198 | } |
192 | 199 | |
193 | - if ($query_params['user_query']) |
|
194 | - $query_where[] = '{raw:user_query}'; |
|
195 | - if ($query_params['board_query']) |
|
196 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
200 | + if ($query_params['user_query']) { |
|
201 | + $query_where[] = '{raw:user_query}'; |
|
202 | + } |
|
203 | + if ($query_params['board_query']) { |
|
204 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
205 | + } |
|
197 | 206 | |
198 | - if ($query_params['topic']) |
|
199 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
200 | - if ($query_params['min_msg_id']) |
|
201 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
202 | - if ($query_params['max_msg_id']) |
|
203 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
207 | + if ($query_params['topic']) { |
|
208 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
209 | + } |
|
210 | + if ($query_params['min_msg_id']) { |
|
211 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
212 | + } |
|
213 | + if ($query_params['max_msg_id']) { |
|
214 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
215 | + } |
|
204 | 216 | |
205 | 217 | $count = 0; |
206 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
207 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
218 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
219 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
208 | 220 | { |
209 | 221 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_phrase_' . $count . '}'; |
222 | + } |
|
210 | 223 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
211 | 224 | } |
212 | 225 | $count = 0; |
213 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
214 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
226 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
227 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
215 | 228 | { |
216 | 229 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : 'RLIKE') . '{string:exclude_subject_words_' . $count . '}'; |
230 | + } |
|
217 | 231 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
218 | 232 | } |
219 | 233 | |
@@ -225,12 +239,11 @@ discard block |
||
225 | 239 | |
226 | 240 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:body_match})'; |
227 | 241 | $query_params['language_ftx'] = $language_ftx; |
242 | + } else { |
|
243 | + $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
228 | 244 | } |
229 | - else |
|
230 | - $query_where[] = 'MATCH (body) AGAINST ({string:body_match})'; |
|
231 | 245 | $query_params['body_match'] = implode(' ', array_diff($words['indexed_words'], $query_params['excluded_index_words'])); |
232 | - } |
|
233 | - else |
|
246 | + } else |
|
234 | 247 | { |
235 | 248 | $query_params['boolean_match'] = ''; |
236 | 249 | |
@@ -246,10 +259,10 @@ discard block |
||
246 | 259 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '!' : '') . $fulltextWord . ' '; |
247 | 260 | $row++; |
248 | 261 | } |
249 | - } |
|
250 | - else |
|
251 | - foreach ($words['indexed_words'] as $fulltextWord) |
|
262 | + } else { |
|
263 | + foreach ($words['indexed_words'] as $fulltextWord) |
|
252 | 264 | $query_params['boolean_match'] .= (in_array($fulltextWord, $query_params['excluded_index_words']) ? '-' : '+') . $fulltextWord . ' '; |
265 | + } |
|
253 | 266 | |
254 | 267 | $query_params['boolean_match'] = substr($query_params['boolean_match'], 0, -1); |
255 | 268 | |
@@ -262,9 +275,9 @@ discard block |
||
262 | 275 | |
263 | 276 | $query_where[] = 'to_tsvector({string:language_ftx},body) @@ plainto_tsquery({string:language_ftx},{string:boolean_match})'; |
264 | 277 | $query_params['language_ftx'] = $language_ftx; |
278 | + } else { |
|
279 | + $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
265 | 280 | } |
266 | - else |
|
267 | - $query_where[] = 'MATCH (body) AGAINST ({string:boolean_match} IN BOOLEAN MODE)'; |
|
268 | 281 | } |
269 | 282 | } |
270 | 283 |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 4 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | } |
87 | 89 | |
88 | 90 | // Maybe parent got support |
89 | - if (!$return) |
|
90 | - $return = parent::supportsMethod($methodName, $query_params); |
|
91 | + if (!$return) { |
|
92 | + $return = parent::supportsMethod($methodName, $query_params); |
|
93 | + } |
|
91 | 94 | |
92 | 95 | return $return; |
93 | 96 | } |
@@ -124,21 +127,23 @@ discard block |
||
124 | 127 | |
125 | 128 | $subwords = text2words($word, $this->min_word_length, true); |
126 | 129 | |
127 | - if (empty($modSettings['search_force_index'])) |
|
128 | - $wordsSearch['words'][] = $word; |
|
130 | + if (empty($modSettings['search_force_index'])) { |
|
131 | + $wordsSearch['words'][] = $word; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | // Excluded phrases don't benefit from being split into subwords. |
131 | - if (count($subwords) > 1 && $isExcluded) |
|
132 | - return; |
|
133 | - else |
|
135 | + if (count($subwords) > 1 && $isExcluded) { |
|
136 | + return; |
|
137 | + } else |
|
134 | 138 | { |
135 | 139 | foreach ($subwords as $subword) |
136 | 140 | { |
137 | 141 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
138 | 142 | { |
139 | 143 | $wordsSearch['indexed_words'][] = $subword; |
140 | - if ($isExcluded) |
|
141 | - $wordsExclude[] = $subword; |
|
144 | + if ($isExcluded) { |
|
145 | + $wordsExclude[] = $subword; |
|
146 | + } |
|
142 | 147 | } |
143 | 148 | } |
144 | 149 | } |
@@ -159,8 +164,9 @@ discard block |
||
159 | 164 | $query_where = array(); |
160 | 165 | $query_params = $search_data['params']; |
161 | 166 | |
162 | - if ($query_params['id_search']) |
|
163 | - $query_select['id_search'] = '{int:id_search}'; |
|
167 | + if ($query_params['id_search']) { |
|
168 | + $query_select['id_search'] = '{int:id_search}'; |
|
169 | + } |
|
164 | 170 | |
165 | 171 | $count = 0; |
166 | 172 | foreach ($words['words'] as $regularWord) |
@@ -169,30 +175,37 @@ discard block |
||
169 | 175 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
170 | 176 | } |
171 | 177 | |
172 | - if ($query_params['user_query']) |
|
173 | - $query_where[] = '{raw:user_query}'; |
|
174 | - if ($query_params['board_query']) |
|
175 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
178 | + if ($query_params['user_query']) { |
|
179 | + $query_where[] = '{raw:user_query}'; |
|
180 | + } |
|
181 | + if ($query_params['board_query']) { |
|
182 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
183 | + } |
|
176 | 184 | |
177 | - if ($query_params['topic']) |
|
178 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
179 | - if ($query_params['min_msg_id']) |
|
180 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
181 | - if ($query_params['max_msg_id']) |
|
182 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
185 | + if ($query_params['topic']) { |
|
186 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
187 | + } |
|
188 | + if ($query_params['min_msg_id']) { |
|
189 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
190 | + } |
|
191 | + if ($query_params['max_msg_id']) { |
|
192 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
193 | + } |
|
183 | 194 | |
184 | 195 | $count = 0; |
185 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
186 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
196 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
197 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
187 | 198 | { |
188 | 199 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
200 | + } |
|
189 | 201 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
190 | 202 | } |
191 | 203 | $count = 0; |
192 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
193 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
204 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
205 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
194 | 206 | { |
195 | 207 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
208 | + } |
|
196 | 209 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
197 | 210 | } |
198 | 211 | |
@@ -205,8 +218,7 @@ discard block |
||
205 | 218 | { |
206 | 219 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
207 | 220 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
208 | - } |
|
209 | - else |
|
221 | + } else |
|
210 | 222 | { |
211 | 223 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
212 | 224 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -242,16 +254,18 @@ discard block |
||
242 | 254 | $customIndexSettings = $smcFunc['json_decode']($modSettings['search_custom_index_config'], true); |
243 | 255 | |
244 | 256 | $inserts = array(); |
245 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
246 | - $inserts[] = array($word, $msgOptions['id']); |
|
257 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
258 | + $inserts[] = array($word, $msgOptions['id']); |
|
259 | + } |
|
247 | 260 | |
248 | - if (!empty($inserts)) |
|
249 | - $smcFunc['db_insert']('ignore', |
|
261 | + if (!empty($inserts)) { |
|
262 | + $smcFunc['db_insert']('ignore', |
|
250 | 263 | '{db_prefix}log_search_words', |
251 | 264 | array('id_word' => 'int', 'id_msg' => 'int'), |
252 | 265 | $inserts, |
253 | 266 | array('id_word', 'id_msg') |
254 | 267 | ); |
268 | + } |
|
255 | 269 | } |
256 | 270 | |
257 | 271 | /** |
@@ -294,8 +308,9 @@ discard block |
||
294 | 308 | if (!empty($inserted_words)) |
295 | 309 | { |
296 | 310 | $inserts = array(); |
297 | - foreach ($inserted_words as $word) |
|
298 | - $inserts[] = array($word, $msgOptions['id']); |
|
311 | + foreach ($inserted_words as $word) { |
|
312 | + $inserts[] = array($word, $msgOptions['id']); |
|
313 | + } |
|
299 | 314 | $smcFunc['db_insert']('insert', |
300 | 315 | '{db_prefix}log_search_words', |
301 | 316 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Delete one of more membergroups. |
@@ -31,15 +32,16 @@ discard block |
||
31 | 32 | global $smcFunc, $modSettings, $txt; |
32 | 33 | |
33 | 34 | // Make sure it's an array. |
34 | - if (!is_array($groups)) |
|
35 | - $groups = array((int) $groups); |
|
36 | - else |
|
35 | + if (!is_array($groups)) { |
|
36 | + $groups = array((int) $groups); |
|
37 | + } else |
|
37 | 38 | { |
38 | 39 | $groups = array_unique($groups); |
39 | 40 | |
40 | 41 | // Make sure all groups are integer. |
41 | - foreach ($groups as $key => $value) |
|
42 | - $groups[$key] = (int) $value; |
|
42 | + foreach ($groups as $key => $value) { |
|
43 | + $groups[$key] = (int) $value; |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | // Some groups are protected (guests, administrators, moderators, newbies). |
@@ -56,15 +58,17 @@ discard block |
||
56 | 58 | 'is_protected' => 1, |
57 | 59 | ) |
58 | 60 | ); |
59 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
60 | - $protected_groups[] = $row['id_group']; |
|
61 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
62 | + $protected_groups[] = $row['id_group']; |
|
63 | + } |
|
61 | 64 | $smcFunc['db_free_result']($request); |
62 | 65 | } |
63 | 66 | |
64 | 67 | // Make sure they don't delete protected groups! |
65 | 68 | $groups = array_diff($groups, array_unique($protected_groups)); |
66 | - if (empty($groups)) |
|
67 | - return 'no_group_found'; |
|
69 | + if (empty($groups)) { |
|
70 | + return 'no_group_found'; |
|
71 | + } |
|
68 | 72 | |
69 | 73 | // Make sure they don't try to delete a group attached to a paid subscription. |
70 | 74 | $subscriptions = array(); |
@@ -74,13 +78,14 @@ discard block |
||
74 | 78 | ORDER BY name'); |
75 | 79 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
76 | 80 | { |
77 | - if (in_array($row['id_group'], $groups)) |
|
78 | - $subscriptions[] = $row['name']; |
|
79 | - else |
|
81 | + if (in_array($row['id_group'], $groups)) { |
|
82 | + $subscriptions[] = $row['name']; |
|
83 | + } else |
|
80 | 84 | { |
81 | 85 | $add_groups = explode(',', $row['add_groups']); |
82 | - if (count(array_intersect($add_groups, $groups)) != 0) |
|
83 | - $subscriptions[] = $row['name']; |
|
86 | + if (count(array_intersect($add_groups, $groups)) != 0) { |
|
87 | + $subscriptions[] = $row['name']; |
|
88 | + } |
|
84 | 89 | } |
85 | 90 | } |
86 | 91 | $smcFunc['db_free_result']($request); |
@@ -101,8 +106,9 @@ discard block |
||
101 | 106 | 'group_list' => $groups, |
102 | 107 | ) |
103 | 108 | ); |
104 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
105 | - logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
110 | + logAction('delete_group', array('group' => $row['group_name']), 'admin'); |
|
111 | + } |
|
106 | 112 | $smcFunc['db_free_result']($request); |
107 | 113 | |
108 | 114 | call_integration_hook('integrate_delete_membergroups', array($groups)); |
@@ -187,12 +193,14 @@ discard block |
||
187 | 193 | ) |
188 | 194 | ); |
189 | 195 | $updates = array(); |
190 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
191 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
196 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
197 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
198 | + } |
|
192 | 199 | $smcFunc['db_free_result']($request); |
193 | 200 | |
194 | - foreach ($updates as $additional_groups => $memberArray) |
|
195 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
201 | + foreach ($updates as $additional_groups => $memberArray) { |
|
202 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)))); |
|
203 | + } |
|
196 | 204 | |
197 | 205 | // No boards can provide access to these membergroups anymore. |
198 | 206 | $request = $smcFunc['db_query']('', ' |
@@ -204,12 +212,13 @@ discard block |
||
204 | 212 | ) |
205 | 213 | ); |
206 | 214 | $updates = array(); |
207 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
208 | - $updates[$row['member_groups']][] = $row['id_board']; |
|
215 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
216 | + $updates[$row['member_groups']][] = $row['id_board']; |
|
217 | + } |
|
209 | 218 | $smcFunc['db_free_result']($request); |
210 | 219 | |
211 | - foreach ($updates as $member_groups => $boardArray) |
|
212 | - $smcFunc['db_query']('', ' |
|
220 | + foreach ($updates as $member_groups => $boardArray) { |
|
221 | + $smcFunc['db_query']('', ' |
|
213 | 222 | UPDATE {db_prefix}boards |
214 | 223 | SET member_groups = {string:member_groups} |
215 | 224 | WHERE id_board IN ({array_int:board_lists})', |
@@ -218,6 +227,7 @@ discard block |
||
218 | 227 | 'member_groups' => implode(',', array_diff(explode(',', $member_groups), $groups)), |
219 | 228 | ) |
220 | 229 | ); |
230 | + } |
|
221 | 231 | |
222 | 232 | // Recalculate the post groups, as they likely changed. |
223 | 233 | updateStats('postgroups'); |
@@ -225,8 +235,9 @@ discard block |
||
225 | 235 | // Make a note of the fact that the cache may be wrong. |
226 | 236 | $settings_update = array('settings_updated' => time()); |
227 | 237 | // Have we deleted the spider group? |
228 | - if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) |
|
229 | - $settings_update['spider_group'] = 0; |
|
238 | + if (isset($modSettings['spider_group']) && in_array($modSettings['spider_group'], $groups)) { |
|
239 | + $settings_update['spider_group'] = 0; |
|
240 | + } |
|
230 | 241 | |
231 | 242 | updateSettings($settings_update); |
232 | 243 | |
@@ -250,22 +261,24 @@ discard block |
||
250 | 261 | global $smcFunc, $modSettings, $sourcedir; |
251 | 262 | |
252 | 263 | // You're getting nowhere without this permission, unless of course you are the group's moderator. |
253 | - if (!$permissionCheckDone) |
|
254 | - isAllowedTo('manage_membergroups'); |
|
264 | + if (!$permissionCheckDone) { |
|
265 | + isAllowedTo('manage_membergroups'); |
|
266 | + } |
|
255 | 267 | |
256 | 268 | // Assume something will happen. |
257 | 269 | updateSettings(array('settings_updated' => time())); |
258 | 270 | |
259 | 271 | // Cleaning the input. |
260 | - if (!is_array($members)) |
|
261 | - $members = array((int) $members); |
|
262 | - else |
|
272 | + if (!is_array($members)) { |
|
273 | + $members = array((int) $members); |
|
274 | + } else |
|
263 | 275 | { |
264 | 276 | $members = array_unique($members); |
265 | 277 | |
266 | 278 | // Cast the members to integer. |
267 | - foreach ($members as $key => $value) |
|
268 | - $members[$key] = (int) $value; |
|
279 | + foreach ($members as $key => $value) { |
|
280 | + $members[$key] = (int) $value; |
|
281 | + } |
|
269 | 282 | } |
270 | 283 | |
271 | 284 | // Before we get started, let's check we won't leave the admin group empty! |
@@ -277,14 +290,15 @@ discard block |
||
277 | 290 | // Remove any admins if there are too many. |
278 | 291 | $non_changing_admins = array_diff(array_keys($admins), $members); |
279 | 292 | |
280 | - if (empty($non_changing_admins)) |
|
281 | - $members = array_diff($members, array_keys($admins)); |
|
293 | + if (empty($non_changing_admins)) { |
|
294 | + $members = array_diff($members, array_keys($admins)); |
|
295 | + } |
|
282 | 296 | } |
283 | 297 | |
284 | 298 | // Just in case. |
285 | - if (empty($members)) |
|
286 | - return false; |
|
287 | - elseif ($groups === null) |
|
299 | + if (empty($members)) { |
|
300 | + return false; |
|
301 | + } elseif ($groups === null) |
|
288 | 302 | { |
289 | 303 | // Wanna remove all groups from these members? That's easy. |
290 | 304 | $smcFunc['db_query']('', ' |
@@ -306,20 +320,21 @@ discard block |
||
306 | 320 | updateStats('postgroups', $members); |
307 | 321 | |
308 | 322 | // Log what just happened. |
309 | - foreach ($members as $member) |
|
310 | - logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
323 | + foreach ($members as $member) { |
|
324 | + logAction('removed_all_groups', array('member' => $member), 'admin'); |
|
325 | + } |
|
311 | 326 | |
312 | 327 | return true; |
313 | - } |
|
314 | - elseif (!is_array($groups)) |
|
315 | - $groups = array((int) $groups); |
|
316 | - else |
|
328 | + } elseif (!is_array($groups)) { |
|
329 | + $groups = array((int) $groups); |
|
330 | + } else |
|
317 | 331 | { |
318 | 332 | $groups = array_unique($groups); |
319 | 333 | |
320 | 334 | // Make sure all groups are integer. |
321 | - foreach ($groups as $key => $value) |
|
322 | - $groups[$key] = (int) $value; |
|
335 | + foreach ($groups as $key => $value) { |
|
336 | + $groups[$key] = (int) $value; |
|
337 | + } |
|
323 | 338 | } |
324 | 339 | |
325 | 340 | // Fetch a list of groups members cannot be assigned to explicitly, and the group names of the ones we want. |
@@ -335,10 +350,11 @@ discard block |
||
335 | 350 | $group_names = array(); |
336 | 351 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
337 | 352 | { |
338 | - if ($row['min_posts'] != -1) |
|
339 | - $implicitGroups[] = $row['id_group']; |
|
340 | - else |
|
341 | - $group_names[$row['id_group']] = $row['group_name']; |
|
353 | + if ($row['min_posts'] != -1) { |
|
354 | + $implicitGroups[] = $row['id_group']; |
|
355 | + } else { |
|
356 | + $group_names[$row['id_group']] = $row['group_name']; |
|
357 | + } |
|
342 | 358 | } |
343 | 359 | $smcFunc['db_free_result']($request); |
344 | 360 | |
@@ -357,8 +373,9 @@ discard block |
||
357 | 373 | ) |
358 | 374 | ); |
359 | 375 | $protected_groups = array(1); |
360 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
361 | - $protected_groups[] = $row['id_group']; |
|
376 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
377 | + $protected_groups[] = $row['id_group']; |
|
378 | + } |
|
362 | 379 | $smcFunc['db_free_result']($request); |
363 | 380 | |
364 | 381 | // If you're not an admin yourself, you can't touch protected groups! |
@@ -366,8 +383,9 @@ discard block |
||
366 | 383 | } |
367 | 384 | |
368 | 385 | // Only continue if there are still groups and members left. |
369 | - if (empty($groups) || empty($members)) |
|
370 | - return false; |
|
386 | + if (empty($groups) || empty($members)) { |
|
387 | + return false; |
|
388 | + } |
|
371 | 389 | |
372 | 390 | // First, reset those who have this as their primary group - this is the easy one. |
373 | 391 | $log_inserts = array(); |
@@ -381,8 +399,9 @@ discard block |
||
381 | 399 | 'member_list' => $members, |
382 | 400 | ) |
383 | 401 | ); |
384 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
385 | - $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
403 | + $log_inserts[] = array('group' => $group_names[$row['id_group']], 'member' => $row['id_member']); |
|
404 | + } |
|
386 | 405 | $smcFunc['db_free_result']($request); |
387 | 406 | |
388 | 407 | $smcFunc['db_query']('', ' |
@@ -414,16 +433,17 @@ discard block |
||
414 | 433 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
415 | 434 | { |
416 | 435 | // What log entries must we make for this one, eh? |
417 | - foreach (explode(',', $row['additional_groups']) as $group) |
|
418 | - if (in_array($group, $groups)) |
|
436 | + foreach (explode(',', $row['additional_groups']) as $group) { |
|
437 | + if (in_array($group, $groups)) |
|
419 | 438 | $log_inserts[] = array('group' => $group_names[$group], 'member' => $row['id_member']); |
439 | + } |
|
420 | 440 | |
421 | 441 | $updates[$row['additional_groups']][] = $row['id_member']; |
422 | 442 | } |
423 | 443 | $smcFunc['db_free_result']($request); |
424 | 444 | |
425 | - foreach ($updates as $additional_groups => $memberArray) |
|
426 | - $smcFunc['db_query']('', ' |
|
445 | + foreach ($updates as $additional_groups => $memberArray) { |
|
446 | + $smcFunc['db_query']('', ' |
|
427 | 447 | UPDATE {db_prefix}members |
428 | 448 | SET additional_groups = {string:additional_groups} |
429 | 449 | WHERE id_member IN ({array_int:member_list})', |
@@ -432,6 +452,7 @@ discard block |
||
432 | 452 | 'additional_groups' => implode(',', array_diff(explode(',', $additional_groups), $groups)), |
433 | 453 | ) |
434 | 454 | ); |
455 | + } |
|
435 | 456 | |
436 | 457 | // Their post groups may have changed now... |
437 | 458 | updateStats('postgroups', $members); |
@@ -440,8 +461,9 @@ discard block |
||
440 | 461 | if (!empty($log_inserts) && !empty($modSettings['modlog_enabled'])) |
441 | 462 | { |
442 | 463 | require_once($sourcedir . '/Logging.php'); |
443 | - foreach ($log_inserts as $extra) |
|
444 | - logAction('removed_from_group', $extra, 'admin'); |
|
464 | + foreach ($log_inserts as $extra) { |
|
465 | + logAction('removed_from_group', $extra, 'admin'); |
|
466 | + } |
|
445 | 467 | } |
446 | 468 | |
447 | 469 | // Mission successful. |
@@ -477,21 +499,23 @@ discard block |
||
477 | 499 | global $smcFunc, $sourcedir; |
478 | 500 | |
479 | 501 | // Show your licence, but only if it hasn't been done yet. |
480 | - if (!$permissionCheckDone) |
|
481 | - isAllowedTo('manage_membergroups'); |
|
502 | + if (!$permissionCheckDone) { |
|
503 | + isAllowedTo('manage_membergroups'); |
|
504 | + } |
|
482 | 505 | |
483 | 506 | // Make sure we don't keep old stuff cached. |
484 | 507 | updateSettings(array('settings_updated' => time())); |
485 | 508 | |
486 | - if (!is_array($members)) |
|
487 | - $members = array((int) $members); |
|
488 | - else |
|
509 | + if (!is_array($members)) { |
|
510 | + $members = array((int) $members); |
|
511 | + } else |
|
489 | 512 | { |
490 | 513 | $members = array_unique($members); |
491 | 514 | |
492 | 515 | // Make sure all members are integer. |
493 | - foreach ($members as $key => $value) |
|
494 | - $members[$key] = (int) $value; |
|
516 | + foreach ($members as $key => $value) { |
|
517 | + $members[$key] = (int) $value; |
|
518 | + } |
|
495 | 519 | } |
496 | 520 | $group = (int) $group; |
497 | 521 | |
@@ -508,20 +532,23 @@ discard block |
||
508 | 532 | $group_names = array(); |
509 | 533 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
510 | 534 | { |
511 | - if ($row['min_posts'] != -1) |
|
512 | - $implicitGroups[] = $row['id_group']; |
|
513 | - else |
|
514 | - $group_names[$row['id_group']] = $row['group_name']; |
|
535 | + if ($row['min_posts'] != -1) { |
|
536 | + $implicitGroups[] = $row['id_group']; |
|
537 | + } else { |
|
538 | + $group_names[$row['id_group']] = $row['group_name']; |
|
539 | + } |
|
515 | 540 | } |
516 | 541 | $smcFunc['db_free_result']($request); |
517 | 542 | |
518 | 543 | // Sorry, you can't join an implicit group. |
519 | - if (in_array($group, $implicitGroups) || empty($members)) |
|
520 | - return false; |
|
544 | + if (in_array($group, $implicitGroups) || empty($members)) { |
|
545 | + return false; |
|
546 | + } |
|
521 | 547 | |
522 | 548 | // Only admins can add admins... |
523 | - if (!allowedTo('admin_forum') && $group == 1) |
|
524 | - return false; |
|
549 | + if (!allowedTo('admin_forum') && $group == 1) { |
|
550 | + return false; |
|
551 | + } |
|
525 | 552 | // ... and assign protected groups! |
526 | 553 | elseif (!allowedTo('admin_forum') && !$ignoreProtected) |
527 | 554 | { |
@@ -539,13 +566,14 @@ discard block |
||
539 | 566 | $smcFunc['db_free_result']($request); |
540 | 567 | |
541 | 568 | // Is it protected? |
542 | - if ($is_protected == 1) |
|
543 | - return false; |
|
569 | + if ($is_protected == 1) { |
|
570 | + return false; |
|
571 | + } |
|
544 | 572 | } |
545 | 573 | |
546 | 574 | // Do the actual updates. |
547 | - if ($type == 'only_additional') |
|
548 | - $smcFunc['db_query']('', ' |
|
575 | + if ($type == 'only_additional') { |
|
576 | + $smcFunc['db_query']('', ' |
|
549 | 577 | UPDATE {db_prefix}members |
550 | 578 | SET additional_groups = CASE WHEN additional_groups = {string:blank_string} THEN {string:id_group_string} ELSE CONCAT(additional_groups, {string:id_group_string_extend}) END |
551 | 579 | WHERE id_member IN ({array_int:member_list}) |
@@ -559,8 +587,8 @@ discard block |
||
559 | 587 | 'blank_string' => '', |
560 | 588 | ) |
561 | 589 | ); |
562 | - elseif ($type == 'only_primary' || $type == 'force_primary') |
|
563 | - $smcFunc['db_query']('', ' |
|
590 | + } elseif ($type == 'only_primary' || $type == 'force_primary') { |
|
591 | + $smcFunc['db_query']('', ' |
|
564 | 592 | UPDATE {db_prefix}members |
565 | 593 | SET id_group = {int:id_group} |
566 | 594 | WHERE id_member IN ({array_int:member_list})' . ($type == 'force_primary' ? '' : ' |
@@ -572,8 +600,8 @@ discard block |
||
572 | 600 | 'regular_group' => 0, |
573 | 601 | ) |
574 | 602 | ); |
575 | - elseif ($type == 'auto') |
|
576 | - $smcFunc['db_query']('', ' |
|
603 | + } elseif ($type == 'auto') { |
|
604 | + $smcFunc['db_query']('', ' |
|
577 | 605 | UPDATE {db_prefix}members |
578 | 606 | SET |
579 | 607 | id_group = CASE WHEN id_group = {int:regular_group} THEN {int:id_group} ELSE id_group END, |
@@ -592,9 +620,11 @@ discard block |
||
592 | 620 | 'id_group_string_extend' => ',' . $group, |
593 | 621 | ) |
594 | 622 | ); |
623 | + } |
|
595 | 624 | // Ack!!? What happened? |
596 | - else |
|
597 | - trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
625 | + else { |
|
626 | + trigger_error('addMembersToGroup(): Unknown type \'' . $type . '\'', E_USER_WARNING); |
|
627 | + } |
|
598 | 628 | |
599 | 629 | call_integration_hook('integrate_add_members_to_group', array($members, $group, &$group_names)); |
600 | 630 | |
@@ -603,8 +633,9 @@ discard block |
||
603 | 633 | |
604 | 634 | // Log the data. |
605 | 635 | require_once($sourcedir . '/Logging.php'); |
606 | - foreach ($members as $member) |
|
607 | - logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin'); |
|
636 | + foreach ($members as $member) { |
|
637 | + logAction('added_to_group', array('group' => $group_names[$group], 'member_affected' => $member), 'admin'); |
|
638 | + } |
|
608 | 639 | |
609 | 640 | return true; |
610 | 641 | } |
@@ -632,8 +663,9 @@ discard block |
||
632 | 663 | ) |
633 | 664 | ); |
634 | 665 | $members = array(); |
635 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
636 | - $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
666 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
667 | + $members[$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
668 | + } |
|
637 | 669 | $smcFunc['db_free_result']($request); |
638 | 670 | |
639 | 671 | // If there are more than $limit members, add a 'more' link. |
@@ -641,10 +673,10 @@ discard block |
||
641 | 673 | { |
642 | 674 | array_pop($members); |
643 | 675 | return true; |
676 | + } else { |
|
677 | + return false; |
|
678 | + } |
|
644 | 679 | } |
645 | - else |
|
646 | - return false; |
|
647 | -} |
|
648 | 680 | |
649 | 681 | /** |
650 | 682 | * Retrieve a list of (visible) membergroups used by the cache. |
@@ -669,8 +701,9 @@ discard block |
||
669 | 701 | ) |
670 | 702 | ); |
671 | 703 | $groupCache = array(); |
672 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
673 | - $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
704 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
705 | + $groupCache[] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row['id_group'] . '" ' . ($row['online_color'] ? 'style="color: ' . $row['online_color'] . '"' : '') . '>' . $row['group_name'] . '</a>'; |
|
706 | + } |
|
674 | 707 | $smcFunc['db_free_result']($request); |
675 | 708 | |
676 | 709 | return array( |
@@ -716,8 +749,9 @@ discard block |
||
716 | 749 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
717 | 750 | { |
718 | 751 | // We only list the groups they can see. |
719 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
720 | - continue; |
|
752 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
753 | + continue; |
|
754 | + } |
|
721 | 755 | |
722 | 756 | $row['icons'] = explode('#', $row['icons']); |
723 | 757 | |
@@ -752,12 +786,11 @@ discard block |
||
752 | 786 | 'group_list' => $group_ids, |
753 | 787 | ) |
754 | 788 | ); |
755 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
756 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
789 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
790 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
791 | + } |
|
757 | 792 | $smcFunc['db_free_result']($query); |
758 | - } |
|
759 | - |
|
760 | - else |
|
793 | + } else |
|
761 | 794 | { |
762 | 795 | $query = $smcFunc['db_query']('', ' |
763 | 796 | SELECT id_group, COUNT(*) AS num_members |
@@ -768,8 +801,9 @@ discard block |
||
768 | 801 | 'group_list' => $group_ids, |
769 | 802 | ) |
770 | 803 | ); |
771 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
772 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
804 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
805 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
806 | + } |
|
773 | 807 | $smcFunc['db_free_result']($query); |
774 | 808 | |
775 | 809 | // Only do additional groups if we can moderate... |
@@ -788,8 +822,9 @@ discard block |
||
788 | 822 | 'blank_string' => '', |
789 | 823 | ) |
790 | 824 | ); |
791 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
792 | - $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
825 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
826 | + $groups[$row['id_group']]['num_members'] += $row['num_members']; |
|
827 | + } |
|
793 | 828 | $smcFunc['db_free_result']($query); |
794 | 829 | } |
795 | 830 | } |
@@ -803,8 +838,9 @@ discard block |
||
803 | 838 | 'group_list' => $group_ids, |
804 | 839 | ) |
805 | 840 | ); |
806 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
807 | - $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
841 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
842 | + $groups[$row['id_group']]['moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
843 | + } |
|
808 | 844 | $smcFunc['db_free_result']($query); |
809 | 845 | } |
810 | 846 | |
@@ -813,8 +849,9 @@ discard block |
||
813 | 849 | { |
814 | 850 | $sort_ascending = strpos($sort, 'DESC') === false; |
815 | 851 | |
816 | - foreach ($groups as $group) |
|
817 | - $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
852 | + foreach ($groups as $group) { |
|
853 | + $sort_array[] = $group['id_group'] != 3 ? (int) $group['num_members'] : -1; |
|
854 | + } |
|
818 | 855 | |
819 | 856 | array_multisort($sort_array, $sort_ascending ? SORT_ASC : SORT_DESC, SORT_REGULAR, $groups); |
820 | 857 | } |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Truncate the GET array to a specified length |
@@ -26,24 +27,28 @@ discard block |
||
26 | 27 | function truncateArray($arr, $max_length=1900) |
27 | 28 | { |
28 | 29 | $curr_length = 0; |
29 | - foreach ($arr as $key => $value) |
|
30 | - if (is_array($value)) |
|
30 | + foreach ($arr as $key => $value) { |
|
31 | + if (is_array($value)) |
|
31 | 32 | foreach ($value as $key2 => $value2) |
32 | 33 | $curr_length += strlen ($value2); |
33 | - else |
|
34 | - $curr_length += strlen ($value); |
|
35 | - if ($curr_length <= $max_length) |
|
36 | - return $arr; |
|
37 | - else |
|
34 | + } |
|
35 | + else { |
|
36 | + $curr_length += strlen ($value); |
|
37 | + } |
|
38 | + if ($curr_length <= $max_length) { |
|
39 | + return $arr; |
|
40 | + } else |
|
38 | 41 | { |
39 | 42 | // Truncate each element's value to a reasonable length |
40 | 43 | $param_max = floor($max_length/count($arr)); |
41 | - foreach ($arr as $key => &$value) |
|
42 | - if (is_array($value)) |
|
44 | + foreach ($arr as $key => &$value) { |
|
45 | + if (is_array($value)) |
|
43 | 46 | foreach ($value as $key2 => &$value2) |
44 | 47 | $value2 = substr($value2, 0, $param_max - strlen($key) - 5); |
45 | - else |
|
46 | - $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
48 | + } |
|
49 | + else { |
|
50 | + $value = substr($value, 0, $param_max - strlen($key) - 5); |
|
51 | + } |
|
47 | 52 | return $arr; |
48 | 53 | } |
49 | 54 | } |
@@ -65,8 +70,9 @@ discard block |
||
65 | 70 | // Don't update for every page - this isn't wholly accurate but who cares. |
66 | 71 | if ($topic) |
67 | 72 | { |
68 | - if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) |
|
69 | - $force = false; |
|
73 | + if (isset($_SESSION['last_topic_id']) && $_SESSION['last_topic_id'] == $topic) { |
|
74 | + $force = false; |
|
75 | + } |
|
70 | 76 | $_SESSION['last_topic_id'] = $topic; |
71 | 77 | } |
72 | 78 | } |
@@ -79,22 +85,24 @@ discard block |
||
79 | 85 | } |
80 | 86 | |
81 | 87 | // Don't mark them as online more than every so often. |
82 | - if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) |
|
83 | - return; |
|
88 | + if (!empty($_SESSION['log_time']) && $_SESSION['log_time'] >= (time() - 8) && !$force) { |
|
89 | + return; |
|
90 | + } |
|
84 | 91 | |
85 | 92 | if (!empty($modSettings['who_enabled'])) |
86 | 93 | { |
87 | 94 | $encoded_get = truncateArray($_GET) + array('USER_AGENT' => $_SERVER['HTTP_USER_AGENT']); |
88 | 95 | |
89 | 96 | // In the case of a dlattach action, session_var may not be set. |
90 | - if (!isset($context['session_var'])) |
|
91 | - $context['session_var'] = $_SESSION['session_var']; |
|
97 | + if (!isset($context['session_var'])) { |
|
98 | + $context['session_var'] = $_SESSION['session_var']; |
|
99 | + } |
|
92 | 100 | |
93 | 101 | unset($encoded_get['sesc'], $encoded_get[$context['session_var']]); |
94 | 102 | $encoded_get = $smcFunc['json_encode']($encoded_get); |
103 | + } else { |
|
104 | + $encoded_get = ''; |
|
95 | 105 | } |
96 | - else |
|
97 | - $encoded_get = ''; |
|
98 | 106 | |
99 | 107 | // Guests use 0, members use their session ID. |
100 | 108 | $session_id = $user_info['is_guest'] ? 'ip' . $user_info['ip'] : session_id(); |
@@ -134,17 +142,18 @@ discard block |
||
134 | 142 | ); |
135 | 143 | |
136 | 144 | // Guess it got deleted. |
137 | - if ($smcFunc['db_affected_rows']() == 0) |
|
145 | + if ($smcFunc['db_affected_rows']() == 0) { |
|
146 | + $_SESSION['log_time'] = 0; |
|
147 | + } |
|
148 | + } else { |
|
138 | 149 | $_SESSION['log_time'] = 0; |
139 | 150 | } |
140 | - else |
|
141 | - $_SESSION['log_time'] = 0; |
|
142 | 151 | |
143 | 152 | // Otherwise, we have to delete and insert. |
144 | 153 | if (empty($_SESSION['log_time'])) |
145 | 154 | { |
146 | - if ($do_delete || !empty($user_info['id'])) |
|
147 | - $smcFunc['db_query']('', ' |
|
155 | + if ($do_delete || !empty($user_info['id'])) { |
|
156 | + $smcFunc['db_query']('', ' |
|
148 | 157 | DELETE FROM {db_prefix}log_online |
149 | 158 | WHERE ' . ($do_delete ? 'log_time < {int:log_time}' : '') . ($do_delete && !empty($user_info['id']) ? ' OR ' : '') . (empty($user_info['id']) ? '' : 'id_member = {int:current_member}'), |
150 | 159 | array( |
@@ -152,6 +161,7 @@ discard block |
||
152 | 161 | 'log_time' => time() - $modSettings['lastActive'] * 60, |
153 | 162 | ) |
154 | 163 | ); |
164 | + } |
|
155 | 165 | |
156 | 166 | $smcFunc['db_insert']($do_delete ? 'ignore' : 'replace', |
157 | 167 | '{db_prefix}log_online', |
@@ -165,21 +175,24 @@ discard block |
||
165 | 175 | $_SESSION['log_time'] = time(); |
166 | 176 | |
167 | 177 | // Well, they are online now. |
168 | - if (empty($_SESSION['timeOnlineUpdated'])) |
|
169 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
178 | + if (empty($_SESSION['timeOnlineUpdated'])) { |
|
179 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
180 | + } |
|
170 | 181 | |
171 | 182 | // Set their login time, if not already done within the last minute. |
172 | 183 | if (SMF != 'SSI' && !empty($user_info['last_login']) && $user_info['last_login'] < time() - 60 && (!isset($_REQUEST['action']) || !in_array($_REQUEST['action'], array('.xml', 'login2', 'logintfa')))) |
173 | 184 | { |
174 | 185 | // Don't count longer than 15 minutes. |
175 | - if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) |
|
176 | - $_SESSION['timeOnlineUpdated'] = time(); |
|
186 | + if (time() - $_SESSION['timeOnlineUpdated'] > 60 * 15) { |
|
187 | + $_SESSION['timeOnlineUpdated'] = time(); |
|
188 | + } |
|
177 | 189 | |
178 | 190 | $user_settings['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
179 | 191 | updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP'], 'total_time_logged_in' => $user_settings['total_time_logged_in'])); |
180 | 192 | |
181 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) |
|
182 | - cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
193 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) { |
|
194 | + cache_put_data('user_settings-' . $user_info['id'], $user_settings, 60); |
|
195 | + } |
|
183 | 196 | |
184 | 197 | $user_info['total_time_logged_in'] += time() - $_SESSION['timeOnlineUpdated']; |
185 | 198 | $_SESSION['timeOnlineUpdated'] = time(); |
@@ -216,8 +229,7 @@ discard block |
||
216 | 229 | // Oops. maybe we have no more disk space left, or some other troubles, troubles... |
217 | 230 | // Copy the file back and run for your life! |
218 | 231 | @copy($cachedir . '/db_last_error_bak.php', $cachedir . '/db_last_error.php'); |
219 | - } |
|
220 | - else |
|
232 | + } else |
|
221 | 233 | { |
222 | 234 | @touch($boarddir . '/' . 'Settings.php'); |
223 | 235 | return true; |
@@ -237,22 +249,27 @@ discard block |
||
237 | 249 | global $db_cache, $db_count, $cache_misses, $cache_count_misses, $db_show_debug, $cache_count, $cache_hits, $smcFunc, $txt; |
238 | 250 | |
239 | 251 | // Add to Settings.php if you want to show the debugging information. |
240 | - if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) |
|
241 | - return; |
|
252 | + if (!isset($db_show_debug) || $db_show_debug !== true || (isset($_GET['action']) && $_GET['action'] == 'viewquery')) { |
|
253 | + return; |
|
254 | + } |
|
242 | 255 | |
243 | - if (empty($_SESSION['view_queries'])) |
|
244 | - $_SESSION['view_queries'] = 0; |
|
245 | - if (empty($context['debug']['language_files'])) |
|
246 | - $context['debug']['language_files'] = array(); |
|
247 | - if (empty($context['debug']['sheets'])) |
|
248 | - $context['debug']['sheets'] = array(); |
|
256 | + if (empty($_SESSION['view_queries'])) { |
|
257 | + $_SESSION['view_queries'] = 0; |
|
258 | + } |
|
259 | + if (empty($context['debug']['language_files'])) { |
|
260 | + $context['debug']['language_files'] = array(); |
|
261 | + } |
|
262 | + if (empty($context['debug']['sheets'])) { |
|
263 | + $context['debug']['sheets'] = array(); |
|
264 | + } |
|
249 | 265 | |
250 | 266 | $files = get_included_files(); |
251 | 267 | $total_size = 0; |
252 | 268 | for ($i = 0, $n = count($files); $i < $n; $i++) |
253 | 269 | { |
254 | - if (file_exists($files[$i])) |
|
255 | - $total_size += filesize($files[$i]); |
|
270 | + if (file_exists($files[$i])) { |
|
271 | + $total_size += filesize($files[$i]); |
|
272 | + } |
|
256 | 273 | $files[$i] = strtr($files[$i], array($boarddir => '.', $sourcedir => '(Sources)', $cachedir => '(Cache)', $settings['actual_theme_dir'] => '(Current Theme)')); |
257 | 274 | } |
258 | 275 | |
@@ -261,8 +278,9 @@ discard block |
||
261 | 278 | { |
262 | 279 | foreach ($db_cache as $q => $query_data) |
263 | 280 | { |
264 | - if (!empty($query_data['w'])) |
|
265 | - $warnings += count($query_data['w']); |
|
281 | + if (!empty($query_data['w'])) { |
|
282 | + $warnings += count($query_data['w']); |
|
283 | + } |
|
266 | 284 | } |
267 | 285 | |
268 | 286 | $_SESSION['debug'] = &$db_cache; |
@@ -283,12 +301,14 @@ discard block |
||
283 | 301 | ',(isset($context['debug']['instances']) ? ($txt['debug_instances'] . (empty($context['debug']['instances']) ? 0 : count($context['debug']['instances'])) . ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_instances\').style.display = \'inline\'; this.style.display = \'none\'; return false;">'. $txt['debug_show'] .'</a><span id="debug_instances" style="display: none;"><em>'. implode('</em>, <em>', array_keys($context['debug']['instances'])) .'</em></span>)'. '<br>') : ''),' |
284 | 302 | ', $txt['debug_files_included'], count($files), ' - ', round($total_size / 1024), $txt['debug_kb'], ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_include_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_include_info" style="display: none;"><em>', implode('</em>, <em>', $files), '</em></span>)<br>'; |
285 | 303 | |
286 | - if (function_exists('memory_get_peak_usage')) |
|
287 | - echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
304 | + if (function_exists('memory_get_peak_usage')) { |
|
305 | + echo $txt['debug_memory_use'], ceil(memory_get_peak_usage() / 1024), $txt['debug_kb'], '<br>'; |
|
306 | + } |
|
288 | 307 | |
289 | 308 | // What tokens are active? |
290 | - if (isset($_SESSION['token'])) |
|
291 | - echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
309 | + if (isset($_SESSION['token'])) { |
|
310 | + echo $txt['debug_tokens'] . '<em>' . implode(',</em> <em>', array_keys($_SESSION['token'])), '</em>.<br>'; |
|
311 | + } |
|
292 | 312 | |
293 | 313 | if (!empty($modSettings['cache_enable']) && !empty($cache_hits)) |
294 | 314 | { |
@@ -302,10 +322,12 @@ discard block |
||
302 | 322 | $total_t += $cache_hit['t']; |
303 | 323 | $total_s += $cache_hit['s']; |
304 | 324 | } |
305 | - if (!isset($cache_misses)) |
|
306 | - $cache_misses = array(); |
|
307 | - foreach ($cache_misses as $missed) |
|
308 | - $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
325 | + if (!isset($cache_misses)) { |
|
326 | + $cache_misses = array(); |
|
327 | + } |
|
328 | + foreach ($cache_misses as $missed) { |
|
329 | + $missed_entries[] = $missed['d'] . ' ' . $missed['k']; |
|
330 | + } |
|
309 | 331 | |
310 | 332 | echo ' |
311 | 333 | ', $txt['debug_cache_hits'], $cache_count, ': ', sprintf($txt['debug_cache_seconds_bytes_total'], comma_format($total_t, 5), comma_format($total_s)), ' (<a href="javascript:void(0);" onclick="document.getElementById(\'debug_cache_info\').style.display = \'inline\'; this.style.display = \'none\'; return false;">', $txt['debug_show'], '</a><span id="debug_cache_info" style="display: none;"><em>', implode('</em>, <em>', $entries), '</em></span>)<br> |
@@ -316,38 +338,44 @@ discard block |
||
316 | 338 | <a href="', $scripturl, '?action=viewquery" target="_blank" rel="noopener">', $warnings == 0 ? sprintf($txt['debug_queries_used'], (int) $db_count) : sprintf($txt['debug_queries_used_and_warnings'], (int) $db_count, $warnings), '</a><br> |
317 | 339 | <br>'; |
318 | 340 | |
319 | - if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) |
|
320 | - foreach ($db_cache as $q => $query_data) |
|
341 | + if ($_SESSION['view_queries'] == 1 && !empty($db_cache)) { |
|
342 | + foreach ($db_cache as $q => $query_data) |
|
321 | 343 | { |
322 | 344 | $is_select = strpos(trim($query_data['q']), 'SELECT') === 0 || preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+SELECT .+$~s', trim($query_data['q'])) != 0; |
345 | + } |
|
323 | 346 | // Temporary tables created in earlier queries are not explainable. |
324 | 347 | if ($is_select) |
325 | 348 | { |
326 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
327 | - if (strpos(trim($query_data['q']), $tmp) !== false) |
|
349 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
350 | + if (strpos(trim($query_data['q']), $tmp) !== false) |
|
328 | 351 | { |
329 | 352 | $is_select = false; |
353 | + } |
|
330 | 354 | break; |
331 | 355 | } |
332 | 356 | } |
333 | 357 | // But actual creation of the temporary tables are. |
334 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) |
|
335 | - $is_select = true; |
|
358 | + elseif (preg_match('~^CREATE TEMPORARY TABLE .+?SELECT .+$~s', trim($query_data['q'])) != 0) { |
|
359 | + $is_select = true; |
|
360 | + } |
|
336 | 361 | |
337 | 362 | // Make the filenames look a bit better. |
338 | - if (isset($query_data['f'])) |
|
339 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
363 | + if (isset($query_data['f'])) { |
|
364 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
365 | + } |
|
340 | 366 | |
341 | 367 | echo ' |
342 | 368 | <strong>', $is_select ? '<a href="' . $scripturl . '?action=viewquery;qq=' . ($q + 1) . '#qq' . $q . '" target="_blank" rel="noopener" style="text-decoration: none;">' : '', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars'](ltrim($query_data['q'], "\n\r")))) . ($is_select ? '</a></strong>' : '</strong>') . '<br> |
343 | 369 | '; |
344 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
345 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
370 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
371 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
372 | + } |
|
346 | 373 | |
347 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
348 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
349 | - elseif (isset($query_data['t'])) |
|
350 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
374 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
375 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)) . '<br>'; |
|
376 | + } elseif (isset($query_data['t'])) { |
|
377 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)) . '<br>'; |
|
378 | + } |
|
351 | 379 | echo ' |
352 | 380 | <br>'; |
353 | 381 | } |
@@ -372,12 +400,14 @@ discard block |
||
372 | 400 | global $modSettings, $smcFunc; |
373 | 401 | static $cache_stats = array(); |
374 | 402 | |
375 | - if (empty($modSettings['trackStats'])) |
|
376 | - return false; |
|
377 | - if (!empty($stats)) |
|
378 | - return $cache_stats = array_merge($cache_stats, $stats); |
|
379 | - elseif (empty($cache_stats)) |
|
380 | - return false; |
|
403 | + if (empty($modSettings['trackStats'])) { |
|
404 | + return false; |
|
405 | + } |
|
406 | + if (!empty($stats)) { |
|
407 | + return $cache_stats = array_merge($cache_stats, $stats); |
|
408 | + } elseif (empty($cache_stats)) { |
|
409 | + return false; |
|
410 | + } |
|
381 | 411 | |
382 | 412 | $setStringUpdate = ''; |
383 | 413 | $insert_keys = array(); |
@@ -390,10 +420,11 @@ discard block |
||
390 | 420 | $setStringUpdate .= ' |
391 | 421 | ' . $field . ' = ' . ($change === '+' ? $field . ' + 1' : '{int:' . $field . '}') . ','; |
392 | 422 | |
393 | - if ($change === '+') |
|
394 | - $cache_stats[$field] = 1; |
|
395 | - else |
|
396 | - $update_parameters[$field] = $change; |
|
423 | + if ($change === '+') { |
|
424 | + $cache_stats[$field] = 1; |
|
425 | + } else { |
|
426 | + $update_parameters[$field] = $change; |
|
427 | + } |
|
397 | 428 | $insert_keys[$field] = 'int'; |
398 | 429 | } |
399 | 430 | |
@@ -457,43 +488,50 @@ discard block |
||
457 | 488 | ); |
458 | 489 | |
459 | 490 | // Make sure this particular log is enabled first... |
460 | - if (empty($modSettings['modlog_enabled'])) |
|
461 | - unset ($log_types['moderate']); |
|
462 | - if (empty($modSettings['userlog_enabled'])) |
|
463 | - unset ($log_types['user']); |
|
464 | - if (empty($modSettings['adminlog_enabled'])) |
|
465 | - unset ($log_types['admin']); |
|
491 | + if (empty($modSettings['modlog_enabled'])) { |
|
492 | + unset ($log_types['moderate']); |
|
493 | + } |
|
494 | + if (empty($modSettings['userlog_enabled'])) { |
|
495 | + unset ($log_types['user']); |
|
496 | + } |
|
497 | + if (empty($modSettings['adminlog_enabled'])) { |
|
498 | + unset ($log_types['admin']); |
|
499 | + } |
|
466 | 500 | |
467 | 501 | call_integration_hook('integrate_log_types', array(&$log_types)); |
468 | 502 | |
469 | 503 | foreach ($logs as $log) |
470 | 504 | { |
471 | - if (!isset($log_types[$log['log_type']])) |
|
472 | - return false; |
|
505 | + if (!isset($log_types[$log['log_type']])) { |
|
506 | + return false; |
|
507 | + } |
|
473 | 508 | |
474 | - if (!is_array($log['extra'])) |
|
475 | - trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
509 | + if (!is_array($log['extra'])) { |
|
510 | + trigger_error('logActions(): data is not an array with action \'' . $log['action'] . '\'', E_USER_NOTICE); |
|
511 | + } |
|
476 | 512 | |
477 | 513 | // Pull out the parts we want to store separately, but also make sure that the data is proper |
478 | 514 | if (isset($log['extra']['topic'])) |
479 | 515 | { |
480 | - if (!is_numeric($log['extra']['topic'])) |
|
481 | - trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
516 | + if (!is_numeric($log['extra']['topic'])) { |
|
517 | + trigger_error('logActions(): data\'s topic is not a number', E_USER_NOTICE); |
|
518 | + } |
|
482 | 519 | $topic_id = empty($log['extra']['topic']) ? 0 : (int) $log['extra']['topic']; |
483 | 520 | unset($log['extra']['topic']); |
521 | + } else { |
|
522 | + $topic_id = 0; |
|
484 | 523 | } |
485 | - else |
|
486 | - $topic_id = 0; |
|
487 | 524 | |
488 | 525 | if (isset($log['extra']['message'])) |
489 | 526 | { |
490 | - if (!is_numeric($log['extra']['message'])) |
|
491 | - trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
527 | + if (!is_numeric($log['extra']['message'])) { |
|
528 | + trigger_error('logActions(): data\'s message is not a number', E_USER_NOTICE); |
|
529 | + } |
|
492 | 530 | $msg_id = empty($log['extra']['message']) ? 0 : (int) $log['extra']['message']; |
493 | 531 | unset($log['extra']['message']); |
532 | + } else { |
|
533 | + $msg_id = 0; |
|
494 | 534 | } |
495 | - else |
|
496 | - $msg_id = 0; |
|
497 | 535 | |
498 | 536 | // @todo cache this? |
499 | 537 | // Is there an associated report on this? |
@@ -520,23 +558,26 @@ discard block |
||
520 | 558 | $smcFunc['db_free_result']($request); |
521 | 559 | } |
522 | 560 | |
523 | - if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) |
|
524 | - trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
561 | + if (isset($log['extra']['member']) && !is_numeric($log['extra']['member'])) { |
|
562 | + trigger_error('logActions(): data\'s member is not a number', E_USER_NOTICE); |
|
563 | + } |
|
525 | 564 | |
526 | 565 | if (isset($log['extra']['board'])) |
527 | 566 | { |
528 | - if (!is_numeric($log['extra']['board'])) |
|
529 | - trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
567 | + if (!is_numeric($log['extra']['board'])) { |
|
568 | + trigger_error('logActions(): data\'s board is not a number', E_USER_NOTICE); |
|
569 | + } |
|
530 | 570 | $board_id = empty($log['extra']['board']) ? 0 : (int) $log['extra']['board']; |
531 | 571 | unset($log['extra']['board']); |
572 | + } else { |
|
573 | + $board_id = 0; |
|
532 | 574 | } |
533 | - else |
|
534 | - $board_id = 0; |
|
535 | 575 | |
536 | 576 | if (isset($log['extra']['board_to'])) |
537 | 577 | { |
538 | - if (!is_numeric($log['extra']['board_to'])) |
|
539 | - trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
578 | + if (!is_numeric($log['extra']['board_to'])) { |
|
579 | + trigger_error('logActions(): data\'s board_to is not a number', E_USER_NOTICE); |
|
580 | + } |
|
540 | 581 | if (empty($board_id)) |
541 | 582 | { |
542 | 583 | $board_id = empty($log['extra']['board_to']) ? 0 : (int) $log['extra']['board_to']; |
@@ -544,15 +585,17 @@ discard block |
||
544 | 585 | } |
545 | 586 | } |
546 | 587 | |
547 | - if (isset($log['extra']['member_affected'])) |
|
548 | - $memID = $log['extra']['member_affected']; |
|
549 | - else |
|
550 | - $memID = $user_info['id']; |
|
588 | + if (isset($log['extra']['member_affected'])) { |
|
589 | + $memID = $log['extra']['member_affected']; |
|
590 | + } else { |
|
591 | + $memID = $user_info['id']; |
|
592 | + } |
|
551 | 593 | |
552 | - if (isset($user_info['ip'])) |
|
553 | - $memIP = $user_info['ip']; |
|
554 | - else |
|
555 | - $memIP = 'null'; |
|
594 | + if (isset($user_info['ip'])) { |
|
595 | + $memIP = $user_info['ip']; |
|
596 | + } else { |
|
597 | + $memIP = 'null'; |
|
598 | + } |
|
556 | 599 | |
557 | 600 | $inserts[] = array( |
558 | 601 | time(), $log_types[$log['log_type']], $memID, $memIP, $log['action'], |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * This function allows to move a topic, making sure to ask the moderator |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | { |
33 | 34 | global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir; |
34 | 35 | |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('no_access', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('no_access', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $request = $smcFunc['db_query']('', ' |
39 | 41 | SELECT t.id_member_started, ms.subject, t.approved |
@@ -49,8 +51,9 @@ discard block |
||
49 | 51 | $smcFunc['db_free_result']($request); |
50 | 52 | |
51 | 53 | // Can they see it - if not approved? |
52 | - if ($modSettings['postmod_active'] && !$context['is_approved']) |
|
53 | - isAllowedTo('approve_posts'); |
|
54 | + if ($modSettings['postmod_active'] && !$context['is_approved']) { |
|
55 | + isAllowedTo('approve_posts'); |
|
56 | + } |
|
54 | 57 | |
55 | 58 | // Permission check! |
56 | 59 | // @todo |
@@ -59,9 +62,9 @@ discard block |
||
59 | 62 | if ($id_member_started == $user_info['id']) |
60 | 63 | { |
61 | 64 | isAllowedTo('move_own'); |
65 | + } else { |
|
66 | + isAllowedTo('move_any'); |
|
62 | 67 | } |
63 | - else |
|
64 | - isAllowedTo('move_any'); |
|
65 | 68 | } |
66 | 69 | |
67 | 70 | $context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any']; |
@@ -83,11 +86,13 @@ discard block |
||
83 | 86 | 'not_redirection' => true, |
84 | 87 | ); |
85 | 88 | |
86 | - if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) |
|
87 | - $options['selected_board'] = $_SESSION['move_to_topic']; |
|
89 | + if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) { |
|
90 | + $options['selected_board'] = $_SESSION['move_to_topic']; |
|
91 | + } |
|
88 | 92 | |
89 | - if (!$context['move_any']) |
|
90 | - $options['included_boards'] = $boards; |
|
93 | + if (!$context['move_any']) { |
|
94 | + $options['included_boards'] = $boards; |
|
95 | + } |
|
91 | 96 | |
92 | 97 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
93 | 98 | $context['categories'] = getBoardList($options); |
@@ -138,12 +143,14 @@ discard block |
||
138 | 143 | global $txt, $topic, $scripturl, $sourcedir, $context; |
139 | 144 | global $board, $language, $user_info, $smcFunc; |
140 | 145 | |
141 | - if (empty($topic)) |
|
142 | - fatal_lang_error('no_access', false); |
|
146 | + if (empty($topic)) { |
|
147 | + fatal_lang_error('no_access', false); |
|
148 | + } |
|
143 | 149 | |
144 | 150 | // You can't choose to have a redirection topic and use an empty reason. |
145 | - if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) |
|
146 | - fatal_lang_error('movetopic_no_reason', false); |
|
151 | + if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) { |
|
152 | + fatal_lang_error('movetopic_no_reason', false); |
|
153 | + } |
|
147 | 154 | |
148 | 155 | moveTopicConcurrence(); |
149 | 156 | |
@@ -163,16 +170,18 @@ discard block |
||
163 | 170 | $smcFunc['db_free_result']($request); |
164 | 171 | |
165 | 172 | // Can they see it? |
166 | - if (!$context['is_approved']) |
|
167 | - isAllowedTo('approve_posts'); |
|
173 | + if (!$context['is_approved']) { |
|
174 | + isAllowedTo('approve_posts'); |
|
175 | + } |
|
168 | 176 | |
169 | 177 | // Can they move topics on this board? |
170 | 178 | if (!allowedTo('move_any')) |
171 | 179 | { |
172 | - if ($id_member_started == $user_info['id']) |
|
173 | - isAllowedTo('move_own'); |
|
174 | - else |
|
175 | - isAllowedTo('move_any'); |
|
180 | + if ($id_member_started == $user_info['id']) { |
|
181 | + isAllowedTo('move_own'); |
|
182 | + } else { |
|
183 | + isAllowedTo('move_any'); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | |
178 | 187 | checkSession(); |
@@ -197,8 +206,9 @@ discard block |
||
197 | 206 | 'blank_redirect' => '', |
198 | 207 | ) |
199 | 208 | ); |
200 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
201 | - fatal_lang_error('no_board'); |
|
209 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
210 | + fatal_lang_error('no_board'); |
|
211 | + } |
|
202 | 212 | list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request); |
203 | 213 | $smcFunc['db_free_result']($request); |
204 | 214 | |
@@ -210,8 +220,9 @@ discard block |
||
210 | 220 | { |
211 | 221 | $_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => '')); |
212 | 222 | // Keep checking the length. |
213 | - if ($smcFunc['strlen']($_POST['custom_subject']) > 100) |
|
214 | - $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
223 | + if ($smcFunc['strlen']($_POST['custom_subject']) > 100) { |
|
224 | + $_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100); |
|
225 | + } |
|
215 | 226 | |
216 | 227 | // If it's still valid move onwards and upwards. |
217 | 228 | if ($_POST['custom_subject'] != '') |
@@ -221,9 +232,9 @@ discard block |
||
221 | 232 | // Get a response prefix, but in the forum's default language. |
222 | 233 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
223 | 234 | { |
224 | - if ($language === $user_info['language']) |
|
225 | - $context['response_prefix'] = $txt['response_prefix']; |
|
226 | - else |
|
235 | + if ($language === $user_info['language']) { |
|
236 | + $context['response_prefix'] = $txt['response_prefix']; |
|
237 | + } else |
|
227 | 238 | { |
228 | 239 | loadLanguage('index', $language, false); |
229 | 240 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -263,8 +274,9 @@ discard block |
||
263 | 274 | if (isset($_POST['postRedirect'])) |
264 | 275 | { |
265 | 276 | // Should be in the boardwide language. |
266 | - if ($user_info['language'] != $language) |
|
267 | - loadLanguage('index', $language); |
|
277 | + if ($user_info['language'] != $language) { |
|
278 | + loadLanguage('index', $language); |
|
279 | + } |
|
268 | 280 | |
269 | 281 | $_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES); |
270 | 282 | preparsecode($_POST['reason']); |
@@ -328,8 +340,9 @@ discard block |
||
328 | 340 | $posters = array(); |
329 | 341 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
330 | 342 | { |
331 | - if (!isset($posters[$row['id_member']])) |
|
332 | - $posters[$row['id_member']] = 0; |
|
343 | + if (!isset($posters[$row['id_member']])) { |
|
344 | + $posters[$row['id_member']] = 0; |
|
345 | + } |
|
333 | 346 | |
334 | 347 | $posters[$row['id_member']]++; |
335 | 348 | } |
@@ -338,11 +351,13 @@ discard block |
||
338 | 351 | foreach ($posters as $id_member => $posts) |
339 | 352 | { |
340 | 353 | // The board we're moving from counted posts, but not to. |
341 | - if (empty($pcounter_from)) |
|
342 | - updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
354 | + if (empty($pcounter_from)) { |
|
355 | + updateMemberData($id_member, array('posts' => 'posts - ' . $posts)); |
|
356 | + } |
|
343 | 357 | // The reverse: from didn't, to did. |
344 | - else |
|
345 | - updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
358 | + else { |
|
359 | + updateMemberData($id_member, array('posts' => 'posts + ' . $posts)); |
|
360 | + } |
|
346 | 361 | } |
347 | 362 | } |
348 | 363 | |
@@ -350,19 +365,21 @@ discard block |
||
350 | 365 | moveTopics($topic, $_POST['toboard']); |
351 | 366 | |
352 | 367 | // Log that they moved this topic. |
353 | - if (!allowedTo('move_own') || $id_member_started != $user_info['id']) |
|
354 | - logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
368 | + if (!allowedTo('move_own') || $id_member_started != $user_info['id']) { |
|
369 | + logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard'])); |
|
370 | + } |
|
355 | 371 | // Notify people that this topic has been moved? |
356 | 372 | sendNotifications($topic, 'move'); |
357 | 373 | |
358 | 374 | call_integration_hook('integrate_movetopic2_end'); |
359 | 375 | |
360 | 376 | // Why not go back to the original board in case they want to keep moving? |
361 | - if (!isset($_REQUEST['goback'])) |
|
362 | - redirectexit('board=' . $board . '.0'); |
|
363 | - else |
|
364 | - redirectexit('topic=' . $topic . '.0'); |
|
365 | -} |
|
377 | + if (!isset($_REQUEST['goback'])) { |
|
378 | + redirectexit('board=' . $board . '.0'); |
|
379 | + } else { |
|
380 | + redirectexit('topic=' . $topic . '.0'); |
|
381 | + } |
|
382 | + } |
|
366 | 383 | |
367 | 384 | /** |
368 | 385 | * Moves one or more topics to a specific board. (doesn't check permissions.) |
@@ -378,18 +395,21 @@ discard block |
||
378 | 395 | global $sourcedir, $user_info, $modSettings, $smcFunc; |
379 | 396 | |
380 | 397 | // Empty array? |
381 | - if (empty($topics)) |
|
382 | - return; |
|
398 | + if (empty($topics)) { |
|
399 | + return; |
|
400 | + } |
|
383 | 401 | |
384 | 402 | // Only a single topic. |
385 | - if (is_numeric($topics)) |
|
386 | - $topics = array($topics); |
|
403 | + if (is_numeric($topics)) { |
|
404 | + $topics = array($topics); |
|
405 | + } |
|
387 | 406 | |
388 | 407 | $fromBoards = array(); |
389 | 408 | |
390 | 409 | // Destination board empty or equal to 0? |
391 | - if (empty($toBoard)) |
|
392 | - return; |
|
410 | + if (empty($toBoard)) { |
|
411 | + return; |
|
412 | + } |
|
393 | 413 | |
394 | 414 | // Are we moving to the recycle board? |
395 | 415 | $isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard; |
@@ -397,8 +417,9 @@ discard block |
||
397 | 417 | // Callback for search APIs to do their thing |
398 | 418 | require_once($sourcedir . '/Search.php'); |
399 | 419 | $searchAPI = findSearchAPI(); |
400 | - if ($searchAPI->supportsMethod('topicsMoved')) |
|
401 | - $searchAPI->topicsMoved($topics, $toBoard); |
|
420 | + if ($searchAPI->supportsMethod('topicsMoved')) { |
|
421 | + $searchAPI->topicsMoved($topics, $toBoard); |
|
422 | + } |
|
402 | 423 | |
403 | 424 | // Determine the source boards... |
404 | 425 | $request = $smcFunc['db_query']('', ' |
@@ -412,8 +433,9 @@ discard block |
||
412 | 433 | ) |
413 | 434 | ); |
414 | 435 | // Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards. |
415 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
416 | - return; |
|
436 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
437 | + return; |
|
438 | + } |
|
417 | 439 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
418 | 440 | { |
419 | 441 | if (!isset($fromBoards[$row['id_board']]['num_posts'])) |
@@ -431,10 +453,11 @@ discard block |
||
431 | 453 | $fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts']; |
432 | 454 | |
433 | 455 | // Add the topics to the right type. |
434 | - if ($row['approved']) |
|
435 | - $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
436 | - else |
|
437 | - $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
456 | + if ($row['approved']) { |
|
457 | + $fromBoards[$row['id_board']]['num_topics'] += $row['num_topics']; |
|
458 | + } else { |
|
459 | + $fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics']; |
|
460 | + } |
|
438 | 461 | } |
439 | 462 | $smcFunc['db_free_result']($request); |
440 | 463 | |
@@ -560,13 +583,14 @@ discard block |
||
560 | 583 | ) |
561 | 584 | ); |
562 | 585 | $approval_msgs = array(); |
563 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
564 | - $approval_msgs[] = $row['id_msg']; |
|
586 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
587 | + $approval_msgs[] = $row['id_msg']; |
|
588 | + } |
|
565 | 589 | $smcFunc['db_free_result']($request); |
566 | 590 | |
567 | 591 | // Empty the approval queue for these, as we're going to approve them next. |
568 | - if (!empty($approval_msgs)) |
|
569 | - $smcFunc['db_query']('', ' |
|
592 | + if (!empty($approval_msgs)) { |
|
593 | + $smcFunc['db_query']('', ' |
|
570 | 594 | DELETE FROM {db_prefix}approval_queue |
571 | 595 | WHERE id_msg IN ({array_int:message_list}) |
572 | 596 | AND id_attach = {int:id_attach}', |
@@ -575,6 +599,7 @@ discard block |
||
575 | 599 | 'id_attach' => 0, |
576 | 600 | ) |
577 | 601 | ); |
602 | + } |
|
578 | 603 | |
579 | 604 | // Get all the current max and mins. |
580 | 605 | $request = $smcFunc['db_query']('', ' |
@@ -608,8 +633,8 @@ discard block |
||
608 | 633 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
609 | 634 | { |
610 | 635 | // If not, update. |
611 | - if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) |
|
612 | - $smcFunc['db_query']('', ' |
|
636 | + if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) { |
|
637 | + $smcFunc['db_query']('', ' |
|
613 | 638 | UPDATE {db_prefix}topics |
614 | 639 | SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg} |
615 | 640 | WHERE id_topic = {int:selected_topic}', |
@@ -619,6 +644,7 @@ discard block |
||
619 | 644 | 'selected_topic' => $row['id_topic'], |
620 | 645 | ) |
621 | 646 | ); |
647 | + } |
|
622 | 648 | } |
623 | 649 | $smcFunc['db_free_result']($request); |
624 | 650 | } |
@@ -677,9 +703,10 @@ discard block |
||
677 | 703 | } |
678 | 704 | |
679 | 705 | // Update the cache? |
680 | - if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) |
|
681 | - foreach ($topics as $topic_id) |
|
706 | + if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) { |
|
707 | + foreach ($topics as $topic_id) |
|
682 | 708 | cache_put_data('topic_board-' . $topic_id, null, 120); |
709 | + } |
|
683 | 710 | |
684 | 711 | require_once($sourcedir . '/Subs-Post.php'); |
685 | 712 | |
@@ -703,15 +730,17 @@ discard block |
||
703 | 730 | { |
704 | 731 | global $board, $topic, $smcFunc, $scripturl; |
705 | 732 | |
706 | - if (isset($_GET['current_board'])) |
|
707 | - $move_from = (int) $_GET['current_board']; |
|
733 | + if (isset($_GET['current_board'])) { |
|
734 | + $move_from = (int) $_GET['current_board']; |
|
735 | + } |
|
708 | 736 | |
709 | - if (empty($move_from) || empty($board) || empty($topic)) |
|
710 | - return true; |
|
737 | + if (empty($move_from) || empty($board) || empty($topic)) { |
|
738 | + return true; |
|
739 | + } |
|
711 | 740 | |
712 | - if ($move_from == $board) |
|
713 | - return true; |
|
714 | - else |
|
741 | + if ($move_from == $board) { |
|
742 | + return true; |
|
743 | + } else |
|
715 | 744 | { |
716 | 745 | $request = $smcFunc['db_query']('', ' |
717 | 746 | SELECT m.subject, b.name |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * View the forum's error log. |
@@ -30,12 +31,14 @@ discard block |
||
30 | 31 | global $scripturl, $txt, $context, $modSettings, $user_profile, $filter, $smcFunc; |
31 | 32 | |
32 | 33 | // Viewing contents of a file? |
33 | - if (isset($_GET['file'])) |
|
34 | - return ViewFile(); |
|
34 | + if (isset($_GET['file'])) { |
|
35 | + return ViewFile(); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Viewing contents of a backtrace? |
37 | - if (isset($_GET['backtrace'])) |
|
38 | - return ViewBacktrace(); |
|
39 | + if (isset($_GET['backtrace'])) { |
|
40 | + return ViewBacktrace(); |
|
41 | + } |
|
39 | 42 | |
40 | 43 | // Check for the administrative permission to do this. |
41 | 44 | isAllowedTo('admin_forum'); |
@@ -89,8 +92,8 @@ discard block |
||
89 | 92 | ); |
90 | 93 | |
91 | 94 | // Set up the filtering... |
92 | - if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) |
|
93 | - $filter = array( |
|
95 | + if (isset($_GET['value'], $_GET['filter']) && isset($filters[$_GET['filter']])) { |
|
96 | + $filter = array( |
|
94 | 97 | 'variable' => $_GET['filter'], |
95 | 98 | 'value' => array( |
96 | 99 | 'sql' => in_array($_GET['filter'], array('message', 'url', 'file')) ? base64_decode(strtr($_GET['value'], array(' ' => '+'))) : $smcFunc['db_escape_wildcard_string']($_GET['value']), |
@@ -98,10 +101,12 @@ discard block |
||
98 | 101 | 'href' => ';filter=' . $_GET['filter'] . ';value=' . $_GET['value'], |
99 | 102 | 'entity' => $filters[$_GET['filter']]['txt'] |
100 | 103 | ); |
104 | + } |
|
101 | 105 | |
102 | 106 | // Deleting, are we? |
103 | - if (isset($_POST['delall']) || isset($_POST['delete'])) |
|
104 | - deleteErrors(); |
|
107 | + if (isset($_POST['delall']) || isset($_POST['delete'])) { |
|
108 | + deleteErrors(); |
|
109 | + } |
|
105 | 110 | |
106 | 111 | // Just how many errors are there? |
107 | 112 | $result = $smcFunc['db_query']('', ' |
@@ -116,12 +121,14 @@ discard block |
||
116 | 121 | $smcFunc['db_free_result']($result); |
117 | 122 | |
118 | 123 | // If this filter is empty... |
119 | - if ($num_errors == 0 && isset($filter)) |
|
120 | - redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
124 | + if ($num_errors == 0 && isset($filter)) { |
|
125 | + redirectexit('action=admin;area=logs;sa=errorlog' . (isset($_REQUEST['desc']) ? ';desc' : '')); |
|
126 | + } |
|
121 | 127 | |
122 | 128 | // Clean up start. |
123 | - if (!isset($_GET['start']) || $_GET['start'] < 0) |
|
124 | - $_GET['start'] = 0; |
|
129 | + if (!isset($_GET['start']) || $_GET['start'] < 0) { |
|
130 | + $_GET['start'] = 0; |
|
131 | + } |
|
125 | 132 | |
126 | 133 | // Do we want to reverse error listing? |
127 | 134 | $context['sort_direction'] = isset($_REQUEST['desc']) ? 'down' : 'up'; |
@@ -131,9 +138,9 @@ discard block |
||
131 | 138 | $context['start'] = $_GET['start']; |
132 | 139 | |
133 | 140 | // Update the error count |
134 | - if (!isset($filter)) |
|
135 | - $context['num_errors'] = $num_errors; |
|
136 | - else |
|
141 | + if (!isset($filter)) { |
|
142 | + $context['num_errors'] = $num_errors; |
|
143 | + } else |
|
137 | 144 | { |
138 | 145 | // We want all errors, not just the number of filtered messages... |
139 | 146 | $query = $smcFunc['db_query']('', ' |
@@ -165,8 +172,9 @@ discard block |
||
165 | 172 | for ($i = 0; $row = $smcFunc['db_fetch_assoc']($request); $i++) |
166 | 173 | { |
167 | 174 | $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $smcFunc['db_escape_wildcard_string']($row['message'])); |
168 | - if ($search_message == $filter['value']['sql']) |
|
169 | - $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
175 | + if ($search_message == $filter['value']['sql']) { |
|
176 | + $search_message = $smcFunc['db_escape_wildcard_string']($row['message']); |
|
177 | + } |
|
170 | 178 | $show_message = strtr(strtr(preg_replace('~<span class="remove">(.+?)</span>~', '$1', $row['message']), array("\r" => '', '<br>' => "\n", '<' => '<', '>' => '>', '"' => '"')), array("\n" => '<br>')); |
171 | 179 | |
172 | 180 | $context['errors'][$row['id_error']] = array( |
@@ -225,8 +233,9 @@ discard block |
||
225 | 233 | 'members' => count($members), |
226 | 234 | ) |
227 | 235 | ); |
228 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
229 | - $members[$row['id_member']] = $row; |
|
236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
237 | + $members[$row['id_member']] = $row; |
|
238 | + } |
|
230 | 239 | $smcFunc['db_free_result']($request); |
231 | 240 | |
232 | 241 | // This is a guest... |
@@ -258,20 +267,18 @@ discard block |
||
258 | 267 | $id = $filter['value']['sql']; |
259 | 268 | loadMemberData($id, false, 'minimal'); |
260 | 269 | $context['filter']['value']['html'] = '<a href="' . $scripturl . '?action=profile;u=' . $id . '">' . $user_profile[$id]['real_name'] . '</a>'; |
261 | - } |
|
262 | - elseif ($filter['variable'] == 'url') |
|
263 | - $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
264 | - elseif ($filter['variable'] == 'message') |
|
270 | + } elseif ($filter['variable'] == 'url') { |
|
271 | + $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']((substr($filter['value']['sql'], 0, 1) == '?' ? $scripturl : '') . $filter['value']['sql']), array('\_' => '_')) . '\''; |
|
272 | + } elseif ($filter['variable'] == 'message') |
|
265 | 273 | { |
266 | 274 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
267 | 275 | $context['filter']['value']['html'] = preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $context['filter']['value']['html']); |
268 | - } |
|
269 | - elseif ($filter['variable'] == 'error_type') |
|
276 | + } elseif ($filter['variable'] == 'error_type') |
|
270 | 277 | { |
271 | 278 | $context['filter']['value']['html'] = '\'' . strtr($smcFunc['htmlspecialchars']($filter['value']['sql']), array("\n" => '<br>', '<br />' => '<br>', "\t" => ' ', '\_' => '_', '\\%' => '%', '\\\\' => '\\')) . '\''; |
279 | + } else { |
|
280 | + $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
272 | 281 | } |
273 | - else |
|
274 | - $context['filter']['value']['html'] = &$filter['value']['sql']; |
|
275 | 282 | } |
276 | 283 | |
277 | 284 | $context['error_types'] = array(); |
@@ -312,10 +319,11 @@ discard block |
||
312 | 319 | $context['error_types']['all']['label'] .= ' (' . $sum . ')'; |
313 | 320 | |
314 | 321 | // Finally, work out what is the last tab! |
315 | - if (isset($context['error_types'][$sum])) |
|
316 | - $context['error_types'][$sum]['is_last'] = true; |
|
317 | - else |
|
318 | - $context['error_types']['all']['is_last'] = true; |
|
322 | + if (isset($context['error_types'][$sum])) { |
|
323 | + $context['error_types'][$sum]['is_last'] = true; |
|
324 | + } else { |
|
325 | + $context['error_types']['all']['is_last'] = true; |
|
326 | + } |
|
319 | 327 | |
320 | 328 | // And this is pretty basic ;). |
321 | 329 | $context['page_title'] = $txt['errlog']; |
@@ -341,21 +349,23 @@ discard block |
||
341 | 349 | validateToken('admin-el'); |
342 | 350 | |
343 | 351 | // Delete all or just some? |
344 | - if (isset($_POST['delall']) && !isset($filter)) |
|
345 | - $smcFunc['db_query']('truncate_table', ' |
|
352 | + if (isset($_POST['delall']) && !isset($filter)) { |
|
353 | + $smcFunc['db_query']('truncate_table', ' |
|
346 | 354 | TRUNCATE {db_prefix}log_errors', |
347 | 355 | array( |
348 | 356 | ) |
349 | 357 | ); |
358 | + } |
|
350 | 359 | // Deleting all with a filter? |
351 | - elseif (isset($_POST['delall']) && isset($filter)) |
|
352 | - $smcFunc['db_query']('', ' |
|
360 | + elseif (isset($_POST['delall']) && isset($filter)) { |
|
361 | + $smcFunc['db_query']('', ' |
|
353 | 362 | DELETE FROM {db_prefix}log_errors |
354 | 363 | WHERE ' . $filter['variable'] . ' LIKE {string:filter}', |
355 | 364 | array( |
356 | 365 | 'filter' => $filter['value']['sql'], |
357 | 366 | ) |
358 | 367 | ); |
368 | + } |
|
359 | 369 | // Just specific errors? |
360 | 370 | elseif (!empty($_POST['delete'])) |
361 | 371 | { |
@@ -401,15 +411,17 @@ discard block |
||
401 | 411 | $line = isset($_REQUEST['line']) ? (int) $_REQUEST['line'] : 0; |
402 | 412 | |
403 | 413 | // Make sure the file we are looking for is one they are allowed to look at |
404 | - if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) |
|
405 | - fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
414 | + if ($ext != '.php' || (strpos($file, $real_board) === false && strpos($file, $real_source) === false) || ($basename == 'settings.php' || $basename == 'settings_bak.php') || strpos($file, $real_cache) !== false || !is_readable($file)) { |
|
415 | + fatal_lang_error('error_bad_file', true, array($smcFunc['htmlspecialchars']($file))); |
|
416 | + } |
|
406 | 417 | |
407 | 418 | // get the min and max lines |
408 | 419 | $min = $line - 20 <= 0 ? 1 : $line - 20; |
409 | 420 | $max = $line + 21; // One additional line to make everything work out correctly |
410 | 421 | |
411 | - if ($max <= 0 || $min >= $max) |
|
412 | - fatal_lang_error('error_bad_line'); |
|
422 | + if ($max <= 0 || $min >= $max) { |
|
423 | + fatal_lang_error('error_bad_line'); |
|
424 | + } |
|
413 | 425 | |
414 | 426 | $file_data = explode('<br />', highlight_php_code($smcFunc['htmlspecialchars'](implode('', file($file))))); |
415 | 427 |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 4 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | |
20 | 21 | /** |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
45 | 46 | |
46 | 47 | // Is it elsewhere? |
47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Do the permission check, you might not be allowed her. |
51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
104 | 106 | 'function' => function($rowData) use ($scripturl) |
105 | 107 | { |
106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
107 | - if ($rowData['id_group'] == 3) |
|
108 | - $group_name = $rowData['group_name']; |
|
109 | - else |
|
109 | + if ($rowData['id_group'] == 3) { |
|
110 | + $group_name = $rowData['group_name']; |
|
111 | + } else |
|
110 | 112 | { |
111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
113 | 115 | } |
114 | 116 | |
115 | 117 | // Add a help option for moderator and administrator. |
116 | - if ($rowData['id_group'] == 1) |
|
117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | - elseif ($rowData['id_group'] == 3) |
|
119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | + if ($rowData['id_group'] == 1) { |
|
119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
120 | + } elseif ($rowData['id_group'] == 3) { |
|
121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | return $group_name; |
122 | 125 | }, |
@@ -329,12 +332,14 @@ discard block |
||
329 | 332 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
330 | 333 | |
331 | 334 | // Update the post groups now, if this is a post group! |
332 | - if (isset($_POST['min_posts'])) |
|
333 | - updateStats('postgroups'); |
|
335 | + if (isset($_POST['min_posts'])) { |
|
336 | + updateStats('postgroups'); |
|
337 | + } |
|
334 | 338 | |
335 | 339 | // You cannot set permissions for post groups if they are disabled. |
336 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
337 | - $_POST['perm_type'] = ''; |
|
340 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
341 | + $_POST['perm_type'] = ''; |
|
342 | + } |
|
338 | 343 | |
339 | 344 | if ($_POST['perm_type'] == 'predefined') |
340 | 345 | { |
@@ -364,8 +369,9 @@ discard block |
||
364 | 369 | $smcFunc['db_free_result']($request); |
365 | 370 | |
366 | 371 | // Protected groups are... well, protected! |
367 | - if ($copy_type == 1) |
|
368 | - fatal_lang_error('membergroup_does_not_exist'); |
|
372 | + if ($copy_type == 1) { |
|
373 | + fatal_lang_error('membergroup_does_not_exist'); |
|
374 | + } |
|
369 | 375 | } |
370 | 376 | |
371 | 377 | // Don't allow copying of a real priviledged person! |
@@ -383,18 +389,20 @@ discard block |
||
383 | 389 | $inserts = array(); |
384 | 390 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
385 | 391 | { |
386 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
387 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
392 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
393 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
394 | + } |
|
388 | 395 | } |
389 | 396 | $smcFunc['db_free_result']($request); |
390 | 397 | |
391 | - if (!empty($inserts)) |
|
392 | - $smcFunc['db_insert']('insert', |
|
398 | + if (!empty($inserts)) { |
|
399 | + $smcFunc['db_insert']('insert', |
|
393 | 400 | '{db_prefix}permissions', |
394 | 401 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
395 | 402 | $inserts, |
396 | 403 | array('id_group', 'permission') |
397 | 404 | ); |
405 | + } |
|
398 | 406 | |
399 | 407 | $request = $smcFunc['db_query']('', ' |
400 | 408 | SELECT id_profile, permission, add_deny |
@@ -405,17 +413,19 @@ discard block |
||
405 | 413 | ) |
406 | 414 | ); |
407 | 415 | $inserts = array(); |
408 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
409 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
416 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
417 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
418 | + } |
|
410 | 419 | $smcFunc['db_free_result']($request); |
411 | 420 | |
412 | - if (!empty($inserts)) |
|
413 | - $smcFunc['db_insert']('insert', |
|
421 | + if (!empty($inserts)) { |
|
422 | + $smcFunc['db_insert']('insert', |
|
414 | 423 | '{db_prefix}board_permissions', |
415 | 424 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
416 | 425 | $inserts, |
417 | 426 | array('id_group', 'id_profile', 'permission') |
418 | 427 | ); |
428 | + } |
|
419 | 429 | |
420 | 430 | // Also get some membergroup information if we're copying and not copying from guests... |
421 | 431 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -468,14 +478,15 @@ discard block |
||
468 | 478 | $changed_boards['allow'] = array(); |
469 | 479 | $changed_boards['deny'] = array(); |
470 | 480 | $changed_boards['ignore'] = array(); |
471 | - foreach ($accesses as $group_id => $action) |
|
472 | - $changed_boards[$action][] = (int) $group_id; |
|
481 | + foreach ($accesses as $group_id => $action) { |
|
482 | + $changed_boards[$action][] = (int) $group_id; |
|
483 | + } |
|
473 | 484 | |
474 | 485 | foreach (array('allow', 'deny') as $board_action) |
475 | 486 | { |
476 | 487 | // Only do this if they have special access requirements. |
477 | - if (!empty($changed_boards[$board_action])) |
|
478 | - $smcFunc['db_query']('', ' |
|
488 | + if (!empty($changed_boards[$board_action])) { |
|
489 | + $smcFunc['db_query']('', ' |
|
479 | 490 | UPDATE {db_prefix}boards |
480 | 491 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
481 | 492 | WHERE id_board IN ({array_int:board_list})', |
@@ -487,11 +498,13 @@ discard block |
||
487 | 498 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
488 | 499 | ) |
489 | 500 | ); |
501 | + } |
|
490 | 502 | } |
491 | 503 | |
492 | 504 | // If this is joinable then set it to show group membership in people's profiles. |
493 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
494 | - updateSettings(array('show_group_membership' => 1)); |
|
505 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
506 | + updateSettings(array('show_group_membership' => 1)); |
|
507 | + } |
|
495 | 508 | |
496 | 509 | // Rebuild the group cache. |
497 | 510 | updateSettings(array( |
@@ -512,8 +525,9 @@ discard block |
||
512 | 525 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
513 | 526 | $context['allow_protected'] = allowedTo('admin_forum'); |
514 | 527 | |
515 | - if (!empty($modSettings['deny_boards_access'])) |
|
516 | - loadLanguage('ManagePermissions'); |
|
528 | + if (!empty($modSettings['deny_boards_access'])) { |
|
529 | + loadLanguage('ManagePermissions'); |
|
530 | + } |
|
517 | 531 | |
518 | 532 | $result = $smcFunc['db_query']('', ' |
519 | 533 | SELECT id_group, group_name |
@@ -530,11 +544,12 @@ discard block |
||
530 | 544 | ) |
531 | 545 | ); |
532 | 546 | $context['groups'] = array(); |
533 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
534 | - $context['groups'][] = array( |
|
547 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
548 | + $context['groups'][] = array( |
|
535 | 549 | 'id' => $row['id_group'], |
536 | 550 | 'name' => $row['group_name'] |
537 | 551 | ); |
552 | + } |
|
538 | 553 | $smcFunc['db_free_result']($result); |
539 | 554 | |
540 | 555 | $request = $smcFunc['db_query']('', ' |
@@ -551,12 +566,13 @@ discard block |
||
551 | 566 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
552 | 567 | { |
553 | 568 | // This category hasn't been set up yet.. |
554 | - if (!isset($context['categories'][$row['id_cat']])) |
|
555 | - $context['categories'][$row['id_cat']] = array( |
|
569 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
570 | + $context['categories'][$row['id_cat']] = array( |
|
556 | 571 | 'id' => $row['id_cat'], |
557 | 572 | 'name' => $row['cat_name'], |
558 | 573 | 'boards' => array() |
559 | 574 | ); |
575 | + } |
|
560 | 576 | |
561 | 577 | // Set this board up, and let the template know when it's a child. (indent them..) |
562 | 578 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -603,8 +619,9 @@ discard block |
||
603 | 619 | require_once($sourcedir . '/Subs-Membergroups.php'); |
604 | 620 | $result = deleteMembergroups((int) $_REQUEST['group']); |
605 | 621 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
606 | - if ($result === 'group_cannot_delete_sub') |
|
607 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
622 | + if ($result === 'group_cannot_delete_sub') { |
|
623 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
624 | + } |
|
608 | 625 | |
609 | 626 | // Go back to the membergroup index. |
610 | 627 | redirectexit('action=admin;area=membergroups;'); |
@@ -626,8 +643,9 @@ discard block |
||
626 | 643 | |
627 | 644 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
628 | 645 | |
629 | - if (!empty($modSettings['deny_boards_access'])) |
|
630 | - loadLanguage('ManagePermissions'); |
|
646 | + if (!empty($modSettings['deny_boards_access'])) { |
|
647 | + loadLanguage('ManagePermissions'); |
|
648 | + } |
|
631 | 649 | |
632 | 650 | // Make sure this group is editable. |
633 | 651 | if (!empty($_REQUEST['group'])) |
@@ -649,8 +667,9 @@ discard block |
||
649 | 667 | } |
650 | 668 | |
651 | 669 | // Now, do we have a valid id? |
652 | - if (empty($_REQUEST['group'])) |
|
653 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
670 | + if (empty($_REQUEST['group'])) { |
|
671 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
672 | + } |
|
654 | 673 | |
655 | 674 | // People who can manage boards are a bit special. |
656 | 675 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -681,8 +700,9 @@ discard block |
||
681 | 700 | require_once($sourcedir . '/Subs-Membergroups.php'); |
682 | 701 | $result = deleteMembergroups($_REQUEST['group']); |
683 | 702 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
684 | - if ($result === 'group_cannot_delete_sub') |
|
685 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
703 | + if ($result === 'group_cannot_delete_sub') { |
|
704 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
705 | + } |
|
686 | 706 | |
687 | 707 | redirectexit('action=admin;area=membergroups;'); |
688 | 708 | } |
@@ -759,16 +779,18 @@ discard block |
||
759 | 779 | $request = $smcFunc['db_query']('', ' |
760 | 780 | SELECT id_board |
761 | 781 | FROM {db_prefix}boards'); |
762 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
763 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
782 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
783 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
784 | + } |
|
764 | 785 | $smcFunc['db_free_result']($request); |
765 | 786 | } |
766 | 787 | |
767 | 788 | $changed_boards['allow'] = array(); |
768 | 789 | $changed_boards['deny'] = array(); |
769 | 790 | $changed_boards['ignore'] = array(); |
770 | - foreach ($accesses as $group_id => $action) |
|
771 | - $changed_boards[$action][] = (int) $group_id; |
|
791 | + foreach ($accesses as $group_id => $action) { |
|
792 | + $changed_boards[$action][] = (int) $group_id; |
|
793 | + } |
|
772 | 794 | |
773 | 795 | foreach (array('allow', 'deny') as $board_action) |
774 | 796 | { |
@@ -784,8 +806,8 @@ discard block |
||
784 | 806 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
785 | 807 | ) |
786 | 808 | ); |
787 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
788 | - $smcFunc['db_query']('', ' |
|
809 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
810 | + $smcFunc['db_query']('', ' |
|
789 | 811 | UPDATE {db_prefix}boards |
790 | 812 | SET {raw:column} = {string:member_group_access} |
791 | 813 | WHERE id_board = {int:current_board}', |
@@ -795,11 +817,12 @@ discard block |
||
795 | 817 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
796 | 818 | ) |
797 | 819 | ); |
820 | + } |
|
798 | 821 | $smcFunc['db_free_result']($request); |
799 | 822 | |
800 | 823 | // Add the membergroup to all boards that hadn't been set yet. |
801 | - if (!empty($changed_boards[$board_action])) |
|
802 | - $smcFunc['db_query']('', ' |
|
824 | + if (!empty($changed_boards[$board_action])) { |
|
825 | + $smcFunc['db_query']('', ' |
|
803 | 826 | UPDATE {db_prefix}boards |
804 | 827 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
805 | 828 | WHERE id_board IN ({array_int:board_list}) |
@@ -813,6 +836,7 @@ discard block |
||
813 | 836 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
814 | 837 | ) |
815 | 838 | ); |
839 | + } |
|
816 | 840 | } |
817 | 841 | } |
818 | 842 | |
@@ -838,12 +862,14 @@ discard block |
||
838 | 862 | ) |
839 | 863 | ); |
840 | 864 | $updates = array(); |
841 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
842 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
865 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
866 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
867 | + } |
|
843 | 868 | $smcFunc['db_free_result']($request); |
844 | 869 | |
845 | - foreach ($updates as $additional_groups => $memberArray) |
|
846 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
870 | + foreach ($updates as $additional_groups => $memberArray) { |
|
871 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
872 | + } |
|
847 | 873 | |
848 | 874 | // Sorry, but post groups can't moderate boards |
849 | 875 | $smcFunc['db_query']('', ' |
@@ -853,8 +879,7 @@ discard block |
||
853 | 879 | 'current_group' => (int) $_REQUEST['group'], |
854 | 880 | ) |
855 | 881 | ); |
856 | - } |
|
857 | - elseif ($_REQUEST['group'] != 3) |
|
882 | + } elseif ($_REQUEST['group'] != 3) |
|
858 | 883 | { |
859 | 884 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
860 | 885 | if ($_POST['group_hidden'] == 2) |
@@ -869,8 +894,9 @@ discard block |
||
869 | 894 | ) |
870 | 895 | ); |
871 | 896 | $updates = array(); |
872 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
873 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
897 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
898 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
899 | + } |
|
874 | 900 | $smcFunc['db_free_result']($request); |
875 | 901 | |
876 | 902 | foreach ($updates as $additional_groups => $memberArray) |
@@ -912,8 +938,9 @@ discard block |
||
912 | 938 | $smcFunc['db_free_result']($request); |
913 | 939 | |
914 | 940 | // Do we need to update the setting? |
915 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
916 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
941 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
942 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
943 | + } |
|
917 | 944 | } |
918 | 945 | |
919 | 946 | // Do we need to set inherited permissions? |
@@ -946,8 +973,9 @@ discard block |
||
946 | 973 | { |
947 | 974 | $moderators[$k] = trim($moderators[$k]); |
948 | 975 | |
949 | - if (strlen($moderators[$k]) == 0) |
|
950 | - unset($moderators[$k]); |
|
976 | + if (strlen($moderators[$k]) == 0) { |
|
977 | + unset($moderators[$k]); |
|
978 | + } |
|
951 | 979 | } |
952 | 980 | |
953 | 981 | // Find all the id_member's for the member_name's in the list. |
@@ -963,8 +991,9 @@ discard block |
||
963 | 991 | 'count' => count($moderators), |
964 | 992 | ) |
965 | 993 | ); |
966 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
967 | - $group_moderators[] = $row['id_member']; |
|
994 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
995 | + $group_moderators[] = $row['id_member']; |
|
996 | + } |
|
968 | 997 | $smcFunc['db_free_result']($request); |
969 | 998 | } |
970 | 999 | } |
@@ -972,8 +1001,9 @@ discard block |
||
972 | 1001 | if (!empty($_POST['moderator_list'])) |
973 | 1002 | { |
974 | 1003 | $moderators = array(); |
975 | - foreach ($_POST['moderator_list'] as $moderator) |
|
976 | - $moderators[] = (int) $moderator; |
|
1004 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
1005 | + $moderators[] = (int) $moderator; |
|
1006 | + } |
|
977 | 1007 | |
978 | 1008 | if (!empty($moderators)) |
979 | 1009 | { |
@@ -987,8 +1017,9 @@ discard block |
||
987 | 1017 | 'num_moderators' => count($moderators), |
988 | 1018 | ) |
989 | 1019 | ); |
990 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
991 | - $group_moderators[] = $row['id_member']; |
|
1020 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1021 | + $group_moderators[] = $row['id_member']; |
|
1022 | + } |
|
992 | 1023 | $smcFunc['db_free_result']($request); |
993 | 1024 | } |
994 | 1025 | } |
@@ -1000,8 +1031,9 @@ discard block |
||
1000 | 1031 | if (!empty($group_moderators)) |
1001 | 1032 | { |
1002 | 1033 | $mod_insert = array(); |
1003 | - foreach ($group_moderators as $moderator) |
|
1004 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1034 | + foreach ($group_moderators as $moderator) { |
|
1035 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1036 | + } |
|
1005 | 1037 | |
1006 | 1038 | $smcFunc['db_insert']('insert', |
1007 | 1039 | '{db_prefix}group_moderators', |
@@ -1035,8 +1067,9 @@ discard block |
||
1035 | 1067 | 'current_group' => (int) $_REQUEST['group'], |
1036 | 1068 | ) |
1037 | 1069 | ); |
1038 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1039 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
1070 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1071 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
1072 | + } |
|
1040 | 1073 | $row = $smcFunc['db_fetch_assoc']($request); |
1041 | 1074 | $smcFunc['db_free_result']($request); |
1042 | 1075 | |
@@ -1073,14 +1106,16 @@ discard block |
||
1073 | 1106 | ) |
1074 | 1107 | ); |
1075 | 1108 | $context['group']['moderators'] = array(); |
1076 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1077 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1109 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1110 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1111 | + } |
|
1078 | 1112 | $smcFunc['db_free_result']($request); |
1079 | 1113 | |
1080 | 1114 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
1081 | 1115 | |
1082 | - if (!empty($context['group']['moderators'])) |
|
1083 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1116 | + if (!empty($context['group']['moderators'])) { |
|
1117 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1118 | + } |
|
1084 | 1119 | |
1085 | 1120 | // Get a list of boards this membergroup is allowed to see. |
1086 | 1121 | $context['boards'] = array(); |
@@ -1100,12 +1135,13 @@ discard block |
||
1100 | 1135 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1101 | 1136 | { |
1102 | 1137 | // This category hasn't been set up yet.. |
1103 | - if (!isset($context['categories'][$row['id_cat']])) |
|
1104 | - $context['categories'][$row['id_cat']] = array( |
|
1138 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
1139 | + $context['categories'][$row['id_cat']] = array( |
|
1105 | 1140 | 'id' => $row['id_cat'], |
1106 | 1141 | 'name' => $row['cat_name'], |
1107 | 1142 | 'boards' => array() |
1108 | 1143 | ); |
1144 | + } |
|
1109 | 1145 | |
1110 | 1146 | // Set this board up, and let the template know when it's a child. (indent them..) |
1111 | 1147 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1147,14 +1183,16 @@ discard block |
||
1147 | 1183 | $ext = pathinfo($settings['default_theme_dir'] . '/images/membericons/' . $value, PATHINFO_EXTENSION); |
1148 | 1184 | |
1149 | 1185 | // If the extension is not empty, and it is valid |
1150 | - if (!empty($ext) && in_array($ext, $imageExts)) |
|
1151 | - $context['possible_icons'][] = $value; |
|
1186 | + if (!empty($ext) && in_array($ext, $imageExts)) { |
|
1187 | + $context['possible_icons'][] = $value; |
|
1188 | + } |
|
1152 | 1189 | } |
1153 | 1190 | } |
1154 | 1191 | |
1155 | 1192 | // Insert our JS, if we have possible icons. |
1156 | - if (!empty($context['possible_icons'])) |
|
1157 | - loadJavaScriptFile('icondropdown.js', array('validate' => true, 'minimize' => true), 'smf_icondropdown'); |
|
1193 | + if (!empty($context['possible_icons'])) { |
|
1194 | + loadJavaScriptFile('icondropdown.js', array('validate' => true, 'minimize' => true), 'smf_icondropdown'); |
|
1195 | + } |
|
1158 | 1196 | |
1159 | 1197 | loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest'); |
1160 | 1198 | |
@@ -1176,8 +1214,9 @@ discard block |
||
1176 | 1214 | ) |
1177 | 1215 | ); |
1178 | 1216 | $context['inheritable_groups'] = array(); |
1179 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1180 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1217 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1218 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1219 | + } |
|
1181 | 1220 | $smcFunc['db_free_result']($request); |
1182 | 1221 | |
1183 | 1222 | call_integration_hook('integrate_view_membergroup'); |