[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 // Disallow direct access to this file for security reasons 13 if(!defined("IN_MYBB")) 14 { 15 die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); 16 } 17 18 $page->add_breadcrumb_item($lang->forum_management, "index.php?module=forum-management"); 19 20 if($mybb->input['action'] == "add" || $mybb->input['action'] == "edit" || $mybb->input['action'] == "copy" || $mybb->input['action'] == "permissions" || !$mybb->input['action']) 21 { 22 if(isset($mybb->input['fid']) && ($mybb->input['action'] == "management" || $mybb->input['action'] == "edit" || $mybb->input['action'] == "copy" || !$mybb->input['action'])) 23 { 24 $sub_tabs['view_forum'] = array( 25 'title' => $lang->view_forum, 26 'link' => "index.php?module=forum-management&fid=".$mybb->input['fid'], 27 'description' => $lang->view_forum_desc 28 ); 29 30 $sub_tabs['add_child_forum'] = array( 31 'title' => $lang->add_child_forum, 32 'link' => "index.php?module=forum-management&action=add&pid=".$mybb->input['fid'], 33 'description' => $lang->view_forum_desc 34 ); 35 36 $sub_tabs['edit_forum_settings'] = array( 37 'title' => $lang->edit_forum_settings, 38 'link' => "index.php?module=forum-management&action=edit&fid=".$mybb->input['fid'], 39 'description' => $lang->edit_forum_settings_desc 40 ); 41 42 $sub_tabs['copy_forum'] = array( 43 'title' => $lang->copy_forum, 44 'link' => "index.php?module=forum-management&action=copy&fid=".$mybb->input['fid'], 45 'description' => $lang->copy_forum_desc 46 ); 47 } 48 else 49 { 50 $sub_tabs['forum_management'] = array( 51 'title' => $lang->forum_management, 52 'link' => "index.php?module=forum-management", 53 'description' => $lang->forum_management_desc 54 ); 55 56 $sub_tabs['add_forum'] = array( 57 'title' => $lang->add_forum, 58 'link' => "index.php?module=forum-management&action=add", 59 'description' => $lang->add_forum_desc 60 ); 61 } 62 } 63 64 $plugins->run_hooks("admin_forum_management_begin"); 65 66 if($mybb->input['action'] == "copy") 67 { 68 $plugins->run_hooks("admin_forum_management_copy"); 69 70 if($mybb->request_method == "post") 71 { 72 $from = intval($mybb->input['from']); 73 $to = intval($mybb->input['to']); 74 75 // Find the source forum 76 $query = $db->simple_select("forums", '*', "fid='{$from}'"); 77 $from_forum = $db->fetch_array($query); 78 if(!$db->num_rows($query)) 79 { 80 $errors[] = $lang->error_invalid_source_forum; 81 } 82 83 if($to == -1) 84 { 85 // Create a new forum 86 if(empty($mybb->input['title'])) 87 { 88 $errors[] = $lang->error_new_forum_needs_name; 89 } 90 91 if($mybb->input['pid'] == -1 && $mybb->input['type'] == 'f') 92 { 93 $errors[] = $lang->error_no_parent; 94 } 95 96 if(!$errors) 97 { 98 $new_forum = $from_forum; 99 unset($new_forum['fid'], $new_forum['threads'], $new_forum['posts'], $new_forum['lastpost'], $new_forum['lastposter'], $new_forum['lastposteruid'], $new_forum['lastposttid'], $new_forum['lastpostsubject'], $new_forum['unapprovedthreads'], $new_forum['unapprovedposts']); 100 $new_forum['name'] = $db->escape_string($mybb->input['title']); 101 $new_forum['description'] = $db->escape_string($mybb->input['description']); 102 $new_forum['type'] = $db->escape_string($mybb->input['type']); 103 $new_forum['pid'] = intval($mybb->input['pid']); 104 $new_forum['rulestitle'] = $db->escape_string($new_forum['rulestitle']); 105 $new_forum['rules'] = $db->escape_string($new_forum['rules']); 106 $new_forum['parentlist'] = ''; 107 108 $to = $db->insert_query("forums", $new_forum); 109 110 // Generate parent list 111 $parentlist = make_parent_list($to); 112 $updatearray = array( 113 'parentlist' => $parentlist 114 ); 115 $db->update_query("forums", $updatearray, "fid='{$to}'"); 116 } 117 } 118 elseif($mybb->input['copyforumsettings'] == 1) 119 { 120 // Copy settings to existing forum 121 $query = $db->simple_select("forums", '*', "fid='{$to}'"); 122 $to_forum = $db->fetch_array($query); 123 if(!$db->num_rows($query)) 124 { 125 $errors[] = $lang->error_invalid_destination_forum; 126 } 127 128 if(!$errors) 129 { 130 $new_forum = $from_forum; 131 unset($new_forum['fid'], $new_forum['threads'], $new_forum['posts'], $new_forum['lastpost'], $new_forum['lastposter'], $new_forum['lastposteruid'], $new_forum['lastposttid'], $new_forum['lastpostsubject'], $new_forum['unapprovedthreads'], $new_forum['unapprovedposts']); 132 $new_forum['name'] = $db->escape_string($to_forum['name']); 133 $new_forum['description'] = $db->escape_string($to_forum['description']); 134 $new_forum['pid'] = $db->escape_string($to_forum['pid']); 135 $new_forum['parentlist'] = $db->escape_string($to_forum['parentlist']); 136 $new_forum['rulestitle'] = $db->escape_string($new_forum['rulestitle']); 137 $new_forum['rules'] = $db->escape_string($new_forum['rules']); 138 139 $db->update_query("forums", $new_forum, "fid='{$to}'"); 140 } 141 } 142 143 if(!$errors) 144 { 145 // Copy permissions 146 if(is_array($mybb->input['copygroups']) && count($mybb->input['copygroups'] > 0)) 147 { 148 foreach($mybb->input['copygroups'] as $gid) 149 { 150 $groups[] = intval($gid); 151 } 152 $groups = implode(',', $groups); 153 $query = $db->simple_select("forumpermissions", '*', "fid='{$from}' AND gid IN ({$groups})"); 154 $db->delete_query("forumpermissions", "fid='{$to}' AND gid IN ({$groups})", 1); 155 while($permissions = $db->fetch_array($query)) 156 { 157 unset($permissions['pid']); 158 $permissions['fid'] = $to; 159 160 $db->insert_query("forumpermissions", $permissions); 161 } 162 163 // Log admin action 164 log_admin_action($from, $from_forum['name'], $to, $new_forum['name'], $groups); 165 } 166 else 167 { 168 // Log admin action (no group permissions) 169 log_admin_action($from, $from_forum['name'], $to, $new_forum['name']); 170 } 171 $cache->update_forums(); 172 $cache->update_forumpermissions(); 173 174 $plugins->run_hooks("admin_forum_management_copy_commit"); 175 176 flash_message($lang->success_forum_copied, 'success'); 177 admin_redirect("index.php?module=forum-management&action=edit&fid={$to}"); 178 } 179 } 180 181 $page->add_breadcrumb_item($lang->copy_forum); 182 $page->output_header($lang->copy_forum); 183 $page->output_nav_tabs($sub_tabs, 'copy_forum'); 184 185 $form = new Form("index.php?module=forum-management&action=copy", "post"); 186 187 if($errors) 188 { 189 $page->output_inline_error($errors); 190 $copy_data = $mybb->input; 191 } 192 else 193 { 194 $copy_data['type'] = "f"; 195 $copy_data['title'] = ""; 196 $copy_data['description'] = ""; 197 198 if(!$mybb->input['pid']) 199 { 200 $copy_data['pid'] = "-1"; 201 } 202 else 203 { 204 $copy_data['pid'] = intval($mybb->input['pid']); 205 } 206 $copy_data['disporder'] = "1"; 207 $copy_data['from'] = $mybb->input['fid']; 208 $copy_data['copyforumsettings'] = 0; 209 $copy_data['pid'] = 0; 210 } 211 212 $types = array( 213 'f' => $lang->forum, 214 'c' => $lang->category 215 ); 216 217 $create_a_options_f = array( 218 'id' => 'forum' 219 ); 220 221 $create_a_options_c = array( 222 'id' => 'category' 223 ); 224 225 if($copy_data['type'] == "f") 226 { 227 $create_a_options_f['checked'] = true; 228 } 229 else 230 { 231 $create_a_options_c['checked'] = true; 232 } 233 234 $usergroups = array(); 235 236 $query = $db->simple_select("usergroups", "gid, title", "gid != '1'", array('order_by' => 'title')); 237 while($usergroup = $db->fetch_array($query)) 238 { 239 $usergroups[$usergroup['gid']] = $usergroup['title']; 240 } 241 242 $form_container = new FormContainer($lang->copy_forum); 243 $form_container->output_row($lang->source_forum." <em>*</em>", $lang->source_forum_desc, $form->generate_forum_select('from', $copy_data['from'], array('id' => 'from')), 'from'); 244 $form_container->output_row($lang->destination_forum." <em>*</em>", $lang->destination_forum_desc, $form->generate_forum_select('to', $copy_data['to'], array('id' => 'to', 'main_option' => $lang->copy_to_new_forum)), 'to'); 245 $form_container->output_row($lang->copy_settings_and_properties, $lang->copy_settings_and_properties_desc, $form->generate_yes_no_radio('copyforumsettings', $copy_data['copyforumsettings'])); 246 $form_container->output_row($lang->copy_user_group_permissions, $lang->copy_user_group_permissions_desc, $form->generate_select_box('copygroups[]', $usergroups, $mybb->input['copygroups'], array('id' => 'copygroups', 'multiple' => true, 'size' => 5)), 'copygroups'); 247 248 $form_container->end(); 249 250 $form_container = new FormContainer($lang->new_forum_settings); 251 $form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f)."<br />\n".$form->generate_radio_button('type', 'c', $lang->category, $create_a_options_c)); 252 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $copy_data['title'], array('id' => 'title')), 'title'); 253 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $copy_data['description'], array('id' => 'description')), 'description'); 254 $form_container->output_row($lang->parent_forum." <em>*</em>", $lang->parent_forum_desc, $form->generate_forum_select('pid', $copy_data['pid'], array('id' => 'pid', 'main_option' => $lang->none)), 'pid'); 255 256 $form_container->end(); 257 258 $buttons[] = $form->generate_submit_button($lang->copy_forum); 259 $form->output_submit_wrapper($buttons); 260 $form->end(); 261 262 $page->output_footer(); 263 } 264 265 if($mybb->input['action'] == "editmod") 266 { 267 $query = $db->simple_select("moderators", "*", "mid='".intval($mybb->input['mid'])."'"); 268 $mod_data = $db->fetch_array($query); 269 270 $plugins->run_hooks("admin_forum_management_editmod"); 271 272 if(!$mod_data['id']) 273 { 274 flash_message($lang->error_incorrect_moderator, 'error'); 275 admin_redirect("index.php?module=forum-management"); 276 } 277 278 if($mod_data['isgroup']) 279 { 280 $fieldname = "title"; 281 } 282 else 283 { 284 $fieldname = "username"; 285 } 286 287 if($mybb->request_method == "post") 288 { 289 $mid = intval($mybb->input['mid']); 290 if(!$mid) 291 { 292 flash_message($lang->error_incorrect_moderator, 'error'); 293 admin_redirect("index.php?module=forum-management"); 294 } 295 296 if(!$errors) 297 { 298 $fid = intval($mybb->input['fid']); 299 $forum = get_forum($fid); 300 if($mod_data['isgroup']) 301 { 302 $mod = $groupscache[$mod_data['id']]; 303 } 304 else 305 { 306 $mod = get_user($mod_data['id']); 307 } 308 $update_array = array( 309 'fid' => intval($fid), 310 'caneditposts' => intval($mybb->input['caneditposts']), 311 'candeleteposts' => intval($mybb->input['candeleteposts']), 312 'canviewips' => intval($mybb->input['canviewips']), 313 'canopenclosethreads' => intval($mybb->input['canopenclosethreads']), 314 'canmanagethreads' => intval($mybb->input['canmanagethreads']), 315 'canmovetononmodforum' => intval($mybb->input['canmovetononmodforum']), 316 'canusecustomtools' => intval($mybb->input['canusecustomtools']) 317 ); 318 $db->update_query("moderators", $update_array, "mid='".intval($mybb->input['mid'])."'"); 319 320 $cache->update_moderators(); 321 322 $plugins->run_hooks("admin_forum_management_editmod_commit"); 323 324 // Log admin action 325 log_admin_action($fid, $forum['name'], $mid, $mod[$fieldname]); 326 327 flash_message($lang->success_moderator_updated, 'success'); 328 admin_redirect("index.php?module=forum-management&fid=".intval($mybb->input['fid'])."#tab_moderators"); 329 } 330 } 331 332 if($mod_data['isgroup']) 333 { 334 $query = $db->simple_select("usergroups", "title", "gid='{$mod_data['id']}'"); 335 $mod_data[$fieldname] = $db->fetch_field($query, 'title'); 336 } 337 else 338 { 339 $query = $db->simple_select("users", "username", "uid='{$mod_data['id']}'"); 340 $mod_data[$fieldname] = $db->fetch_field($query, 'username'); 341 } 342 343 $sub_tabs = array(); 344 345 $sub_tabs['edit_mod'] = array( 346 'title' => $lang->edit_mod, 347 'link' => "index.php?module=forum-management&action=editmod&mid=".$mybb->input['mid'], 348 'description' => $lang->edit_mod_desc 349 ); 350 351 $page->add_breadcrumb_item($lang->forum_moderators, "index.php?module=forum-management&fid={$mod_data['fid']}#tab_moderators"); 352 $page->add_breadcrumb_item($lang->edit_forum); 353 $page->output_header($lang->edit_mod); 354 $page->output_nav_tabs($sub_tabs, 'edit_mod'); 355 356 $form = new Form("index.php?module=forum-management&action=editmod", "post"); 357 echo $form->generate_hidden_field("mid", $mod_data['mid']); 358 359 if($errors) 360 { 361 $page->output_inline_error($errors); 362 $mod_data = $mybb->input; 363 } 364 365 $form_container = new FormContainer($lang->sprintf($lang->edit_mod_for, $mod_data[$fieldname])); 366 $form_container->output_row($lang->forum, $lang->forum_desc, $form->generate_forum_select('fid', $mod_data['fid'], array('id' => 'fid')), 'fid'); 367 368 $moderator_permissions = array( 369 $form->generate_check_box('caneditposts', 1, $lang->can_edit_posts, array('checked' => $mod_data['caneditposts'], 'id' => 'caneditposts')), 370 $form->generate_check_box('candeleteposts', 1, $lang->can_delete_posts, array('checked' => $mod_data['candeleteposts'], 'id' => 'candeleteposts')), 371 $form->generate_check_box('canviewips', 1, $lang->can_view_ips, array('checked' => $mod_data['canviewips'], 'id' => 'canviewips')), 372 $form->generate_check_box('canopenclosethreads', 1, $lang->can_open_close_threads, array('checked' => $mod_data['canopenclosethreads'], 'id' => 'canopenclosethreads')), 373 $form->generate_check_box('canmanagethreads', 1, $lang->can_manage_threads, array('checked' => $mod_data['canmanagethreads'], 'id' => 'canmanagethreads')), 374 $form->generate_check_box('canmovetononmodforum', 1, $lang->can_move_to_other_forums, array('checked' => $mod_data['canmovetononmodforum'], 'id' => 'canmovetononmodforum')), 375 $form->generate_check_box('canusecustomtools', 1, $lang->can_use_custom_tools, array('checked' => $mod_data['canusecustomtools'], 'id' => 'canusecustomtools')) 376 ); 377 378 $form_container->output_row($lang->moderator_permissions, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $moderator_permissions)."</div>"); 379 380 $form_container->end(); 381 382 $buttons[] = $form->generate_submit_button($lang->save_mod); 383 $form->output_submit_wrapper($buttons); 384 $form->end(); 385 386 $page->output_footer(); 387 } 388 389 if($mybb->input['action'] == "clear_permission") 390 { 391 $plugins->run_hooks("admin_forum_management_deletemod"); 392 393 $pid = intval($mybb->input['pid']); 394 $fid = intval($mybb->input['fid']); 395 $gid = intval($mybb->input['gid']); 396 397 // User clicked no 398 if($mybb->input['no']) 399 { 400 admin_redirect("index.php?module=forum-management&fid={$fid}"); 401 } 402 403 if($mybb->request_method == "post") 404 { 405 if((!$fid || !$gid) && $pid) 406 { 407 $query = $db->simple_select("forumpermissions", "fid, gid", "pid='{$pid}'"); 408 $result = $db->fetch_array($query); 409 $fid = $result['fid']; 410 $gid = $result['gid']; 411 } 412 413 if($pid) 414 { 415 $db->delete_query("forumpermissions", "pid='{$pid}'"); 416 } 417 else 418 { 419 $db->delete_query("forumpermissions", "gid='{$gid}' AND fid='{$fid}'"); 420 } 421 422 $cache->update_forumpermissions(); 423 424 flash_message($lang->success_custom_permission_cleared, 'success'); 425 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_permissions"); 426 } 427 else 428 { 429 $page->output_confirm_action("index.php?module=forum-management&action=clear_permission&pid={$pid}&gid={$gid}&fid={$fid}", $lang->confirm_clear_custom_permission); 430 } 431 } 432 433 if($mybb->input['action'] == "permissions") 434 { 435 $plugins->run_hooks("admin_forum_management_permissions"); 436 437 if($mybb->request_method == "post") 438 { 439 $pid = intval($mybb->input['pid']); 440 $fid = intval($mybb->input['fid']); 441 $gid = intval($mybb->input['gid']); 442 $forum = get_forum($fid); 443 444 if((!$fid || !$gid) && $pid) 445 { 446 $query = $db->simple_select("forumpermissions", "fid, gid", "pid='{$pid}'"); 447 $result = $db->fetch_array($query); 448 $fid = $result['fid']; 449 $gid = $result['gid']; 450 } 451 452 $field_list = array(); 453 $fields_array = $db->show_fields_from("forumpermissions"); 454 if(is_array($mybb->input['permissions'])) 455 { 456 // User has set permissions for this group... 457 foreach($fields_array as $field) 458 { 459 if(strpos($field['Field'], 'can') !== false) 460 { 461 if(array_key_exists($field['Field'], $mybb->input['permissions'])) 462 { 463 $update_array[$db->escape_string($field['Field'])] = intval($mybb->input['permissions'][$field['Field']]); 464 } 465 else 466 { 467 $update_array[$db->escape_string($field['Field'])] = 0; 468 } 469 } 470 } 471 } 472 else 473 { 474 // Else, we assume that the group has no permissions... 475 foreach($fields_array as $field) 476 { 477 if(strpos($field['Field'], 'can') !== false) 478 { 479 $update_array[$db->escape_string($field['Field'])] = 0; 480 } 481 } 482 } 483 484 if($fid && !$pid) 485 { 486 $update_array['fid'] = $fid; 487 $update_array['gid'] = intval($mybb->input['gid']); 488 $db->insert_query("forumpermissions", $update_array); 489 } 490 else 491 { 492 $db->update_query("forumpermissions", $update_array, "pid='{$pid}'"); 493 } 494 495 $cache->update_forumpermissions(); 496 497 $plugins->run_hooks("admin_forum_management_permissions_commit"); 498 499 // Log admin action 500 log_admin_action($fid, $forum['name']); 501 502 if($mybb->input['ajax'] == 1) 503 { 504 echo "<script type=\"text/javascript\">$('row_{$gid}').update('".str_replace(array("'", "\t", "\n"), array("\\'", "", ""), retrieve_single_permissions_row($gid, $fid))."'); QuickPermEditor.init({$gid});</script>"; 505 die; 506 } 507 else 508 { 509 flash_message($lang->success_forum_permissions_saved, 'success'); 510 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_permissions"); 511 } 512 } 513 514 if($mybb->input['ajax'] != 1) 515 { 516 $sub_tabs = array(); 517 518 if($mybb->input['fid'] && $mybb->input['gid']) 519 { 520 $sub_tabs['edit_permissions'] = array( 521 'title' => $lang->forum_permissions, 522 'link' => "index.php?module=forum-management&action=permissions&fid=".$mybb->input['fid']."&gid=".$mybb->input['gid'], 523 'description' => $lang->forum_permissions_desc 524 ); 525 526 $page->add_breadcrumb_item($lang->forum_permissions2, "index.php?module=forum-management&fid=".$mybb->input['fid']."#tab_permissions"); 527 } 528 else 529 { 530 $query = $db->simple_select("forumpermissions", "fid", "pid='".intval($mybb->input['pid'])."'"); 531 $mybb->input['fid'] = $db->fetch_field($query, "fid"); 532 533 $sub_tabs['edit_permissions'] = array( 534 'title' => $lang->forum_permissions, 535 'link' => "index.php?module=forum-management&action=permissions&pid=".intval($mybb->input['pid']), 536 'description' => $lang->forum_permissions_desc 537 ); 538 539 $page->add_breadcrumb_item($lang->forum_permissions2, "index.php?module=forum-management&fid=".$mybb->input['fid']."#tab_permissions"); 540 } 541 542 $page->add_breadcrumb_item($lang->forum_permissions); 543 $page->output_header($lang->forum_permissions); 544 $page->output_nav_tabs($sub_tabs, 'edit_permissions'); 545 } 546 else 547 { 548 echo "<div id=\"ModalContentContainer\"><div class=\"ModalTitle\">{$lang->forum_permissions}<a href=\"javascript:;\" id=\"modalClose\" class=\"float_right modalClose\"> </a></div><div class=\"ModalContent\">"; 549 } 550 551 if($mybb->input['pid'] || ($mybb->input['gid'] && $mybb->input['fid'])) 552 { 553 if($mybb->input['ajax'] != 1) 554 { 555 $form = new Form("index.php?module=forum-management&action=permissions", "post"); 556 } 557 else 558 { 559 $form = new Form("#", "post", "modal_form"); 560 } 561 echo $form->generate_hidden_field("usecustom", "1"); 562 563 if($errors) 564 { 565 $page->output_inline_error($errors); 566 $permission_data = $mybb->input; 567 568 $query = $db->simple_select("usergroups", "*", "gid='{$permission_data['gid']}'"); 569 $usergroup = $db->fetch_array($query); 570 571 $query = $db->simple_select("forums", "*", "fid='{$permission_data['fid']}'"); 572 $forum = $db->fetch_array($query); 573 } 574 else 575 { 576 $pid = intval($mybb->input['pid']); 577 $gid = intval($mybb->input['gid']); 578 $fid = intval($mybb->input['fid']); 579 580 if($pid) 581 { 582 $query = $db->simple_select("forumpermissions", "*", "pid='{$pid}'"); 583 } 584 else 585 { 586 $query = $db->simple_select("forumpermissions", "*", "fid='{$fid}' AND gid='{$gid}'", array('limit' => 1)); 587 } 588 589 $permission_data = $db->fetch_array($query); 590 591 if(!$fid) 592 { 593 $fid = $permission_data['fid']; 594 } 595 596 if(!$gid) 597 { 598 $gid = $permission_data['gid']; 599 } 600 601 if(!$pid) 602 { 603 $pid = $permission_data['pid']; 604 } 605 606 $query = $db->simple_select("usergroups", "*", "gid='$gid'"); 607 $usergroup = $db->fetch_array($query); 608 609 $query = $db->simple_select("forums", "*", "fid='$fid'"); 610 $forum = $db->fetch_array($query); 611 612 $sperms = $permission_data; 613 614 $sql = build_parent_list($fid); 615 $query = $db->simple_select("forumpermissions", "*", "$sql AND gid='$gid'"); 616 $customperms = $db->fetch_array($query); 617 618 if($permission_data['pid']) 619 { 620 $permission_data['usecustom'] = 1; 621 echo $form->generate_hidden_field("pid", $pid); 622 } 623 else 624 { 625 echo $form->generate_hidden_field("fid", $fid); 626 echo $form->generate_hidden_field("gid", $gid); 627 if(!$customperms['pid']) 628 { 629 $permission_data = usergroup_permissions($gid); 630 } 631 else 632 { 633 $permission_data = forum_permissions($fid, 0, $gid); 634 } 635 } 636 } 637 638 $groups = array( 639 'canviewthreads' => 'viewing', 640 'canview' => 'viewing', 641 'canonlyviewownthreads' => 'viewing', 642 'candlattachments' => 'viewing', 643 644 'canpostthreads' => 'posting_rating', 645 'canpostreplys' => 'posting_rating', 646 'canpostattachments' => 'posting_rating', 647 'canratethreads' => 'posting_rating', 648 649 'caneditposts' => 'editing', 650 'candeleteposts' => 'editing', 651 'candeletethreads' => 'editing', 652 'caneditattachments' => 'editing', 653 654 'canpostpolls' => 'polls', 655 'canvotepolls' => 'polls', 656 'cansearch' => 'misc', 657 ); 658 659 $groups = $plugins->run_hooks("admin_forum_management_permission_groups", $groups); 660 661 $tabs = array(); 662 foreach(array_unique(array_values($groups)) as $group) 663 { 664 $lang_group = "group_".$group; 665 $tabs[$group] = $lang->$lang_group; 666 } 667 668 if($mybb->input['ajax'] == 1) 669 { 670 $page->output_tab_control($tabs, false, "tabs2"); 671 } 672 else 673 { 674 $page->output_tab_control($tabs); 675 } 676 677 $field_list = array(); 678 $fields_array = $db->show_fields_from("forumpermissions"); 679 foreach($fields_array as $field) 680 { 681 if(strpos($field['Field'], 'can') !== false) 682 { 683 if(array_key_exists($field['Field'], $groups)) 684 { 685 $field_list[$groups[$field['Field']]][] = $field['Field']; 686 } 687 else 688 { 689 $field_list['misc'][] = $field['Field']; 690 } 691 } 692 } 693 694 foreach(array_unique(array_values($groups)) as $group) 695 { 696 $lang_group = "group_".$group; 697 echo "<div id=\"tab_".$group."\">\n"; 698 $form_container = new FormContainer("\"".htmlspecialchars_uni($usergroup['title'])."\" {$lang->custom_permissions_for} \"".htmlspecialchars_uni($forum['name'])."\""); 699 $fields = array(); 700 foreach($field_list[$group] as $field) 701 { 702 $lang_field = $group."_field_".$field; 703 $fields[] = $form->generate_check_box("permissions[{$field}]", 1, $lang->$lang_field, array('checked' => $permission_data[$field], 'id' => $field)); 704 } 705 $form_container->output_row("", "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $fields)."</div>"); 706 $form_container->end(); 707 echo "</div>"; 708 } 709 710 if($mybb->input['ajax'] == 1) 711 { 712 echo "</div><div class=\"ModalButtonRow\">"; 713 $buttons[] = $form->generate_submit_button($lang->cancel, array('id' => 'modalCancel')); 714 $buttons[] = $form->generate_submit_button($lang->save_permissions, array('id' => 'modalSubmit')); 715 $form->output_submit_wrapper($buttons); 716 echo "</div>"; 717 $form->end(); 718 echo "</div>"; 719 } 720 else 721 { 722 $buttons[] = $form->generate_submit_button($lang->save_permissions); 723 $form->output_submit_wrapper($buttons); 724 725 $form->end(); 726 } 727 } 728 729 if($mybb->input['ajax'] != 1) 730 { 731 $page->output_footer(); 732 } 733 } 734 735 if($mybb->input['action'] == "add") 736 { 737 $plugins->run_hooks("admin_forum_management_add"); 738 739 if($mybb->request_method == "post") 740 { 741 if(!trim($mybb->input['title'])) 742 { 743 $errors[] = $lang->error_missing_title; 744 } 745 746 $pid = intval($mybb->input['pid']); 747 $type = $mybb->input['type']; 748 749 if($pid <= 0 && $type == "f") 750 { 751 $errors[] = $lang->error_no_parent; 752 } 753 754 if(!$errors) 755 { 756 if($pid < 0) 757 { 758 $pid = 0; 759 } 760 $insert_array = array( 761 "name" => $db->escape_string($mybb->input['title']), 762 "description" => $db->escape_string($mybb->input['description']), 763 "linkto" => $db->escape_string($mybb->input['linkto']), 764 "type" => $db->escape_string($type), 765 "pid" => $pid, 766 "parentlist" => '', 767 "disporder" => intval($mybb->input['disporder']), 768 "active" => intval($mybb->input['active']), 769 "open" => intval($mybb->input['open']), 770 "allowhtml" => intval($mybb->input['allowhtml']), 771 "allowmycode" => intval($mybb->input['allowmycode']), 772 "allowsmilies" => intval($mybb->input['allowsmilies']), 773 "allowimgcode" => intval($mybb->input['allowimgcode']), 774 "allowvideocode" => intval($mybb->input['allowvideocode']), 775 "allowpicons" => intval($mybb->input['allowpicons']), 776 "allowtratings" => intval($mybb->input['allowtratings']), 777 "usepostcounts" => intval($mybb->input['usepostcounts']), 778 "password" => $db->escape_string($mybb->input['password']), 779 "showinjump" => intval($mybb->input['showinjump']), 780 "modposts" => intval($mybb->input['modposts']), 781 "modthreads" => intval($mybb->input['modthreads']), 782 "mod_edit_posts" => intval($mybb->input['mod_edit_posts']), 783 "modattachments" => intval($mybb->input['modattachments']), 784 "style" => intval($mybb->input['style']), 785 "overridestyle" => intval($mybb->input['overridestyle']), 786 "rulestype" => intval($mybb->input['rulestype']), 787 "rulestitle" => $db->escape_string($mybb->input['rulestitle']), 788 "rules" => $db->escape_string($mybb->input['rules']), 789 "defaultdatecut" => intval($mybb->input['defaultdatecut']), 790 "defaultsortby" => $db->escape_string($mybb->input['defaultsortby']), 791 "defaultsortorder" => $db->escape_string($mybb->input['defaultsortorder']), 792 ); 793 $fid = $db->insert_query("forums", $insert_array); 794 795 $parentlist = make_parent_list($fid); 796 $db->update_query("forums", array("parentlist" => $parentlist), "fid='$fid'"); 797 798 $inherit = $mybb->input['default_permissions']; 799 800 foreach($mybb->input as $id => $permission) 801 { 802 if(strpos($id, 'fields_') === false) 803 { 804 continue; 805 } 806 807 list(, $gid) = explode('fields_', $id); 808 809 // If it isn't an array then it came from the javascript form 810 if(!is_array($permission)) 811 { 812 $permission = explode(',', $permission); 813 $permission = array_flip($permission); 814 foreach($permission as $name => $value) 815 { 816 $permission[$name] = 1; 817 } 818 } 819 820 foreach(array('canview','canpostthreads','canpostreplys','canpostpolls') as $name) 821 { 822 if(in_array($name, $permission) || $permission[$name]) 823 { 824 $permissions[$name][$gid] = 1; 825 } 826 else 827 { 828 $permissions[$name][$gid] = 0; 829 } 830 } 831 } 832 833 $cache->update_forums(); 834 835 $canview = $permissions['canview']; 836 $canpostthreads = $permissions['canpostthreads']; 837 $canpostpolls = $permissions['canpostpolls']; 838 $canpostattachments = $permissions['canpostattachments']; 839 $canpostreplies = $permissions['canpostreplys']; 840 save_quick_perms($fid); 841 842 $plugins->run_hooks("admin_forum_management_add_commit"); 843 844 // Log admin action 845 log_admin_action($fid, $insert_array['name']); 846 847 flash_message($lang->success_forum_added, 'success'); 848 admin_redirect("index.php?module=forum-management"); 849 } 850 } 851 852 $page->extra_header .= "<script src=\"../jscripts/scriptaculous.js?load=effects,dragdrop,controls\" type=\"text/javascript\"></script>\n"; 853 $page->extra_header .= "<script src=\"jscripts/quick_perm_editor.js\" type=\"text/javascript\"></script>\n"; 854 855 $page->add_breadcrumb_item($lang->add_forum); 856 $page->output_header($lang->add_forum); 857 $page->output_nav_tabs($sub_tabs, 'add_forum'); 858 859 $form = new Form("index.php?module=forum-management&action=add", "post"); 860 861 if($errors) 862 { 863 $page->output_inline_error($errors); 864 $forum_data = $mybb->input; 865 } 866 else 867 { 868 $forum_data['type'] = "f"; 869 $forum_data['title'] = ""; 870 $forum_data['description'] = ""; 871 872 if(!$mybb->input['pid']) 873 { 874 $forum_data['pid'] = "-1"; 875 } 876 else 877 { 878 $forum_data['pid'] = intval($mybb->input['pid']); 879 } 880 $forum_data['disporder'] = "1"; 881 $forum_data['linkto'] = ""; 882 $forum_data['password'] = ""; 883 $forum_data['active'] = 1; 884 $forum_data['open'] = 1; 885 $forum_data['modposts'] = ""; 886 $forum_data['modthreads'] = ""; 887 $forum_data['modattachments'] = ""; 888 $forum_data['mod_edit_posts'] = ""; 889 $forum_data['overridestyle'] = ""; 890 $forum_data['style'] = ""; 891 $forum_data['rulestype'] = ""; 892 $forum_data['rulestitle'] = ""; 893 $forum_data['rules'] = ""; 894 $forum_data['defaultdatecut'] = ""; 895 $forum_data['defaultsortby'] = ""; 896 $forum_data['defaultsortorder'] = ""; 897 $forum_data['allowhtml'] = ""; 898 $forum_data['allowmycode'] = 1; 899 $forum_data['allowsmilies'] = 1; 900 $forum_data['allowimgcode'] = 1; 901 $forum_data['allowvideocode'] = 1; 902 $forum_data['allowpicons'] = 1; 903 $forum_data['allowtratings'] = 1; 904 $forum_data['showinjump'] = 1; 905 $forum_data['usepostcounts'] = 1; 906 } 907 908 $types = array( 909 'f' => $lang->forum, 910 'c' => $lang->category 911 ); 912 913 $create_a_options_f = array( 914 'id' => 'forum' 915 ); 916 917 $create_a_options_c = array( 918 'id' => 'category' 919 ); 920 921 if($forum_data['type'] == "f") 922 { 923 $create_a_options_f['checked'] = true; 924 } 925 else 926 { 927 $create_a_options_c['checked'] = true; 928 } 929 930 $form_container = new FormContainer($lang->add_forum); 931 $form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f)."<br />\n".$form->generate_radio_button('type', 'c', $lang->category, $create_a_options_c)); 932 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $forum_data['title'], array('id' => 'title')), 'title'); 933 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $forum_data['description'], array('id' => 'description')), 'description'); 934 $form_container->output_row($lang->parent_forum." <em>*</em>", $lang->parent_forum_desc, $form->generate_forum_select('pid', $forum_data['pid'], array('id' => 'pid', 'main_option' => $lang->none)), 'pid'); 935 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $forum_data['disporder'], array('id' => 'disporder')), 'disporder'); 936 $form_container->end(); 937 938 echo "<div id=\"additional_options_link\"><strong><a href=\"#\" onclick=\"$('additional_options_link').toggle(); $('additional_options').toggle(); return false;\">{$lang->show_additional_options}</a></strong><br /><br /></div>"; 939 echo "<div id=\"additional_options\" style=\"display: none;\">"; 940 $form_container = new FormContainer("<div class=\"float_right\" style=\"font-weight: normal;\"><a href=\"#\" onclick=\"$('additional_options_link').toggle(); $('additional_options').toggle(); return false;\">{$lang->hide_additional_options}</a></div>".$lang->additional_forum_options); 941 $form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box('linkto', $forum_data['linkto'], array('id' => 'linkto')), 'linkto'); 942 $form_container->output_row($lang->forum_password, $lang->forum_password_desc, $form->generate_text_box('password', $forum_data['password'], array('id' => 'password')), 'password'); 943 944 $access_options = array( 945 $form->generate_check_box('active', 1, $lang->forum_is_active."<br />\n<small>{$lang->forum_is_active_desc}</small>", array('checked' => $forum_data['active'], 'id' => 'active')), 946 $form->generate_check_box('open', 1, $lang->forum_is_open."<br />\n<small>{$lang->forum_is_open_desc}</small>", array('checked' => $forum_data['open'], 'id' => 'open')) 947 ); 948 949 $form_container->output_row($lang->access_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $access_options)."</div>"); 950 951 $moderator_options = array( 952 $form->generate_check_box('modposts', 1, $lang->mod_new_posts, array('checked' => $forum_data['modposts'], 'id' => 'modposts')), 953 $form->generate_check_box('modthreads', 1, $lang->mod_new_threads, array('checked' => $forum_data['modthreads'], 'id' => 'modthreads')), 954 $form->generate_check_box('modattachments', 1, $lang->mod_new_attachments, array('checked' => $forum_data['modattachments'], 'id' => 'modattachments')), 955 $form->generate_check_box('mod_edit_posts', 1, $lang->mod_after_edit, array('checked' => $forum_data['mod_edit_posts'], 'id' => 'mod_edit_posts')) 956 ); 957 958 $form_container->output_row($lang->moderation_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $moderator_options)."</div>"); 959 960 $styles = array( 961 '0' => $lang->use_default 962 ); 963 964 $query = $db->simple_select("themes", "tid,name", "name!='((master))' AND name!='((master-backup))'", array('order_by' => 'name')); 965 while($style = $db->fetch_array($query)) 966 { 967 $styles[$style['tid']] = htmlspecialchars_uni($style['name']); 968 } 969 970 $style_options = array( 971 $form->generate_check_box('overridestyle', 1, $lang->override_user_style, array('checked' => $forum_data['overridestyle'], 'id' => 'overridestyle')), 972 $lang->forum_specific_style."<br />\n".$form->generate_select_box('style', $styles, $forum_data['style'], array('id' => 'style')) 973 ); 974 975 $form_container->output_row($lang->style_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $style_options)."</div>"); 976 977 $display_methods = array( 978 '0' => $lang->dont_display_rules, 979 '1' => $lang->display_rules_inline, 980 '3' => $lang->display_rules_inline_new, 981 '2' => $lang->display_rules_link 982 ); 983 984 $forum_rules = array( 985 $lang->display_method."<br />\n".$form->generate_select_box('rulestype', $display_methods, $forum_data['rulestype'], array('checked' => $forum_data['rulestype'], 'id' => 'rulestype')), 986 $lang->title."<br />\n".$form->generate_text_box('rulestitle', $forum_data['rulestitle'], array('checked' => $forum_data['rulestitle'], 'id' => 'rulestitle')), 987 $lang->rules."<br />\n".$form->generate_text_area('rules', $forum_data['rules'], array('checked' => $forum_data['rules'], 'id' => 'rules')) 988 ); 989 990 $form_container->output_row($lang->forum_rules, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $forum_rules)."</div>"); 991 992 $default_date_cut = array( 993 0 => $lang->board_default, 994 1 => $lang->datelimit_1day, 995 5 => $lang->datelimit_5days, 996 10 => $lang->datelimit_10days, 997 20 => $lang->datelimit_20days, 998 50 => $lang->datelimit_50days, 999 75 => $lang->datelimit_75days, 1000 100 => $lang->datelimit_100days, 1001 365 => $lang->datelimit_lastyear, 1002 9999 => $lang->datelimit_beginning, 1003 ); 1004 1005 $default_sort_by = array( 1006 "" => $lang->board_default, 1007 "subject" => $lang->sort_by_subject, 1008 "lastpost" => $lang->sort_by_lastpost, 1009 "starter" => $lang->sort_by_starter, 1010 "started" => $lang->sort_by_started, 1011 "rating" => $lang->sort_by_rating, 1012 "replies" => $lang->sort_by_replies, 1013 "views" => $lang->sort_by_views, 1014 ); 1015 1016 $default_sort_order = array( 1017 "" => $lang->board_default, 1018 "asc" => $lang->sort_order_asc, 1019 "desc" => $lang->sort_order_desc, 1020 ); 1021 1022 $view_options = array( 1023 $lang->default_date_cut."<br />\n".$form->generate_select_box('defaultdatecut', $default_date_cut, $forum_data['defaultdatecut'], array('checked' => $forum_data['defaultdatecut'], 'id' => 'defaultdatecut')), 1024 $lang->default_sort_by."<br />\n".$form->generate_select_box('defaultsortby', $default_sort_by, $forum_data['defaultsortby'], array('checked' => $forum_data['defaultsortby'], 'id' => 'defaultsortby')), 1025 $lang->default_sort_order."<br />\n".$form->generate_select_box('defaultsortorder', $default_sort_order, $forum_data['defaultsortorder'], array('checked' => $forum_data['defaultsortorder'], 'id' => 'defaultsortorder')), 1026 ); 1027 1028 $form_container->output_row($lang->default_view_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $view_options)."</div>"); 1029 1030 $misc_options = array( 1031 $form->generate_check_box('allowhtml', 1, $lang->allow_html, array('checked' => $forum_data['allowhtml'], 'id' => 'allowhtml')), 1032 $form->generate_check_box('allowmycode', 1, $lang->allow_mycode, array('checked' => $forum_data['allowmycode'], 'id' => 'allowmycode')), 1033 $form->generate_check_box('allowsmilies', 1, $lang->allow_smilies, array('checked' => $forum_data['allowsmilies'], 'id' => 'allowsmilies')), 1034 $form->generate_check_box('allowimgcode', 1, $lang->allow_img_code, array('checked' => $forum_data['allowimgcode'], 'id' => 'allowimgcode')), 1035 $form->generate_check_box('allowvideocode', 1, $lang->allow_video_code, array('checked' => $forum_data['allowvideocode'], 'id' => 'allowvideocode')), 1036 $form->generate_check_box('allowpicons', 1, $lang->allow_post_icons, array('checked' => $forum_data['allowpicons'], 'id' => 'allowpicons')), 1037 $form->generate_check_box('allowtratings', 1, $lang->allow_thread_ratings, array('checked' => $forum_data['allowtratings'], 'id' => 'allowtratings')), 1038 $form->generate_check_box('showinjump', 1, $lang->show_forum_jump, array('checked' => $forum_data['showinjump'], 'id' => 'showinjump')), 1039 $form->generate_check_box('usepostcounts', 1, $lang->use_postcounts, array('checked' => $forum_data['usepostcounts'], 'id' => 'usepostcounts')) 1040 ); 1041 1042 $form_container->output_row($lang->misc_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $misc_options)."</div>"); 1043 $form_container->end(); 1044 echo "</div>"; 1045 1046 $query = $db->simple_select("usergroups", "*", "", array("order_dir" => "name")); 1047 while($usergroup = $db->fetch_array($query)) 1048 { 1049 $usergroups[$usergroup['gid']] = $usergroup; 1050 } 1051 1052 $cached_forum_perms = $cache->read("forumpermissions"); 1053 $field_list = array( 1054 'canview' => $lang->permissions_canview, 1055 'canpostthreads' => $lang->permissions_canpostthreads, 1056 'canpostreplys' => $lang->permissions_canpostreplys, 1057 'canpostpolls' => $lang->permissions_canpostpolls, 1058 ); 1059 1060 $field_list2 = array( 1061 'canview' => $lang->perm_drag_canview, 1062 'canpostthreads' => $lang->perm_drag_canpostthreads, 1063 'canpostreplys' => $lang->perm_drag_canpostreplys, 1064 'canpostpolls' => $lang->perm_drag_canpostpolls, 1065 ); 1066 1067 $ids = array(); 1068 1069 $form_container = new FormContainer($lang->forum_permissions); 1070 $form_container->output_row_header($lang->permissions_group, array("class" => "align_center", 'style' => 'width: 40%')); 1071 $form_container->output_row_header($lang->overview_allowed_actions, array("class" => "align_center")); 1072 $form_container->output_row_header($lang->overview_disallowed_actions, array("class" => "align_center")); 1073 1074 if($mybb->request_method == "post") 1075 { 1076 foreach($usergroups as $usergroup) 1077 { 1078 if(isset($mybb->input['fields_'.$usergroup['gid']])) 1079 { 1080 $input_permissions = $mybb->input['fields_'.$usergroup['gid']]; 1081 if(!is_array($input_permissions)) 1082 { 1083 // Convering the comma separated list from Javascript form into a variable 1084 $input_permissions = explode(',' , $input_permissions); 1085 } 1086 foreach($input_permissions as $input_permission) 1087 { 1088 $mybb->input['permissions'][$usergroup['gid']][$input_permission] = 1; 1089 } 1090 } 1091 } 1092 } 1093 1094 foreach($usergroups as $usergroup) 1095 { 1096 $perms = array(); 1097 if(isset($mybb->input['default_permissions']) && $mybb->input['default_permissions'][$usergroup['gid']]) 1098 { 1099 if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 1100 { 1101 $perms = $existing_permissions[$usergroup['gid']]; 1102 $default_checked = false; 1103 } 1104 elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]) 1105 { 1106 $perms = $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]; 1107 $default_checked = true; 1108 } 1109 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]) 1110 { 1111 $perms = $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]; 1112 $default_checked = true; 1113 } 1114 } 1115 1116 if(!$perms) 1117 { 1118 $perms = $usergroup; 1119 $default_checked = true; 1120 } 1121 1122 foreach($field_list as $forum_permission => $forum_perm_title) 1123 { 1124 if(isset($mybb->input['permissions'])) 1125 { 1126 if($mybb->input['default_permissions'][$usergroup['gid']]) 1127 { 1128 $default_checked = true; 1129 } 1130 else 1131 { 1132 $default_checked = false; 1133 } 1134 1135 if($mybb->input['permissions'][$usergroup['gid']][$forum_permission]) 1136 { 1137 $perms_checked[$forum_permission] = 1; 1138 } 1139 else 1140 { 1141 $perms_checked[$forum_permission] = 0; 1142 } 1143 } 1144 else 1145 { 1146 if($perms[$forum_permission] == 1) 1147 { 1148 $perms_checked[$forum_permission] = 1; 1149 } 1150 else 1151 { 1152 $perms_checked[$forum_permission] = 0; 1153 } 1154 } 1155 } 1156 $usergroup['title'] = htmlspecialchars_uni($usergroup['title']); 1157 1158 if($default_checked) 1159 { 1160 $inherited_text = $lang->inherited_permission; 1161 } 1162 else 1163 { 1164 $inherited_text = $lang->custom_permission; 1165 } 1166 1167 $form_container->output_cell("<strong>{$usergroup['title']}</strong><br />".$form->generate_check_box("default_permissions[{$usergroup['gid']}]", 1, "", array("id" => "default_permissions_{$usergroup['gid']}", "checked" => $default_checked))." <small><label for=\"default_permissions_{$usergroup['gid']}\">{$lang->permissions_use_group_default}</label></small>"); 1168 1169 $field_select = "<div class=\"quick_perm_fields\">\n"; 1170 $field_select .= "<div class=\"enabled\"><ul id=\"fields_enabled_{$usergroup['gid']}\">\n"; 1171 foreach($perms_checked as $perm => $value) 1172 { 1173 if($value == 1) 1174 { 1175 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 1176 } 1177 } 1178 $field_select .= "</ul></div>\n"; 1179 $field_select .= "<div class=\"disabled\"><ul id=\"fields_disabled_{$usergroup['gid']}\">\n"; 1180 foreach($perms_checked as $perm => $value) 1181 { 1182 if($value == 0) 1183 { 1184 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 1185 } 1186 } 1187 $field_select .= "</ul></div></div>\n"; 1188 $field_select .= $form->generate_hidden_field("fields_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_'.$usergroup['gid'])); 1189 $field_select = str_replace("'", "\\'", $field_select); 1190 $field_select = str_replace("\n", "", $field_select); 1191 1192 $field_select = "<script type=\"text/javascript\"> 1193 //<![CDATA[ 1194 document.write('".str_replace("/", "\/", $field_select)."'); 1195 //]]> 1196 </script>\n"; 1197 1198 $field_selected = array(); 1199 foreach($field_list as $forum_permission => $permission_title) 1200 { 1201 $field_options[$forum_permission] = $permission_title; 1202 if($perms_checked[$forum_permission]) 1203 { 1204 $field_selected[] = $forum_permission; 1205 } 1206 } 1207 1208 $field_select .= "<noscript>".$form->generate_select_box('fields_'.$usergroup['gid'].'[]', $field_options, $field_selected, array('id' => 'fields_'.$usergroup['gid'].'[]', 'multiple' => true))."</noscript>\n"; 1209 $form_container->output_cell($field_select, array('colspan' => 2)); 1210 1211 $form_container->construct_row(); 1212 1213 $ids[] = $usergroup['gid']; 1214 } 1215 $form_container->end(); 1216 1217 $buttons[] = $form->generate_submit_button($lang->save_forum); 1218 $form->output_submit_wrapper($buttons); 1219 $form->end(); 1220 1221 // Write in our JS based field selector 1222 echo "<script type=\"text/javascript\">\n<!--\n"; 1223 foreach($ids as $id) 1224 { 1225 echo "Event.observe(window, 'load', function(){ QuickPermEditor.init(".$id.") });\n"; 1226 } 1227 echo "// -->\n</script>\n"; 1228 1229 $page->output_footer(); 1230 } 1231 1232 if($mybb->input['action'] == "edit") 1233 { 1234 $plugins->run_hooks("admin_forum_management_edit"); 1235 1236 if(!$mybb->input['fid']) 1237 { 1238 flash_message($lang->error_invalid_fid, 'error'); 1239 admin_redirect("index.php?module=forum-management"); 1240 } 1241 1242 $query = $db->simple_select("forums", "*", "fid='{$mybb->input['fid']}'"); 1243 $forum_data = $db->fetch_array($query); 1244 if(!$forum_data) 1245 { 1246 flash_message($lang->error_invalid_fid, 'error'); 1247 admin_redirect("index.php?module=forum-management"); 1248 } 1249 1250 $fid = intval($mybb->input['fid']); 1251 1252 if($mybb->request_method == "post") 1253 { 1254 if(!trim($mybb->input['title'])) 1255 { 1256 $errors[] = $lang->error_missing_title; 1257 } 1258 1259 $pid = intval($mybb->input['pid']); 1260 1261 if($pid == $mybb->input['fid']) 1262 { 1263 $errors[] = $lang->error_forum_parent_itself; 1264 } 1265 else 1266 { 1267 $query = $db->simple_select("forums", "*", "pid='{$mybb->input['fid']}'"); 1268 while($child = $db->fetch_array($query)) 1269 { 1270 if($child['fid'] == $pid) 1271 { 1272 $errors[] = $lang->error_forum_parent_child; 1273 break; 1274 } 1275 } 1276 } 1277 1278 $type = $mybb->input['type']; 1279 1280 if($pid <= 0 && $type == "f") 1281 { 1282 $errors[] = $lang->error_no_parent; 1283 } 1284 1285 if($type == 'c' && $forum_data['type'] == 'f') 1286 { 1287 $query = $db->simple_select('threads', 'COUNT(tid) as num_threads', "fid = '{$fid}'"); 1288 if($db->fetch_field($query, "num_threads") > 0) 1289 { 1290 $errors[] = $lang->error_not_empty; 1291 } 1292 } 1293 1294 if(!$errors) 1295 { 1296 if($pid < 0) 1297 { 1298 $pid = 0; 1299 } 1300 $update_array = array( 1301 "name" => $db->escape_string($mybb->input['title']), 1302 "description" => $db->escape_string($mybb->input['description']), 1303 "linkto" => $db->escape_string($mybb->input['linkto']), 1304 "type" => $db->escape_string($type), 1305 "pid" => $pid, 1306 "disporder" => intval($mybb->input['disporder']), 1307 "active" => intval($mybb->input['active']), 1308 "open" => intval($mybb->input['open']), 1309 "allowhtml" => intval($mybb->input['allowhtml']), 1310 "allowmycode" => intval($mybb->input['allowmycode']), 1311 "allowsmilies" => intval($mybb->input['allowsmilies']), 1312 "allowimgcode" => intval($mybb->input['allowimgcode']), 1313 "allowvideocode" => intval($mybb->input['allowvideocode']), 1314 "allowpicons" => intval($mybb->input['allowpicons']), 1315 "allowtratings" => intval($mybb->input['allowtratings']), 1316 "usepostcounts" => intval($mybb->input['usepostcounts']), 1317 "password" => $db->escape_string($mybb->input['password']), 1318 "showinjump" => intval($mybb->input['showinjump']), 1319 "modposts" => intval($mybb->input['modposts']), 1320 "modthreads" => intval($mybb->input['modthreads']), 1321 "mod_edit_posts" => intval($mybb->input['mod_edit_posts']), 1322 "modattachments" => intval($mybb->input['modattachments']), 1323 "style" => intval($mybb->input['style']), 1324 "overridestyle" => intval($mybb->input['overridestyle']), 1325 "rulestype" => intval($mybb->input['rulestype']), 1326 "rulestitle" => $db->escape_string($mybb->input['rulestitle']), 1327 "rules" => $db->escape_string($mybb->input['rules']), 1328 "defaultdatecut" => intval($mybb->input['defaultdatecut']), 1329 "defaultsortby" => $db->escape_string($mybb->input['defaultsortby']), 1330 "defaultsortorder" => $db->escape_string($mybb->input['defaultsortorder']), 1331 ); 1332 $db->update_query("forums", $update_array, "fid='{$fid}'"); 1333 if($pid != $forum_data['pid']) 1334 { 1335 // Update the parentlist of this forum. 1336 $db->update_query("forums", array("parentlist" => make_parent_list($fid)), "fid='{$fid}'", 1); 1337 1338 // Rebuild the parentlist of all of the subforums of this forum 1339 switch($db->type) 1340 { 1341 case "sqlite": 1342 case "pgsql": 1343 $query = $db->simple_select("forums", "fid", "','||parentlist||',' LIKE '%,$fid,%'"); 1344 break; 1345 default: 1346 $query = $db->simple_select("forums", "fid", "CONCAT(',',parentlist,',') LIKE '%,$fid,%'"); 1347 } 1348 1349 while($child = $db->fetch_array($query)) 1350 { 1351 $db->update_query("forums", array("parentlist" => make_parent_list($child['fid'])), "fid='{$child['fid']}'", 1); 1352 } 1353 } 1354 1355 $inherit = $mybb->input['default_permissions']; 1356 1357 foreach($mybb->input as $id => $permission) 1358 { 1359 // Make sure we're only skipping inputs that don't start with "fields_" and aren't fields_default_ or fields_inherit_ 1360 if(strpos($id, 'fields_') === false || (strpos($id, 'fields_default_') !== false || strpos($id, 'fields_inherit_') !== false)) 1361 { 1362 continue; 1363 } 1364 1365 list(, $gid) = explode('fields_', $id); 1366 1367 if($mybb->input['fields_default_'.$gid] == $permission && $mybb->input['fields_inherit_'.$gid] == 1) 1368 { 1369 $inherit[$gid] = 1; 1370 continue; 1371 } 1372 $inherit[$gid] = 0; 1373 1374 // If it isn't an array then it came from the javascript form 1375 if(!is_array($permission)) 1376 { 1377 $permission = explode(',', $permission); 1378 $permission = array_flip($permission); 1379 foreach($permission as $name => $value) 1380 { 1381 $permission[$name] = 1; 1382 } 1383 } 1384 1385 foreach(array('canview','canpostthreads','canpostreplys','canpostpolls') as $name) 1386 { 1387 if(in_array($name, $permission) || $permission[$name]) 1388 { 1389 $permissions[$name][$gid] = 1; 1390 } 1391 else 1392 { 1393 $permissions[$name][$gid] = 0; 1394 } 1395 } 1396 } 1397 1398 $cache->update_forums(); 1399 1400 $canview = $permissions['canview']; 1401 $canpostthreads = $permissions['canpostthreads']; 1402 $canpostpolls = $permissions['canpostpolls']; 1403 $canpostattachments = $permissions['canpostattachments']; 1404 $canpostreplies = $permissions['canpostreplys']; 1405 1406 save_quick_perms($fid); 1407 1408 $plugins->run_hooks("admin_forum_management_edit_commit"); 1409 1410 // Log admin action 1411 log_admin_action($fid, $mybb->input['title']); 1412 1413 flash_message($lang->success_forum_updated, 'success'); 1414 admin_redirect("index.php?module=forum-management&fid={$fid}"); 1415 } 1416 } 1417 1418 $page->extra_header .= "<script src=\"../jscripts/scriptaculous.js?load=effects,dragdrop,controls\" type=\"text/javascript\"></script>\n"; 1419 $page->extra_header .= "<script src=\"jscripts/quick_perm_editor.js\" type=\"text/javascript\"></script>\n"; 1420 $page->extra_header .= "<script src=\"jscripts/imodal.js\" type=\"text/javascript\"></script>\n"; 1421 $page->extra_header .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/default/imodal.css\" />\n"; 1422 1423 $page->add_breadcrumb_item($lang->edit_forum); 1424 $page->output_header($lang->edit_forum); 1425 1426 $page->output_nav_tabs($sub_tabs, 'edit_forum_settings'); 1427 1428 $form = new Form("index.php?module=forum-management&action=edit", "post"); 1429 echo $form->generate_hidden_field("fid", $fid); 1430 1431 if($errors) 1432 { 1433 $page->output_inline_error($errors); 1434 $forum_data = $mybb->input; 1435 } 1436 else 1437 { 1438 $forum_data['title'] = $forum_data['name']; 1439 } 1440 1441 $query = $db->simple_select("usergroups", "*", "", array("order_dir" => "name")); 1442 while($usergroup = $db->fetch_array($query)) 1443 { 1444 $usergroups[$usergroup['gid']] = $usergroup; 1445 } 1446 1447 $query = $db->simple_select("forumpermissions", "*", "fid='{$fid}'"); 1448 while($existing = $db->fetch_array($query)) 1449 { 1450 $existing_permissions[$existing['gid']] = $existing; 1451 } 1452 1453 $types = array( 1454 'f' => $lang->forum, 1455 'c' => $lang->category 1456 ); 1457 1458 $create_a_options_f = array( 1459 'id' => 'forum' 1460 ); 1461 1462 $create_a_options_c = array( 1463 'id' => 'category' 1464 ); 1465 1466 if($forum_data['type'] == "f") 1467 { 1468 $create_a_options_f['checked'] = true; 1469 } 1470 else 1471 { 1472 $create_a_options_c['checked'] = true; 1473 } 1474 1475 $form_container = new FormContainer($lang->edit_forum); 1476 $form_container->output_row($lang->forum_type, $lang->forum_type_desc, $form->generate_radio_button('type', 'f', $lang->forum, $create_a_options_f)."<br />\n".$form->generate_radio_button('type', 'c', $lang->category, $create_a_options_c)); 1477 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $forum_data['title'], array('id' => 'title')), 'title'); 1478 $form_container->output_row($lang->description, "", $form->generate_text_area('description', $forum_data['description'], array('id' => 'description')), 'description'); 1479 $form_container->output_row($lang->parent_forum." <em>*</em>", $lang->parent_forum_desc, $form->generate_forum_select('pid', $forum_data['pid'], array('id' => 'pid', 'main_option' => $lang->none)), 'pid'); 1480 $form_container->output_row($lang->display_order, "", $form->generate_text_box('disporder', $forum_data['disporder'], array('id' => 'disporder')), 'disporder'); 1481 $form_container->end(); 1482 1483 $form_container = new FormContainer($lang->additional_forum_options); 1484 $form_container->output_row($lang->forum_link, $lang->forum_link_desc, $form->generate_text_box('linkto', $forum_data['linkto'], array('id' => 'linkto')), 'linkto'); 1485 $form_container->output_row($lang->forum_password, $lang->forum_password_desc, $form->generate_text_box('password', $forum_data['password'], array('id' => 'password')), 'password'); 1486 1487 $access_options = array( 1488 $form->generate_check_box('active', 1, $lang->forum_is_active."<br />\n<small>{$lang->forum_is_active_desc}</small>", array('checked' => $forum_data['active'], 'id' => 'active')), 1489 $form->generate_check_box('open', 1, $lang->forum_is_open."<br />\n<small>{$lang->forum_is_open_desc}</small>", array('checked' => $forum_data['open'], 'id' => 'open')) 1490 ); 1491 1492 $form_container->output_row($lang->access_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $access_options)."</div>"); 1493 1494 $moderator_options = array( 1495 $form->generate_check_box('modposts', 1, $lang->mod_new_posts, array('checked' => $forum_data['modposts'], 'id' => 'modposts')), 1496 $form->generate_check_box('modthreads', 1, $lang->mod_new_threads, array('checked' => $forum_data['modthreads'], 'id' => 'modthreads')), 1497 $form->generate_check_box('modattachments', 1, $lang->mod_new_attachments, array('checked' => $forum_data['modattachments'], 'id' => 'modattachments')), 1498 $form->generate_check_box('mod_edit_posts',1, $lang->mod_after_edit, array('checked' => $forum_data['mod_edit_posts'], 'id' => 'mod_edit_posts')) 1499 ); 1500 1501 $form_container->output_row($lang->moderation_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $moderator_options)."</div>"); 1502 1503 $styles = array( 1504 '0' => $lang->use_default 1505 ); 1506 1507 $query = $db->simple_select("themes", "tid,name", "name!='((master))' AND name!='((master-backup))'", array('order_by' => 'name')); 1508 while($style = $db->fetch_array($query)) 1509 { 1510 $styles[$style['tid']] = $style['name']; 1511 } 1512 1513 $style_options = array( 1514 $form->generate_check_box('overridestyle', 1, $lang->override_user_style, array('checked' => $forum_data['overridestyle'], 'id' => 'overridestyle')), 1515 $lang->forum_specific_style."<br />\n".$form->generate_select_box('style', $styles, $forum_data['style'], array('id' => 'style')) 1516 ); 1517 1518 $form_container->output_row($lang->style_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $style_options)."</div>"); 1519 1520 $display_methods = array( 1521 '0' => $lang->dont_display_rules, 1522 '1' => $lang->display_rules_inline, 1523 '3' => $lang->display_rules_inline_new, 1524 '2' => $lang->display_rules_link 1525 ); 1526 1527 $forum_rules = array( 1528 $lang->display_method."<br />\n".$form->generate_select_box('rulestype', $display_methods, $forum_data['rulestype'], array('checked' => $forum_data['rulestype'], 'id' => 'rulestype')), 1529 $lang->title."<br />\n".$form->generate_text_box('rulestitle', $forum_data['rulestitle'], array('checked' => $forum_data['rulestitle'], 'id' => 'rulestitle')), 1530 $lang->rules."<br />\n".$form->generate_text_area('rules', $forum_data['rules'], array('checked' => $forum_data['rules'], 'id' => 'rules')) 1531 ); 1532 1533 $form_container->output_row($lang->forum_rules, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $forum_rules)."</div>"); 1534 1535 $default_date_cut = array( 1536 0 => $lang->board_default, 1537 1 => $lang->datelimit_1day, 1538 5 => $lang->datelimit_5days, 1539 10 => $lang->datelimit_10days, 1540 20 => $lang->datelimit_20days, 1541 50 => $lang->datelimit_50days, 1542 75 => $lang->datelimit_75days, 1543 100 => $lang->datelimit_100days, 1544 365 => $lang->datelimit_lastyear, 1545 9999 => $lang->datelimit_beginning, 1546 ); 1547 1548 $default_sort_by = array( 1549 "" => $lang->board_default, 1550 "subject" => $lang->sort_by_subject, 1551 "lastpost" => $lang->sort_by_lastpost, 1552 "starter" => $lang->sort_by_starter, 1553 "started" => $lang->sort_by_started, 1554 "rating" => $lang->sort_by_rating, 1555 "replies" => $lang->sort_by_replies, 1556 "views" => $lang->sort_by_views, 1557 ); 1558 1559 $default_sort_order = array( 1560 "" => $lang->board_default, 1561 "asc" => $lang->sort_order_asc, 1562 "desc" => $lang->sort_order_desc, 1563 ); 1564 1565 $view_options = array( 1566 $lang->default_date_cut."<br />\n".$form->generate_select_box('defaultdatecut', $default_date_cut, $forum_data['defaultdatecut'], array('checked' => $forum_data['defaultdatecut'], 'id' => 'defaultdatecut')), 1567 $lang->default_sort_by."<br />\n".$form->generate_select_box('defaultsortby', $default_sort_by, $forum_data['defaultsortby'], array('checked' => $forum_data['defaultsortby'], 'id' => 'defaultsortby')), 1568 $lang->default_sort_order."<br />\n".$form->generate_select_box('defaultsortorder', $default_sort_order, $forum_data['defaultsortorder'], array('checked' => $forum_data['defaultsortorder'], 'id' => 'defaultsortorder')), 1569 ); 1570 1571 $form_container->output_row($lang->default_view_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $view_options)."</div>"); 1572 1573 $misc_options = array( 1574 $form->generate_check_box('allowhtml', 1, $lang->allow_html, array('checked' => $forum_data['allowhtml'], 'id' => 'allowhtml')), 1575 $form->generate_check_box('allowmycode', 1, $lang->allow_mycode, array('checked' => $forum_data['allowmycode'], 'id' => 'allowmycode')), 1576 $form->generate_check_box('allowsmilies', 1, $lang->allow_smilies, array('checked' => $forum_data['allowsmilies'], 'id' => 'allowsmilies')), 1577 $form->generate_check_box('allowimgcode', 1, $lang->allow_img_code, array('checked' => $forum_data['allowimgcode'], 'id' => 'allowimgcode')), 1578 $form->generate_check_box('allowvideocode', 1, $lang->allow_video_code, array('checked' => $forum_data['allowvideocode'], 'id' => 'allowvideocode')), 1579 $form->generate_check_box('allowpicons', 1, $lang->allow_post_icons, array('checked' => $forum_data['allowpicons'], 'id' => 'allowpicons')), 1580 $form->generate_check_box('allowtratings', 1, $lang->allow_thread_ratings, array('checked' => $forum_data['allowtratings'], 'id' => 'allowtratings')), 1581 $form->generate_check_box('showinjump', 1, $lang->show_forum_jump, array('checked' => $forum_data['showinjump'], 'id' => 'showinjump')), 1582 $form->generate_check_box('usepostcounts', 1, $lang->use_postcounts, array('checked' => $forum_data['usepostcounts'], 'id' => 'usepostcounts')) 1583 ); 1584 1585 $form_container->output_row($lang->misc_options, "", "<div class=\"forum_settings_bit\">".implode("</div><div class=\"forum_settings_bit\">", $misc_options)."</div>"); 1586 $form_container->end(); 1587 1588 $cached_forum_perms = $cache->read("forumpermissions"); 1589 $field_list = array( 1590 'canview' => $lang->permissions_canview, 1591 'canpostthreads' => $lang->permissions_canpostthreads, 1592 'canpostreplys' => $lang->permissions_canpostreplys, 1593 'canpostpolls' => $lang->permissions_canpostpolls, 1594 ); 1595 1596 $field_list2 = array( 1597 'canview' => $lang->perm_drag_canview, 1598 'canpostthreads' => $lang->perm_drag_canpostthreads, 1599 'canpostreplys' => $lang->perm_drag_canpostreplys, 1600 'canpostpolls' => $lang->perm_drag_canpostpolls, 1601 ); 1602 1603 $ids = array(); 1604 1605 $form_container = new FormContainer($lang->sprintf($lang->forum_permissions_in, $forum_data['name'])); 1606 $form_container->output_row_header($lang->permissions_group, array("class" => "align_center", 'style' => 'width: 30%')); 1607 $form_container->output_row_header($lang->overview_allowed_actions, array("class" => "align_center")); 1608 $form_container->output_row_header($lang->overview_disallowed_actions, array("class" => "align_center")); 1609 $form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 120px', 'colspan' => 2)); 1610 1611 if($mybb->request_method == "post") 1612 { 1613 foreach($usergroups as $usergroup) 1614 { 1615 if(isset($mybb->input['fields_'.$usergroup['gid']])) 1616 { 1617 $input_permissions = $mybb->input['fields_'.$usergroup['gid']]; 1618 if(!is_array($input_permissions)) 1619 { 1620 // Convering the comma separated list from Javascript form into a variable 1621 $input_permissions = explode(',' , $input_permissions); 1622 } 1623 foreach($input_permissions as $input_permission) 1624 { 1625 $mybb->input['permissions'][$usergroup['gid']][$input_permission] = 1; 1626 } 1627 } 1628 } 1629 } 1630 1631 foreach($usergroups as $usergroup) 1632 { 1633 $perms = array(); 1634 if(isset($mybb->input['default_permissions'])) 1635 { 1636 if($mybb->input['default_permissions'][$usergroup['gid']]) 1637 { 1638 if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 1639 { 1640 $perms = $existing_permissions[$usergroup['gid']]; 1641 $default_checked = false; 1642 } 1643 elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]) 1644 { 1645 $perms = $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]; 1646 $default_checked = true; 1647 } 1648 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]) 1649 { 1650 $perms = $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]; 1651 $default_checked = true; 1652 } 1653 } 1654 1655 if(!$perms) 1656 { 1657 $perms = $usergroup; 1658 $default_checked = true; 1659 } 1660 } 1661 else 1662 { 1663 if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 1664 { 1665 $perms = $existing_permissions[$usergroup['gid']]; 1666 $default_checked = false; 1667 } 1668 elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]) 1669 { 1670 $perms = $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]; 1671 $default_checked = true; 1672 } 1673 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]) 1674 { 1675 $perms = $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]; 1676 $default_checked = true; 1677 } 1678 1679 if(!$perms) 1680 { 1681 $perms = $usergroup; 1682 $default_checked = true; 1683 } 1684 } 1685 1686 foreach($field_list as $forum_permission => $forum_perm_title) 1687 { 1688 if(isset($mybb->input['permissions'])) 1689 { 1690 if($mybb->input['permissions'][$usergroup['gid']][$forum_permission]) 1691 { 1692 $perms_checked[$forum_permission] = 1; 1693 } 1694 else 1695 { 1696 $perms_checked[$forum_permission] = 0; 1697 } 1698 } 1699 else 1700 { 1701 if($perms[$forum_permission] == 1) 1702 { 1703 $perms_checked[$forum_permission] = 1; 1704 } 1705 else 1706 { 1707 $perms_checked[$forum_permission] = 0; 1708 } 1709 } 1710 } 1711 $usergroup['title'] = htmlspecialchars_uni($usergroup['title']); 1712 1713 if($default_checked) 1714 { 1715 $inherited_text = $lang->inherited_permission; 1716 } 1717 else 1718 { 1719 $inherited_text = $lang->custom_permission; 1720 } 1721 1722 $form_container->output_cell("<strong>{$usergroup['title']}</strong> <small style=\"vertical-align: middle;\">({$inherited_text})</small>"); 1723 1724 $field_select = "<div class=\"quick_perm_fields\">\n"; 1725 $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled_{$usergroup['gid']}\">\n"; 1726 foreach($perms_checked as $perm => $value) 1727 { 1728 if($value == 1) 1729 { 1730 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 1731 } 1732 } 1733 $field_select .= "</ul></div>\n"; 1734 $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled_{$usergroup['gid']}\">\n"; 1735 foreach($perms_checked as $perm => $value) 1736 { 1737 if($value == 0) 1738 { 1739 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 1740 } 1741 } 1742 $field_select .= "</ul></div></div>\n"; 1743 $field_select .= $form->generate_hidden_field("fields_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_'.$usergroup['gid'])); 1744 $field_select .= $form->generate_hidden_field("fields_inherit_".$usergroup['gid'], (int)$default_checked, array('id' => 'fields_inherit_'.$usergroup['gid'])); 1745 $field_select .= $form->generate_hidden_field("fields_default_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_default_'.$usergroup['gid'])); 1746 $field_select = str_replace("'", "\\'", $field_select); 1747 $field_select = str_replace("\n", "", $field_select); 1748 1749 $field_select = "<script type=\"text/javascript\"> 1750 //<![CDATA[ 1751 document.write('".str_replace("/", "\/", $field_select)."'); 1752 //]]> 1753 </script>\n"; 1754 1755 $field_selected = array(); 1756 foreach($field_list as $forum_permission => $permission_title) 1757 { 1758 $field_options[$forum_permission] = $permission_title; 1759 if($perms_checked[$forum_permission]) 1760 { 1761 $field_selected[] = $forum_permission; 1762 } 1763 } 1764 1765 $field_select .= "<noscript>".$form->generate_select_box('fields_'.$usergroup['gid'].'[]', $field_options, $field_selected, array('id' => 'fields_'.$usergroup['gid'].'[]', 'multiple' => true))."</noscript>\n"; 1766 $form_container->output_cell($field_select, array('colspan' => 2)); 1767 1768 if(!$default_checked) 1769 { 1770 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&pid={$perms['pid']}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&pid={$perms['pid']}&ajax=1'}); return false;\">{$lang->edit_permissions}</a>", array("class" => "align_center")); 1771 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=clear_permission&pid={$perms['pid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_clear_custom_permission}')\">{$lang->clear_custom_perms}</a>", array("class" => "align_center")); 1772 } 1773 else 1774 { 1775 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}&ajax=1'}); return false;\">{$lang->set_custom_perms}</a>", array("class" => "align_center", "colspan" => 2)); 1776 } 1777 $form_container->construct_row(array('id' => 'row_'.$usergroup['gid'])); 1778 1779 $ids[] = $usergroup['gid']; 1780 } 1781 $form_container->end(); 1782 1783 $buttons[] = $form->generate_submit_button($lang->save_forum); 1784 $form->output_submit_wrapper($buttons); 1785 $form->end(); 1786 1787 // Write in our JS based field selector 1788 echo "<script type=\"text/javascript\">\n<!--\n"; 1789 foreach($ids as $id) 1790 { 1791 echo "Event.observe(window, 'load', function(){ QuickPermEditor.init(".$id."); });\n"; 1792 } 1793 echo "// -->\n</script>\n"; 1794 1795 $page->output_footer(); 1796 } 1797 1798 if($mybb->input['action'] == "deletemod") 1799 { 1800 $plugins->run_hooks("admin_forum_management_deletemod"); 1801 1802 $modid = intval($mybb->input['id']); 1803 $isgroup = intval($mybb->input['isgroup']); 1804 $fid = intval($mybb->input['fid']); 1805 1806 $query = $db->simple_select("moderators", "*", "id='{$modid}' AND isgroup = '{$isgroup}' AND fid='{$fid}'"); 1807 $mod = $db->fetch_array($query); 1808 1809 // Does the forum not exist? 1810 if(!$mod['mid']) 1811 { 1812 flash_message($lang->error_invalid_moderator, 'error'); 1813 admin_redirect("index.php?module=forum-management&fid={$fid}"); 1814 } 1815 1816 // User clicked no 1817 if($mybb->input['no']) 1818 { 1819 admin_redirect("index.php?module=forum-management&fid={$fid}"); 1820 } 1821 1822 if($mybb->request_method == "post") 1823 { 1824 $mid = $mod['mid']; 1825 if ($mybb->input['isgroup']) 1826 { 1827 $query = $db->query(" 1828 SELECT m.*, g.title 1829 FROM ".TABLE_PREFIX."moderators m 1830 LEFT JOIN ".TABLE_PREFIX."usergroups g ON (g.gid=m.id) 1831 WHERE m.mid='{$mid}' 1832 "); 1833 } 1834 else 1835 { 1836 $query = $db->query(" 1837 SELECT m.*, u.username, u.usergroup 1838 FROM ".TABLE_PREFIX."moderators m 1839 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=m.id) 1840 WHERE m.mid='{$mid}' 1841 "); 1842 } 1843 $mod = $db->fetch_array($query); 1844 1845 $db->delete_query("moderators", "mid='{$mid}'"); 1846 $query = $db->simple_select("moderators", "*", "id='{$mod['id']}' AND isgroup='0'"); 1847 if($db->num_rows($query) == 0) 1848 { 1849 $updatequery = array( 1850 "usergroup" => "2" 1851 ); 1852 $db->update_query("users", $updatequery, "uid='{$mod['id']}' AND usergroup != '4' AND usergroup != '3'"); 1853 } 1854 $cache->update_moderators(); 1855 1856 $plugins->run_hooks("admin_forum_management_deletemod_commit"); 1857 1858 $forum = get_forum($fid); 1859 1860 // Log admin action 1861 if ($isgroup) 1862 { 1863 log_admin_action($mid, $mod['title'], $forum['fid'], $forum['name']); 1864 } 1865 else 1866 { 1867 log_admin_action($mid, $mod['username'], $forum['fid'], $forum['name']); 1868 } 1869 1870 flash_message($lang->success_moderator_deleted, 'success'); 1871 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 1872 } 1873 else 1874 { 1875 $page->output_confirm_action("index.php?module=forum-management&action=deletemod&fid={$mod['fid']}&uid={$mod['uid']}", $lang->confirm_moderator_deletion); 1876 } 1877 } 1878 1879 if($mybb->input['action'] == "delete") 1880 { 1881 $plugins->run_hooks("admin_forum_management_delete"); 1882 1883 $query = $db->simple_select("forums", "*", "fid='{$mybb->input['fid']}'"); 1884 $forum = $db->fetch_array($query); 1885 1886 // Does the forum not exist? 1887 if(!$forum['fid']) 1888 { 1889 flash_message($lang->error_invalid_forum, 'error'); 1890 admin_redirect("index.php?module=forum-management"); 1891 } 1892 1893 // User clicked no 1894 if($mybb->input['no']) 1895 { 1896 admin_redirect("index.php?module=forum-management"); 1897 } 1898 1899 if($mybb->request_method == "post") 1900 { 1901 $fid = intval($mybb->input['fid']); 1902 $forum_info = get_forum($fid); 1903 1904 $query = $db->simple_select("forums", "posts,unapprovedposts,threads,unapprovedthreads", "fid='{$fid}'"); 1905 $stats = $db->fetch_array($query); 1906 1907 // Delete the forum 1908 $db->delete_query("forums", "fid='$fid'"); 1909 1910 switch($db->type) 1911 { 1912 case "pgsql": 1913 case "sqlite": 1914 $query = $db->simple_select("forums", "*", "','|| parentlist|| ',' LIKE '%,$fid,%'"); 1915 break; 1916 default: 1917 $query = $db->simple_select("forums", "*", "CONCAT(',', parentlist, ',') LIKE '%,$fid,%'"); 1918 } 1919 while($forum = $db->fetch_array($query)) 1920 { 1921 $fids[$forum['fid']] = $fid; 1922 $delquery .= " OR fid='{$forum['fid']}'"; 1923 1924 $stats['posts'] += $forum['posts']; 1925 $stats['unapprovedposts'] += $forum['unapprovedposts']; 1926 $stats['threads'] += $forum['threads']; 1927 $stats['unapprovedthreads'] += $forum['unapprovedthreads']; 1928 } 1929 1930 /** 1931 * This slab of code pulls out the moderators for this forum, 1932 * checks if they moderate any other forums, and if they don't 1933 * it moves them back to the registered usergroup 1934 */ 1935 1936 $query = $db->simple_select("moderators", "*", "fid='$fid' AND isgroup='0'"); 1937 while($mod = $db->fetch_array($query)) 1938 { 1939 $moderators[$mod['id']] = $mod['id']; 1940 } 1941 1942 if(is_array($moderators)) 1943 { 1944 $mod_list = implode(",", $moderators); 1945 $query = $db->simple_select("moderators", "*", "fid != '$fid' AND id IN ($mod_list) AND isgroup='0'"); 1946 while($mod = $db->fetch_array($query)) 1947 { 1948 unset($moderators[$mod['id']]); 1949 } 1950 } 1951 1952 if(is_array($moderators)) 1953 { 1954 $mod_list = implode(",", $moderators); 1955 if($mod_list) 1956 { 1957 $updatequery = array( 1958 "usergroup" => "2" 1959 ); 1960 $db->update_query("users", $updatequery, "uid IN ($mod_list) AND usergroup='6'"); 1961 } 1962 } 1963 1964 switch($db->type) 1965 { 1966 case "pgsql": 1967 case "sqlite": 1968 $db->delete_query("forums", "','||parentlist||',' LIKE '%,$fid,%'"); 1969 break; 1970 default: 1971 $db->delete_query("forums", "CONCAT(',',parentlist,',') LIKE '%,$fid,%'"); 1972 } 1973 1974 $db->delete_query("threads", "fid='{$fid}' {$delquery}"); 1975 $db->delete_query("posts", "fid='{$fid}' {$delquery}"); 1976 $db->delete_query("moderators", "fid='{$fid}' {$delquery}"); 1977 $db->delete_query("forumsubscriptions", "fid='{$fid}' {$delquery}"); 1978 1979 $cache->update_forums(); 1980 $cache->update_moderators(); 1981 $cache->update_forumpermissions(); 1982 1983 $update_stats = array( 1984 'numthreads' => "-".$stats['threads'], 1985 'numunapprovedthreads' => "-".$stats['unapprovedthreads'], 1986 'numposts' => "-".$stats['posts'], 1987 'numunapprovedposts' => "-".$stats['unapprovedposts'] 1988 ); 1989 update_stats($update_stats); 1990 1991 $plugins->run_hooks("admin_forum_management_delete_commit"); 1992 1993 // Log admin action 1994 log_admin_action($forum_info['fid'], $forum_info['name']); 1995 1996 flash_message($lang->success_forum_deleted, 'success'); 1997 admin_redirect("index.php?module=forum-management"); 1998 } 1999 else 2000 { 2001 $page->output_confirm_action("index.php?module=forum-management&action=delete&fid={$forum['fid']}", $lang->confirm_forum_deletion); 2002 } 2003 } 2004 2005 if(!$mybb->input['action']) 2006 { 2007 $plugins->run_hooks("admin_forum_management_start"); 2008 2009 if(!isset($mybb->input['fid'])) 2010 { 2011 $mybb->input['fid'] = 0; 2012 } 2013 2014 $fid = intval($mybb->input['fid']); 2015 if($fid) 2016 { 2017 $forum = get_forum($fid); 2018 } 2019 2020 if($mybb->request_method == "post") 2021 { 2022 if($mybb->input['update'] == "permissions") 2023 { 2024 $inherit = array(); 2025 foreach($mybb->input as $id => $permission) 2026 { 2027 // Make sure we're only skipping inputs that don't start with "fields_" and aren't fields_default_ or fields_inherit_ 2028 if(strpos($id, 'fields_') === false || (strpos($id, 'fields_default_') !== false || strpos($id, 'fields_inherit_') !== false)) 2029 { 2030 continue; 2031 } 2032 2033 list(, $gid) = explode('fields_', $id); 2034 2035 if($mybb->input['fields_default_'.$gid] == $permission && $mybb->input['fields_inherit_'.$gid] == 1) 2036 { 2037 $inherit[$gid] = 1; 2038 continue; 2039 } 2040 $inherit[$gid] = 0; 2041 2042 // If it isn't an array then it came from the javascript form 2043 if(!is_array($permission)) 2044 { 2045 $permission = explode(',', $permission); 2046 $permission = array_flip($permission); 2047 foreach($permission as $name => $value) 2048 { 2049 $permission[$name] = 1; 2050 } 2051 } 2052 foreach(array('canview','canpostthreads','canpostreplys','canpostpolls') as $name) 2053 { 2054 if($permission[$name]) 2055 { 2056 $permissions[$name][$gid] = 1; 2057 } 2058 else 2059 { 2060 $permissions[$name][$gid] = 0; 2061 } 2062 } 2063 } 2064 2065 $cache->update_forums(); 2066 2067 $canview = $permissions['canview']; 2068 $canpostthreads = $permissions['canpostthreads']; 2069 $canpostpolls = $permissions['canpostpolls']; 2070 $canpostattachments = $permissions['canpostattachments']; 2071 $canpostreplies = $permissions['canpostreplys']; 2072 2073 save_quick_perms($fid); 2074 2075 $plugins->run_hooks("admin_forum_management_start_permissions_commit"); 2076 2077 // Log admin action 2078 log_admin_action('quickpermissions', $fid, $forum['name']); 2079 2080 flash_message($lang->success_forum_permissions_updated, 'success'); 2081 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_permissions"); 2082 } 2083 elseif($mybb->input['add'] == "moderators") 2084 { 2085 $forum = get_forum($fid); 2086 if(!$forum) 2087 { 2088 flash_message($lang->error_invalid_forum, 'error'); 2089 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 2090 } 2091 if(!empty($mybb->input['usergroup'])) 2092 { 2093 $isgroup = 1; 2094 $gid = intval($mybb->input['usergroup']); 2095 2096 if(!$groupscache[$gid]) 2097 { 2098 // Didn't select a valid moderator 2099 flash_message($lang->error_moderator_not_found, 'error'); 2100 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 2101 } 2102 2103 $newmod = array( 2104 "id" => $gid, 2105 "name" => $groupscache[$gid]['title'] 2106 ); 2107 } 2108 else 2109 { 2110 $query = $db->simple_select("users", "uid AS id, username AS name", "username='".$db->escape_string($mybb->input['username'])."'", array('limit' => 1)); 2111 2112 if(!$db->num_rows($query)) 2113 { 2114 flash_message($lang->error_moderator_not_found, 'error'); 2115 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 2116 } 2117 2118 $isgroup = 0; 2119 $newmod = $db->fetch_array($query); 2120 } 2121 2122 if($newmod['id']) 2123 { 2124 $query = $db->simple_select("moderators", "id", "id='".$newmod['id']."' AND fid='".$fid."' AND isgroup='{$isgroup}'", array('limit' => 1)); 2125 2126 if(!$db->num_rows($query)) 2127 { 2128 $new_mod = array( 2129 "fid" => $fid, 2130 "id" => $newmod['id'], 2131 "isgroup" => $isgroup, 2132 "caneditposts" => 1, 2133 "candeleteposts" => 1, 2134 "canviewips" => 1, 2135 "canopenclosethreads" => 1, 2136 "canmanagethreads" => 1, 2137 "canmovetononmodforum" => 1, 2138 "canusecustomtools" => 1 2139 ); 2140 2141 $mid = $db->insert_query("moderators", $new_mod); 2142 2143 if(!$isgroup) 2144 { 2145 $db->update_query("users", array('usergroup' => 6), "uid='{$newmod['id']}' AND usergroup='2'"); 2146 } 2147 2148 $cache->update_moderators(); 2149 $plugins->run_hooks("admin_forum_management_start_moderators_commit"); 2150 2151 // Log admin action 2152 log_admin_action('addmod', $mid, $newmod['name'], $fid, $forum['name']); 2153 2154 flash_message($lang->success_moderator_added, 'success'); 2155 admin_redirect("index.php?module=forum-management&action=editmod&mid={$mid}"); 2156 } 2157 else 2158 { 2159 flash_message($lang->error_moderator_already_added, 'error'); 2160 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 2161 } 2162 } 2163 else 2164 { 2165 flash_message($lang->error_moderator_not_found, 'error'); 2166 admin_redirect("index.php?module=forum-management&fid={$fid}#tab_moderators"); 2167 } 2168 } 2169 else 2170 { 2171 if(!empty($mybb->input['disporder']) && is_array($mybb->input['disporder'])) 2172 { 2173 foreach($mybb->input['disporder'] as $update_fid => $order) 2174 { 2175 $db->update_query("forums", array('disporder' => intval($order)), "fid='".intval($update_fid)."'"); 2176 } 2177 2178 $cache->update_forums(); 2179 2180 $plugins->run_hooks("admin_forum_management_start_disporder_commit"); 2181 2182 // Log admin action 2183 log_admin_action('orders', $forum['fid'], $forum['name']); 2184 2185 flash_message($lang->success_forum_disporder_updated, 'success'); 2186 admin_redirect("index.php?module=forum-management&fid=".$mybb->input['fid']); 2187 } 2188 } 2189 } 2190 2191 $page->extra_header .= "<script src=\"../jscripts/scriptaculous.js?load=effects,dragdrop,controls\" type=\"text/javascript\"></script>\n"; 2192 $page->extra_header .= "<script src=\"jscripts/quick_perm_editor.js\" type=\"text/javascript\"></script>\n"; 2193 $page->extra_header .= "<script src=\"jscripts/imodal.js\" type=\"text/javascript\"></script>\n"; 2194 $page->extra_header .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/default/imodal.css\" />\n"; 2195 2196 if($fid) 2197 { 2198 $page->add_breadcrumb_item($lang->view_forum, "index.php?module=forum-management"); 2199 } 2200 2201 $page->output_header($lang->forum_management); 2202 2203 if($fid) 2204 { 2205 $page->output_nav_tabs($sub_tabs, 'view_forum'); 2206 } 2207 else 2208 { 2209 $page->output_nav_tabs($sub_tabs, 'forum_management'); 2210 } 2211 2212 $form = new Form("index.php?module=forum-management", "post", "management"); 2213 echo $form->generate_hidden_field("fid", $mybb->input['fid']); 2214 2215 if($fid) 2216 { 2217 $tabs = array( 2218 'subforums' => $lang->subforums, 2219 'permissions' => $lang->forum_permissions, 2220 'moderators' => $lang->moderators, 2221 ); 2222 2223 $page->output_tab_control($tabs); 2224 2225 echo "<div id=\"tab_subforums\">\n"; 2226 if(!isset($forum_cache) || !is_array($forum_cache)) 2227 { 2228 cache_forums(); 2229 } 2230 $form_container = new FormContainer($lang->sprintf($lang->in_forums, $forum_cache[$fid]['name'])); 2231 } 2232 else 2233 { 2234 $form_container = new FormContainer($lang->manage_forums); 2235 } 2236 $form_container->output_row_header($lang->forum); 2237 $form_container->output_row_header($lang->order, array("class" => "align_center", 'width' => '5%')); 2238 $form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 200px')); 2239 2240 build_admincp_forums_list($form_container, $fid); 2241 2242 $submit_options = array(); 2243 2244 if($form_container->num_rows() == 0) 2245 { 2246 $form_container->output_cell($lang->no_forums, array('colspan' => 3)); 2247 $form_container->construct_row(); 2248 $submit_options = array('disabled' => true); 2249 } 2250 2251 $form_container->end(); 2252 2253 $buttons[] = $form->generate_submit_button($lang->update_forum_orders, $submit_options); 2254 $buttons[] = $form->generate_reset_button($lang->reset); 2255 2256 $form->output_submit_wrapper($buttons); 2257 2258 if(!$fid) 2259 { 2260 $form->end(); 2261 } 2262 2263 if($fid) 2264 { 2265 echo "</div>\n"; 2266 $form->end(); 2267 2268 $query = $db->simple_select("usergroups", "*", "", array("order_dir" => "name")); 2269 while($usergroup = $db->fetch_array($query)) 2270 { 2271 $usergroups[$usergroup['gid']] = $usergroup; 2272 } 2273 2274 $query = $db->simple_select("forumpermissions", "*", "fid='{$fid}'"); 2275 while($existing = $db->fetch_array($query)) 2276 { 2277 $existing_permissions[$existing['gid']] = $existing; 2278 } 2279 2280 $cached_forum_perms = $cache->read("forumpermissions"); 2281 $field_list = array( 2282 'canview' => $lang->permissions_canview, 2283 'canpostthreads' => $lang->permissions_canpostthreads, 2284 'canpostreplys' => $lang->permissions_canpostreplys, 2285 'canpostpolls' => $lang->permissions_canpostpolls, 2286 ); 2287 2288 $field_list2 = array( 2289 'canview' => $lang->perm_drag_canview, 2290 'canpostthreads' => $lang->perm_drag_canpostthreads, 2291 'canpostreplys' => $lang->perm_drag_canpostreplys, 2292 'canpostpolls' => $lang->perm_drag_canpostpolls, 2293 ); 2294 2295 $ids = array(); 2296 2297 $form = new Form("index.php?module=forum-management", "post", "management"); 2298 echo $form->generate_hidden_field("fid", $mybb->input['fid']); 2299 echo $form->generate_hidden_field("update", "permissions"); 2300 2301 echo "<div id=\"tab_permissions\">\n"; 2302 2303 $form_container = new FormContainer($lang->sprintf($lang->forum_permissions_in, $forum_cache[$fid]['name'])); 2304 $form_container->output_row_header($lang->permissions_group, array("class" => "align_center", 'style' => 'width: 30%')); 2305 $form_container->output_row_header($lang->overview_allowed_actions, array("class" => "align_center")); 2306 $form_container->output_row_header($lang->overview_disallowed_actions, array("class" => "align_center")); 2307 $form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 120px', 'colspan' => 2)); 2308 foreach($usergroups as $usergroup) 2309 { 2310 $perms = array(); 2311 if(isset($mybb->input['default_permissions'])) 2312 { 2313 if($mybb->input['default_permissions'][$usergroup['gid']]) 2314 { 2315 if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 2316 { 2317 $perms = $existing_permissions[$usergroup['gid']]; 2318 $default_checked = false; 2319 } 2320 elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum['fid']][$usergroup['gid']]) 2321 { 2322 $perms = $cached_forum_perms[$forum['fid']][$usergroup['gid']]; 2323 $default_checked = true; 2324 } 2325 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum['pid']][$usergroup['gid']]) 2326 { 2327 $perms = $cached_forum_perms[$forum['pid']][$usergroup['gid']]; 2328 $default_checked = true; 2329 } 2330 } 2331 2332 if(!$perms) 2333 { 2334 $perms = $usergroup; 2335 $default_checked = true; 2336 } 2337 } 2338 else 2339 { 2340 if(isset($existing_permissions) && is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 2341 { 2342 $perms = $existing_permissions[$usergroup['gid']]; 2343 $default_checked = false; 2344 } 2345 elseif(is_array($cached_forum_perms) && isset($cached_forum_perms[$forum['fid']]) && $cached_forum_perms[$forum['fid']][$usergroup['gid']]) 2346 { 2347 $perms = $cached_forum_perms[$forum['fid']][$usergroup['gid']]; 2348 $default_checked = true; 2349 } 2350 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum['pid']][$usergroup['gid']]) 2351 { 2352 $perms = $cached_forum_perms[$forum['pid']][$usergroup['gid']]; 2353 $default_checked = true; 2354 } 2355 2356 if(!$perms) 2357 { 2358 $perms = $usergroup; 2359 $default_checked = true; 2360 } 2361 } 2362 foreach($field_list as $forum_permission => $forum_perm_title) 2363 { 2364 if(isset($mybb->input['permissions'])) 2365 { 2366 if($mybb->input['permissions'][$usergroup['gid']][$forum_permission]) 2367 { 2368 $perms_checked[$forum_permission] = 1; 2369 } 2370 else 2371 { 2372 $perms_checked[$forum_permission] = 0; 2373 } 2374 } 2375 else 2376 { 2377 if($perms[$forum_permission] == 1) 2378 { 2379 $perms_checked[$forum_permission] = 1; 2380 } 2381 else 2382 { 2383 $perms_checked[$forum_permission] = 0; 2384 } 2385 } 2386 } 2387 $usergroup['title'] = htmlspecialchars_uni($usergroup['title']); 2388 2389 if($default_checked == 1) 2390 { 2391 $inherited_text = $lang->inherited_permission; 2392 } 2393 else 2394 { 2395 $inherited_text = $lang->custom_permission; 2396 } 2397 2398 $form_container->output_cell("<strong>{$usergroup['title']}</strong> <small style=\"vertical-align: middle;\">({$inherited_text})</small>"); 2399 2400 $field_select = "<div class=\"quick_perm_fields\">\n"; 2401 $field_select .= "<div class=\"enabled\"><ul id=\"fields_enabled_{$usergroup['gid']}\">\n"; 2402 foreach($perms_checked as $perm => $value) 2403 { 2404 if($value == 1) 2405 { 2406 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 2407 } 2408 } 2409 $field_select .= "</ul></div>\n"; 2410 $field_select .= "<div class=\"disabled\"><ul id=\"fields_disabled_{$usergroup['gid']}\">\n"; 2411 foreach($perms_checked as $perm => $value) 2412 { 2413 if($value == 0) 2414 { 2415 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 2416 } 2417 } 2418 $field_select .= "</ul></div></div>\n"; 2419 $field_select .= $form->generate_hidden_field("fields_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_'.$usergroup['gid'])); 2420 $field_select .= $form->generate_hidden_field("fields_inherit_".$usergroup['gid'], (int)$default_checked, array('id' => 'fields_inherit_'.$usergroup['gid'])); 2421 $field_select .= $form->generate_hidden_field("fields_default_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, '1')), array('id' => 'fields_default_'.$usergroup['gid'])); 2422 $field_select = str_replace("'", "\\'", $field_select); 2423 $field_select = str_replace("\n", "", $field_select); 2424 2425 $field_select = "<script type=\"text/javascript\"> 2426 //<![CDATA[ 2427 document.write('".str_replace("/", "\/", $field_select)."'); 2428 //]]> 2429 </script>\n"; 2430 2431 $field_selected = array(); 2432 foreach($field_list as $forum_permission => $permission_title) 2433 { 2434 $field_options[$forum_permission] = $permission_title; 2435 if($perms_checked[$forum_permission]) 2436 { 2437 $field_selected[] = $forum_permission; 2438 } 2439 } 2440 2441 $field_select .= "<noscript>".$form->generate_select_box('fields_'.$usergroup['gid'].'[]', $field_options, $field_selected, array('id' => 'fields_'.$usergroup['gid'].'[]', 'multiple' => true))."</noscript>\n"; 2442 $form_container->output_cell($field_select, array('colspan' => 2)); 2443 2444 if(!$default_checked) 2445 { 2446 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&pid={$perms['pid']}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&pid={$perms['pid']}&ajax=1'}); return false;\">{$lang->edit_permissions}</a>", array("class" => "align_center")); 2447 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=clear_permission&pid={$perms['pid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_clear_custom_permission}')\">{$lang->clear_custom_perms}</a>", array("class" => "align_center")); 2448 } 2449 else 2450 { 2451 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}&ajax=1'}); return false;\">{$lang->set_custom_perms}</a>", array("class" => "align_center", "colspan" => 2)); 2452 } 2453 $form_container->construct_row(array('id' => 'row_'.$usergroup['gid'])); 2454 2455 $ids[] = $usergroup['gid']; 2456 } 2457 $form_container->end(); 2458 2459 $buttons = array(); 2460 $buttons[] = $form->generate_submit_button($lang->update_forum_permissions); 2461 $buttons[] = $form->generate_reset_button($lang->reset); 2462 2463 $form->output_submit_wrapper($buttons); 2464 2465 // Write in our JS based field selector 2466 echo "<script type=\"text/javascript\">\n<!--\n"; 2467 foreach($ids as $id) 2468 { 2469 echo "Event.observe(window, 'load', function(){ QuickPermEditor.init(".$id.") });\n"; 2470 } 2471 echo "// -->\n</script>\n"; 2472 2473 echo "</div>\n"; 2474 $form->end(); 2475 echo "<div id=\"tab_moderators\">\n"; 2476 $form_container = new FormContainer($lang->sprintf($lang->moderators_assigned_to, $forum_cache[$fid]['name'])); 2477 $form_container->output_row_header($lang->name, array('width' => '75%')); 2478 $form_container->output_row_header($lang->controls, array("class" => "align_center", 'style' => 'width: 200px', 'colspan' => 2)); 2479 $query = $db->query(" 2480 SELECT m.mid, m.id, m.isgroup, u.username, g.title 2481 FROM ".TABLE_PREFIX."moderators m 2482 LEFT JOIN ".TABLE_PREFIX."users u ON (m.isgroup='0' AND m.id=u.uid) 2483 LEFT JOIN ".TABLE_PREFIX."usergroups g ON (m.isgroup='1' AND m.id=g.gid) 2484 WHERE fid='{$fid}' 2485 ORDER BY m.isgroup DESC, u.username, g.title 2486 "); 2487 while($moderator = $db->fetch_array($query)) 2488 { 2489 if($moderator['isgroup']) 2490 { 2491 $moderator['img'] = "<img src=\"styles/{$page->style}/images/icons/group.gif\" alt=\"{$lang->group}\" title=\"{$lang->group}\" />"; 2492 $form_container->output_cell("{$moderator['img']} <a href=\"index.php?module=user-groups&action=edit&gid={$moderator['id']}\">".htmlspecialchars_uni($moderator['title'])." ({$lang->usergroup} {$moderator['id']})</a>"); 2493 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=editmod&mid={$moderator['mid']}\">{$lang->edit}</a>", array("class" => "align_center")); 2494 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=deletemod&id={$moderator['id']}&isgroup=1&fid={$fid}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_moderator_deletion}')\">{$lang->delete}</a>", array("class" => "align_center")); 2495 } 2496 else 2497 { 2498 $moderator['img'] = "<img src=\"styles/{$page->style}/images/icons/user.gif\" alt=\"{$lang->user}\" title=\"{$lang->user}\" />"; 2499 $form_container->output_cell("{$moderator['img']} <a href=\"index.php?module=user-users&action=edit&uid={$moderator['id']}\">".htmlspecialchars_uni($moderator['username'])."</a>"); 2500 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=editmod&mid={$moderator['mid']}\">{$lang->edit}</a>", array("class" => "align_center")); 2501 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=deletemod&id={$moderator['id']}&isgroup=0&fid={$fid}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_moderator_deletion}')\">{$lang->delete}</a>", array("class" => "align_center")); 2502 } 2503 $form_container->construct_row(); 2504 } 2505 2506 if($form_container->num_rows() == 0) 2507 { 2508 $form_container->output_cell($lang->no_moderators, array('colspan' => 3)); 2509 $form_container->construct_row(); 2510 } 2511 $form_container->end(); 2512 2513 // Users 2514 $buttons = array(); 2515 $form = new Form("index.php?module=forum-management", "post", "management"); 2516 echo $form->generate_hidden_field("fid", $mybb->input['fid']); 2517 echo $form->generate_hidden_field("add", "moderators"); 2518 2519 // Usergroup Moderator 2520 if(!is_array($usergroups)) 2521 { 2522 $usergroups = $groupscache; 2523 } 2524 2525 foreach($usergroups as $group) 2526 { 2527 $modgroups[$group['gid']] = $lang->usergroup." ".$group['gid'].": ".$group['title']; 2528 } 2529 2530 if(!isset($mybb->input['usergroup'])) 2531 { 2532 $mybb->input['usergroup'] = ''; 2533 } 2534 2535 if(!isset($mybb->input['username'])) 2536 { 2537 $mybb->input['username'] = ''; 2538 } 2539 2540 $form_container = new FormContainer($lang->add_usergroup_as_moderator); 2541 $form_container->output_row($lang->usergroup." <em>*</em>", $lang->moderator_usergroup_desc, $form->generate_select_box('usergroup', $modgroups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup'); 2542 $form_container->end(); 2543 2544 $buttons[] = $form->generate_submit_button($lang->add_usergroup_moderator); 2545 $form->output_submit_wrapper($buttons); 2546 $form->end(); 2547 echo "<br />"; 2548 2549 $form = new Form("index.php?module=forum-management", "post", "management"); 2550 echo $form->generate_hidden_field("fid", $mybb->input['fid']); 2551 echo $form->generate_hidden_field("add", "moderators"); 2552 $form_container = new FormContainer($lang->add_user_as_moderator); 2553 $form_container->output_row($lang->username." <em>*</em>", $lang->moderator_username_desc, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username'); 2554 $form_container->end(); 2555 2556 // Autocompletion for usernames 2557 echo ' 2558 <script type="text/javascript" src="../jscripts/autocomplete.js?ver=1400"></script> 2559 <script type="text/javascript"> 2560 <!-- 2561 new autoComplete("username", "../xmlhttp.php?action=get_users", {valueSpan: "username"}); 2562 // --> 2563 </script>'; 2564 2565 $buttons = array($form->generate_submit_button($lang->add_user_moderator)); 2566 $form->output_submit_wrapper($buttons); 2567 $form->end(); 2568 2569 echo "</div>\n"; 2570 } 2571 2572 $page->output_footer(); 2573 } 2574 2575 /** 2576 * 2577 */ 2578 function build_admincp_forums_list(&$form_container, $pid=0, $depth=1) 2579 { 2580 global $mybb, $lang, $db, $sub_forums; 2581 static $forums_by_parent; 2582 2583 if(!is_array($forums_by_parent)) 2584 { 2585 $forum_cache = cache_forums(); 2586 2587 foreach($forum_cache as $forum) 2588 { 2589 $forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum; 2590 } 2591 } 2592 2593 if(!is_array($forums_by_parent[$pid])) 2594 { 2595 return; 2596 } 2597 2598 foreach($forums_by_parent[$pid] as $children) 2599 { 2600 foreach($children as $forum) 2601 { 2602 $forum['name'] = preg_replace("#&(?!\#[0-9]+;)#si", "&", $forum['name']); // Fix & but allow unicode 2603 2604 if($forum['active'] == 0) 2605 { 2606 $forum['name'] = "<em>".$forum['name']."</em>"; 2607 } 2608 2609 if($forum['type'] == "c" && ($depth == 1 || $depth == 2)) 2610 { 2611 $sub_forums = ''; 2612 if(isset($forums_by_parent[$forum['fid']]) && $depth == 2) 2613 { 2614 build_admincp_forums_list($form_container, $forum['fid'], $depth+1); 2615 } 2616 if($sub_forums) 2617 { 2618 $sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>"; 2619 } 2620 2621 $form_container->output_cell("<div style=\"padding-left: ".(40*($depth-1))."px;\"><a href=\"index.php?module=forum-management&fid={$forum['fid']}\"><strong>{$forum['name']}</strong></a>{$sub_forums}</div>"); 2622 2623 $form_container->output_cell("<input type=\"text\" name=\"disporder[".$forum['fid']."]\" value=\"".$forum['disporder']."\" class=\"text_input align_center\" style=\"width: 80%; font-weight: bold;\" />", array("class" => "align_center")); 2624 2625 $popup = new PopupMenu("forum_{$forum['fid']}", $lang->options); 2626 $popup->add_item($lang->edit_forum, "index.php?module=forum-management&action=edit&fid={$forum['fid']}"); 2627 $popup->add_item($lang->subforums, "index.php?module=forum-management&fid={$forum['fid']}"); 2628 $popup->add_item($lang->moderators, "index.php?module=forum-management&fid={$forum['fid']}#tab_moderators"); 2629 $popup->add_item($lang->permissions, "index.php?module=forum-management&fid={$forum['fid']}#tab_permissions"); 2630 $popup->add_item($lang->add_child_forum, "index.php?module=forum-management&action=add&pid={$forum['fid']}"); 2631 $popup->add_item($lang->copy_forum, "index.php?module=forum-management&action=copy&fid={$forum['fid']}"); 2632 $popup->add_item($lang->delete_forum, "index.php?module=forum-management&action=delete&fid={$forum['fid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')"); 2633 2634 $form_container->output_cell($popup->fetch(), array("class" => "align_center")); 2635 2636 $form_container->construct_row(); 2637 2638 // Does this category have any sub forums? 2639 if($forums_by_parent[$forum['fid']]) 2640 { 2641 build_admincp_forums_list($form_container, $forum['fid'], $depth+1); 2642 } 2643 } 2644 elseif($forum['type'] == "f" && ($depth == 1 || $depth == 2)) 2645 { 2646 if($forum['description']) 2647 { 2648 $forum['description'] = preg_replace("#&(?!\#[0-9]+;)#si", "&", $forum['description']); 2649 $forum['description'] = "<br /><small>".$forum['description']."</small>"; 2650 } 2651 2652 $sub_forums = ''; 2653 if(isset($forums_by_parent[$forum['fid']]) && $depth == 2) 2654 { 2655 build_admincp_forums_list($form_container, $forum['fid'], $depth+1); 2656 } 2657 if($sub_forums) 2658 { 2659 $sub_forums = "<br /><small>{$lang->sub_forums}: {$sub_forums}</small>"; 2660 } 2661 2662 $form_container->output_cell("<div style=\"padding-left: ".(40*($depth-1))."px;\"><a href=\"index.php?module=forum-management&fid={$forum['fid']}\">{$forum['name']}</a>{$forum['description']}{$sub_forums}</div>"); 2663 2664 $form_container->output_cell("<input type=\"text\" name=\"disporder[".$forum['fid']."]\" value=\"".$forum['disporder']."\" class=\"text_input align_center\" style=\"width: 80%;\" />", array("class" => "align_center")); 2665 2666 $popup = new PopupMenu("forum_{$forum['fid']}", $lang->options); 2667 $popup->add_item($lang->edit_forum, "index.php?module=forum-management&action=edit&fid={$forum['fid']}"); 2668 $popup->add_item($lang->subforums, "index.php?module=forum-management&fid={$forum['fid']}"); 2669 $popup->add_item($lang->moderators, "index.php?module=forum-management&fid={$forum['fid']}#tab_moderators"); 2670 $popup->add_item($lang->permissions, "index.php?module=forum-management&fid={$forum['fid']}#tab_permissions"); 2671 $popup->add_item($lang->add_child_forum, "index.php?module=forum-management&action=add&pid={$forum['fid']}"); 2672 $popup->add_item($lang->copy_forum, "index.php?module=forum-management&action=copy&fid={$forum['fid']}"); 2673 $popup->add_item($lang->delete_forum, "index.php?module=forum-management&action=delete&fid={$forum['fid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_forum_deletion}')"); 2674 2675 $form_container->output_cell($popup->fetch(), array("class" => "align_center")); 2676 2677 $form_container->construct_row(); 2678 2679 if(isset($forums_by_parent[$forum['fid']]) && $depth == 1) 2680 { 2681 build_admincp_forums_list($form_container, $forum['fid'], $depth+1); 2682 } 2683 } 2684 else if($depth == 3) 2685 { 2686 if($donecount < $mybb->settings['subforumsindex']) 2687 { 2688 $sub_forums .= "{$comma} <a href=\"index.php?module=forum-management&fid={$forum['fid']}\">{$forum['name']}</a>"; 2689 $comma = $lang->comma; 2690 } 2691 2692 // Have we reached our max visible subforums? put a nice message and break out of the loop 2693 ++$donecount; 2694 if($donecount == $mybb->settings['subforumsindex']) 2695 { 2696 if(subforums_count($forums_by_parent[$pid]) > $donecount) 2697 { 2698 $sub_forums .= $comma.$lang->sprintf($lang->more_subforums, (subforums_count($forums_by_parent[$pid]) - $donecount)); 2699 return; 2700 } 2701 } 2702 } 2703 } 2704 } 2705 } 2706 2707 function retrieve_single_permissions_row($gid, $fid) 2708 { 2709 global $mybb, $lang, $cache, $db; 2710 2711 $query = $db->simple_select("usergroups", "*", "gid='{$gid}'"); 2712 $usergroup = $db->fetch_array($query); 2713 2714 $query = $db->simple_select("forums", "*", "fid='{$fid}'"); 2715 $forum_data = $db->fetch_array($query); 2716 2717 $query = $db->simple_select("forumpermissions", "*", "fid='{$fid}'"); 2718 while($existing = $db->fetch_array($query)) 2719 { 2720 $existing_permissions[$existing['gid']] = $existing; 2721 } 2722 2723 $cached_forum_perms = $cache->read("forumpermissions"); 2724 $field_list = array( 2725 'canview' => $lang->permissions_canview, 2726 'canpostthreads' => $lang->permissions_canpostthreads, 2727 'canpostreplys' => $lang->permissions_canpostreplys, 2728 'canpostpolls' => $lang->permissions_canpostpolls, 2729 ); 2730 2731 $field_list2 = array( 2732 'canview' => $lang->permissions_canview, 2733 'canpostthreads' => $lang->permissions_canpostthreads, 2734 'canpostreplys' => $lang->permissions_canpostreplys, 2735 'canpostpolls' => $lang->permissions_canpostpolls, 2736 ); 2737 2738 $form = new Form('', '', "", 0, "", true); 2739 $form_container = new FormContainer(); 2740 2741 $perms = array(); 2742 2743 if(is_array($existing_permissions) && $existing_permissions[$usergroup['gid']]) 2744 { 2745 $perms = $existing_permissions[$usergroup['gid']]; 2746 $default_checked = false; 2747 } 2748 elseif(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]) 2749 { 2750 $perms = $cached_forum_perms[$forum_data['fid']][$usergroup['gid']]; 2751 $default_checked = true; 2752 } 2753 else if(is_array($cached_forum_perms) && $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]) 2754 { 2755 $perms = $cached_forum_perms[$forum_data['pid']][$usergroup['gid']]; 2756 $default_checked = true; 2757 } 2758 2759 if(!$perms) 2760 { 2761 $perms = $usergroup; 2762 $default_checked = true; 2763 } 2764 2765 foreach($field_list as $forum_permission => $forum_perm_title) 2766 { 2767 if($perms[$forum_permission] == 1) 2768 { 2769 $perms_checked[$forum_permission] = 1; 2770 } 2771 else 2772 { 2773 $perms_checked[$forum_permission] = 0; 2774 } 2775 } 2776 2777 $usergroup['title'] = htmlspecialchars_uni($usergroup['title']); 2778 2779 if($default_checked == 1) 2780 { 2781 $inherited_text = $lang->inherited_permission; 2782 } 2783 else 2784 { 2785 $inherited_text = $lang->custom_permission; 2786 } 2787 2788 $form_container->output_cell("<strong>{$usergroup['title']}</strong> <small style=\"vertical-align: middle;\">({$inherited_text})</small>"); 2789 2790 $field_select = "<div class=\"quick_perm_fields\">\n"; 2791 $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled_{$usergroup['gid']}\">\n"; 2792 foreach($perms_checked as $perm => $value) 2793 { 2794 if($value == 1) 2795 { 2796 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 2797 } 2798 } 2799 $field_select .= "</ul></div>\n"; 2800 $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled_{$usergroup['gid']}\">\n"; 2801 foreach($perms_checked as $perm => $value) 2802 { 2803 if($value == 0) 2804 { 2805 $field_select .= "<li id=\"field-{$perm}\">{$field_list2[$perm]}</li>"; 2806 } 2807 } 2808 $field_select .= "</ul></div></div>\n"; 2809 $field_select .= $form->generate_hidden_field("fields_".$usergroup['gid'], @implode(",", @array_keys($perms_checked, 1)), array('id' => 'fields_'.$usergroup['gid'])); 2810 $field_select = str_replace("\n", "", $field_select); 2811 2812 foreach($field_list as $forum_permission => $permission_title) 2813 { 2814 $field_options[$forum_permission] = $permission_title; 2815 } 2816 $form_container->output_cell($field_select, array('colspan' => 2)); 2817 2818 if(!$default_checked) 2819 { 2820 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&pid={$perms['pid']}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&pid={$perms['pid']}&ajax=1'}); return false;\">{$lang->edit_permissions}</a>", array("class" => "align_center")); 2821 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=clear_permission&pid={$perms['pid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_clear_custom_permission}')\">{$lang->clear_custom_perms}</a>", array("class" => "align_center")); 2822 } 2823 else 2824 { 2825 $form_container->output_cell("<a href=\"index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}\" onclick=\"modal = new MyModal({type: 'ajax', url: 'index.php?module=forum-management&action=permissions&gid={$usergroup['gid']}&fid={$fid}&ajax=1'}); return false;\">{$lang->set_custom_perms}</a>", array("class" => "align_center", "colspan" => 2)); 2826 } 2827 $form_container->construct_row(); 2828 return $form_container->output_row_cells(0, true); 2829 } 2830 2831 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |