[ Index ]

PHP Cross Reference of MyBB 1.8.21

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


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