[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/modules/config/ -> mod_tools.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $page->add_breadcrumb_item($lang->mod_tools, "index.php?module=config-mod_tools");
  18  
  19  $plugins->run_hooks("admin_config_mod_tools_begin");
  20  
  21  if($mybb->input['action'] == "delete_post_tool")
  22  {
  23      $query = $db->simple_select("modtools", "*", "tid='{$mybb->input['tid']}'");
  24      $tool = $db->fetch_array($query);
  25  
  26      // Does the post tool not exist?
  27      if(!$tool)
  28      {
  29          flash_message($lang->error_invalid_post_tool, 'error');
  30          admin_redirect("index.php?module=config-mod_tools&action=post_tools");
  31      }
  32  
  33      // User clicked no
  34      if($mybb->get_input('no'))
  35      {
  36          admin_redirect("index.php?module=config-mod_tools&action=post_tools");
  37      }
  38  
  39      $plugins->run_hooks("admin_config_mod_tools_delete_post_tool");
  40  
  41      if($mybb->request_method == 'post')
  42      {
  43          // Delete the type
  44          $db->delete_query('modtools', "tid='{$tool['tid']}'");
  45  
  46          $plugins->run_hooks("admin_config_mod_tools_delete_post_tool_commit");
  47  
  48          // Log admin action
  49          log_admin_action($tool['tid'], $tool['name']);
  50          $cache->update_forumsdisplay();
  51  
  52          flash_message($lang->success_post_tool_deleted, 'success');
  53          admin_redirect("index.php?module=config-mod_tools&action=post_tools");
  54      }
  55      else
  56      {
  57          $page->output_confirm_action("index.php?module=config-mod_tools&amp;action=post_tools&amp;tid={$type['tid']}", $lang->confirm_post_tool_deletion);
  58      }
  59  }
  60  
  61  if($mybb->input['action'] == "delete_thread_tool")
  62  {
  63      $query = $db->simple_select("modtools", "*", "tid='{$mybb->input['tid']}'");
  64      $tool = $db->fetch_array($query);
  65  
  66      // Does the post tool not exist?
  67      if(!$tool)
  68      {
  69          flash_message($lang->error_invalid_thread_tool, 'error');
  70          admin_redirect("index.php?module=config-mod_tools");
  71      }
  72  
  73      // User clicked no
  74      if($mybb->get_input('no'))
  75      {
  76          admin_redirect("index.php?module=config-mod_tools");
  77      }
  78  
  79      $plugins->run_hooks("admin_config_mod_tools_delete_thread_tool");
  80  
  81      if($mybb->request_method == 'post')
  82      {
  83          // Delete the type
  84          $db->delete_query('modtools', "tid='{$tool['tid']}'");
  85  
  86          $plugins->run_hooks("admin_config_mod_tools_delete_thread_tool_commit");
  87  
  88          // Log admin action
  89          log_admin_action($tool['tid'], $tool['name']);
  90          $cache->update_forumsdisplay();
  91  
  92          flash_message($lang->success_thread_tool_deleted, 'success');
  93          admin_redirect("index.php?module=config-mod_tools");
  94      }
  95      else
  96      {
  97          $page->output_confirm_action("index.php?module=config-mod_tools&amp;action=delete_thread_tool&amp;tid={$tool['tid']}", $lang->confirm_thread_tool_deletion);
  98      }
  99  }
 100  
 101  if($mybb->input['action'] == "post_tools")
 102  {
 103      $plugins->run_hooks("admin_config_mod_tools_post_tools");
 104  
 105      $page->add_breadcrumb_item($lang->post_tools);
 106      $page->output_header($lang->mod_tools." - ".$lang->post_tools);
 107  
 108      $sub_tabs['thread_tools'] = array(
 109          'title' => $lang->thread_tools,
 110          'link' => "index.php?module=config-mod_tools"
 111      );
 112      $sub_tabs['add_thread_tool'] = array(
 113          'title'=> $lang->add_thread_tool,
 114          'link' => "index.php?module=config-mod_tools&amp;action=add_thread_tool"
 115      );
 116      $sub_tabs['post_tools'] = array(
 117          'title' => $lang->post_tools,
 118          'link' => "index.php?module=config-mod_tools&amp;action=post_tools",
 119          'description' => $lang->post_tools_desc
 120      );
 121      $sub_tabs['add_post_tool'] = array(
 122          'title'=> $lang->add_post_tool,
 123          'link' => "index.php?module=config-mod_tools&amp;action=add_post_tool"
 124      );
 125  
 126      $page->output_nav_tabs($sub_tabs, 'post_tools');
 127  
 128      $table = new Table;
 129      $table->construct_header($lang->title);
 130      $table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
 131  
 132      $query = $db->simple_select('modtools', 'tid, name, description, type', "type='p'", array('order_by' => 'name'));
 133      while($tool = $db->fetch_array($query))
 134      {
 135          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_post_tool&amp;tid={$tool['tid']}\"><strong>".htmlspecialchars_uni($tool['name'])."</strong></a><br /><small>".htmlspecialchars_uni($tool['description'])."</small>");
 136          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_post_tool&amp;tid={$tool['tid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center"));
 137          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=delete_post_tool&amp;tid={$tool['tid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_post_tool_deletion}')\">{$lang->delete}</a>", array('width' => 100, 'class' => "align_center"));
 138          $table->construct_row();
 139      }
 140  
 141      if($table->num_rows() == 0)
 142      {
 143          $table->construct_cell($lang->no_post_tools, array('colspan' => 3));
 144          $table->construct_row();
 145      }
 146  
 147      $table->output($lang->post_tools);
 148  
 149      $page->output_footer();
 150  }
 151  
 152  if($mybb->input['action'] == "edit_thread_tool")
 153  {
 154      $query = $db->simple_select("modtools", "COUNT(tid) as tools", "tid = '{$mybb->input['tid']}' AND type='t'");
 155      if($db->fetch_field($query, "tools") < 1)
 156      {
 157          flash_message($lang->error_invalid_thread_tool, 'error');
 158          admin_redirect("index.php?module=config-mod_tools");
 159      }
 160  
 161      $plugins->run_hooks("admin_config_mod_tools_edit_thread_tool");
 162  
 163      if($mybb->request_method == 'post')
 164      {
 165          if(trim($mybb->input['title']) == "")
 166          {
 167              $errors[] = $lang->error_missing_title;
 168          }
 169  
 170          if(trim($mybb->input['description']) == "")
 171          {
 172              $errors[] = $lang->error_missing_description;
 173          }
 174  
 175          if($mybb->input['forum_type'] == 2)
 176          {
 177              $forum_checked[1] = '';
 178              $forum_checked[2] = "checked=\"checked\"";
 179  
 180              if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
 181              {
 182                  $errors[] = $lang->error_no_forums_selected;
 183              }
 184          }
 185          else
 186          {
 187              $forum_checked[1] = "checked=\"checked\"";
 188              $forum_checked[2] = '';
 189  
 190              $mybb->input['forum_1_forums'] = '';
 191          }
 192  
 193          if($mybb->input['group_type'] == 2)
 194          {
 195              $group_checked[1] = '';
 196              $group_checked[2] = "checked=\"checked\"";
 197  
 198              if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
 199              {
 200                  $errors[] = $lang->error_no_groups_selected;
 201              }
 202          }
 203          else
 204          {
 205              $group_checked[1] = "checked=\"checked\"";
 206              $group_checked[2] = '';
 207  
 208              $mybb->input['group_1_groups'] = '';
 209          }
 210  
 211          if($mybb->input['approvethread'] != '' && $mybb->input['approvethread'] != 'approve' && $mybb->input['approvethread'] != 'unapprove' && $mybb->input['approvethread'] != 'toggle')
 212          {
 213              $mybb->input['approvethread'] = '';
 214          }
 215  
 216          if($mybb->input['softdeletethread'] != '' && $mybb->input['softdeletethread'] != 'softdelete' && $mybb->input['softdeletethread'] != 'restore' && $mybb->input['softdeletethread'] != 'toggle')
 217          {
 218              $mybb->input['softdeletethread'] = '';
 219          }
 220  
 221          if($mybb->input['openthread'] != '' && $mybb->input['openthread'] != 'open' && $mybb->input['openthread'] != 'close' && $mybb->input['openthread'] != 'toggle')
 222          {
 223              $mybb->input['openthread'] = '';
 224          }
 225  
 226          if($mybb->input['stickthread'] != '' && $mybb->input['stickthread'] != 'stick' && $mybb->input['stickthread'] != 'unstick' && $mybb->input['stickthread'] != 'toggle')
 227          {
 228              $mybb->input['stickthread'] = '';
 229          }
 230  
 231          if($mybb->input['move_type'] == 2)
 232          {
 233              $move_checked[1] = '';
 234              $move_checked[2] = "checked=\"checked\"";
 235  
 236              if(!$mybb->input['move_1_forum'])
 237              {
 238                  $errors[] = $lang->error_no_move_forum_selected;
 239              }
 240              else
 241              {
 242                  // Check that the destination forum is not a category
 243                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('move_1_forum', MyBB::INPUT_INT)."'");
 244                  if($db->fetch_field($query, "type") == "c")
 245                  {
 246                      $errors[] = $lang->error_forum_is_category;
 247                  }
 248              }
 249  
 250              if($mybb->input['move_2_redirect'] != 1 && $mybb->input['move_2_redirect'] != 0)
 251              {
 252                  $mybb->input['move_2_redirect'] = 0;
 253              }
 254  
 255              if(!isset($mybb->input['move_3_redirecttime']))
 256              {
 257                  $mybb->input['move_3_redirecttime'] = '';
 258              }
 259          }
 260          else
 261          {
 262              $move_checked[1] = "checked=\"checked\"";
 263              $move_checked[2] = '';
 264  
 265              $mybb->input['move_1_forum'] = '';
 266              $mybb->input['move_2_redirect'] = 0;
 267              $mybb->input['move_3_redirecttime'] = '';
 268          }
 269  
 270          if($mybb->input['copy_type'] == 2)
 271          {
 272              $copy_checked[1] = '';
 273              $copy_checked[2] = "checked=\"checked\"";
 274  
 275              if(!$mybb->input['copy_1_forum'])
 276              {
 277                  $errors[] = $lang->error_no_copy_forum_selected;
 278              }
 279              else
 280              {
 281                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('copy_1_forum', MyBB::INPUT_INT)."'");
 282                  if($db->fetch_field($query, "type") == "c")
 283                  {
 284                      $errors[] = $lang->error_forum_is_category;
 285                  }
 286              }
 287          }
 288          else
 289          {
 290              $copy_checked[1] = "checked=\"checked\"";
 291              $copy_checked[2] = '';
 292  
 293              $mybb->input['copy_1_forum'] = '';
 294          }
 295  
 296          if(!$errors)
 297          {
 298              $thread_options = array(
 299                  'confirmation' => $mybb->get_input('confirmation', MyBB::INPUT_INT),
 300                  'deletethread' => $mybb->get_input('deletethread', MyBB::INPUT_INT),
 301                  'mergethreads' => $mybb->get_input('mergethreads', MyBB::INPUT_INT),
 302                  'deletepoll' => $mybb->get_input('deletepoll', MyBB::INPUT_INT),
 303                  'removeredirects' => $mybb->get_input('removeredirects', MyBB::INPUT_INT),
 304                  'removesubscriptions' => $mybb->get_input('removesubscriptions', MyBB::INPUT_INT),
 305                  'recountrebuild' => $mybb->get_input('recountrebuild', MyBB::INPUT_INT),
 306                  'approvethread' => $mybb->input['approvethread'],
 307                  'softdeletethread' => $mybb->input['softdeletethread'],
 308                  'openthread' => $mybb->input['openthread'],
 309                  'stickthread' => $mybb->input['stickthread'],
 310                  'movethread' => $mybb->get_input('move_1_forum', MyBB::INPUT_INT),
 311                  'movethreadredirect' => $mybb->get_input('move_2_redirect', MyBB::INPUT_INT),
 312                  'movethreadredirectexpire' => $mybb->get_input('move_3_redirecttime', MyBB::INPUT_INT),
 313                  'copythread' => $mybb->get_input('copy_1_forum', MyBB::INPUT_INT),
 314                  'newsubject' => $mybb->input['newsubject'],
 315                  'addreply' => $mybb->input['newreply'],
 316                  'replysubject' => $mybb->input['newreplysubject'],
 317                  'pm_subject' => $mybb->input['pm_subject'],
 318                  'pm_message' => $mybb->input['pm_message'],
 319                  'threadprefix' => $mybb->get_input('threadprefix', MyBB::INPUT_INT)
 320              );
 321  
 322              $args = array(
 323                  'thread_options' => &$thread_options,
 324              );
 325  
 326              $plugins->run_hooks("admin_config_mod_tools_edit_thread_tool_options", $args);
 327  
 328              $update_tool['type'] = 't';
 329              $update_tool['threadoptions'] = $db->escape_string(my_serialize($thread_options));
 330              $update_tool['name'] = $db->escape_string($mybb->input['title']);
 331              $update_tool['description'] = $db->escape_string($mybb->input['description']);
 332              $update_tool['forums'] = '';
 333              $update_tool['groups'] = '';
 334  
 335              if($mybb->input['forum_type'] == 2)
 336              {
 337                  if(is_array($mybb->input['forum_1_forums']))
 338                  {
 339                      $checked = array();
 340  
 341                      foreach($mybb->input['forum_1_forums'] as $fid)
 342                      {
 343                          $checked[] = (int)$fid;
 344                      }
 345  
 346                      $update_tool['forums'] = implode(',', $checked);
 347                  }
 348              }
 349              else
 350              {
 351                  $update_tool['forums'] = "-1";
 352              }
 353  
 354              if($mybb->input['group_type'] == 2)
 355              {
 356                  if(is_array($mybb->input['group_1_groups']))
 357                  {
 358                      $checked = array();
 359  
 360                      foreach($mybb->input['group_1_groups'] as $gid)
 361                      {
 362                          $checked[] = (int)$gid;
 363                      }
 364  
 365                      $update_tool['groups'] = implode(',', $checked);
 366                  }
 367              }
 368              else
 369              {
 370                  $update_tool['groups'] = "-1";
 371              }
 372  
 373              $plugins->run_hooks("admin_config_mod_tools_edit_thread_tool_commit");
 374  
 375              $db->update_query("modtools", $update_tool, "tid='{$mybb->input['tid']}'");
 376  
 377              // Log admin action
 378              log_admin_action($mybb->input['tid'], $mybb->input['title']);
 379              $cache->update_forumsdisplay();
 380  
 381              flash_message($lang->success_mod_tool_updated, 'success');
 382              admin_redirect("index.php?module=config-mod_tools");
 383          }
 384      }
 385  
 386      $page->add_breadcrumb_item($lang->edit_thread_tool);
 387      $page->output_header($lang->mod_tools." - ".$lang->edit_thread_tool);
 388  
 389      $sub_tabs['edit_thread_tool'] = array(
 390          "title" => $lang->edit_thread_tool,
 391          "description" => $lang->edit_thread_tool_desc,
 392          "link" => "index.php?module=config-mod_tools"
 393      );
 394  
 395      $page->output_nav_tabs($sub_tabs, 'edit_thread_tool');
 396  
 397      $form = new Form("index.php?module=config-mod_tools&amp;action=edit_thread_tool", 'post');
 398      echo $form->generate_hidden_field("tid", $mybb->input['tid']);
 399  
 400      if($errors)
 401      {
 402          $page->output_inline_error($errors);
 403      }
 404      else
 405      {
 406          $query = $db->simple_select("modtools", "*", "tid = '{$mybb->input['tid']}'");
 407          $modtool = $db->fetch_array($query);
 408          $thread_options = my_unserialize($modtool['threadoptions']);
 409  
 410          $mybb->input['title'] = $modtool['name'];
 411          $mybb->input['description'] = $modtool['description'];
 412          $mybb->input['forum_1_forums'] = explode(",", $modtool['forums']);
 413          $mybb->input['group_1_groups'] = explode(",", $modtool['groups']);
 414  
 415          if(!$modtool['forums'] || $modtool['forums'] == -1)
 416          {
 417              $forum_checked[1] = "checked=\"checked\"";
 418              $forum_checked[2] = '';
 419          }
 420          else
 421          {
 422              $forum_checked[1] = '';
 423              $forum_checked[2] = "checked=\"checked\"";
 424          }
 425  
 426          if(!$modtool['groups'] || $modtool['groups'] == -1)
 427          {
 428              $group_checked[1] = "checked=\"checked\"";
 429              $group_checked[2] = '';
 430          }
 431          else
 432          {
 433              $group_checked[1] = '';
 434              $group_checked[2] = "checked=\"checked\"";
 435          }
 436  
 437          $mybb->input['confirmation'] = $thread_options['confirmation'];
 438          $mybb->input['approvethread'] = $thread_options['approvethread'];
 439          $mybb->input['softdeletethread'] = $thread_options['softdeletethread'];
 440          $mybb->input['openthread'] = $thread_options['openthread'];
 441          $mybb->input['stickthread'] = $thread_options['stickthread'];
 442          $mybb->input['move_1_forum'] = $thread_options['movethread'];
 443          $mybb->input['move_2_redirect'] = $thread_options['movethreadredirect'];
 444          $mybb->input['move_3_redirecttime'] = $thread_options['movethreadredirectexpire'];
 445  
 446          if(!$thread_options['movethread'])
 447          {
 448              $move_checked[1] = "checked=\"checked\"";
 449              $move_checked[2] = '';
 450          }
 451          else
 452          {
 453              $move_checked[1] = '';
 454              $move_checked[2] = "checked=\"checked\"";
 455          }
 456  
 457          if(!$thread_options['copythread'])
 458          {
 459              $copy_checked[1] = "checked=\"checked\"";
 460              $copy_checked[2] = '';
 461          }
 462          else
 463          {
 464              $copy_checked[1] = '';
 465              $copy_checked[2] = "checked=\"checked\"";
 466          }
 467  
 468          $mybb->input['copy_1_forum'] = $thread_options['copythread'];
 469          $mybb->input['deletethread'] = $thread_options['deletethread'];
 470          $mybb->input['mergethreads'] = $thread_options['mergethreads'];
 471          $mybb->input['deletepoll'] = $thread_options['deletepoll'];
 472          $mybb->input['removeredirects'] = $thread_options['removeredirects'];
 473          $mybb->input['removesubscriptions'] = $thread_options['removesubscriptions'];
 474          $mybb->input['recountrebuild'] = $thread_options['recountrebuild'];
 475          $mybb->input['threadprefix'] = $thread_options['threadprefix'];
 476          $mybb->input['newsubject'] = $thread_options['newsubject'];
 477          $mybb->input['newreply'] = $thread_options['addreply'];
 478          $mybb->input['newreplysubject'] = $thread_options['replysubject'];
 479          $mybb->input['pm_subject'] = $thread_options['pm_subject'];
 480          $mybb->input['pm_message'] = $thread_options['pm_message'];
 481      }
 482  
 483      $form_container = new FormContainer($lang->general_options);
 484      $form_container->output_row($lang->name." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 485      $form_container->output_row($lang->short_description." <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 486  
 487      $actions = "<script type=\"text/javascript\">
 488  	function checkAction(id)
 489      {
 490          var checked = '';
 491  
 492          $('.'+id+'s_check').each(function(e, val)
 493          {
 494              if($(this).prop('checked') == true)
 495              {
 496                  checked = $(this).val();
 497              }
 498          });
 499          $('.'+id+'s').each(function(e)
 500          {
 501              $(this).hide();
 502          });
 503          if($('#'+id+'_'+checked))
 504          {
 505              $('#'+id+'_'+checked).show();
 506          }
 507      }
 508  </script>
 509      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 510      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
 511          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
 512          <dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
 513              <table cellpadding=\"4\">
 514                  <tr>
 515                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
 516                      <td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
 517                  </tr>
 518              </table>
 519          </dd>
 520      </dl>
 521      <script type=\"text/javascript\">
 522      checkAction('forum');
 523      </script>";
 524      $form_container->output_row($lang->available_in_forums." <em>*</em>", '', $actions);
 525  
 526      $actions = "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 527      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 528          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 529          <dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
 530              <table cellpadding=\"4\">
 531                  <tr>
 532                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 533                      <td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
 534                  </tr>
 535              </table>
 536          </dd>
 537      </dl>
 538      <script type=\"text/javascript\">
 539      checkAction('group');
 540      </script>";
 541      $form_container->output_row($lang->available_to_groups." <em>*</em>", '', $actions);
 542      $form_container->output_row($lang->show_confirmation." <em>*</em>", '', $form->generate_yes_no_radio('confirmation', $mybb->input['confirmation'], array('style' => 'width: 2em;')));
 543      $form_container->end();
 544  
 545      $approve_unapprove = array(
 546          '' => $lang->no_change,
 547          'approve' => $lang->approve,
 548          'unapprove' => $lang->unapprove,
 549          'toggle' => $lang->toggle
 550      );
 551  
 552      $open_close = array(
 553          '' => $lang->no_change,
 554          'open' => $lang->open,
 555          'close' => $lang->close,
 556          'toggle' => $lang->toggle
 557      );
 558  
 559      $stick_unstick = array(
 560          '' => $lang->no_change,
 561          'stick' => $lang->stick,
 562          'unstick' => $lang->unstick,
 563          'toggle' => $lang->toggle
 564      );
 565  
 566      $form_container = new FormContainer($lang->thread_moderation);
 567      $form_container->output_row($lang->approve_unapprove." <em>*</em>", '', $form->generate_select_box('approvethread', $approve_unapprove, $mybb->input['approvethread'], array('id' => 'approvethread')), 'approvethread');
 568      $form_container->output_row($lang->open_close_thread." <em>*</em>", '', $form->generate_select_box('openthread', $open_close, $mybb->input['openthread'], array('id' => 'openthread')), 'openthread');
 569      $form_container->output_row($lang->stick_unstick_thread." <em>*</em>", '', $form->generate_select_box('stickthread', $stick_unstick, $mybb->input['stickthread'], array('id' => 'stickthread')), 'stickthread');
 570  
 571  
 572      $actions = "
 573      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 574      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"1\" {$move_checked[1]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_move_thread}</strong></label></dt>
 575          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"2\" {$move_checked[2]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->move_thread}</strong></label></dt>
 576          <dd style=\"margin-top: 4px;\" id=\"move_2\" class=\"moves\">
 577              <table cellpadding=\"4\">
 578                  <tr>
 579                      <td><small>{$lang->forum_to_move_to}</small></td>
 580                      <td>".$form->generate_forum_select('move_1_forum', $mybb->input['move_1_forum'])."</td>
 581                  </tr>
 582                  <tr>
 583                      <td><small>{$lang->leave_redirect}</small></td>
 584                      <td>".$form->generate_yes_no_radio('move_2_redirect', $mybb->input['move_2_redirect'], array('style' => 'width: 2em;'))."</td>
 585                  </tr>
 586                  <tr>
 587                      <td><small>{$lang->delete_redirect_after}</small></td>
 588                      <td>".$form->generate_numeric_field('move_3_redirecttime', $mybb->input['move_3_redirecttime'], array('style' => 'width: 3em;', 'min' => 0))." {$lang->days}</td>
 589                  </tr>
 590              </table>
 591          </dd>
 592      </dl>
 593      <script type=\"text/javascript\">
 594      checkAction('move');
 595      </script>";
 596      $form_container->output_row($lang->move_thread." <em>*</em>", $lang->move_thread_desc, $actions);
 597  
 598      $actions = "
 599      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 600      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"1\" {$copy_checked[1]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_copy_thread}</strong></label></dt>
 601          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"2\" {$copy_checked[2]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->copy_thread}</strong></label></dt>
 602          <dd style=\"margin-top: 4px;\" id=\"copy_2\" class=\"copys\">
 603              <table cellpadding=\"4\">
 604                  <tr>
 605                      <td><small>{$lang->forum_to_copy_to}</small></td>
 606                      <td>".$form->generate_forum_select('copy_1_forum', $mybb->input['copy_1_forum'])."</td>
 607                  </tr>
 608              </table>
 609          </dd>
 610      </dl>
 611      <script type=\"text/javascript\">
 612      checkAction('copy');
 613      </script>";
 614      $form_container->output_row($lang->copy_thread." <em>*</em>", '', $actions);
 615  
 616      $softdelete_restore = array(
 617          '' => $lang->no_change,
 618          'restore' => $lang->restore,
 619          'softdelete' => $lang->softdelete,
 620          'toggle' => $lang->toggle
 621      );
 622  
 623      $form_container->output_row($lang->softdelete_restore_thread." <em>*</em>", '', $form->generate_select_box('softdeletethread', $softdelete_restore, $mybb->input['softdeletethread'], array('id' => 'softdeletethread')), 'softdeletethread');
 624      $form_container->output_row($lang->delete_thread." <em>*</em>", '', $form->generate_yes_no_radio('deletethread', $mybb->input['deletethread'], array('style' => 'width: 2em;')));
 625      $form_container->output_row($lang->merge_thread." <em>*</em>", $lang->merge_thread_desc, $form->generate_yes_no_radio('mergethreads', $mybb->input['mergethreads'], array('style' => 'width: 2em;')));
 626      $form_container->output_row($lang->delete_poll." <em>*</em>", '', $form->generate_yes_no_radio('deletepoll', $mybb->input['deletepoll'], array('style' => 'width: 2em;')));
 627      $form_container->output_row($lang->delete_redirects." <em>*</em>", '', $form->generate_yes_no_radio('removeredirects', $mybb->input['removeredirects'], array('style' => 'width: 2em;')));
 628      $form_container->output_row($lang->remove_subscriptions." <em>*</em>", '', $form->generate_yes_no_radio('removesubscriptions', $mybb->input['removesubscriptions'], array('style' => 'width: 2em;')));
 629      $form_container->output_row($lang->recount_rebuild." <em>*</em>", '', $form->generate_yes_no_radio('recountrebuild', $mybb->input['recountrebuild'], array('style' => 'width: 2em;')));
 630  
 631      $threadprefixes = build_prefixes();
 632      if(!empty($threadprefixes))
 633      {
 634          $thread_prefixes = array(
 635              '-1' => $lang->no_change,
 636              '0' => $lang->no_prefix
 637          );
 638  
 639          foreach($threadprefixes as $prefix)
 640          {
 641              $thread_prefixes[$prefix['pid']] = $prefix['prefix'];
 642          }
 643  
 644          $form_container->output_row($lang->apply_thread_prefix." <em>*</em>", '', $form->generate_select_box('threadprefix', $thread_prefixes, array($mybb->get_input('threadprefix', MyBB::INPUT_INT)), array('id' => 'threadprefix')), 'threadprefix');
 645      }
 646  
 647      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
 648      $form_container->output_row($lang->new_subject." <em>*</em>", $lang->new_subject_desc, $form->generate_text_box('newsubject', $mybb->input['newsubject'], array('id' => 'newsubject')));
 649      $form_container->end();
 650  
 651      $form_container = new FormContainer($lang->add_new_reply);
 652      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
 653      $form_container->output_row($lang->add_new_reply, $lang->add_new_reply_desc, $form->generate_text_area('newreply', $mybb->input['newreply'], array('id' => 'newreply')), 'newreply');
 654      $form_container->output_row($lang->reply_subject, $lang->reply_subject_desc, $form->generate_text_box('newreplysubject', $mybb->input['newreplysubject'], array('id' => 'newreplysubject')), 'newreplysubject');
 655      $form_container->end();
 656  
 657      $form_container = new FormContainer($lang->send_private_message);
 658      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
 659      $form_container->output_row($lang->private_message_message, $lang->private_message_message_desc, $form->generate_text_area('pm_message', $mybb->input['pm_message'], array('id' => 'pm_message')), 'pm_message');
 660      $form_container->output_row($lang->private_message_subject, $lang->private_message_subject_desc, $form->generate_text_box('pm_subject', $mybb->input['pm_subject'], array('id' => 'pm_subject')), 'pm_subject');
 661      $form_container->end();
 662  
 663      $plugins->run_hooks("admin_config_mod_tools_edit_thread_tool_end");
 664  
 665      $buttons[] = $form->generate_submit_button($lang->save_thread_tool);
 666  
 667      $form->output_submit_wrapper($buttons);
 668      $form->end();
 669  
 670      $page->output_footer();
 671  }
 672  
 673  if($mybb->input['action'] == "add_thread_tool")
 674  {
 675      $plugins->run_hooks("admin_config_mod_tools_add_thread_tool");
 676  
 677      if($mybb->request_method == 'post')
 678      {
 679          if(trim($mybb->input['title']) == "")
 680          {
 681              $errors[] = $lang->error_missing_title;
 682          }
 683  
 684          if(trim($mybb->input['description']) == "")
 685          {
 686              $errors[] = $lang->error_missing_description;
 687          }
 688  
 689          if($mybb->input['forum_type'] == 2)
 690          {
 691              $forum_checked[1] = '';
 692              $forum_checked[2] = "checked=\"checked\"";
 693  
 694              if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
 695              {
 696                  $errors[] = $lang->error_no_forums_selected;
 697              }
 698          }
 699          else
 700          {
 701              $forum_checked[1] = "checked=\"checked\"";
 702              $forum_checked[2] = '';
 703  
 704              $mybb->input['forum_1_forums'] = '';
 705          }
 706  
 707          if($mybb->input['group_type'] == 2)
 708          {
 709              $group_checked[1] = '';
 710              $group_checked[2] = "checked=\"checked\"";
 711  
 712              if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
 713              {
 714                  $errors[] = $lang->error_no_groups_selected;
 715              }
 716          }
 717          else
 718          {
 719              $group_checked[1] = "checked=\"checked\"";
 720              $group_checked[2] = '';
 721  
 722              $mybb->input['group_1_groups'] = '';
 723          }
 724  
 725          if($mybb->input['approvethread'] != '' && $mybb->input['approvethread'] != 'approve' && $mybb->input['approvethread'] != 'unapprove' && $mybb->input['approvethread'] != 'toggle')
 726          {
 727              $mybb->input['approvethread'] = '';
 728          }
 729  
 730          if($mybb->input['softdeletethread'] != '' && $mybb->input['softdeletethread'] != 'restore' && $mybb->input['softdeletethread'] != 'softdelete' && $mybb->input['softdeletethread'] != 'toggle')
 731          {
 732              $mybb->input['softdeletethread'] = '';
 733          }
 734  
 735          if($mybb->input['openthread'] != '' && $mybb->input['openthread'] != 'open' && $mybb->input['openthread'] != 'close' && $mybb->input['openthread'] != 'toggle')
 736          {
 737              $mybb->input['openthread'] = '';
 738          }
 739  
 740          if($mybb->input['stickthread'] != '' && $mybb->input['stickthread'] != 'stick' && $mybb->input['stickthread'] != 'unstick' && $mybb->input['stickthread'] != 'toggle')
 741          {
 742              $mybb->input['stickthread'] = '';
 743          }
 744  
 745          if(!isset($mybb->input['threadprefix']))
 746          {
 747              $mybb->input['threadprefix'] = '';
 748          }
 749  
 750          if($mybb->input['move_type'] == 2)
 751          {
 752              $move_checked[1] = '';
 753              $move_checked[2] = "checked=\"checked\"";
 754  
 755              if(!$mybb->input['move_1_forum'])
 756              {
 757                  $errors[] = $lang->error_no_move_forum_selected;
 758              }
 759              else
 760              {
 761                  // Check that the destination forum is not a category
 762                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('move_1_forum', MyBB::INPUT_INT)."'");
 763                  if($db->fetch_field($query, "type") == "c")
 764                  {
 765                      $errors[] = $lang->error_forum_is_category;
 766                  }
 767              }
 768          }
 769          else
 770          {
 771              $move_checked[1] = "checked=\"checked\"";
 772              $move_checked[2] = '';
 773  
 774              $mybb->input['move_1_forum'] = '';
 775              $mybb->input['move_2_redirect'] = 0;
 776              $mybb->input['move_3_redirecttime'] = '';
 777          }
 778  
 779          if($mybb->input['copy_type'] == 2)
 780          {
 781              $copy_checked[1] = '';
 782              $copy_checked[2] = "checked=\"checked\"";
 783  
 784              if(!$mybb->input['copy_1_forum'])
 785              {
 786                  $errors[] = $lang->error_no_copy_forum_selected;
 787              }
 788              else
 789              {
 790                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('copy_1_forum', MyBB::INPUT_INT)."'");
 791                  if($db->fetch_field($query, "type") == "c")
 792                  {
 793                      $errors[] = $lang->error_forum_is_category;
 794                  }
 795              }
 796          }
 797          else
 798          {
 799              $copy_checked[1] = "checked=\"checked\"";
 800              $copy_checked[2] = '';
 801  
 802              $mybb->input['copy_1_forum'] = '';
 803          }
 804  
 805          if(!$errors)
 806          {
 807              $thread_options = array(
 808                  'confirmation' => $mybb->get_input('confirmation', MyBB::INPUT_INT),
 809                  'deletethread' => $mybb->get_input('deletethread', MyBB::INPUT_INT),
 810                  'mergethreads' => $mybb->get_input('mergethreads', MyBB::INPUT_INT),
 811                  'deletepoll' => $mybb->get_input('deletepoll', MyBB::INPUT_INT),
 812                  'removeredirects' => $mybb->get_input('removeredirects', MyBB::INPUT_INT),
 813                  'removesubscriptions' => $mybb->get_input('removesubscriptions', MyBB::INPUT_INT),
 814                  'recountrebuild' => $mybb->get_input('recountrebuild', MyBB::INPUT_INT),
 815                  'approvethread' => $mybb->input['approvethread'],
 816                  'softdeletethread' => $mybb->input['softdeletethread'],
 817                  'openthread' => $mybb->input['openthread'],
 818                  'stickthread' => $mybb->input['stickthread'],
 819                  'movethread' => $mybb->get_input('move_1_forum', MyBB::INPUT_INT),
 820                  'movethreadredirect' => $mybb->get_input('move_2_redirect', MyBB::INPUT_INT),
 821                  'movethreadredirectexpire' => $mybb->get_input('move_3_redirecttime', MyBB::INPUT_INT),
 822                  'copythread' => $mybb->get_input('copy_1_forum', MyBB::INPUT_INT),
 823                  'newsubject' => $mybb->input['newsubject'],
 824                  'addreply' => $mybb->input['newreply'],
 825                  'replysubject' => $mybb->input['newreplysubject'],
 826                  'pm_subject' => $mybb->input['pm_subject'],
 827                  'pm_message' => $mybb->input['pm_message'],
 828                  'threadprefix' => $mybb->input['threadprefix'],
 829              );
 830  
 831              $args = array(
 832                  'thread_options' => &$thread_options,
 833              );
 834  
 835              $plugins->run_hooks("admin_config_mod_tools_add_thread_tool_options", $args);
 836  
 837              $new_tool['type'] = 't';
 838              $new_tool['threadoptions'] = $db->escape_string(my_serialize($thread_options));
 839              $new_tool['name'] = $db->escape_string($mybb->input['title']);
 840              $new_tool['description'] = $db->escape_string($mybb->input['description']);
 841              $new_tool['forums'] = '';
 842              $new_tool['groups'] = '';
 843              $new_tool['postoptions'] = '';
 844  
 845              if($mybb->input['forum_type'] == 2)
 846              {
 847                  if(is_array($mybb->input['forum_1_forums']))
 848                  {
 849                      $checked = array();
 850  
 851                      foreach($mybb->input['forum_1_forums'] as $fid)
 852                      {
 853                          $checked[] = (int)$fid;
 854                      }
 855  
 856                      $new_tool['forums'] = implode(',', $checked);
 857                  }
 858              }
 859              else
 860              {
 861                  $new_tool['forums'] = "-1";
 862              }
 863  
 864              if($mybb->input['group_type'] == 2)
 865              {
 866                  if(is_array($mybb->input['group_1_groups']))
 867                  {
 868                      $checked = array();
 869  
 870                      foreach($mybb->input['group_1_groups'] as $gid)
 871                      {
 872                          $checked[] = (int)$gid;
 873                      }
 874  
 875                      $new_tool['groups'] = implode(',', $checked);
 876                  }
 877              }
 878              else
 879              {
 880                  $new_tool['groups'] = "-1";
 881              }
 882  
 883              if($mybb->get_input('threadprefix', MyBB::INPUT_INT) >= 0)
 884              {
 885                  $thread_options['threadprefix'] = $mybb->get_input('threadprefix', MyBB::INPUT_INT);
 886              }
 887  
 888              $tid = $db->insert_query("modtools", $new_tool);
 889  
 890              $plugins->run_hooks("admin_config_mod_tools_add_thread_tool_commit");
 891  
 892              // Log admin action
 893              log_admin_action($tid, $mybb->input['title']);
 894              $cache->update_forumsdisplay();
 895  
 896              flash_message($lang->success_mod_tool_created, 'success');
 897              admin_redirect("index.php?module=config-mod_tools");
 898          }
 899      }
 900  
 901      $page->add_breadcrumb_item($lang->add_new_thread_tool);
 902      $page->output_header($lang->mod_tools." - ".$lang->add_new_thread_tool);
 903  
 904      $sub_tabs['thread_tools'] = array(
 905          'title' => $lang->thread_tools,
 906          'link' => "index.php?module=config-mod_tools"
 907      );
 908      $sub_tabs['add_thread_tool'] = array(
 909          'title'=> $lang->add_new_thread_tool,
 910          'link' => "index.php?module=config-mod_tools&amp;action=add_thread_tool",
 911          'description' => $lang->add_thread_tool_desc
 912      );
 913      $sub_tabs['post_tools'] = array(
 914          'title' => $lang->post_tools,
 915          'link' => "index.php?module=config-mod_tools&amp;action=post_tools",
 916      );
 917      $sub_tabs['add_post_tool'] = array(
 918          'title'=> $lang->add_new_post_tool,
 919          'link' => "index.php?module=config-mod_tools&amp;action=add_post_tool"
 920      );
 921  
 922      $page->output_nav_tabs($sub_tabs, 'add_thread_tool');
 923  
 924      $form = new Form("index.php?module=config-mod_tools&amp;action=add_thread_tool", 'post');
 925  
 926      if($errors)
 927      {
 928          $page->output_inline_error($errors);
 929      }
 930      else
 931      {
 932          $mybb->input['title'] = '';
 933          $mybb->input['description'] = '';
 934          $mybb->input['forum_1_forums'] = '';
 935          $forum_checked[1] = "checked=\"checked\"";
 936          $forum_checked[2] = '';
 937          $mybb->input['group_1_groups'] = '';
 938          $group_checked[1] = "checked=\"checked\"";
 939          $group_checked[2] = '';
 940          $mybb->input['confirmation'] = '0';
 941          $mybb->input['approvethread'] = '';
 942          $mybb->input['softdeletethread'] = '';
 943          $mybb->input['openthread'] = '';
 944          $mybb->input['stickthread'] = '';
 945          $mybb->input['move_1_forum'] = '';
 946          $mybb->input['move_2_redirect'] = '0';
 947          $mybb->input['move_3_redirecttime'] = '';
 948          $move_checked[1] = "checked=\"checked\"";
 949          $move_checked[2] = '';
 950          $copy_checked[1] = "checked=\"checked\"";
 951          $copy_checked[2] = '';
 952          $mybb->input['copy_1_forum'] = '';
 953          $mybb->input['deletethread'] = '0';
 954          $mybb->input['mergethreads'] = '0';
 955          $mybb->input['deletepoll'] = '0';
 956          $mybb->input['removeredirects'] = '0';
 957          $mybb->input['removesubscriptions'] = '0';
 958          $mybb->input['recountrebuild'] = '0';
 959          $mybb->input['threadprefix'] = '-1';
 960          $mybb->input['newsubject'] = '{subject}';
 961          $mybb->input['newreply'] = '';
 962          $mybb->input['newreplysubject'] = '{subject}';
 963          $mybb->input['pm_subject'] = '';
 964          $mybb->input['pm_message'] = '';
 965      }
 966  
 967      $form_container = new FormContainer($lang->general_options);
 968      $form_container->output_row($lang->name." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 969      $form_container->output_row($lang->short_description." <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 970  
 971      $actions = "<script type=\"text/javascript\">
 972  	function checkAction(id)
 973      {
 974          var checked = '';
 975  
 976          $('.'+id+'s_check').each(function(e, val)
 977          {
 978              if($(this).prop('checked') == true)
 979              {
 980                  checked = $(this).val();
 981              }
 982          });
 983          $('.'+id+'s').each(function(e)
 984          {
 985              $(this).hide();
 986          });
 987          if($('#'+id+'_'+checked))
 988          {
 989              $('#'+id+'_'+checked).show();
 990          }
 991      }
 992  </script>
 993      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 994      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
 995          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
 996          <dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
 997              <table cellpadding=\"4\">
 998                  <tr>
 999                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
1000                      <td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
1001                  </tr>
1002              </table>
1003          </dd>
1004      </dl>
1005      <script type=\"text/javascript\">
1006      checkAction('forum');
1007      </script>";
1008      $form_container->output_row($lang->available_in_forums." <em>*</em>", '', $actions);
1009  
1010      $actions = "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1011      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
1012          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
1013          <dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
1014              <table cellpadding=\"4\">
1015                  <tr>
1016                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
1017                      <td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
1018                  </tr>
1019              </table>
1020          </dd>
1021      </dl>
1022      <script type=\"text/javascript\">
1023      checkAction('group');
1024      </script>";
1025      $form_container->output_row($lang->available_to_groups." <em>*</em>", '', $actions);
1026      $form_container->output_row($lang->show_confirmation." <em>*</em>", '', $form->generate_yes_no_radio('confirmation', $mybb->input['confirmation'], array('style' => 'width: 2em;')));
1027      $form_container->end();
1028  
1029      $approve_unapprove = array(
1030          '' => $lang->no_change,
1031          'approve' => $lang->approve,
1032          'unapprove' => $lang->unapprove,
1033          'toggle' => $lang->toggle
1034      );
1035  
1036      $open_close = array(
1037          '' => $lang->no_change,
1038          'open' => $lang->open,
1039          'close' => $lang->close,
1040          'toggle' => $lang->toggle
1041      );
1042  
1043      $stick_unstick = array(
1044          '' => $lang->no_change,
1045          'stick' => $lang->stick,
1046          'unstick' => $lang->unstick,
1047          'toggle' => $lang->toggle
1048      );
1049  
1050      $form_container = new FormContainer($lang->thread_moderation);
1051      $form_container->output_row($lang->approve_unapprove." <em>*</em>", '', $form->generate_select_box('approvethread', $approve_unapprove, $mybb->input['approvethread'], array('id' => 'approvethread')), 'approvethread');
1052      $form_container->output_row($lang->open_close_thread." <em>*</em>", '', $form->generate_select_box('openthread', $open_close, $mybb->input['openthread'], array('id' => 'openthread')), 'openthread');
1053      $form_container->output_row($lang->stick_unstick_thread." <em>*</em>", '', $form->generate_select_box('stickthread', $stick_unstick, $mybb->input['stickthread'], array('id' => 'stickthread')), 'stickthread');
1054  
1055  
1056      $actions = "
1057      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1058      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"1\" {$move_checked[1]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_move_thread}</strong></label></dt>
1059          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"2\" {$move_checked[2]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->move_thread}</strong></label></dt>
1060          <dd style=\"margin-top: 4px;\" id=\"move_2\" class=\"moves\">
1061              <table cellpadding=\"4\">
1062                  <tr>
1063                      <td><small>{$lang->forum_to_move_to}</small></td>
1064                      <td>".$form->generate_forum_select('move_1_forum', $mybb->input['move_1_forum'])."</td>
1065                  </tr>
1066                  <tr>
1067                      <td><small>{$lang->leave_redirect}</small></td>
1068                      <td>".$form->generate_yes_no_radio('move_2_redirect', $mybb->input['move_2_redirect'], array('style' => 'width: 2em;'))."</td>
1069                  </tr>
1070                  <tr>
1071                      <td><small>{$lang->delete_redirect_after}</small></td>
1072                      <td>".$form->generate_numeric_field('move_3_redirecttime', $mybb->input['move_3_redirecttime'], array('style' => 'width: 3em;', 'min' => 0))." {$lang->days}</td>
1073                  </tr>
1074              </table>
1075          </dd>
1076      </dl>
1077      <script type=\"text/javascript\">
1078      checkAction('move');
1079      </script>";
1080      $form_container->output_row($lang->move_thread." <em>*</em>", $lang->move_thread_desc, $actions);
1081  
1082      $actions = "
1083      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1084      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"1\" {$copy_checked[1]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_copy_thread}</strong></label></dt>
1085          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"2\" {$copy_checked[2]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->copy_thread}</strong></label></dt>
1086          <dd style=\"margin-top: 4px;\" id=\"copy_2\" class=\"copys\">
1087              <table cellpadding=\"4\">
1088                  <tr>
1089                      <td><small>{$lang->forum_to_copy_to}</small></td>
1090                      <td>".$form->generate_forum_select('copy_1_forum', $mybb->input['copy_1_forum'])."</td>
1091                  </tr>
1092              </table>
1093          </dd>
1094      </dl>
1095      <script type=\"text/javascript\">
1096      checkAction('copy');
1097      </script>";
1098      $form_container->output_row($lang->copy_thread." <em>*</em>", '', $actions);
1099  
1100      $softdelete_restore = array(
1101          '' => $lang->no_change,
1102          'restore' => $lang->restore,
1103          'softdelete' => $lang->softdelete,
1104          'toggle' => $lang->toggle
1105      );
1106  
1107      $form_container->output_row($lang->softdelete_restore_thread." <em>*</em>", '', $form->generate_select_box('softdeletethread', $softdelete_restore, $mybb->input['softdeletethread'], array('id' => 'softdeletethread')), 'softdeletethread');
1108      $form_container->output_row($lang->delete_thread." <em>*</em>", '', $form->generate_yes_no_radio('deletethread', $mybb->input['deletethread'], array('style' => 'width: 2em;')));
1109      $form_container->output_row($lang->merge_thread." <em>*</em>", $lang->merge_thread_desc, $form->generate_yes_no_radio('mergethreads', $mybb->input['mergethreads'], array('style' => 'width: 2em;')));
1110      $form_container->output_row($lang->delete_poll." <em>*</em>", '', $form->generate_yes_no_radio('deletepoll', $mybb->input['deletepoll'], array('style' => 'width: 2em;')));
1111      $form_container->output_row($lang->delete_redirects." <em>*</em>", '', $form->generate_yes_no_radio('removeredirects', $mybb->input['removeredirects'], array('style' => 'width: 2em;')));
1112      $form_container->output_row($lang->remove_subscriptions." <em>*</em>", '', $form->generate_yes_no_radio('removesubscriptions', $mybb->input['removesubscriptions'], array('style' => 'width: 2em;')));
1113      $form_container->output_row($lang->recount_rebuild." <em>*</em>", '', $form->generate_yes_no_radio('recountrebuild', $mybb->input['recountrebuild'], array('style' => 'width: 2em;')));
1114  
1115      $threadprefixes = build_prefixes();
1116      if(!empty($threadprefixes))
1117      {
1118          $thread_prefixes = array(
1119              '-1' => $lang->no_change,
1120              '0' => $lang->no_prefix
1121          );
1122  
1123          foreach($threadprefixes as $prefix)
1124          {
1125              $thread_prefixes[$prefix['pid']] = $prefix['prefix'];
1126          }
1127  
1128          $form_container->output_row($lang->apply_thread_prefix." <em>*</em>", '', $form->generate_select_box('threadprefix', $thread_prefixes, $mybb->input['threadprefix'], array('id' => 'threadprefix')), 'threadprefix');
1129      }
1130  
1131      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1132      $form_container->output_row($lang->new_subject." <em>*</em>", $lang->new_subject_desc, $form->generate_text_box('newsubject', $mybb->input['newsubject'], array('id' => 'newsubject')));
1133      $form_container->end();
1134  
1135      $form_container = new FormContainer($lang->add_new_reply);
1136      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1137      $form_container->output_row($lang->add_new_reply, $lang->add_new_reply_desc, $form->generate_text_area('newreply', $mybb->input['newreply'], array('id' => 'newreply')), 'newreply');
1138      $form_container->output_row($lang->reply_subject, $lang->reply_subject_desc, $form->generate_text_box('newreplysubject', $mybb->input['newreplysubject'], array('id' => 'newreplysubject')), 'newreplysubject');
1139      $form_container->end();
1140  
1141      $form_container = new FormContainer($lang->send_private_message);
1142      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1143      $form_container->output_row($lang->private_message_message, $lang->private_message_message_desc, $form->generate_text_area('pm_message', $mybb->input['pm_message'], array('id' => 'pm_message')), 'pm_message');
1144      $form_container->output_row($lang->private_message_subject, $lang->private_message_subject_desc, $form->generate_text_box('pm_subject', $mybb->input['pm_subject'], array('id' => 'pm_subject')), 'pm_subject');
1145      $form_container->end();
1146  
1147      $plugins->run_hooks("admin_config_mod_tools_add_thread_tool_end");
1148  
1149      $buttons[] = $form->generate_submit_button($lang->save_thread_tool);
1150  
1151      $form->output_submit_wrapper($buttons);
1152      $form->end();
1153  
1154      $page->output_footer();
1155  }
1156  
1157  // This will be accounted for both GET and POST requests in both 'add_post_tool' / 'edit_post_tool'
1158  $do_not_split_checked = '';
1159  $split_same_checked = '';
1160  
1161  if($mybb->input['action'] == "edit_post_tool")
1162  {
1163      $query = $db->simple_select("modtools", "COUNT(tid) as tools", "tid = '{$mybb->input['tid']}' AND type='p'");
1164      if($db->fetch_field($query, "tools") < 1)
1165      {
1166          flash_message($lang->error_invalid_post_tool, 'error');
1167          admin_redirect("index.php?module=config-mod_tools&action=post_tools");
1168      }
1169  
1170      $plugins->run_hooks("admin_config_mod_tools_edit_post_tool");
1171  
1172      if($mybb->request_method == 'post')
1173      {
1174          if(trim($mybb->input['title']) == "")
1175          {
1176              $errors[] = $lang->error_missing_title;
1177          }
1178  
1179          if(trim($mybb->input['description']) == "")
1180          {
1181              $errors[] = $lang->error_missing_description;
1182          }
1183  
1184          if($mybb->input['forum_type'] == 2)
1185          {
1186              if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
1187              {
1188                  $errors[] = $lang->error_no_forums_selected;
1189              }
1190          }
1191          else
1192          {
1193              $mybb->input['forum_1_forums'] = '';
1194          }
1195  
1196          if($mybb->input['group_type'] == 2)
1197          {
1198              if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
1199              {
1200                  $errors[] = $lang->error_no_groups_selected;
1201              }
1202          }
1203          else
1204          {
1205              $mybb->input['group_1_groups'] = '';
1206          }
1207  
1208          if($mybb->input['approvethread'] != '' && $mybb->input['approvethread'] != 'approve' && $mybb->input['approvethread'] != 'unapprove' && $mybb->input['approvethread'] != 'toggle')
1209          {
1210              $mybb->input['approvethread'] = '';
1211          }
1212  
1213          if($mybb->input['softdeletethread'] != '' && $mybb->input['softdeletethread'] != 'softdelete' && $mybb->input['softdeletethread'] != 'restore' && $mybb->input['softdeletethread'] != 'toggle')
1214          {
1215              $mybb->input['softdeletethread'] = '';
1216          }
1217  
1218          if($mybb->input['openthread'] != '' && $mybb->input['openthread'] != 'open' && $mybb->input['openthread'] != 'close' && $mybb->input['openthread'] != 'toggle')
1219          {
1220              $mybb->input['openthread'] = '';
1221          }
1222  
1223          if($mybb->input['stickthread'] != '' && $mybb->input['stickthread'] != 'stick' && $mybb->input['stickthread'] != 'unstick' && $mybb->input['stickthread'] != 'toggle')
1224          {
1225              $mybb->input['stickthread'] = '';
1226          }
1227  
1228          if($mybb->input['move_type'] == 2)
1229          {
1230              if(!$mybb->input['move_1_forum'])
1231              {
1232                  $errors[] = $lang->error_no_move_forum_selected;
1233              }
1234              else
1235              {
1236                  // Check that the destination forum is not a category
1237                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('move_1_forum', MyBB::INPUT_INT)."'");
1238                  if($db->fetch_field($query, "type") == "c")
1239                  {
1240                      $errors[] = $lang->error_forum_is_category;
1241                  }
1242              }
1243          }
1244          else
1245          {
1246              $mybb->input['move_1_forum'] = '';
1247              $mybb->input['move_2_redirect'] = 0;
1248              $mybb->input['move_3_redirecttime'] = '';
1249          }
1250  
1251          if($mybb->input['copy_type'] == 2)
1252          {
1253              if(!$mybb->input['copy_1_forum'])
1254              {
1255                  $errors[] = $lang->error_no_copy_forum_selected;
1256              }
1257              else
1258              {
1259                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('copy_1_forum', MyBB::INPUT_INT)."'");
1260                  if($db->fetch_field($query, "type") == "c")
1261                  {
1262                      $errors[] = $lang->error_forum_is_category;
1263                  }
1264              }
1265          }
1266          else
1267          {
1268              $mybb->input['copy_1_forum'] = '';
1269          }
1270  
1271          if($mybb->input['approveposts'] != '' && $mybb->input['approveposts'] != 'approve' && $mybb->input['approveposts'] != 'unapprove' && $mybb->input['approveposts'] != 'toggle')
1272          {
1273              $mybb->input['approveposts'] = '';
1274          }
1275  
1276          if($mybb->input['softdeleteposts'] != '' && $mybb->input['softdeleteposts'] != 'approve' && $mybb->input['softdeleteposts'] != 'unapprove' && $mybb->input['softdeleteposts'] != 'toggle')
1277          {
1278              $mybb->input['softdeleteposts'] = '';
1279          }
1280  
1281          if($mybb->input['splitposts'] < -2)
1282          {
1283              $mybb->input['splitposts'] = -1;
1284          }
1285  
1286          if($mybb->input['splitpostsclose'] == 1)
1287          {
1288              $mybb->input['splitpostsclose'] = 'close';
1289          }
1290          else
1291          {
1292              $mybb->input['splitpostsclose'] = '';
1293          }
1294  
1295          if($mybb->input['splitpostsstick'] == 1)
1296          {
1297              $mybb->input['splitpostsstick'] = 'stick';
1298          }
1299          else
1300          {
1301              $mybb->input['splitpostsstick'] = '';
1302          }
1303  
1304          if($mybb->input['splitpostsunapprove'] == 1)
1305          {
1306              $mybb->input['splitpostsunapprove'] = 'unapprove';
1307          }
1308          else
1309          {
1310              $mybb->input['splitpostsunapprove'] = '';
1311          }
1312  
1313          if(!$errors)
1314          {
1315              $thread_options = array(
1316                  'confirmation' => $mybb->get_input('confirmation', MyBB::INPUT_INT),
1317                  'deletethread' => $mybb->get_input('deletethread', MyBB::INPUT_INT),
1318                  'softdeletethread' => $mybb->input['softdeletethread'],
1319                  'approvethread' => $mybb->input['approvethread'],
1320                  'openthread' => $mybb->input['openthread'],
1321                  'stickthread' => $mybb->input['stickthread'],
1322                  'movethread' => $mybb->get_input('move_1_forum', MyBB::INPUT_INT),
1323                  'movethreadredirect' => $mybb->get_input('move_2_redirect', MyBB::INPUT_INT),
1324                  'movethreadredirectexpire' => $mybb->get_input('move_3_redirecttime', MyBB::INPUT_INT),
1325                  'copythread' => $mybb->get_input('copy_1_forum', MyBB::INPUT_INT),
1326                  'newsubject' => $mybb->input['newsubject'],
1327                  'addreply' => $mybb->input['newreply'],
1328                  'replysubject' => $mybb->input['newreplysubject'],
1329                  'pm_subject' => $mybb->input['pm_subject'],
1330                  'pm_message' => $mybb->input['pm_message'],
1331                  'threadprefix' => $mybb->get_input('threadprefix', MyBB::INPUT_INT)
1332              );
1333  
1334              if(stripos($mybb->input['splitpostsnewsubject'], '{subject}') === false)
1335              {
1336                  $mybb->input['splitpostsnewsubject'] = '{subject}'.$mybb->input['splitpostsnewsubject'];
1337              }
1338  
1339              $post_options = array(
1340                  'deleteposts' => $mybb->get_input('deleteposts', MyBB::INPUT_INT),
1341                  'softdeleteposts' => $mybb->input['softdeleteposts'],
1342                  'mergeposts' =>$mybb->get_input('mergeposts', MyBB::INPUT_INT),
1343                  'approveposts' => $mybb->input['approveposts'],
1344                  'splitposts' => $mybb->get_input('splitposts', MyBB::INPUT_INT),
1345                  'splitpostsclose' => $mybb->input['splitpostsclose'],
1346                  'splitpostsstick' => $mybb->input['splitpostsstick'],
1347                  'splitpostsunapprove' => $mybb->input['splitpostsunapprove'],
1348                  'splitthreadprefix' => $mybb->get_input('splitthreadprefix', MyBB::INPUT_INT),
1349                  'splitpostsnewsubject' => $mybb->input['splitpostsnewsubject'],
1350                  'splitpostsaddreply' => $mybb->input['splitpostsaddreply'],
1351                  'splitpostsreplysubject' => $mybb->input['splitpostsreplysubject']
1352              );
1353  
1354              $args = array(
1355                  'thread_options' => &$thread_options,
1356                  'post_options' => &$post_options,
1357              );
1358  
1359              $plugins->run_hooks("admin_config_mod_tools_edit_post_tool_options", $args);
1360  
1361              $update_tool['type'] = 'p';
1362              $update_tool['threadoptions'] = $db->escape_string(my_serialize($thread_options));
1363              $update_tool['postoptions'] = $db->escape_string(my_serialize($post_options));
1364              $update_tool['name'] = $db->escape_string($mybb->input['title']);
1365              $update_tool['description'] = $db->escape_string($mybb->input['description']);
1366              $update_tool['forums'] = '';
1367              $update_tool['groups'] = '';
1368  
1369              if($mybb->input['forum_type'] == 2)
1370              {
1371                  if(is_array($mybb->input['forum_1_forums']))
1372                  {
1373                      $checked = array();
1374  
1375                      foreach($mybb->input['forum_1_forums'] as $fid)
1376                      {
1377                          $checked[] = (int)$fid;
1378                      }
1379  
1380                      $update_tool['forums'] = implode(',', $checked);
1381                  }
1382              }
1383              else
1384              {
1385                  $update_tool['forums'] = "-1";
1386              }
1387  
1388              if($mybb->input['group_type'] == 2)
1389              {
1390                  if(is_array($mybb->input['group_1_groups']))
1391                  {
1392                      $checked = array();
1393  
1394                      foreach($mybb->input['group_1_groups'] as $gid)
1395                      {
1396                          $checked[] = (int)$gid;
1397                      }
1398  
1399                      $update_tool['groups'] = implode(',', $checked);
1400                  }
1401              }
1402              else
1403              {
1404                  $update_tool['groups'] = "-1";
1405              }
1406  
1407              $plugins->run_hooks("admin_config_mod_tools_edit_post_tool_commit");
1408  
1409              $db->update_query("modtools", $update_tool, "tid = '{$mybb->input['tid']}'");
1410  
1411              // Log admin action
1412              log_admin_action($mybb->input['tid'], $mybb->input['title']);
1413              $cache->update_forumsdisplay();
1414  
1415              flash_message($lang->success_mod_tool_updated, 'success');
1416              admin_redirect("index.php?module=config-mod_tools&action=post_tools");
1417          }
1418      }
1419  
1420      $page->add_breadcrumb_item($lang->edit_post_tool);
1421      $page->output_header($lang->mod_tools." - ".$lang->edit_post_tool);
1422  
1423      $sub_tabs['edit_post_tool'] = array(
1424          "title" => $lang->edit_post_tool,
1425          "description" => $lang->edit_post_tool_desc,
1426          "link" => "index.php?module=config-mod_tools"
1427      );
1428  
1429      $page->output_nav_tabs($sub_tabs, 'edit_post_tool');
1430  
1431      $form = new Form("index.php?module=config-mod_tools&amp;action=edit_post_tool", 'post');
1432      echo $form->generate_hidden_field("tid", $mybb->input['tid']);
1433  
1434  
1435      if($errors)
1436      {
1437          $page->output_inline_error($errors);
1438      }
1439      else
1440      {
1441          $query = $db->simple_select("modtools", "*", "tid = '{$mybb->input['tid']}'");
1442          $modtool = $db->fetch_array($query);
1443          $thread_options = my_unserialize($modtool['threadoptions']);
1444          $post_options = my_unserialize($modtool['postoptions']);
1445  
1446          $mybb->input['title'] = $modtool['name'];
1447          $mybb->input['description'] = $modtool['description'];
1448          $mybb->input['forum_1_forums'] = explode(",", $modtool['forums']);
1449          $mybb->input['group_1_groups'] = explode(",", $modtool['groups']);
1450  
1451          if(!$modtool['forums'] || $modtool['forums'] == -1)
1452          {
1453              $forum_checked[1] = "checked=\"checked\"";
1454              $forum_checked[2] = '';
1455          }
1456          else
1457          {
1458              $forum_checked[1] = '';
1459              $forum_checked[2] = "checked=\"checked\"";
1460          }
1461  
1462          if(!$modtool['groups'] || $modtool['groups'] == -1)
1463          {
1464              $group_checked[1] = "checked=\"checked\"";
1465              $group_checked[2] = '';
1466          }
1467          else
1468          {
1469              $group_checked[1] = '';
1470              $group_checked[2] = "checked=\"checked\"";
1471          }
1472  
1473          $mybb->input['confirmation'] = $thread_options['confirmation'];
1474          $mybb->input['approvethread'] = $thread_options['approvethread'];
1475          $mybb->input['softdeletethread'] = $thread_options['softdeletethread'];
1476          $mybb->input['openthread'] = $thread_options['openthread'];
1477          $mybb->input['stickthread'] = $thread_options['stickthread'];
1478          $mybb->input['move_1_forum'] = $thread_options['movethread'];
1479          $mybb->input['move_2_redirect'] = $thread_options['movethreadredirect'];
1480          $mybb->input['move_3_redirecttime'] = $thread_options['movethreadredirectexpire'];
1481  
1482          if(!$thread_options['movethread'])
1483          {
1484              $move_checked[1] = "checked=\"checked\"";
1485              $move_checked[2] = '';
1486          }
1487          else
1488          {
1489              $move_checked[1] = '';
1490              $move_checked[2] = "checked=\"checked\"";
1491          }
1492  
1493          if(!$thread_options['copythread'])
1494          {
1495              $copy_checked[1] = "checked=\"checked\"";
1496              $copy_checked[2] = '';
1497          }
1498          else
1499          {
1500              $copy_checked[1] = '';
1501              $copy_checked[2] = "checked=\"checked\"";
1502          }
1503  
1504          $mybb->input['copy_1_forum'] = $thread_options['copythread'];
1505          $mybb->input['deletethread'] = $thread_options['deletethread'];
1506          $mybb->input['threadprefix'] = $thread_options['threadprefix'];
1507          $mybb->input['newsubject'] = $thread_options['newsubject'];
1508          $mybb->input['newreply'] = $thread_options['addreply'];
1509          $mybb->input['newreplysubject'] = $thread_options['replysubject'];
1510          $mybb->input['pm_subject'] = $thread_options['pm_subject'];
1511          $mybb->input['pm_message'] = $thread_options['pm_message'];
1512  
1513          if($post_options['splitposts'] == '-1')
1514          {
1515              $do_not_split_checked = ' selected="selected"';
1516          }
1517          else if($post_options['splitposts'] == '-2')
1518          {
1519              $split_same_checked = ' selected="selected"';
1520          }
1521  
1522          $mybb->input['softdeleteposts'] = $post_options['softdeleteposts'];
1523          $mybb->input['deleteposts'] = $post_options['deleteposts'];
1524          $mybb->input['mergeposts'] = $post_options['mergeposts'];
1525          $mybb->input['approveposts'] = $post_options['approveposts'];
1526  
1527          if($post_options['splitpostsclose'] == 'close')
1528          {
1529              $mybb->input['splitpostsclose'] = '1';
1530          }
1531          else
1532          {
1533              $mybb->input['splitpostsclose'] = '0';
1534          }
1535  
1536          if($post_options['splitpostsstick'] == 'stick')
1537          {
1538              $mybb->input['splitpostsstick'] = '1';
1539          }
1540          else
1541          {
1542              $mybb->input['splitpostsstick'] = '0';
1543          }
1544  
1545          if($post_options['splitpostsunapprove'] == 'unapprove')
1546          {
1547              $mybb->input['splitpostsunapprove'] = '1';
1548          }
1549          else
1550          {
1551              $mybb->input['splitpostsunapprove'] = '0';
1552          }
1553  
1554          $mybb->input['splitposts'] = $post_options['splitposts'];
1555          $mybb->input['splitthreadprefix'] = $post_options['splitthreadprefix'];
1556          $mybb->input['splitpostsnewsubject'] = $post_options['splitpostsnewsubject'];
1557          $mybb->input['splitpostsaddreply'] = $post_options['splitpostsaddreply'];
1558          $mybb->input['splitpostsreplysubject'] = $post_options['splitpostsreplysubject'];
1559      }
1560  
1561      $form_container = new FormContainer($lang->general_options);
1562      $form_container->output_row($lang->name." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
1563      $form_container->output_row($lang->short_description." <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
1564  
1565      $actions = "<script type=\"text/javascript\">
1566  	function checkAction(id)
1567      {
1568          var checked = '';
1569  
1570          $('.'+id+'s_check').each(function(e, val)
1571          {
1572              if($(this).prop('checked') == true)
1573              {
1574                  checked = $(this).val();
1575              }
1576          });
1577          $('.'+id+'s').each(function(e)
1578          {
1579              $(this).hide();
1580          });
1581          if($('#'+id+'_'+checked))
1582          {
1583              $('#'+id+'_'+checked).show();
1584          }
1585      }
1586  </script>
1587      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1588      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
1589          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
1590          <dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
1591              <table cellpadding=\"4\">
1592                  <tr>
1593                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
1594                      <td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
1595                  </tr>
1596              </table>
1597          </dd>
1598      </dl>
1599      <script type=\"text/javascript\">
1600      checkAction('forum');
1601      </script>";
1602      $form_container->output_row($lang->available_in_forums." <em>*</em>", '', $actions);
1603  
1604      $actions = "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1605      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
1606          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
1607          <dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
1608              <table cellpadding=\"4\">
1609                  <tr>
1610                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
1611                      <td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
1612                  </tr>
1613              </table>
1614          </dd>
1615      </dl>
1616      <script type=\"text/javascript\">
1617      checkAction('group');
1618      </script>";
1619      $form_container->output_row($lang->available_to_groups." <em>*</em>", '', $actions);
1620      $form_container->output_row($lang->show_confirmation." <em>*</em>", '', $form->generate_yes_no_radio('confirmation', $mybb->input['confirmation'], array('style' => 'width: 2em;')));
1621      $form_container->end();
1622  
1623      $approve_unapprove = array(
1624          '' => $lang->no_change,
1625          'approve' => $lang->approve,
1626          'unapprove' => $lang->unapprove,
1627          'toggle' => $lang->toggle
1628      );
1629  
1630      $form_container = new FormContainer($lang->inline_post_moderation);
1631  
1632      $softdelete_restore = array(
1633          '' => $lang->no_change,
1634          'restore' => $lang->restore,
1635          'softdelete' => $lang->softdelete,
1636          'toggle' => $lang->toggle
1637      );
1638  
1639      $form_container->output_row($lang->softdelete_restore_posts." <em>*</em>", '', $form->generate_select_box('softdeleteposts', $softdelete_restore, $mybb->input['softdeleteposts'], array('id' => 'softdeleteposts')), 'softdeleteposts');
1640      $form_container->output_row($lang->delete_posts." <em>*</em>", '', $form->generate_yes_no_radio('deleteposts', $mybb->input['deleteposts']));
1641      $form_container->output_row($lang->merge_posts." <em>*</em>", $lang->merge_posts_desc, $form->generate_yes_no_radio('mergeposts', $mybb->input['mergeposts']));
1642      $form_container->output_row($lang->approve_unapprove_posts." <em>*</em>", '', $form->generate_select_box('approveposts', $approve_unapprove, $mybb->input['approveposts'], array('id' => 'approveposts')), 'approveposts');
1643      $form_container->end();
1644  
1645      $selectoptions = "<option value=\"-1\"{$do_not_split_checked}>{$lang->do_not_split}</option>\n";
1646      $selectoptions .= "<option value=\"-2\"{$split_same_checked} style=\"border-bottom: 1px solid #000;\">{$lang->split_to_same_forum}</option>\n";
1647  
1648      $form_container = new FormContainer($lang->split_posts);
1649      $form_container->output_row($lang->split_posts2." <em>*</em>", '', $form->generate_forum_select('splitposts', $mybb->input['splitposts']));
1650      $form_container->output_row($lang->close_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsclose', $mybb->input['splitpostsclose']));
1651      $form_container->output_row($lang->stick_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsstick', $mybb->input['splitpostsstick']));
1652      $form_container->output_row($lang->unapprove_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsunapprove', $mybb->input['splitpostsunapprove']));
1653  
1654      $splitthreadprefix = build_prefixes();
1655      if(!empty($splitthreadprefix))
1656      {
1657          $split_thread_prefixes = array(
1658              '0' => $lang->no_prefix
1659          );
1660  
1661          foreach($splitthreadprefix as $prefix)
1662          {
1663              $split_thread_prefixes[$prefix['pid']] = $prefix['prefix'];
1664          }
1665  
1666          $form_container->output_row($lang->split_thread_prefix." <em>*</em>", '', $form->generate_select_box('splitthreadprefix', $split_thread_prefixes, array($mybb->get_input('splitthreadprefix', MyBB::INPUT_INT)), array('id' => 'splitthreadprefix')), 'splitthreadprefix');
1667      }
1668  
1669      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1670      $form_container->output_row($lang->split_thread_subject, $lang->split_thread_subject_desc, $form->generate_text_box('splitpostsnewsubject', $mybb->input['splitpostsnewsubject'], array('id' => 'splitpostsnewsubject ')), 'newreplysubject');
1671      $form_container->output_row($lang->add_new_split_reply, $lang->add_new_split_reply_desc, $form->generate_text_area('splitpostsaddreply', $mybb->input['splitpostsaddreply'], array('id' => 'splitpostsaddreply')), 'splitpostsaddreply');
1672      $form_container->output_row($lang->split_reply_subject, $lang->split_reply_subject_desc, $form->generate_text_box('splitpostsreplysubject', $mybb->input['splitpostsreplysubject'], array('id' => 'splitpostsreplysubject')), 'splitpostsreplysubject');
1673      $form_container->end();
1674  
1675      $open_close = array(
1676          '' => $lang->no_change,
1677          'open' => $lang->open,
1678          'close' => $lang->close,
1679          'toggle' => $lang->toggle
1680      );
1681  
1682      $stick_unstick = array(
1683          '' => $lang->no_change,
1684          'stick' => $lang->stick,
1685          'unstick' => $lang->unstick,
1686          'toggle' => $lang->toggle
1687      );
1688  
1689      $form_container = new FormContainer($lang->thread_moderation);
1690      $form_container->output_row($lang->approve_unapprove." <em>*</em>", '', $form->generate_select_box('approvethread', $approve_unapprove, $mybb->input['approvethread'], array('id' => 'approvethread')), 'approvethread');
1691      $form_container->output_row($lang->open_close_thread." <em>*</em>", '', $form->generate_select_box('openthread', $open_close, $mybb->input['openthread'], array('id' => 'openthread')), 'openthread');
1692      $form_container->output_row($lang->stick_unstick_thread." <em>*</em>", '', $form->generate_select_box('stickthread', $stick_unstick, $mybb->input['stickthread'], array('id' => 'stickthread')), 'stickthread');
1693  
1694  
1695      $actions = "
1696      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1697      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"1\" {$move_checked[1]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_move_thread}</strong></label></dt>
1698          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"2\" {$move_checked[2]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->move_thread}</strong></label></dt>
1699          <dd style=\"margin-top: 4px;\" id=\"move_2\" class=\"moves\">
1700              <table cellpadding=\"4\">
1701                  <tr>
1702                      <td><small>{$lang->forum_to_move_to}</small></td>
1703                      <td>".$form->generate_forum_select('move_1_forum', $mybb->input['move_1_forum'])."</td>
1704                  </tr>
1705                  <tr>
1706                      <td><small>{$lang->leave_redirect}</small></td>
1707                      <td>".$form->generate_yes_no_radio('move_2_redirect', $mybb->input['move_2_redirect'])."</td>
1708                  </tr>
1709                  <tr>
1710                      <td><small>{$lang->delete_redirect_after}</small></td>
1711                      <td>".$form->generate_numeric_field('move_3_redirecttime', $mybb->input['move_3_redirecttime'], array('style' => 'width: 3em;', 'min' => 0))." {$lang->days}</td>
1712                  </tr>
1713              </table>
1714          </dd>
1715      </dl>
1716      <script type=\"text/javascript\">
1717      checkAction('move');
1718      </script>";
1719      $form_container->output_row($lang->move_thread." <em>*</em>", $lang->move_thread_desc, $actions);
1720  
1721      $actions = "
1722      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
1723      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"1\" {$copy_checked[1]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_copy_thread}</strong></label></dt>
1724          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"2\" {$copy_checked[2]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->copy_thread}</strong></label></dt>
1725          <dd style=\"margin-top: 4px;\" id=\"copy_2\" class=\"copys\">
1726              <table cellpadding=\"4\">
1727                  <tr>
1728                      <td><small>{$lang->forum_to_copy_to}</small></td>
1729                      <td>".$form->generate_forum_select('copy_1_forum', $mybb->input['copy_1_forum'])."</td>
1730                  </tr>
1731              </table>
1732          </dd>
1733      </dl>
1734      <script type=\"text/javascript\">
1735      checkAction('copy');
1736      </script>";
1737      $form_container->output_row($lang->copy_thread." <em>*</em>", '', $actions);
1738      $form_container->output_row($lang->softdelete_restore_thread." <em>*</em>", '', $form->generate_select_box('softdeletethread', $softdelete_restore, $mybb->input['softdeletethread'], array('id' => 'softdeletethread')), 'softdeletethread');
1739      $form_container->output_row($lang->delete_thread." <em>*</em>", '', $form->generate_yes_no_radio('deletethread', $mybb->input['deletethread']));
1740  
1741      $threadprefixes = build_prefixes();
1742      if(!empty($threadprefixes))
1743      {
1744          $thread_prefixes = array(
1745              '-1' => $lang->no_change,
1746              '0' => $lang->no_prefix
1747          );
1748  
1749          foreach($threadprefixes as $prefix)
1750          {
1751              $thread_prefixes[$prefix['pid']] = $prefix['prefix'];
1752          }
1753  
1754          $form_container->output_row($lang->apply_thread_prefix." <em>*</em>", '', $form->generate_select_box('threadprefix', $thread_prefixes, array($mybb->get_input('threadprefix', MyBB::INPUT_INT)), array('id' => 'threadprefix')), 'threadprefix');
1755      }
1756  
1757      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1758      $form_container->output_row($lang->new_subject." <em>*</em>", $lang->new_subject_desc, $form->generate_text_box('newsubject', $mybb->input['newsubject']));
1759      $form_container->end();
1760  
1761      $form_container = new FormContainer($lang->add_new_reply);
1762      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1763      $form_container->output_row($lang->add_new_reply, $lang->add_new_reply_desc, $form->generate_text_area('newreply', $mybb->input['newreply']), 'newreply');
1764      $form_container->output_row($lang->reply_subject, $lang->reply_subject_desc, $form->generate_text_box('newreplysubject', $mybb->input['newreplysubject'], array('id' => 'newreplysubject')), 'newreplysubject');
1765      $form_container->end();
1766  
1767      $form_container = new FormContainer($lang->send_private_message);
1768      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
1769      $form_container->output_row($lang->private_message_message, $lang->private_message_message_desc, $form->generate_text_area('pm_message', $mybb->input['pm_message'], array('id' => 'pm_message')), 'pm_message');
1770      $form_container->output_row($lang->private_message_subject, $lang->private_message_subject_desc, $form->generate_text_box('pm_subject', $mybb->input['pm_subject'], array('id' => 'pm_subject')), 'pm_subject');
1771      $form_container->end();
1772  
1773      $plugins->run_hooks("admin_config_mod_tools_edit_post_tool_end");
1774  
1775      $buttons[] = $form->generate_submit_button($lang->save_post_tool);
1776  
1777      $form->output_submit_wrapper($buttons);
1778      $form->end();
1779  
1780      $page->output_footer();
1781  }
1782  
1783  if($mybb->input['action'] == "add_post_tool")
1784  {
1785      $plugins->run_hooks("admin_config_mod_tools_add_post_tool");
1786  
1787      if($mybb->request_method == 'post')
1788      {
1789          if(trim($mybb->input['title']) == "")
1790          {
1791              $errors[] = $lang->error_missing_title;
1792          }
1793  
1794          if(trim($mybb->input['description']) == "")
1795          {
1796              $errors[] = $lang->error_missing_description;
1797          }
1798  
1799          if($mybb->input['forum_type'] == 2)
1800          {
1801              $forum_checked[1] = '';
1802              $forum_checked[2] = "checked=\"checked\"";
1803  
1804              if(is_array($mybb->input['forum_1_forums']) && count($mybb->input['forum_1_forums']) < 1)
1805              {
1806                  $errors[] = $lang->error_no_forums_selected;
1807              }
1808          }
1809          else
1810          {
1811              $forum_checked[1] = "checked=\"checked\"";
1812              $forum_checked[2] = '';
1813  
1814              $mybb->input['forum_1_forums'] = '';
1815          }
1816  
1817          if($mybb->input['group_type'] == 2)
1818          {
1819              $group_checked[1] = '';
1820              $group_checked[2] = "checked=\"checked\"";
1821  
1822              if(is_array($mybb->input['group_1_groups']) && count($mybb->input['group_1_groups']) < 1)
1823              {
1824                  $errors[] = $lang->error_no_groups_selected;
1825              }
1826          }
1827          else
1828          {
1829              $group_checked[1] = "checked=\"checked\"";
1830              $group_checked[2] = '';
1831  
1832              $mybb->input['group_1_groups'] = '';
1833          }
1834  
1835          if($mybb->input['approvethread'] != '' && $mybb->input['approvethread'] != 'approve' && $mybb->input['approvethread'] != 'unapprove' && $mybb->input['approvethread'] != 'toggle')
1836          {
1837              $mybb->input['approvethread'] = '';
1838          }
1839  
1840          if($mybb->input['softdeletethread'] != '' && $mybb->input['softdeletethread'] != 'softdelete' && $mybb->input['softdeletethread'] != 'restore' && $mybb->input['softdeletethread'] != 'toggle')
1841          {
1842              $mybb->input['softdeletethread'] = '';
1843          }
1844  
1845          if($mybb->input['openthread'] != '' && $mybb->input['openthread'] != 'open' && $mybb->input['openthread'] != 'close' && $mybb->input['openthread'] != 'toggle')
1846          {
1847              $mybb->input['openthread'] = '';
1848          }
1849  
1850          if($mybb->input['stickthread'] != '' && $mybb->input['stickthread'] != 'stick' && $mybb->input['stickthread'] != 'unstick' && $mybb->input['stickthread'] != 'toggle')
1851          {
1852              $mybb->input['stickthread'] = '';
1853          }
1854  
1855          if(!$mybb->get_input('threadprefix', MyBB::INPUT_INT))
1856          {
1857              $mybb->input['threadprefix'] = '';
1858          }
1859  
1860          if($mybb->input['move_type'] == 2)
1861          {
1862              $move_checked[1] = '';
1863              $move_checked[2] = "checked=\"checked\"";
1864  
1865              if(!$mybb->input['move_1_forum'])
1866              {
1867                  $errors[] = $lang->error_no_move_forum_selected;
1868              }
1869              else
1870              {
1871                  // Check that the destination forum is not a category
1872                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('move_1_forum', MyBB::INPUT_INT)."'");
1873                  if($db->fetch_field($query, "type") == "c")
1874                  {
1875                      $errors[] = $lang->error_forum_is_category;
1876                  }
1877              }
1878          }
1879          else
1880          {
1881              $move_checked[1] = "checked=\"checked\"";
1882              $move_checked[2] = '';
1883  
1884              $mybb->input['move_1_forum'] = '';
1885              $mybb->input['move_2_redirect'] = 0;
1886              $mybb->input['move_3_redirecttime'] = '';
1887          }
1888  
1889          if($mybb->input['copy_type'] == 2)
1890          {
1891              $copy_checked[1] = '';
1892              $copy_checked[2] = "checked=\"checked\"";
1893  
1894              if(!$mybb->input['copy_1_forum'])
1895              {
1896                  $errors[] = $lang->error_no_copy_forum_selected;
1897              }
1898              else
1899              {
1900                  $query = $db->simple_select("forums", "type", "fid = '".$mybb->get_input('copy_1_forum', MyBB::INPUT_INT)."'");
1901                  if($db->fetch_field($query, "type") == "c")
1902                  {
1903                      $errors[] = $lang->error_forum_is_category;
1904                  }
1905              }
1906          }
1907          else
1908          {
1909              $copy_checked[1] = 'checked=\"checked\"';
1910              $copy_checked[2] = '';
1911  
1912              $mybb->input['copy_1_forum'] = '';
1913          }
1914  
1915          if($mybb->input['approveposts'] != '' && $mybb->input['approveposts'] != 'approve' && $mybb->input['approveposts'] != 'unapprove' && $mybb->input['approveposts'] != 'toggle')
1916          {
1917              $mybb->input['approveposts'] = '';
1918          }
1919  
1920          if($mybb->input['softdeleteposts'] != '' && $mybb->input['softdeleteposts'] != 'softdelete' && $mybb->input['softdeleteposts'] != 'restore' && $mybb->input['softdeleteposts'] != 'toggle')
1921          {
1922              $mybb->input['softdeleteposts'] = '';
1923          }
1924  
1925          if($mybb->input['splitposts'] < -2)
1926          {
1927              $mybb->input['splitposts'] = -1;
1928          }
1929  
1930          if($mybb->input['splitpostsclose'] == 1)
1931          {
1932              $mybb->input['splitpostsclose'] = 'close';
1933          }
1934          else
1935          {
1936              $mybb->input['splitpostsclose'] = '';
1937          }
1938  
1939          if($mybb->input['splitpostsstick'] == 1)
1940          {
1941              $mybb->input['splitpostsstick'] = 'stick';
1942          }
1943          else
1944          {
1945              $mybb->input['splitpostsstick'] = '';
1946          }
1947  
1948          if($mybb->input['splitpostsunapprove'] == 1)
1949          {
1950              $mybb->input['splitpostsunapprove'] = 'unapprove';
1951          }
1952          else
1953          {
1954              $mybb->input['splitpostsunapprove'] = '';
1955          }
1956  
1957          if(!$mybb->get_input('splitthreadprefix', MyBB::INPUT_INT))
1958          {
1959              $mybb->input['splitthreadprefix'] = '';
1960          }
1961  
1962          if(!$errors)
1963          {
1964              $thread_options = array(
1965                  'confirmation' => $mybb->get_input('confirmation', MyBB::INPUT_INT),
1966                  'deletethread' => $mybb->get_input('deletethread', MyBB::INPUT_INT),
1967                  'softdeletethread' => $mybb->input['softdeletethread'],
1968                  'approvethread' => $mybb->input['approvethread'],
1969                  'openthread' => $mybb->input['openthread'],
1970                  'stickthread' => $mybb->input['stickthread'],
1971                  'movethread' => $mybb->get_input('move_1_forum', MyBB::INPUT_INT),
1972                  'movethreadredirect' => $mybb->get_input('move_2_redirect', MyBB::INPUT_INT),
1973                  'movethreadredirectexpire' => $mybb->get_input('move_3_redirecttime', MyBB::INPUT_INT),
1974                  'copythread' => $mybb->get_input('copy_1_forum', MyBB::INPUT_INT),
1975                  'newsubject' => $mybb->input['newsubject'],
1976                  'addreply' => $mybb->input['newreply'],
1977                  'replysubject' => $mybb->input['newreplysubject'],
1978                  'pm_subject' => $mybb->input['pm_subject'],
1979                  'pm_message' => $mybb->input['pm_message'],
1980                  'threadprefix' => $mybb->get_input('threadprefix', MyBB::INPUT_INT)
1981              );
1982  
1983              if(stripos($mybb->input['splitpostsnewsubject'], '{subject}') === false)
1984              {
1985                  $mybb->input['splitpostsnewsubject'] = '{subject}'.$mybb->input['splitpostsnewsubject'];
1986              }
1987  
1988              $post_options = array(
1989                  'deleteposts' => $mybb->get_input('deleteposts', MyBB::INPUT_INT),
1990                  'softdeleteposts' => $mybb->input['softdeleteposts'],
1991                  'mergeposts' => $mybb->get_input('mergeposts', MyBB::INPUT_INT),
1992                  'approveposts' => $mybb->input['approveposts'],
1993                  'splitposts' => $mybb->get_input('splitposts', MyBB::INPUT_INT),
1994                  'splitpostsclose' => $mybb->input['splitpostsclose'],
1995                  'splitpostsstick' => $mybb->input['splitpostsstick'],
1996                  'splitpostsunapprove' => $mybb->input['splitpostsunapprove'],
1997                  'splitthreadprefix' => $mybb->get_input('splitthreadprefix', MyBB::INPUT_INT),
1998                  'splitpostsnewsubject' => $mybb->input['splitpostsnewsubject'],
1999                  'splitpostsaddreply' => $mybb->input['splitpostsaddreply'],
2000                  'splitpostsreplysubject' => $mybb->input['splitpostsreplysubject']
2001              );
2002  
2003              $args = array(
2004                  'thread_options' => &$thread_options,
2005                  'post_options' => &$post_options,
2006              );
2007  
2008              $plugins->run_hooks("admin_config_mod_tools_add_post_tool_options", $args);
2009  
2010              $new_tool['type'] = 'p';
2011              $new_tool['threadoptions'] = $db->escape_string(my_serialize($thread_options));
2012              $new_tool['postoptions'] = $db->escape_string(my_serialize($post_options));
2013              $new_tool['name'] = $db->escape_string($mybb->input['title']);
2014              $new_tool['description'] = $db->escape_string($mybb->input['description']);
2015              $new_tool['forums'] = '';
2016              $new_tool['groups'] = '';
2017  
2018              if($mybb->input['forum_type'] == 2)
2019              {
2020                  if(is_array($mybb->input['forum_1_forums']))
2021                  {
2022                      $checked = array();
2023  
2024                      foreach($mybb->input['forum_1_forums'] as $fid)
2025                      {
2026                          $checked[] = (int)$fid;
2027                      }
2028  
2029                      $new_tool['forums'] = implode(',', $checked);
2030                  }
2031              }
2032              else
2033              {
2034                  $new_tool['forums'] = "-1";
2035              }
2036  
2037              if($mybb->input['group_type'] == 2)
2038              {
2039                  if(is_array($mybb->input['group_1_groups']))
2040                  {
2041                      $checked = array();
2042  
2043                      foreach($mybb->input['group_1_groups'] as $gid)
2044                      {
2045                          $checked[] = (int)$gid;
2046                      }
2047  
2048                      $new_tool['groups'] = implode(',', $checked);
2049                  }
2050              }
2051              else
2052              {
2053                  $new_tool['groups'] = "-1";
2054              }
2055  
2056              $tid = $db->insert_query("modtools", $new_tool);
2057  
2058              $plugins->run_hooks("admin_config_mod_tools_add_post_tool_commit");
2059  
2060              // Log admin action
2061              log_admin_action($tid, $mybb->input['title']);
2062              $cache->update_forumsdisplay();
2063  
2064              flash_message($lang->success_mod_tool_created, 'success');
2065              admin_redirect("index.php?module=config-mod_tools&action=post_tools");
2066          }
2067      }
2068  
2069      $page->add_breadcrumb_item($lang->add_new_post_tool);
2070      $page->output_header($lang->mod_tools." - ".$lang->add_new_post_tool);
2071  
2072      $sub_tabs['thread_tools'] = array(
2073          'title' => $lang->thread_tools,
2074          'link' => "index.php?module=config-mod_tools"
2075      );
2076      $sub_tabs['add_thread_tool'] = array(
2077          'title'=> $lang->add_new_thread_tool,
2078          'link' => "index.php?module=config-mod_tools&amp;action=add_thread_tool"
2079      );
2080      $sub_tabs['post_tools'] = array(
2081          'title' => $lang->post_tools,
2082          'link' => "index.php?module=config-mod_tools&amp;action=post_tools",
2083      );
2084      $sub_tabs['add_post_tool'] = array(
2085          'title'=> $lang->add_new_post_tool,
2086          'link' => "index.php?module=config-mod_tools&amp;action=add_post_tool",
2087          'description' => $lang->add_post_tool_desc
2088      );
2089  
2090      $page->output_nav_tabs($sub_tabs, 'add_post_tool');
2091  
2092      $form = new Form("index.php?module=config-mod_tools&amp;action=add_post_tool", 'post');
2093  
2094      if($errors)
2095      {
2096          $page->output_inline_error($errors);
2097      }
2098      else
2099      {
2100          $mybb->input['title'] = '';
2101          $mybb->input['description'] = '';
2102          $mybb->input['forum_1_forums'] = '';
2103          $forum_checked[1] = "checked=\"checked\"";
2104          $forum_checked[2] = '';
2105          $mybb->input['group_1_groups'] = '';
2106          $group_checked[1] = "checked=\"checked\"";
2107          $group_checked[2] = '';
2108          $mybb->input['confirmation'] = '0';
2109          $mybb->input['approvethread'] = '';
2110          $mybb->input['softdeletethread'] = '';
2111          $mybb->input['openthread'] = '';
2112          $mybb->input['stickthread'] = '';
2113          $mybb->input['move_1_forum'] = '';
2114          $mybb->input['move_2_redirect'] = '0';
2115          $mybb->input['move_3_redirecttime'] = '';
2116          $move_checked[1] = "checked=\"checked\"";
2117          $move_checked[2] = '';
2118          $copy_checked[1] = "checked=\"checked\"";
2119          $copy_checked[2] = '';
2120          $mybb->input['copy_1_forum'] = '';
2121          $mybb->input['deletethread'] = '0';
2122          $mybb->input['threadprefix'] = '-1';
2123          $mybb->input['newsubject'] = '{subject}';
2124          $mybb->input['newreply'] = '';
2125          $mybb->input['newreplysubject'] = '{subject}';
2126          $do_not_split_checked = ' selected="selected"';
2127          $mybb->input['deleteposts'] = '0';
2128          $mybb->input['mergeposts'] = '0';
2129          $mybb->input['approveposts'] = '';
2130          $mybb->input['softdeleteposts'] = '';
2131          $mybb->input['splitposts'] = '-1';
2132          $mybb->input['splitpostsclose'] = '0';
2133          $mybb->input['splitpostsstick'] = '0';
2134          $mybb->input['splitpostsunapprove'] = '0';
2135          $mybb->input['splitthreadprefix'] = '0';
2136          $mybb->input['splitpostsnewsubject'] = '{subject}';
2137          $mybb->input['splitpostsaddreply'] = '';
2138          $mybb->input['splitpostsreplysubject'] = '{subject}';
2139      }
2140  
2141      $form_container = new FormContainer($lang->general_options);
2142      $form_container->output_row($lang->name." <em>*</em>", '', $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
2143      $form_container->output_row($lang->short_description." <em>*</em>", '', $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
2144  
2145      $actions = "<script type=\"text/javascript\">
2146  	function checkAction(id)
2147      {
2148          var checked = '';
2149  
2150          $('.'+id+'s_check').each(function(e, val)
2151          {
2152              if($(this).prop('checked') == true)
2153              {
2154                  checked = $(this).val();
2155              }
2156          });
2157          $('.'+id+'s').each(function(e)
2158          {
2159              $(this).hide();
2160          });
2161          if($('#'+id+'_'+checked))
2162          {
2163              $('#'+id+'_'+checked).show();
2164          }
2165      }
2166  </script>
2167      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
2168      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"1\" {$forum_checked[1]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
2169          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forum_type\" value=\"2\" {$forum_checked[2]} class=\"forums_check\" onclick=\"checkAction('forum');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
2170          <dd style=\"margin-top: 4px;\" id=\"forum_2\" class=\"forums\">
2171              <table cellpadding=\"4\">
2172                  <tr>
2173                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
2174                      <td>".$form->generate_forum_select('forum_1_forums[]', $mybb->input['forum_1_forums'], array('multiple' => true, 'size' => 5))."</td>
2175                  </tr>
2176              </table>
2177          </dd>
2178      </dl>
2179      <script type=\"text/javascript\">
2180      checkAction('forum');
2181      </script>";
2182      $form_container->output_row($lang->available_in_forums." <em>*</em>", '', $actions);
2183  
2184      $actions = "<dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
2185      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"1\" {$group_checked[1]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
2186          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"group_type\" value=\"2\" {$group_checked[2]} class=\"groups_check\" onclick=\"checkAction('group');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
2187          <dd style=\"margin-top: 4px;\" id=\"group_2\" class=\"groups\">
2188              <table cellpadding=\"4\">
2189                  <tr>
2190                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
2191                      <td>".$form->generate_group_select('group_1_groups[]', $mybb->input['group_1_groups'], array('multiple' => true, 'size' => 5))."</td>
2192                  </tr>
2193              </table>
2194          </dd>
2195      </dl>
2196      <script type=\"text/javascript\">
2197      checkAction('group');
2198      </script>";
2199      $form_container->output_row($lang->available_to_groups." <em>*</em>", '', $actions);
2200      $form_container->output_row($lang->show_confirmation." <em>*</em>", '', $form->generate_yes_no_radio('confirmation', $mybb->input['confirmation'], array('style' => 'width: 2em;')));
2201      $form_container->end();
2202  
2203      $approve_unapprove = array(
2204          '' => $lang->no_change,
2205          'approve' => $lang->approve,
2206          'unapprove' => $lang->unapprove,
2207          'toggle' => $lang->toggle
2208      );
2209  
2210      $form_container = new FormContainer($lang->inline_post_moderation);
2211  
2212      $softdelete_restore = array(
2213          '' => $lang->no_change,
2214          'restore' => $lang->restore,
2215          'softdelete' => $lang->softdelete,
2216          'toggle' => $lang->toggle
2217      );
2218  
2219      $form_container->output_row($lang->softdelete_restore_posts." <em>*</em>", '', $form->generate_select_box('softdeleteposts', $softdelete_restore, $mybb->input['softdeleteposts'], array('id' => 'softdeleteposts')), 'softdeleteposts');
2220      $form_container->output_row($lang->delete_posts." <em>*</em>", '', $form->generate_yes_no_radio('deleteposts', $mybb->input['deleteposts']));
2221      $form_container->output_row($lang->merge_posts." <em>*</em>", $lang->merge_posts_desc, $form->generate_yes_no_radio('mergeposts', $mybb->input['mergeposts']));
2222      $form_container->output_row($lang->approve_unapprove_posts." <em>*</em>", '', $form->generate_select_box('approveposts', $approve_unapprove, $mybb->input['approveposts'], array('id' => 'approveposts')), 'approveposts');
2223      $form_container->end();
2224  
2225      $selectoptions = "<option value=\"-1\"{$do_not_split_checked}>{$lang->do_not_split}</option>\n";
2226      $selectoptions .= "<option value=\"-2\"{$split_same_checked} style=\"border-bottom: 1px solid #000;\">{$lang->split_to_same_forum}</option>\n";
2227  
2228      $form_container = new FormContainer($lang->split_posts);
2229      $form_container->output_row($lang->split_posts2." <em>*</em>", '', $form->generate_forum_select('splitposts', $mybb->input['splitposts']));
2230      $form_container->output_row($lang->close_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsclose', $mybb->input['splitpostsclose']));
2231      $form_container->output_row($lang->stick_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsstick', $mybb->input['splitpostsstick']));
2232      $form_container->output_row($lang->unapprove_split_thread." <em>*</em>", '', $form->generate_yes_no_radio('splitpostsunapprove', $mybb->input['splitpostsunapprove']));
2233  
2234      $splitthreadprefix = build_prefixes();
2235      if(!empty($splitthreadprefix))
2236      {
2237          $split_thread_prefixes = array(
2238              '0' => $lang->no_prefix
2239          );
2240  
2241          foreach($splitthreadprefix as $prefix)
2242          {
2243              $split_thread_prefixes[$prefix['pid']] = $prefix['prefix'];
2244          }
2245  
2246          $form_container->output_row($lang->split_thread_prefix." <em>*</em>", '', $form->generate_select_box('splitthreadprefix', $split_thread_prefixes, array($mybb->get_input('splitthreadprefix', MyBB::INPUT_INT)), array('id' => 'splitthreadprefix')), 'splitthreadprefix');
2247      }
2248  
2249      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
2250      $form_container->output_row($lang->split_thread_subject, $lang->split_thread_subject_desc, $form->generate_text_box('splitpostsnewsubject', $mybb->input['splitpostsnewsubject'], array('id' => 'splitpostsnewsubject ')), 'newreplysubject');
2251      $form_container->output_row($lang->add_new_split_reply, $lang->add_new_split_reply_desc, $form->generate_text_area('splitpostsaddreply', $mybb->input['splitpostsaddreply'], array('id' => 'splitpostsaddreply')), 'splitpostsaddreply');
2252      $form_container->output_row($lang->split_reply_subject, $lang->split_reply_subject_desc, $form->generate_text_box('splitpostsreplysubject', $mybb->input['splitpostsreplysubject'], array('id' => 'splitpostsreplysubject')), 'splitpostsreplysubject');
2253      $form_container->end();
2254  
2255      $open_close = array(
2256          '' => $lang->no_change,
2257          'open' => $lang->open,
2258          'close' => $lang->close,
2259          'toggle' => $lang->toggle
2260      );
2261  
2262      $stick_unstick = array(
2263          '' => $lang->no_change,
2264          'stick' => $lang->stick,
2265          'unstick' => $lang->unstick,
2266          'toggle' => $lang->toggle
2267      );
2268  
2269  
2270      $form_container = new FormContainer($lang->thread_moderation);
2271      $form_container->output_row($lang->approve_unapprove." <em>*</em>", '', $form->generate_select_box('approvethread', $approve_unapprove, $mybb->input['approvethread'], array('id' => 'approvethread')), 'approvethread');
2272      $form_container->output_row($lang->open_close_thread." <em>*</em>", '', $form->generate_select_box('openthread', $open_close, $mybb->input['openthread'], array('id' => 'openthread')), 'openthread');
2273      $form_container->output_row($lang->stick_unstick_thread." <em>*</em>", '', $form->generate_select_box('stickthread', $stick_unstick, $mybb->input['stickthread'], array('id' => 'stickthread')), 'stickthread');
2274  
2275  
2276      $actions = "
2277      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
2278      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"1\" {$move_checked[1]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_move_thread}</strong></label></dt>
2279          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"move_type\" value=\"2\" {$move_checked[2]} class=\"moves_check\" onclick=\"checkAction('move');\" style=\"vertical-align: middle;\" /> <strong>{$lang->move_thread}</strong></label></dt>
2280          <dd style=\"margin-top: 4px;\" id=\"move_2\" class=\"moves\">
2281              <table cellpadding=\"4\">
2282                  <tr>
2283                      <td><small>{$lang->forum_to_move_to}</small></td>
2284                      <td>".$form->generate_forum_select('move_1_forum', $mybb->input['move_1_forum'])."</td>
2285                  </tr>
2286                  <tr>
2287                      <td><small>{$lang->leave_redirect}</small></td>
2288                      <td>".$form->generate_yes_no_radio('move_2_redirect', $mybb->input['move_2_redirect'])."</td>
2289                  </tr>
2290                  <tr>
2291                      <td><small>{$lang->delete_redirect_after}</small></td>
2292                      <td>".$form->generate_numeric_field('move_3_redirecttime', $mybb->input['move_3_redirecttime'], array('style' => 'width: 3em;', 'min' => 0))." {$lang->days}</td>
2293                  </tr>
2294              </table>
2295          </dd>
2296      </dl>
2297      <script type=\"text/javascript\">
2298      checkAction('move');
2299      </script>";
2300      $form_container->output_row($lang->move_thread." <em>*</em>", $lang->move_thread_desc, $actions);
2301  
2302      $actions = "
2303      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
2304      <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"1\" {$copy_checked[1]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->do_not_copy_thread}</strong></label></dt>
2305          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"copy_type\" value=\"2\" {$copy_checked[2]} class=\"copys_check\" onclick=\"checkAction('copy');\" style=\"vertical-align: middle;\" /> <strong>{$lang->copy_thread}</strong></label></dt>
2306          <dd style=\"margin-top: 4px;\" id=\"copy_2\" class=\"copys\">
2307              <table cellpadding=\"4\">
2308                  <tr>
2309                      <td><small>{$lang->forum_to_copy_to}</small></td>
2310                      <td>".$form->generate_forum_select('copy_1_forum', $mybb->input['copy_1_forum'])."</td>
2311                  </tr>
2312              </table>
2313          </dd>
2314      </dl>
2315      <script type=\"text/javascript\">
2316      checkAction('copy');
2317      </script>";
2318      $form_container->output_row($lang->copy_thread." <em>*</em>", '', $actions);
2319      $form_container->output_row($lang->softdelete_restore_thread." <em>*</em>", '', $form->generate_select_box('softdeletethread', $softdelete_restore, $mybb->input['softdeletethread'], array('id' => 'softdeletethread')), 'softdeletethread');
2320      $form_container->output_row($lang->delete_thread." <em>*</em>", '', $form->generate_yes_no_radio('deletethread', $mybb->input['deletethread']));
2321  
2322      $threadprefixes = build_prefixes();
2323      if(!empty($threadprefixes))
2324      {
2325          $thread_prefixes = array(
2326              '-1' => $lang->no_change,
2327              '0' => $lang->no_prefix
2328          );
2329  
2330          foreach($threadprefixes as $prefix)
2331          {
2332              $thread_prefixes[$prefix['pid']] = $prefix['prefix'];
2333          }
2334  
2335          $form_container->output_row($lang->apply_thread_prefix." <em>*</em>", '', $form->generate_select_box('threadprefix', $thread_prefixes, $mybb->input['threadprefix'], array('id' => 'threadprefix')), 'threadprefix');
2336      }
2337  
2338      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
2339      $form_container->output_row($lang->new_subject." <em>*</em>", $lang->new_subject_desc, $form->generate_text_box('newsubject', $mybb->input['newsubject']));
2340      $form_container->end();
2341  
2342      $form_container = new FormContainer($lang->add_new_reply);
2343      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
2344      $form_container->output_row($lang->add_new_reply, $lang->add_new_reply_desc, $form->generate_text_area('newreply', $mybb->input['newreply'], array('id' => 'newreply')), 'newreply');
2345      $form_container->output_row($lang->reply_subject, $lang->reply_subject_desc, $form->generate_text_box('newreplysubject', $mybb->input['newreplysubject'], array('id' => 'newreplysubject')), 'newreplysubject');
2346      $form_container->end();
2347  
2348      $form_container = new FormContainer($lang->send_private_message);
2349      $form_container->output_row($lang->subject_message_replacements, $lang->subject_message_replacements_desc);
2350      $form_container->output_row($lang->private_message_message, $lang->private_message_message_desc, $form->generate_text_area('pm_message', $mybb->get_input('pm_message'), array('id' => 'pm_message')), 'pm_message');
2351      $form_container->output_row($lang->private_message_subject, $lang->private_message_subject_desc, $form->generate_text_box('pm_subject', $mybb->get_input('pm_subject'), array('id' => 'pm_subject')), 'pm_subject');
2352      $form_container->end();
2353  
2354      $plugins->run_hooks("admin_config_mod_tools_add_post_tool_end");
2355  
2356      $buttons[] = $form->generate_submit_button($lang->save_post_tool);
2357  
2358      $form->output_submit_wrapper($buttons);
2359      $form->end();
2360  
2361      $page->output_footer();
2362  }
2363  
2364  if(!$mybb->input['action'])
2365  {
2366      $plugins->run_hooks("admin_config_mod_tools_start");
2367  
2368      $page->output_header($lang->mod_tools." - ".$lang->thread_tools);
2369  
2370      $sub_tabs['thread_tools'] = array(
2371          'title' => $lang->thread_tools,
2372          'link' => "index.php?module=config-mod_tools",
2373          'description' => $lang->thread_tools_desc
2374      );
2375      $sub_tabs['add_thread_tool'] = array(
2376          'title'=> $lang->add_new_thread_tool,
2377          'link' => "index.php?module=config-mod_tools&amp;action=add_thread_tool"
2378      );
2379      $sub_tabs['post_tools'] = array(
2380          'title' => $lang->post_tools,
2381          'link' => "index.php?module=config-mod_tools&amp;action=post_tools",
2382      );
2383      $sub_tabs['add_post_tool'] = array(
2384          'title'=> $lang->add_new_post_tool,
2385          'link' => "index.php?module=config-mod_tools&amp;action=add_post_tool"
2386      );
2387  
2388      $page->output_nav_tabs($sub_tabs, 'thread_tools');
2389  
2390      $table = new Table;
2391      $table->construct_header($lang->title);
2392      $table->construct_header($lang->controls, array('class' => "align_center", 'colspan' => 2));
2393  
2394      $query = $db->simple_select('modtools', 'tid, name, description, type', "type='t'", array('order_by' => 'name'));
2395      while($tool = $db->fetch_array($query))
2396      {
2397          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_thread_tool&amp;tid={$tool['tid']}\"><strong>".htmlspecialchars_uni($tool['name'])."</strong></a><br /><small>".htmlspecialchars_uni($tool['description'])."</small>");
2398          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=edit_thread_tool&amp;tid={$tool['tid']}\">{$lang->edit}</a>", array('width' => 100, 'class' => "align_center"));
2399          $table->construct_cell("<a href=\"index.php?module=config-mod_tools&amp;action=delete_thread_tool&amp;tid={$tool['tid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_thread_tool_deletion}')\">{$lang->delete}</a>", array('width' => 100, 'class' => "align_center"));
2400          $table->construct_row();
2401      }
2402  
2403      if($table->num_rows() == 0)
2404      {
2405          $table->construct_cell($lang->no_thread_tools, array('colspan' => 3));
2406          $table->construct_row();
2407      }
2408  
2409      $table->output($lang->thread_tools);
2410  
2411      $page->output_footer();
2412  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref