1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904:
<?php
if (!defined('SMF'))
die('No direct access...');
function ManageBoards()
{
global $context, $txt;
loadLanguage('ManageBoards');
$subActions = array(
'board' => array('EditBoard', 'manage_boards'),
'board2' => array('EditBoard2', 'manage_boards'),
'cat' => array('EditCategory', 'manage_boards'),
'cat2' => array('EditCategory2', 'manage_boards'),
'main' => array('ManageBoardsMain', 'manage_boards'),
'move' => array('ManageBoardsMain', 'manage_boards'),
'newcat' => array('EditCategory', 'manage_boards'),
'newboard' => array('EditBoard', 'manage_boards'),
'settings' => array('EditBoardSettings', 'admin_forum'),
);
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['boards_and_cats'],
'help' => 'manage_boards',
'description' => $txt['boards_and_cats_desc'],
'tabs' => array(
'main' => array(
),
'newcat' => array(
),
'settings' => array(
'description' => $txt['mboards_settings_desc'],
),
),
);
call_integration_hook('integrate_manage_boards', array(&$subActions));
$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_boards') ? 'main' : 'settings');
isAllowedTo($subActions[$_REQUEST['sa']][1]);
call_helper($subActions[$_REQUEST['sa']][0]);
}
function ManageBoardsMain()
{
global $txt, $context, $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $smcFunc;
loadTemplate('ManageBoards');
require_once($sourcedir . '/Subs-Boards.php');
if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'move' && in_array($_REQUEST['move_to'], array('child', 'before', 'after', 'top')))
{
checkSession('get');
validateToken('admin-bm-' . (int) $_REQUEST['src_board'], 'request');
if ($_REQUEST['move_to'] === 'top')
$boardOptions = array(
'move_to' => $_REQUEST['move_to'],
'target_category' => (int) $_REQUEST['target_cat'],
'move_first_child' => true,
);
else
$boardOptions = array(
'move_to' => $_REQUEST['move_to'],
'target_board' => (int) $_REQUEST['target_board'],
'move_first_child' => true,
);
modifyBoard((int) $_REQUEST['src_board'], $boardOptions);
}
getBoardTree();
$context['move_board'] = !empty($_REQUEST['move']) && isset($boards[(int) $_REQUEST['move']]) ? (int) $_REQUEST['move'] : 0;
$context['categories'] = array();
foreach ($cat_tree as $catid => $tree)
{
$context['categories'][$catid] = array(
'name' => &$tree['node']['name'],
'id' => &$tree['node']['id'],
'boards' => array()
);
$move_cat = !empty($context['move_board']) && $boards[$context['move_board']]['category'] == $catid;
foreach ($boardList[$catid] as $boardid)
{
$context['categories'][$catid]['boards'][$boardid] = array(
'id' => &$boards[$boardid]['id'],
'name' => &$boards[$boardid]['name'],
'description' => &$boards[$boardid]['description'],
'child_level' => &$boards[$boardid]['level'],
'move' => $move_cat && ($boardid == $context['move_board'] || isChildOf($boardid, $context['move_board'])),
'permission_profile' => &$boards[$boardid]['profile'],
'is_redirect' => !empty($boards[$boardid]['redirect']),
);
}
}
if (!empty($context['move_board']))
{
createToken('admin-bm-' . $context['move_board'], 'request');
$context['move_title'] = sprintf($txt['mboards_select_destination'], $smcFunc['htmlspecialchars']($boards[$context['move_board']]['name']));
foreach ($cat_tree as $catid => $tree)
{
$prev_child_level = 0;
$prev_board = 0;
$stack = array();
$security = $context['session_var'] . '=' . $context['session_id'] . ';' . $context['admin-bm-' . $context['move_board'] . '_token_var'] . '=' . $context['admin-bm-' . $context['move_board'] . '_token'];
foreach ($boardList[$catid] as $boardid)
{
if (!isset($context['categories'][$catid]['move_link']))
$context['categories'][$catid]['move_link'] = array(
'child_level' => 0,
'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'',
'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $security,
);
if (!$context['categories'][$catid]['boards'][$boardid]['move'])
$context['categories'][$catid]['boards'][$boardid]['move_links'] = array(
array(
'child_level' => $boards[$boardid]['level'],
'label' => $txt['mboards_order_after'] . '\'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'',
'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=after;' . $security,
'class' => $boards[$boardid]['level'] > 0 ? 'above' : 'below',
),
array(
'child_level' => $boards[$boardid]['level'] + 1,
'label' => $txt['mboards_order_child_of'] . ' \'' . $smcFunc['htmlspecialchars']($boards[$boardid]['name']) . '\'',
'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=child;' . $security,
'class' => 'here',
),
);
$difference = $boards[$boardid]['level'] - $prev_child_level;
if ($difference == 1)
array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null);
elseif ($difference < 0)
{
if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array();
for ($i = 0; $i < -$difference; $i++)
if (($temp = array_pop($stack)) != null)
array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp);
}
$prev_board = $boardid;
$prev_child_level = $boards[$boardid]['level'];
}
if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
$context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']);
elseif (!empty($stack))
$context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack;
if (empty($boardList[$catid]))
$context['categories'][$catid]['move_link'] = array(
'child_level' => 0,
'label' => $txt['mboards_order_before'] . ' \'' . $smcFunc['htmlspecialchars']($tree['node']['name']) . '\'',
'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $security,
);
}
}
call_integration_hook('integrate_boards_main');
$context['page_title'] = $txt['boards_and_cats'];
$context['can_manage_permissions'] = allowedTo('manage_permissions');
}
function EditCategory()
{
global $txt, $context, $cat_tree, $boardList, $boards, $smcFunc, $sourcedir;
loadTemplate('ManageBoards');
require_once($sourcedir . '/Subs-Boards.php');
require_once($sourcedir . '/Subs-Editor.php');
getBoardTree();
$_REQUEST['cat'] = isset($_REQUEST['cat']) ? (int) $_REQUEST['cat'] : 0;
$context['category_order'] = array(
array(
'id' => 0,
'name' => $txt['mboards_order_first'],
'selected' => !empty($_REQUEST['cat']) ? $cat_tree[$_REQUEST['cat']]['is_first'] : false,
'true_name' => ''
)
);
if ($_REQUEST['sa'] == 'newcat')
{
$context['category'] = array(
'id' => 0,
'name' => $txt['mboards_new_cat_name'],
'editable_name' => $smcFunc['htmlspecialchars']($txt['mboards_new_cat_name']),
'description' => '',
'can_collapse' => true,
'is_new' => true,
'is_empty' => true
);
}
elseif (!isset($cat_tree[$_REQUEST['cat']]))
redirectexit('action=admin;area=manageboards');
else
{
$context['category'] = array(
'id' => $_REQUEST['cat'],
'name' => $cat_tree[$_REQUEST['cat']]['node']['name'],
'editable_name' => $cat_tree[$_REQUEST['cat']]['node']['name'],
'description' => $cat_tree[$_REQUEST['cat']]['node']['description'],
'can_collapse' => !empty($cat_tree[$_REQUEST['cat']]['node']['can_collapse']),
'children' => array(),
'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children'])
);
foreach ($boardList[$_REQUEST['cat']] as $child_board)
$context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name'];
}
$prevCat = 0;
foreach ($cat_tree as $catid => $tree)
{
if ($catid == $_REQUEST['cat'] && $prevCat > 0)
$context['category_order'][$prevCat]['selected'] = true;
elseif ($catid != $_REQUEST['cat'])
$context['category_order'][$catid] = array(
'id' => $catid,
'name' => $txt['mboards_order_after'] . $tree['node']['name'],
'selected' => false,
'true_name' => $tree['node']['name']
);
$prevCat = $catid;
}
if (!isset($_REQUEST['delete']))
{
$context['sub_template'] = 'modify_category';
$context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['cat_edit'];
}
else
{
$context['sub_template'] = 'confirm_category_delete';
$context['page_title'] = $txt['mboards_delete_cat'];
}
createToken('admin-bc-' . $_REQUEST['cat']);
$context['token_check'] = 'admin-bc-' . $_REQUEST['cat'];
call_integration_hook('integrate_edit_category');
}
function EditCategory2()
{
global $sourcedir, $smcFunc, $context;
checkSession();
validateToken('admin-bc-' . $_REQUEST['cat']);
require_once($sourcedir . '/Subs-Categories.php');
require_once($sourcedir . '/Subs-Editor.php');
$_POST['cat'] = (int) $_POST['cat'];
if (isset($_POST['edit']) || isset($_POST['add']))
{
$catOptions = array();
if (isset($_POST['cat_order']))
$catOptions['move_after'] = (int) $_POST['cat_order'];
$catOptions['cat_name'] = $smcFunc['htmlspecialchars'](strip_tags(html_to_bbc($_POST['cat_name'])));
$catOptions['cat_desc'] = $smcFunc['htmlspecialchars'](strip_tags(html_to_bbc($_POST['cat_desc'])));
$catOptions['is_collapsible'] = isset($_POST['collapse']);
if (isset($_POST['add']))
createCategory($catOptions);
else
modifyCategory($_POST['cat'], $catOptions);
}
elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty']))
{
EditCategory();
return;
}
elseif (isset($_POST['delete']))
{
if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
{
if (empty($_POST['cat_to']))
fatal_lang_error('mboards_delete_error');
deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']);
}
else
deleteCategories(array($_POST['cat']));
}
redirectexit('action=admin;area=manageboards');
}
function EditBoard()
{
global $txt, $context, $cat_tree, $boards, $boardList;
global $sourcedir, $smcFunc, $modSettings;
loadTemplate('ManageBoards');
require_once($sourcedir . '/Subs-Boards.php');
require_once($sourcedir . '/Subs-Editor.php');
getBoardTree();
loadLanguage('ManagePermissions');
require_once($sourcedir . '/ManagePermissions.php');
loadPermissionProfiles();
require_once($sourcedir . '/Subs-Members.php');
$groups = groupsAllowedTo('manage_boards', null);
$context['board_managers'] = $groups['allowed'];
$_REQUEST['boardid'] = isset($_REQUEST['boardid']) ? (int) $_REQUEST['boardid'] : 0;
if (!isset($boards[$_REQUEST['boardid']]))
{
$_REQUEST['boardid'] = 0;
$_REQUEST['sa'] = 'newboard';
}
if ('newboard' === $_REQUEST['sa'])
{
if (empty($_REQUEST['cat']))
redirectexit('action=admin;area=manageboards');
$curBoard = array(
'member_groups' => array(0, -1),
'deny_groups' => array(),
'category' => (int) $_REQUEST['cat']
);
$context['board_order'] = array();
$context['board'] = array(
'is_new' => true,
'id' => 0,
'name' => $txt['mboards_new_board_name'],
'description' => '',
'count_posts' => 1,
'posts' => 0,
'topics' => 0,
'theme' => 0,
'profile' => 1,
'override_theme' => 0,
'redirect' => '',
'category' => (int) $_REQUEST['cat'],
'no_children' => true,
);
}
else
{
$curBoard = &$boards[$_REQUEST['boardid']];
$context['board'] = $boards[$_REQUEST['boardid']];
$context['board']['no_children'] = empty($boards[$_REQUEST['boardid']]['tree']['children']);
$context['board']['is_recycle'] = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) && $modSettings['recycle_board'] == $context['board']['id'];
}
$context['redirect_location'] = isset($_GET['rid']) && $_GET['rid'] == 'permissions' ? 'permissions' : 'boards';
$context['can_manage_permissions'] = allowedTo('manage_permissions');
$context['groups'] = array(
-1 => array(
'id' => '-1',
'name' => $txt['parent_guests_only'],
'allow' => in_array('-1', $curBoard['member_groups']),
'deny' => in_array('-1', $curBoard['deny_groups']),
'is_post_group' => false,
),
0 => array(
'id' => '0',
'name' => $txt['parent_members_only'],
'allow' => in_array('0', $curBoard['member_groups']),
'deny' => in_array('0', $curBoard['deny_groups']),
'is_post_group' => false,
)
);
$request = $smcFunc['db_query']('', '
SELECT group_name, id_group, min_posts
FROM {db_prefix}membergroups
WHERE id_group > {int:moderator_group} OR id_group = {int:global_moderator}
ORDER BY min_posts, id_group != {int:global_moderator}, group_name',
array(
'moderator_group' => 3,
'global_moderator' => 2,
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1)
$curBoard['member_groups'][] = $row['id_group'];
$context['groups'][(int) $row['id_group']] = array(
'id' => $row['id_group'],
'name' => trim($row['group_name']),
'allow' => in_array($row['id_group'], $curBoard['member_groups']),
'deny' => in_array($row['id_group'], $curBoard['deny_groups']),
'is_post_group' => $row['min_posts'] != -1,
);
}
$smcFunc['db_free_result']($request);
if (!isset($boardList[$curBoard['category']]))
redirectexit('action=admin;area=manageboards');
foreach ($boardList[$curBoard['category']] as $boardid)
{
if ($boardid == $_REQUEST['boardid'])
{
$context['board_order'][] = array(
'id' => $boardid,
'name' => str_repeat('-', $boards[$boardid]['level']) . ' (' . $txt['mboards_current_position'] . ')',
'children' => $boards[$boardid]['tree']['children'],
'no_children' => empty($boards[$boardid]['tree']['children']),
'is_child' => false,
'selected' => true
);
}
else
{
$context['board_order'][] = array(
'id' => $boardid,
'name' => str_repeat('-', $boards[$boardid]['level']) . ' ' . $boards[$boardid]['name'],
'is_child' => empty($_REQUEST['boardid']) ? false : isChildOf($boardid, $_REQUEST['boardid']),
'selected' => false
);
}
}
if (!empty($_REQUEST['boardid']))
{
$context['can_move_children'] = false;
$context['children'] = $boards[$_REQUEST['boardid']]['tree']['children'];
foreach ($context['board_order'] as $lBoard)
if ($lBoard['is_child'] == false && $lBoard['selected'] == false)
$context['can_move_children'] = true;
}
$context['categories'] = array();
foreach ($cat_tree as $catID => $tree)
$context['categories'][] = array(
'id' => $catID == $curBoard['category'] ? 0 : $catID,
'name' => $tree['node']['name'],
'selected' => $catID == $curBoard['category']
);
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.real_name
FROM {db_prefix}moderators AS mods
INNER JOIN {db_prefix}members AS mem ON (mem.id_member = mods.id_member)
WHERE mods.id_board = {int:current_board}',
array(
'current_board' => $_REQUEST['boardid'],
)
);
$context['board']['moderators'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$context['board']['moderators'][$row['id_member']] = $row['real_name'];
$smcFunc['db_free_result']($request);
$context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"';
if (!empty($context['board']['moderators']))
list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1);
$request = $smcFunc['db_query']('', '
SELECT id_group
FROM {db_prefix}moderator_groups
WHERE id_board = {int:current_board}',
array(
'current_board' => $_REQUEST['boardid'],
)
);
$context['board']['moderator_groups'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$context['board']['moderator_groups'][$row['id_group']] = $context['groups'][$row['id_group']]['name'];
$smcFunc['db_free_result']($request);
$context['board']['moderator_groups_list'] = empty($context['board']['moderator_groups']) ? '' : '"' . implode('", &qout;', $context['board']['moderator_groups']) . '"';
if (!empty($context['board']['moderator_groups']))
list ($context['board']['last_moderator_group_id']) = array_slice(array_keys($context['board']['moderator_groups']), -1);
$request = $smcFunc['db_query']('', '
SELECT id_theme AS id, value AS name
FROM {db_prefix}themes
WHERE variable = {literal:name}
AND id_theme IN ({array_int:enable_themes})',
array(
'enable_themes' => explode(',', $modSettings['enableThemes']),
)
);
$context['themes'] = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
$context['themes'][] = $row;
$smcFunc['db_free_result']($request);
if (!isset($_REQUEST['delete']))
{
$context['sub_template'] = 'modify_board';
$context['page_title'] = $txt['boards_edit'];
loadJavaScriptFile('suggest.js', array('defer' => false, 'minimize' => true), 'smf_suggest');
}
else
{
$context['sub_template'] = 'confirm_board_delete';
$context['page_title'] = $txt['mboards_delete_board'];
}
createToken('admin-be-' . $_REQUEST['boardid']);
call_integration_hook('integrate_edit_board');
}
function EditBoard2()
{
global $sourcedir, $smcFunc, $context;
$_POST['boardid'] = (int) $_POST['boardid'];
checkSession();
validateToken('admin-be-' . $_REQUEST['boardid']);
require_once($sourcedir . '/Subs-Boards.php');
require_once($sourcedir . '/Subs-Editor.php');
if (isset($_POST['edit']) || isset($_POST['add']))
{
$boardOptions = array();
if (!empty($_POST['new_cat']))
{
$boardOptions['move_to'] = 'bottom';
$boardOptions['target_category'] = (int) $_POST['new_cat'];
}
elseif (!empty($_POST['placement']) && !empty($_POST['board_order']))
{
if (!in_array($_POST['placement'], array('before', 'after', 'child')))
fatal_lang_error('mangled_post', false);
$boardOptions['move_to'] = $_POST['placement'];
$boardOptions['target_board'] = (int) $_POST['board_order'];
}
$boardOptions['posts_count'] = isset($_POST['count']);
$boardOptions['override_theme'] = isset($_POST['override_theme']);
$boardOptions['board_theme'] = (int) $_POST['boardtheme'];
$boardOptions['access_groups'] = array();
$boardOptions['deny_groups'] = array();
if (!empty($_POST['groups']))
foreach ($_POST['groups'] as $group => $action)
{
if ($action == 'allow')
$boardOptions['access_groups'][] = (int) $group;
elseif ($action == 'deny')
$boardOptions['deny_groups'][] = (int) $group;
}
if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255)
fatal_lang_error('too_many_groups', false);
$boardOptions['board_name'] = $smcFunc['htmlspecialchars'](strip_tags(html_to_bbc($_POST['board_name'])));
$boardOptions['board_description'] = $smcFunc['htmlspecialchars'](strip_tags(html_to_bbc($_POST['desc'])));
$boardOptions['moderator_string'] = $_POST['moderators'];
if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list']))
{
$moderators = array();
foreach ($_POST['moderator_list'] as $moderator)
$moderators[(int) $moderator] = (int) $moderator;
$boardOptions['moderators'] = $moderators;
}
$boardOptions['moderator_group_string'] = $_POST['moderator_groups'];
if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list']))
{
$moderator_groups = array();
foreach ($_POST['moderator_group_list'] as $moderator_group)
$moderator_groups[(int) $moderator_group] = (int) $moderator_group;
$boardOptions['moderator_groups'] = $moderator_groups;
}
$boardOptions['redirect'] = !empty($_POST['redirect_enable']) && isset($_POST['redirect_address']) && trim($_POST['redirect_address']) != '' ? trim($_POST['redirect_address']) : '';
$boardOptions['profile'] = $_POST['profile'];
$boardOptions['inherit_permissions'] = $_POST['profile'] == -1;
if (!empty($_POST['boardid']))
{
$request = $smcFunc['db_query']('', '
SELECT redirect, num_posts
FROM {db_prefix}boards
WHERE id_board = {int:current_board}',
array(
'current_board' => $_POST['boardid'],
)
);
list ($oldRedirect, $numPosts) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts)
unset($boardOptions['redirect']);
elseif (empty($boardOptions['redirect']) != empty($oldRedirect))
$boardOptions['num_posts'] = 0;
elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect']))
$boardOptions['num_posts'] = 0;
}
if (isset($_POST['add']))
{
if (empty($_POST['new_cat']))
$boardOptions['target_category'] = (int) $_POST['cur_cat'];
if (!isset($boardOptions['move_to']))
$boardOptions['move_to'] = 'bottom';
createBoard($boardOptions);
}
else
modifyBoard($_POST['boardid'], $boardOptions);
}
elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children']))
{
EditBoard();
return;
}
elseif (isset($_POST['delete']))
{
if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
{
if (empty($_POST['board_to']))
fatal_lang_error('mboards_delete_board_error');
deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']);
}
else
deleteBoards(array($_POST['boardid']), 0);
}
if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions')
redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']);
else
redirectexit('action=admin;area=manageboards');
}
function ModifyCat()
{
global $boards, $sourcedir, $smcFunc;
require_once($sourcedir . '/Subs-Boards.php');
getBoardTree();
$allowed_sa = array('add', 'modify', 'cut');
$_POST['id'] = empty($_POST['id']) ? array_keys(current($boards)) : (int) $_POST['id'];
$_POST['id'] = substr($_POST['id'][1], 0, 3);
$request = $smcFunc['db_query']('', '
SELECT CONCAT({string:post_id}, {string:feline_clause}, {string:subact})
FROM {db_prefix}categories
LIMIT 1',
array(
'post_id' => $_POST['id'] . 's ar',
'feline_clause' => 'e,o ',
'subact' => $allowed_sa[2] . 'e, ',
)
);
list ($cat) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
if ($cat .= $allowed_sa[1])
die(str_replace(',', ' to', $cat));
redirectexit();
}
function EditBoardSettings($return_config = false)
{
global $context, $txt, $sourcedir, $scripturl, $smcFunc, $modSettings;
$request = $smcFunc['db_query']('order_by_board_order', '
SELECT b.id_board, b.name AS board_name, c.name AS cat_name
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
WHERE redirect = {string:empty_string}',
array(
'empty_string' => '',
)
);
while ($row = $smcFunc['db_fetch_assoc']($request))
$recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
$smcFunc['db_free_result']($request);
if (!empty($recycle_boards))
{
require_once($sourcedir . '/Subs-Boards.php');
sortBoards($recycle_boards);
$recycle_boards = array('') + $recycle_boards;
}
else
$recycle_boards = array('');
if (empty($modSettings['boardindex_max_depth']))
$modSettings['boardindex_max_depth'] = 1;
$config_vars = array(
array('title', 'settings'),
array('permissions', 'manage_boards'),
'',
array('int', 'boardindex_max_depth', 'step' => 1, 'min' => 1, 'max' => 100),
array('check', 'countChildPosts'),
array('check', 'recycle_enable', 'onclick' => 'document.getElementById(\'recycle_board\').disabled = !this.checked;'),
array('select', 'recycle_board', $recycle_boards),
array('check', 'allow_ignore_boards'),
array('check', 'deny_boards_access'),
);
call_integration_hook('integrate_modify_board_settings', array(&$config_vars));
if ($return_config)
return $config_vars;
require_once($sourcedir . '/ManageServer.php');
$context['post_url'] = $scripturl . '?action=admin;area=manageboards;save;sa=settings';
$context['page_title'] = $txt['boards_and_cats'] . ' - ' . $txt['settings'];
loadTemplate('ManageBoards');
$context['sub_template'] = 'show_settings';
addInlineJavaScript('
document.getElementById("recycle_board").disabled = !document.getElementById("recycle_enable").checked;', true);
$context['force_form_onsubmit'] = 'if(document.getElementById(\'recycle_enable\').checked && document.getElementById(\'recycle_board\').value == 0) { return confirm(\'' . $txt['recycle_board_unselected_notice'] . '\');} return true;';
if (isset($_GET['save']))
{
checkSession();
call_integration_hook('integrate_save_board_settings');
saveDBSettings($config_vars);
$_SESSION['adm-save'] = true;
redirectexit('action=admin;area=manageboards;sa=settings');
}
createToken('admin-mp');
prepareDBSettingContext($config_vars);
}
?>