@@ -309,7 +309,7 @@ |
||
309 | 309 | { |
310 | 310 | // I see you made it to the final stage, my young padawan. |
311 | 311 | if (!empty($id)) |
312 | - $smcFunc['db_query']('',' |
|
312 | + $smcFunc['db_query']('', ' |
|
313 | 313 | UPDATE {db_prefix}um_menu |
314 | 314 | SET name = {string:name}, type = {string:type}, target = {string:target}, position = {string:position}, link = {string:link}, status = {string:status}, permissions = {string:permissions}, parent = {string:parent} |
315 | 315 | WHERE id_button = {int:id}', |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | 'addbutton' => 'PrepareContext', |
38 | 38 | 'savebutton' => 'SaveButton', |
39 | 39 | ); |
40 | - if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) |
|
41 | - $_GET['sa'] = 'manmenu'; |
|
40 | + if (!isset($_GET['sa']) || !isset($subActions[$_GET['sa']])) { |
|
41 | + $_GET['sa'] = 'manmenu'; |
|
42 | + } |
|
42 | 43 | $this->$subActions[$_GET['sa']](); |
43 | 44 | } |
44 | 45 | |
@@ -64,8 +65,9 @@ discard block |
||
64 | 65 | checkSession(); |
65 | 66 | |
66 | 67 | // Make sure every entry is a proper integer. |
67 | - foreach ($_POST['remove'] as $index => $page_id) |
|
68 | - $_POST['remove'][(int) $index] = (int) $page_id; |
|
68 | + foreach ($_POST['remove'] as $index => $page_id) { |
|
69 | + $_POST['remove'][(int) $index] = (int) $page_id; |
|
70 | + } |
|
69 | 71 | |
70 | 72 | // Delete the page! |
71 | 73 | $smcFunc['db_query']('', ' |
@@ -86,8 +88,8 @@ discard block |
||
86 | 88 | foreach ($this->total_getMenu() as $item) |
87 | 89 | { |
88 | 90 | $status = !empty($_POST['status'][$item['id_button']]) ? 'active' : 'inactive'; |
89 | - if ($status != $item['status']) |
|
90 | - $smcFunc['db_query']('', ' |
|
91 | + if ($status != $item['status']) { |
|
92 | + $smcFunc['db_query']('', ' |
|
91 | 93 | UPDATE {db_prefix}um_menu |
92 | 94 | SET status = {string:status} |
93 | 95 | WHERE id_button = {int:item}', |
@@ -96,14 +98,16 @@ discard block |
||
96 | 98 | 'item' => $item['id_button'], |
97 | 99 | ) |
98 | 100 | ); |
101 | + } |
|
99 | 102 | } |
100 | 103 | $this->rebuildMenu(); |
101 | 104 | redirectexit('action=admin;area=umen'); |
102 | 105 | } |
103 | 106 | |
104 | 107 | // New item? |
105 | - if (isset($_POST['new'])) |
|
106 | - redirectexit('action=admin;area=umen;sa=addbutton'); |
|
108 | + if (isset($_POST['new'])) { |
|
109 | + redirectexit('action=admin;area=umen;sa=addbutton'); |
|
110 | + } |
|
107 | 111 | |
108 | 112 | loadLanguage('ManageBoards'); |
109 | 113 | $button_names = $this->getButtonNames(); |
@@ -280,13 +284,15 @@ discard block |
||
280 | 284 | $target = isset($_REQUEST['target']) ? $_REQUEST['target'] : '_self'; |
281 | 285 | |
282 | 286 | // These fields are required! |
283 | - foreach ($required_fields as $required_field) |
|
284 | - if ($_POST[$required_field] == '') |
|
287 | + foreach ($required_fields as $required_field) { |
|
288 | + if ($_POST[$required_field] == '') |
|
285 | 289 | $post_errors[$required_field] = 'um_menu_empty_' . $required_field; |
290 | + } |
|
286 | 291 | |
287 | 292 | // Stop making numeric names! |
288 | - if (is_numeric($name)) |
|
289 | - $post_errors['name'] = 'um_menu_numeric'; |
|
293 | + if (is_numeric($name)) { |
|
294 | + $post_errors['name'] = 'um_menu_numeric'; |
|
295 | + } |
|
290 | 296 | |
291 | 297 | // Let's make sure you're not trying to make a name that's already taken. |
292 | 298 | $request = $smcFunc['db_query']('', ' |
@@ -302,14 +308,15 @@ discard block |
||
302 | 308 | $check = $smcFunc['db_num_rows']($request); |
303 | 309 | $smcFunc['db_free_result']($request); |
304 | 310 | |
305 | - if ($check > 0) |
|
306 | - $post_errors['name'] = 'um_menu_mysql'; |
|
311 | + if ($check > 0) { |
|
312 | + $post_errors['name'] = 'um_menu_mysql'; |
|
313 | + } |
|
307 | 314 | |
308 | 315 | if (empty($post_errors)) |
309 | 316 | { |
310 | 317 | // I see you made it to the final stage, my young padawan. |
311 | - if (!empty($id)) |
|
312 | - $smcFunc['db_query']('',' |
|
318 | + if (!empty($id)) { |
|
319 | + $smcFunc['db_query']('',' |
|
313 | 320 | UPDATE {db_prefix}um_menu |
314 | 321 | SET name = {string:name}, type = {string:type}, target = {string:target}, position = {string:position}, link = {string:link}, status = {string:status}, permissions = {string:permissions}, parent = {string:parent} |
315 | 322 | WHERE id_button = {int:id}', |
@@ -325,8 +332,8 @@ discard block |
||
325 | 332 | 'parent' => $parent, |
326 | 333 | ) |
327 | 334 | ); |
328 | - else |
|
329 | - $smcFunc['db_insert']('insert', |
|
335 | + } else { |
|
336 | + $smcFunc['db_insert']('insert', |
|
330 | 337 | '{db_prefix}um_menu', |
331 | 338 | array( |
332 | 339 | 'name' => 'string', 'type' => 'string', 'target' => 'string', 'position' => 'string', 'link' => 'string', 'status' => 'string', 'permissions' => 'string', 'parent' => 'string', |
@@ -336,6 +343,7 @@ discard block |
||
336 | 343 | ), |
337 | 344 | array('id_button') |
338 | 345 | ); |
346 | + } |
|
339 | 347 | |
340 | 348 | $this->rebuildMenu(); |
341 | 349 | |
@@ -344,8 +352,7 @@ discard block |
||
344 | 352 | clean_cache('menu_buttons'); |
345 | 353 | |
346 | 354 | redirectexit('action=admin;area=umen'); |
347 | - } |
|
348 | - else |
|
355 | + } else |
|
349 | 356 | { |
350 | 357 | $context['post_error'] = $post_errors; |
351 | 358 | $context['error_title'] = empty($id) ? 'um_menu_errors_create' : 'um_menu_errors_modify'; |
@@ -402,8 +409,7 @@ discard block |
||
402 | 409 | 'status' => $row['status'], |
403 | 410 | 'parent' => $row['parent'], |
404 | 411 | ); |
405 | - } |
|
406 | - else |
|
412 | + } else |
|
407 | 413 | { |
408 | 414 | $context['button_data'] = array( |
409 | 415 | 'name' => '', |
@@ -429,8 +435,9 @@ discard block |
||
429 | 435 | SELECT id_button, name, target, type, position, link, status, permissions, parent |
430 | 436 | FROM {db_prefix}um_menu'); |
431 | 437 | $buttons = array(); |
432 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
433 | - $buttons[] = $row; |
|
438 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
439 | + $buttons[] = $row; |
|
440 | + } |
|
434 | 441 | $smcFunc['db_free_result']($request); |
435 | 442 | |
436 | 443 | return $buttons; |
@@ -452,8 +459,9 @@ discard block |
||
452 | 459 | ) |
453 | 460 | ); |
454 | 461 | $buttons = array(); |
455 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
456 | - $buttons[] = $row; |
|
462 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
463 | + $buttons[] = $row; |
|
464 | + } |
|
457 | 465 | $smcFunc['db_free_result']($request); |
458 | 466 | |
459 | 467 | return $buttons; |
@@ -481,8 +489,9 @@ discard block |
||
481 | 489 | FROM {db_prefix}um_menu'); |
482 | 490 | |
483 | 491 | $buttons = array(); |
484 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
485 | - $buttons['um_button_' . $row['id_button']] = json_encode($row); |
|
492 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
493 | + $buttons['um_button_' . $row['id_button']] = json_encode($row); |
|
494 | + } |
|
486 | 495 | $smcFunc['db_free_result']($request); |
487 | 496 | updateSettings( |
488 | 497 | array( |
@@ -508,12 +517,14 @@ discard block |
||
508 | 517 | |
509 | 518 | if (!empty($buttonData['sub_buttons'])) |
510 | 519 | { |
511 | - foreach ($buttonData['sub_buttons'] as $childButton => $childButtonData) |
|
512 | - $button_names[$childButton] = $childButtonData['title']; |
|
520 | + foreach ($buttonData['sub_buttons'] as $childButton => $childButtonData) { |
|
521 | + $button_names[$childButton] = $childButtonData['title']; |
|
522 | + } |
|
513 | 523 | |
514 | - if (!empty($childButtonData['sub_buttons'])) |
|
515 | - foreach ($childButtonData['sub_buttons'] as $grandChildButton => $grandChildButtonData) |
|
524 | + if (!empty($childButtonData['sub_buttons'])) { |
|
525 | + foreach ($childButtonData['sub_buttons'] as $grandChildButton => $grandChildButtonData) |
|
516 | 526 | $button_names[$grandChildButton] = $grandChildButtonData['title']; |
527 | + } |
|
517 | 528 | } |
518 | 529 | } |
519 | 530 |
@@ -9,12 +9,14 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // If SSI.php is in the same place as this file, and SMF isn't defined... |
12 | -if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) |
|
12 | +if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { |
|
13 | 13 | require_once(dirname(__FILE__) . '/SSI.php'); |
14 | +} |
|
14 | 15 | |
15 | 16 | // Hmm... no SSI.php and no SMF? |
16 | -elseif (!defined('SMF')) |
|
17 | +elseif (!defined('SMF')) { |
|
17 | 18 | die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.'); |
19 | +} |
|
18 | 20 | |
19 | 21 | $tables = array( |
20 | 22 | array( |
@@ -86,17 +88,19 @@ discard block |
||
86 | 88 | { |
87 | 89 | $smcFunc['db_create_table']('{db_prefix}' . $table['name'], $table['columns'], $table['indexes'], array(), 'update'); |
88 | 90 | |
89 | - if (isset($table['default'])) |
|
90 | - $smcFunc['db_insert']('ignore', '{db_prefix}' . $table['name'], $table['default']['columns'], $table['default']['values'], $table['default']['keys']); |
|
91 | -} |
|
91 | + if (isset($table['default'])) { |
|
92 | + $smcFunc['db_insert']('ignore', '{db_prefix}' . $table['name'], $table['default']['columns'], $table['default']['values'], $table['default']['keys']); |
|
93 | + } |
|
94 | + } |
|
92 | 95 | |
93 | 96 | $request = $smcFunc['db_query']('', ' |
94 | 97 | SELECT id_button, name, target, type, position, link, status, permissions, parent |
95 | 98 | FROM {db_prefix}um_menu'); |
96 | 99 | |
97 | 100 | $buttons = array(); |
98 | -while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
101 | +while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
99 | 102 | $buttons['um_button_' . $row['id_button']] = json_encode($row); |
103 | +} |
|
100 | 104 | $smcFunc['db_free_result']($request); |
101 | 105 | updateSettings( |
102 | 106 | array( |
@@ -191,7 +191,7 @@ |
||
191 | 191 | $admin_areas['config']['areas']['umen'] = array( |
192 | 192 | 'label' => $txt['um_admin_menu'], |
193 | 193 | 'file' => 'ManageUltimateMenu.php', |
194 | - 'function' => function () { |
|
194 | + 'function' => function() { |
|
195 | 195 | new ManageUltimateMenu; |
196 | 196 | }, |
197 | 197 | 'icon' => 'umen.png', |
@@ -8,8 +8,9 @@ discard block |
||
8 | 8 | * @license http://opensource.org/licenses/MIT MIT |
9 | 9 | */ |
10 | 10 | |
11 | -if (!defined('SMF')) |
|
11 | +if (!defined('SMF')) { |
|
12 | 12 | die('Hacking attempt...'); |
13 | +} |
|
13 | 14 | |
14 | 15 | function um_load_menu(&$menu_buttons) |
15 | 16 | { |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | for ($i = 1; $i <= $num_buttons; $i++) |
30 | 31 | { |
31 | 32 | $key = 'um_button_' . $i; |
32 | - if (!isset($modSettings[$key])) |
|
33 | - break; |
|
33 | + if (!isset($modSettings[$key])) { |
|
34 | + break; |
|
35 | + } |
|
34 | 36 | $row = json_decode($modSettings[$key], true); |
35 | 37 | $temp_menu = array( |
36 | 38 | 'title' => $row['name'], |
@@ -50,21 +52,18 @@ discard block |
||
50 | 52 | insert_button(array($key => $temp_menu), $menu_buttons, $row['parent'], $row['position']); |
51 | 53 | break; |
52 | 54 | } |
53 | - } |
|
54 | - elseif ($row['position'] == 'child_of') |
|
55 | + } elseif ($row['position'] == 'child_of') |
|
55 | 56 | { |
56 | 57 | $info['sub_buttons'][$key] = $temp_menu; |
57 | 58 | break; |
58 | 59 | } |
59 | - } |
|
60 | - elseif (isset($info['sub_buttons'][$row['parent']])) |
|
60 | + } elseif (isset($info['sub_buttons'][$row['parent']])) |
|
61 | 61 | { |
62 | 62 | if ($row['position'] == 'before' || $row['position'] == 'after') |
63 | 63 | { |
64 | 64 | insert_button(array($key => $temp_menu), $info['sub_buttons'], $row['parent'], $row['position']); |
65 | 65 | break; |
66 | - } |
|
67 | - elseif ($row['position'] == 'child_of') |
|
66 | + } elseif ($row['position'] == 'child_of') |
|
68 | 67 | { |
69 | 68 | $info['sub_buttons'][$row['parent']]['sub_buttons'][$key] = $temp_menu; |
70 | 69 | break; |
@@ -88,8 +87,9 @@ discard block |
||
88 | 87 | global $context, $modSettings, $smcFunc, $sourcedir, $txt; |
89 | 88 | |
90 | 89 | // We'll need this for loading up the names of each group. |
91 | - if (!loadLanguage('ManageBoards')) |
|
92 | - loadLanguage('ManageBoards'); |
|
90 | + if (!loadLanguage('ManageBoards')) { |
|
91 | + loadLanguage('ManageBoards'); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | $checked = explode(',', $checked); |
95 | 95 | $disallowed = explode(',', $disallowed); |
@@ -104,23 +104,25 @@ discard block |
||
104 | 104 | |
105 | 105 | $groups = array(); |
106 | 106 | |
107 | - if (!in_array(-1, $disallowed)) |
|
108 | - // Guests |
|
107 | + if (!in_array(-1, $disallowed)) { |
|
108 | + // Guests |
|
109 | 109 | $groups[-1] = array( |
110 | 110 | 'id' => -1, |
111 | 111 | 'name' => $txt['parent_guests_only'], |
112 | 112 | 'checked' => in_array(-1, $checked) || in_array(-3, $checked), |
113 | 113 | 'is_post_group' => false, |
114 | 114 | ); |
115 | + } |
|
115 | 116 | |
116 | - if (!in_array(0, $disallowed)) |
|
117 | - // Regular Members |
|
117 | + if (!in_array(0, $disallowed)) { |
|
118 | + // Regular Members |
|
118 | 119 | $groups[0] = array( |
119 | 120 | 'id' => 0, |
120 | 121 | 'name' => $txt['parent_members_only'], |
121 | 122 | 'checked' => in_array(0, $checked) || in_array(-3, $checked), |
122 | 123 | 'is_post_group' => false, |
123 | 124 | ); |
125 | + } |
|
124 | 126 | |
125 | 127 | // Load membergroups. |
126 | 128 | $request = $smcFunc['db_query']('', ' |
@@ -135,14 +137,15 @@ discard block |
||
135 | 137 | 'min_posts' => -1, |
136 | 138 | ) |
137 | 139 | ); |
138 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
139 | - if (!in_array($row['id_group'], $disallowed)) |
|
140 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
141 | + if (!in_array($row['id_group'], $disallowed)) |
|
140 | 142 | $groups[(int) $row['id_group']] = array( |
141 | 143 | 'id' => $row['id_group'], |
142 | 144 | 'name' => trim($row['group_name']), |
143 | 145 | 'checked' => in_array($row['id_group'], $checked) || in_array(-3, $checked), |
144 | 146 | 'is_post_group' => $row['min_posts'] != -1, |
145 | 147 | ); |
148 | + } |
|
146 | 149 | $smcFunc['db_free_result']($request); |
147 | 150 | |
148 | 151 | asort($groups); |
@@ -156,27 +159,31 @@ discard block |
||
156 | 159 | { |
157 | 160 | $offset = 0; |
158 | 161 | |
159 | - foreach ($haystack as $area => $dummy) |
|
160 | - if (++$offset && $area == $insertion_point) |
|
162 | + foreach ($haystack as $area => $dummy) { |
|
163 | + if (++$offset && $area == $insertion_point) |
|
161 | 164 | break; |
165 | + } |
|
162 | 166 | |
163 | - if ($where == 'before') |
|
164 | - $offset--; |
|
167 | + if ($where == 'before') { |
|
168 | + $offset--; |
|
169 | + } |
|
165 | 170 | |
166 | 171 | $haystack = array_slice($haystack, 0, $offset, true) + $needle + array_slice($haystack, $offset, null, true); |
167 | - } |
|
168 | - else |
|
169 | - foreach ($haystack as $stack) |
|
172 | + } else { |
|
173 | + foreach ($haystack as $stack) |
|
170 | 174 | if (array_key_exists($insertion_point, $haystack[$stack])) |
171 | 175 | { |
172 | 176 | $offset = 0; |
177 | + } |
|
173 | 178 | |
174 | - foreach ($haystack[$stack] as $area => $dummy) |
|
175 | - if (++$offset && $area == $insertion_point) |
|
179 | + foreach ($haystack[$stack] as $area => $dummy) { |
|
180 | + if (++$offset && $area == $insertion_point) |
|
176 | 181 | break; |
182 | + } |
|
177 | 183 | |
178 | - if ($where == 'before') |
|
179 | - $offset--; |
|
184 | + if ($where == 'before') { |
|
185 | + $offset--; |
|
186 | + } |
|
180 | 187 | |
181 | 188 | $haystack[$stack] = array_slice($haystack[$stack], 0, $offset, true) + $needle + array_slice($haystack[$stack], $offset, null, true); |
182 | 189 | break; |
@@ -9,17 +9,21 @@ |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // If SSI.php is in the same place as this file, and SMF isn't defined... |
12 | -if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) |
|
12 | +if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF')) { |
|
13 | 13 | require_once(dirname(__FILE__) . '/SSI.php'); |
14 | +} |
|
14 | 15 | |
15 | 16 | // Hmm... no SSI.php and no SMF? |
16 | -elseif (!defined('SMF')) |
|
17 | +elseif (!defined('SMF')) { |
|
17 | 18 | die('<b>Error:</b> Cannot uninstall - please verify you put this in the same place as SMF\'s index.php.'); |
19 | +} |
|
18 | 20 | |
19 | -if (isset($modSettings['um_menu'])) |
|
21 | +if (isset($modSettings['um_menu'])) { |
|
20 | 22 | unset($modSettings['um_menu']); |
21 | -if (isset($modSettings['um_count'])) |
|
23 | +} |
|
24 | +if (isset($modSettings['um_count'])) { |
|
22 | 25 | unset($modSettings['um_count']); |
26 | +} |
|
23 | 27 | |
24 | 28 | $smcFunc['db_query']('', ' |
25 | 29 | DELETE FROM {db_prefix}settings |