[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/admin/modules/config/ -> warning.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  require_once  MYBB_ROOT."inc/functions_warnings.php";
  18  
  19  $page->add_breadcrumb_item($lang->warning_system, "index.php?module=config-warning");
  20  
  21  if($mybb->input['action'] == "levels" || $mybb->input['action'] == "add_type" || $mybb->input['action'] == "add_level" || !$mybb->input['action'])
  22  {
  23      $sub_tabs['manage_types'] = array(
  24          'title' => $lang->warning_types,
  25          'link' => "index.php?module=config-warning",
  26          'description' => $lang->warning_types_desc
  27      );
  28      $sub_tabs['add_type'] = array(
  29          'title'=> $lang->add_warning_type,
  30          'link' => "index.php?module=config-warning&amp;action=add_type",
  31          'description' => $lang->add_warning_type_desc
  32      );
  33      $sub_tabs['manage_levels'] = array(
  34          'title' => $lang->warning_levels,
  35          'link' => "index.php?module=config-warning&amp;action=levels",
  36          'description' => $lang->warning_levels_desc,
  37      );
  38      $sub_tabs['add_level'] = array(
  39          'title'=> $lang->add_warning_level,
  40          'link' => "index.php?module=config-warning&amp;action=add_level",
  41          'description' => $lang->add_warning_level_desc
  42      );
  43  }
  44  
  45  $plugins->run_hooks("admin_config_warning_begin");
  46  
  47  if($mybb->input['action'] == "add_level")
  48  {
  49      $plugins->run_hooks("admin_config_warning_add_level");
  50  
  51      if($mybb->request_method == "post")
  52      {
  53          if(!is_numeric($mybb->input['percentage']) || $mybb->input['percentage'] > 100 || $mybb->input['percentage'] < 0)
  54          {
  55              $errors[] = $lang->error_invalid_warning_percentage;
  56          }
  57  
  58          if(!$mybb->input['action_type'])
  59          {
  60              $errors[] = $lang->error_missing_action_type;
  61          }
  62  
  63          if(!$errors)
  64          {
  65              // Ban
  66              if($mybb->input['action_type'] == 1)
  67              {
  68                  $action = array(
  69                      "type" => 1,
  70                      "usergroup" => $mybb->get_input('action_1_usergroup', MyBB::INPUT_INT),
  71                      "length" => fetch_time_length($mybb->input['action_1_time'], $mybb->input['action_1_period'])
  72                  );
  73              }
  74              // Suspend posting
  75              else if($mybb->input['action_type'] == 2)
  76              {
  77                  $action = array(
  78                      "type" => 2,
  79                      "length" => fetch_time_length($mybb->input['action_2_time'], $mybb->input['action_2_period'])
  80                  );
  81              }
  82              // Moderate posts
  83              else if($mybb->input['action_type'] == 3)
  84              {
  85                  $action = array(
  86                      "type" => 3,
  87                      "length" => fetch_time_length($mybb->input['action_3_time'], $mybb->input['action_3_period'])
  88                  );
  89              }
  90              $new_level = array(
  91                  "percentage" => $mybb->get_input('percentage', MyBB::INPUT_INT),
  92                  "action" => my_serialize($action)
  93              );
  94  
  95              $lid = $db->insert_query("warninglevels", $new_level);
  96  
  97              $plugins->run_hooks("admin_config_warning_add_level_commit");
  98  
  99              // Log admin action
 100              log_admin_action($lid, $mybb->input['percentage']);
 101  
 102              flash_message($lang->success_warning_level_created, 'success');
 103              admin_redirect("index.php?module=config-warning&action=levels");
 104          }
 105      }
 106  
 107      $page->add_breadcrumb_item($lang->add_warning_level);
 108      $page->output_header($lang->warning_levels." - ".$lang->add_warning_level);
 109  
 110      $page->output_nav_tabs($sub_tabs, 'add_level');
 111      $form = new Form("index.php?module=config-warning&amp;action=add_level", "post");
 112  
 113      $action_checked = array_fill(1, 3, null);
 114      if($errors)
 115      {
 116          $page->output_inline_error($errors);
 117          $action_checked[$mybb->input['action_type']] = "checked=\"checked\"";
 118      }
 119  
 120      $form_container = new FormContainer($lang->add_warning_level);
 121      $form_container->output_row($lang->warning_points_percentage, $lang->warning_points_percentage_desc, $form->generate_numeric_field('percentage', $mybb->get_input('percentage'), array('id' => 'percentage', 'min' => 0, 'max' => 100)), 'percentage');
 122  
 123      $query = $db->simple_select("usergroups", "*", "isbannedgroup=1");
 124      while($group = $db->fetch_array($query))
 125      {
 126          $banned_groups[$group['gid']] = $group['title'];
 127      }
 128  
 129      $periods = array(
 130          "hours" => $lang->expiration_hours,
 131          "days" => $lang->expiration_days,
 132          "weeks" => $lang->expiration_weeks,
 133          "months" => $lang->expiration_months,
 134          "never" => $lang->expiration_permanent
 135      );
 136  
 137      $actions = "<script type=\"text/javascript\">
 138  	function checkAction(id)
 139      {
 140          var checked = '';
 141  
 142          $('.'+id+'s_check').each(function(e, val)
 143          {
 144              if($(this).prop('checked') == true)
 145              {
 146                  checked = $(this).val();
 147              }
 148          });
 149          $('.'+id+'s').each(function(e)
 150          {
 151              $(this).hide();
 152          });
 153          if($('#'+id+'_'+checked))
 154          {
 155              $('#'+id+'_'+checked).show();
 156          }
 157      }
 158      </script>
 159      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 160          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"1\" {$action_checked[1]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->ban_user}</strong></label></dt>
 161          <dd style=\"margin-top: 4px;\" id=\"action_1\" class=\"actions\">
 162              <table cellpadding=\"4\">
 163                  <tr>
 164                      <td><small>{$lang->banned_group}</small></td>
 165                      <td>".$form->generate_select_box('action_1_usergroup', $banned_groups, $mybb->get_input('action_1_usergroup'))."</td>
 166                  </tr>
 167                  <tr>
 168                      <td><small>{$lang->ban_length}</small></td>
 169                      <td>".$form->generate_numeric_field('action_1_time', $mybb->get_input('action_1_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->get_input('action_1_period'))."</td>
 170                  </tr>
 171              </table>
 172          </dd>
 173          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"2\" {$action_checked[2]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->suspend_posting_privileges}</strong></label></dt>
 174          <dd style=\"margin-top: 4px;\" id=\"action_2\" class=\"actions\">
 175              <table cellpadding=\"4\">
 176                  <tr>
 177                      <td><small>{$lang->suspension_length}</small></td>
 178                      <td>".$form->generate_numeric_field('action_2_time', $mybb->get_input('action_2_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->get_input('action_2_period'))."</td>
 179                  </tr>
 180              </table>
 181          </dd>
 182          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"3\" {$action_checked[3]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->moderate_posts}</strong></label></dt>
 183          <dd style=\"margin-top: 4px;\" id=\"action_3\" class=\"actions\">
 184              <table cellpadding=\"4\">
 185                  <tr>
 186                      <td><small>{$lang->moderation_length}</small></td>
 187                      <td>".$form->generate_numeric_field('action_3_time', $mybb->get_input('action_3_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->get_input('action_3_period'))."</td>
 188                  </tr>
 189              </table>
 190          </dd>
 191      </dl>
 192      <script type=\"text/javascript\">
 193      checkAction('action');
 194      </script>";
 195      $form_container->output_row($lang->action_to_be_taken, $lang->action_to_be_taken_desc, $actions);
 196      $form_container->end();
 197  
 198      $buttons[] = $form->generate_submit_button($lang->save_warning_level);
 199  
 200      $form->output_submit_wrapper($buttons);
 201      $form->end();
 202  
 203      $page->output_footer();
 204  }
 205  
 206  if($mybb->input['action'] == "edit_level")
 207  {
 208      $query = $db->simple_select("warninglevels", "*", "lid='".$mybb->get_input('lid', MyBB::INPUT_INT)."'");
 209      $level = $db->fetch_array($query);
 210  
 211      // Does the warning level not exist?
 212      if(!$level)
 213      {
 214          flash_message($lang->error_invalid_warning_level, 'error');
 215          admin_redirect("index.php?module=config-warning");
 216      }
 217  
 218      $plugins->run_hooks("admin_config_warning_edit_level");
 219  
 220      if($mybb->request_method == "post")
 221      {
 222          if(!is_numeric($mybb->input['percentage']) || $mybb->input['percentage'] > 100 || $mybb->input['percentage'] < 0)
 223          {
 224              $errors[] = $lang->error_invalid_warning_percentage;
 225          }
 226  
 227          if(!$mybb->input['action_type'])
 228          {
 229              $errors[] = $lang->error_missing_action_type;
 230          }
 231  
 232          if(!$errors)
 233          {
 234              // Ban
 235              if($mybb->input['action_type'] == 1)
 236              {
 237                  $action = array(
 238                      "type" => 1,
 239                      "usergroup" => $mybb->get_input('action_1_usergroup', MyBB::INPUT_INT),
 240                      "length" => fetch_time_length($mybb->input['action_1_time'], $mybb->input['action_1_period'])
 241                  );
 242              }
 243              // Suspend posting
 244              else if($mybb->input['action_type'] == 2)
 245              {
 246                  $action = array(
 247                      "type" => 2,
 248                      "length" => fetch_time_length($mybb->input['action_2_time'], $mybb->input['action_2_period'])
 249                  );
 250              }
 251              // Moderate posts
 252              else if($mybb->input['action_type'] == 3)
 253              {
 254                  $action = array(
 255                      "type" => 3,
 256                      "length" => fetch_time_length($mybb->input['action_3_time'], $mybb->input['action_3_period'])
 257                  );
 258              }
 259              $updated_level = array(
 260                  "percentage" => $mybb->get_input('percentage', MyBB::INPUT_INT),
 261                  "action" => my_serialize($action)
 262              );
 263  
 264              $plugins->run_hooks("admin_config_warning_edit_level_commit");
 265  
 266              $db->update_query("warninglevels", $updated_level, "lid='{$level['lid']}'");
 267  
 268              // Log admin action
 269              log_admin_action($level['lid'], $mybb->input['percentage']);
 270  
 271              flash_message($lang->success_warning_level_updated, 'success');
 272              admin_redirect("index.php?module=config-warning&action=levels");
 273          }
 274      }
 275  
 276      $page->add_breadcrumb_item($lang->edit_warning_level);
 277      $page->output_header($lang->warning_levels." - ".$lang->edit_warning_level);
 278  
 279      $sub_tabs['edit_level'] = array(
 280          'link' => "index.php?module=config-warning&amp;action=edit_level&amp;lid={$level['lid']}",
 281          'title' => $lang->edit_warning_level,
 282          'description' => $lang->edit_warning_level_desc
 283      );
 284  
 285      $page->output_nav_tabs($sub_tabs, 'edit_level');
 286      $form = new Form("index.php?module=config-warning&amp;action=edit_level&amp;lid={$level['lid']}", "post");
 287  
 288      if($errors)
 289      {
 290          $page->output_inline_error($errors);
 291      }
 292      else
 293      {
 294          $mybb->input = array_merge($mybb->input, array(
 295                  "percentage" => $level['percentage'],
 296              )
 297          );
 298          $action = my_unserialize($level['action']);
 299          if($action['type'] == 1)
 300          {
 301              $mybb->input['action_1_usergroup'] = $action['usergroup'];
 302              $length = fetch_friendly_expiration($action['length']);
 303              $mybb->input['action_1_time'] = isset($length['time']) ? $length['time'] : null;
 304              $mybb->input['action_1_period'] = $length['period'];
 305          }
 306          else if($action['type'] == 2)
 307          {
 308              $length = fetch_friendly_expiration($action['length']);
 309              $mybb->input['action_2_time'] = isset($length['time']) ? $length['time'] : null;
 310              $mybb->input['action_2_period'] = $length['period'];
 311          }
 312          else if($action['type'] == 3)
 313          {
 314              $length = fetch_friendly_expiration($action['length']);
 315              $mybb->input['action_3_time'] = isset($length['time']) ? $length['time'] : null;
 316              $mybb->input['action_3_period'] = $length['period'];
 317          }
 318  
 319          $action_checked = array_fill(1, 3, null);
 320          $action_checked[$action['type']] = "checked=\"checked\"";
 321      }
 322  
 323      $form_container = new FormContainer($lang->edit_warning_level);
 324      $form_container->output_row($lang->warning_points_percentage, $lang->warning_points_percentage_desc, $form->generate_numeric_field('percentage', $mybb->input['percentage'], array('id' => 'percentage', 'min' => 0, 'max' => 100)), 'percentage');
 325  
 326      $query = $db->simple_select("usergroups", "*", "isbannedgroup=1");
 327      while($group = $db->fetch_array($query))
 328      {
 329          $banned_groups[$group['gid']] = $group['title'];
 330      }
 331  
 332      $periods = array(
 333          "hours" => $lang->expiration_hours,
 334          "days" => $lang->expiration_days,
 335          "weeks" => $lang->expiration_weeks,
 336          "months" => $lang->expiration_months,
 337          "never" => $lang->expiration_permanent
 338      );
 339  
 340      $actions = "<script type=\"text/javascript\">
 341  	function checkAction(id)
 342      {
 343          var checked = '';
 344  
 345          $('.'+id+'s_check').each(function(e, val)
 346          {
 347              if($(this).prop('checked') == true)
 348              {
 349                  checked = $(this).val();
 350              }
 351          });
 352          $('.'+id+'s').each(function(e)
 353          {
 354              $(this).hide();
 355          });
 356          if($('#'+id+'_'+checked))
 357          {
 358              $('#'+id+'_'+checked).show();
 359          }
 360      }
 361      </script>
 362      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 363          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"1\" {$action_checked[1]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->ban_user}</strong></label></dt>
 364          <dd style=\"margin-top: 4px;\" id=\"action_1\" class=\"actions\">
 365              <table cellpadding=\"4\">
 366                  <tr>
 367                      <td><small>{$lang->banned_group}</small></td>
 368                      <td>".$form->generate_select_box('action_1_usergroup', $banned_groups, $mybb->get_input('action_1_usergroup'))."</td>
 369                  </tr>
 370                  <tr>
 371                      <td><small>{$lang->ban_length}</small></td>
 372                      <td>".$form->generate_numeric_field('action_1_time', $mybb->get_input('action_1_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->get_input('action_1_period'))."</td>
 373                  </tr>
 374              </table>
 375          </dd>
 376          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"2\" {$action_checked[2]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->suspend_posting_privileges}</strong></label></dt>
 377          <dd style=\"margin-top: 4px;\" id=\"action_2\" class=\"actions\">
 378              <table cellpadding=\"4\">
 379                  <tr>
 380                      <td><small>{$lang->suspension_length}</small></td>
 381                      <td>".$form->generate_numeric_field('action_2_time', $mybb->get_input('action_2_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->get_input('action_2_period'))."</td>
 382                  </tr>
 383              </table>
 384          </dd>
 385          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"action_type\" value=\"3\" {$action_checked[3]} class=\"actions_check\" onclick=\"checkAction('action');\" style=\"vertical-align: middle;\" /> <strong>{$lang->moderate_posts}</strong></label></dt>
 386          <dd style=\"margin-top: 4px;\" id=\"action_3\" class=\"actions\">
 387              <table cellpadding=\"4\">
 388                  <tr>
 389                      <td><small>{$lang->moderation_length}</small></td>
 390                      <td>".$form->generate_numeric_field('action_3_time', $mybb->get_input('action_3_time'), array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->get_input('action_3_period'))."</td>
 391                  </tr>
 392              </table>
 393          </dd>
 394      </dl>
 395      <script type=\"text/javascript\">
 396      checkAction('action');
 397      </script>";
 398      $form_container->output_row($lang->action_to_be_taken, $lang->action_to_be_taken_desc, $actions);
 399      $form_container->end();
 400  
 401      $buttons[] = $form->generate_submit_button($lang->save_warning_level);
 402  
 403      $form->output_submit_wrapper($buttons);
 404      $form->end();
 405  
 406      $page->output_footer();
 407  }
 408  
 409  if($mybb->input['action'] == "delete_level")
 410  {
 411      $query = $db->simple_select("warninglevels", "*", "lid='".$mybb->get_input('lid', MyBB::INPUT_INT)."'");
 412      $level = $db->fetch_array($query);
 413  
 414      // Does the warning level not exist?
 415      if(!$level)
 416      {
 417          flash_message($lang->error_invalid_warning_level, 'error');
 418          admin_redirect("index.php?module=config-warning");
 419      }
 420  
 421      // User clicked no
 422      if($mybb->get_input('no'))
 423      {
 424          admin_redirect("index.php?module=config-warning");
 425      }
 426  
 427      $plugins->run_hooks("admin_config_warning_delete_level");
 428  
 429      if($mybb->request_method == "post")
 430      {
 431          // Delete the level
 432          $db->delete_query("warninglevels", "lid='{$level['lid']}'");
 433  
 434          $plugins->run_hooks("admin_config_warning_delete_level_commit");
 435  
 436          // Log admin action
 437          log_admin_action($level['lid'], $level['percentage']);
 438  
 439          flash_message($lang->success_warning_level_deleted, 'success');
 440          admin_redirect("index.php?module=config-warning");
 441      }
 442      else
 443      {
 444          $page->output_confirm_action("index.php?module=config-warning&amp;action=delete_level&amp;lid={$level['lid']}", $lang->confirm_warning_level_deletion);
 445      }
 446  }
 447  
 448  if($mybb->input['action'] == "add_type")
 449  {
 450      $plugins->run_hooks("admin_config_warning_add_type");
 451  
 452      if($mybb->request_method == "post")
 453      {
 454          if(!trim($mybb->input['title']))
 455          {
 456              $errors[] = $lang->error_missing_type_title;
 457          }
 458  
 459          if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] <= 0)
 460          {
 461              $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
 462          }
 463  
 464          if(!$errors)
 465          {
 466              $new_type = array(
 467                  "title" => $db->escape_string($mybb->input['title']),
 468                  "points" => $mybb->get_input('points', MyBB::INPUT_INT),
 469                  "expirationtime" =>  fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
 470              );
 471  
 472              $tid = $db->insert_query("warningtypes", $new_type);
 473  
 474              $plugins->run_hooks("admin_config_warning_add_type_commit");
 475  
 476              // Log admin action
 477              log_admin_action($tid, $mybb->input['title']);
 478  
 479              flash_message($lang->success_warning_type_created, 'success');
 480              admin_redirect("index.php?module=config-warning");
 481          }
 482      }
 483      else
 484      {
 485          $mybb->input = array_merge($mybb->input, array(
 486                  "points" => "2",
 487                  "expire_time" => 1,
 488                  "expire_period" => "days"
 489              )
 490          );
 491      }
 492  
 493      $page->add_breadcrumb_item($lang->add_warning_type);
 494      $page->output_header($lang->warning_types." - ".$lang->add_warning_type);
 495  
 496      $page->output_nav_tabs($sub_tabs, 'add_type');
 497      $form = new Form("index.php?module=config-warning&amp;action=add_type", "post");
 498  
 499  
 500      if($errors)
 501      {
 502          $page->output_inline_error($errors);
 503      }
 504  
 505      $form_container = new FormContainer($lang->add_warning_type);
 506      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->get_input('title'), array('id' => 'title')), 'title');
 507      $form_container->output_row($lang->points_to_add." <em>*</em>", $lang->points_to_add_desc, $form->generate_numeric_field('points', $mybb->get_input('points'), array('id' => 'points', 'min' => 0, 'max' => $mybb->settings['maxwarningpoints'])), 'points');
 508      $expiration_periods = array(
 509          "hours" => $lang->expiration_hours,
 510          "days" => $lang->expiration_days,
 511          "weeks" => $lang->expiration_weeks,
 512          "months" => $lang->expiration_months,
 513          "never" => $lang->expiration_never
 514      );
 515      $form_container->output_row($lang->warning_expiry, $lang->warning_expiry_desc, $form->generate_numeric_field('expire_time', $mybb->input['expire_time'], array('id' => 'expire_time', 'min' => 0))." ".$form->generate_select_box('expire_period', $expiration_periods, $mybb->input['expire_period'], array('id' => 'expire_period')), 'expire_time');
 516      $form_container->end();
 517  
 518      $buttons[] = $form->generate_submit_button($lang->save_warning_type);
 519  
 520      $form->output_submit_wrapper($buttons);
 521      $form->end();
 522  
 523      $page->output_footer();
 524  }
 525  
 526  if($mybb->input['action'] == "edit_type")
 527  {
 528      $query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
 529      $type = $db->fetch_array($query);
 530  
 531      // Does the warning type not exist?
 532      if(!$type)
 533      {
 534          flash_message($lang->error_invalid_warning_type, 'error');
 535          admin_redirect("index.php?module=config-warning");
 536      }
 537  
 538      $plugins->run_hooks("admin_config_warning_edit_type");
 539  
 540      if($mybb->request_method == "post")
 541      {
 542          if(!trim($mybb->input['title']))
 543          {
 544              $errors[] = $lang->error_missing_type_title;
 545          }
 546  
 547          if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] <= 0)
 548          {
 549              $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
 550          }
 551  
 552          if(!$errors)
 553          {
 554              $updated_type = array(
 555                  "title" => $db->escape_string($mybb->input['title']),
 556                  "points" => $mybb->get_input('points', MyBB::INPUT_INT),
 557                  "expirationtime" =>  fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
 558              );
 559  
 560              $plugins->run_hooks("admin_config_warning_edit_type_commit");
 561  
 562              $db->update_query("warningtypes", $updated_type, "tid='{$type['tid']}'");
 563  
 564              // Log admin action
 565              log_admin_action($type['tid'], $mybb->input['title']);
 566  
 567              flash_message($lang->success_warning_type_updated, 'success');
 568              admin_redirect("index.php?module=config-warning");
 569          }
 570      }
 571      else
 572      {
 573          $expiration = fetch_friendly_expiration($type['expirationtime']);
 574          $mybb->input = array_merge($mybb->input, array(
 575                  "title" => $type['title'],
 576                  "points" => $type['points'],
 577                  "expire_time" => $expiration['time'],
 578                  "expire_period" => $expiration['period']
 579              )
 580          );
 581      }
 582  
 583      $page->add_breadcrumb_item($lang->edit_warning_type);
 584      $page->output_header($lang->warning_types." - ".$lang->edit_warning_type);
 585  
 586      $sub_tabs['edit_type'] = array(
 587          'link' => "index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}",
 588          'title' => $lang->edit_warning_type,
 589          'description' => $lang->edit_warning_type_desc
 590      );
 591  
 592      $page->output_nav_tabs($sub_tabs, 'edit_type');
 593      $form = new Form("index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}", "post");
 594  
 595  
 596      if($errors)
 597      {
 598          $page->output_inline_error($errors);
 599      }
 600  
 601      $form_container = new FormContainer($lang->edit_warning_type);
 602      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 603      $form_container->output_row($lang->points_to_add." <em>*</em>", $lang->points_to_add_desc, $form->generate_numeric_field('points', $mybb->input['points'], array('id' => 'points', 'min' => 0, 'max' => $mybb->settings['maxwarningpoints'])), 'points');
 604      $expiration_periods = array(
 605          "hours" => $lang->expiration_hours,
 606          "days" => $lang->expiration_days,
 607          "weeks" => $lang->expiration_weeks,
 608          "months" => $lang->expiration_months,
 609          "never" => $lang->expiration_never
 610      );
 611      $form_container->output_row($lang->warning_expiry, $lang->warning_expiry_desc, $form->generate_numeric_field('expire_time', $mybb->input['expire_time'], array('id' => 'expire_time', 'min' => 0))." ".$form->generate_select_box('expire_period', $expiration_periods, $mybb->input['expire_period'], array('id' => 'expire_period')), 'expire_time');
 612      $form_container->end();
 613  
 614      $buttons[] = $form->generate_submit_button($lang->save_warning_type);
 615  
 616      $form->output_submit_wrapper($buttons);
 617      $form->end();
 618  
 619      $page->output_footer();
 620  }
 621  
 622  if($mybb->input['action'] == "delete_type")
 623  {
 624      $query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
 625      $type = $db->fetch_array($query);
 626  
 627      // Does the warning type not exist?
 628      if(!$type)
 629      {
 630          flash_message($lang->error_invalid_warning_type, 'error');
 631          admin_redirect("index.php?module=config-warning");
 632      }
 633  
 634      // User clicked no
 635      if($mybb->get_input('no'))
 636      {
 637          admin_redirect("index.php?module=config-warning");
 638      }
 639  
 640      $plugins->run_hooks("admin_config_warning_delete_type");
 641  
 642      if($mybb->request_method == "post")
 643      {
 644          // Delete the type
 645          $db->delete_query("warningtypes", "tid='{$type['tid']}'");
 646  
 647          $plugins->run_hooks("admin_config_warning_delete_type_commit");
 648  
 649          // Log admin action
 650          log_admin_action($type['tid'], $type['title']);
 651  
 652          flash_message($lang->success_warning_type_deleted, 'success');
 653          admin_redirect("index.php?module=config-warning");
 654      }
 655      else
 656      {
 657          $page->output_confirm_action("index.php?module=config-warning&amp;action=delete_type&amp;tid={$type['tid']}", $lang->confirm_warning_type_deletion);
 658      }
 659  }
 660  
 661  if($mybb->input['action'] == "levels")
 662  {
 663      $plugins->run_hooks("admin_config_warning_levels");
 664  
 665      $page->output_header($lang->warning_levels);
 666  
 667      $page->output_nav_tabs($sub_tabs, 'manage_levels');
 668  
 669      $table = new Table;
 670      $table->construct_header($lang->percentage, array('width' => '5%', 'class' => 'align_center'));
 671      $table->construct_header($lang->action_to_take);
 672      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
 673  
 674      $query = $db->simple_select("warninglevels", "*", "", array('order_by' => 'percentage'));
 675      while($level = $db->fetch_array($query))
 676      {
 677          $table->construct_cell("<strong>{$level['percentage']}%</strong>", array("class" => "align_center"));
 678          $action = my_unserialize($level['action']);
 679          $period = fetch_friendly_expiration($action['length']);
 680  
 681          // Get the right language for the ban period
 682          $lang_str = "expiration_".$period['period'];
 683          $period_str = $lang->$lang_str;
 684          $group_name = '';
 685  
 686          if($action['type'] == 1)
 687          {
 688              $type = "move_banned_group";
 689              $group_name = $groupscache[$action['usergroup']]['title'];
 690          }
 691          elseif($action['type'] == 2)
 692          {
 693              $type = "suspend_posting";
 694          }
 695          elseif($action['type'] == 3)
 696          {
 697              $type = "moderate_new_posts";
 698          }
 699  
 700          if($period['period'] == "never")
 701          {
 702              $type .= "_permanent";
 703  
 704              if($group_name)
 705              {
 706                  // Permanently banned? Oh noes... switch group to the first sprintf replacement...
 707                  $period['time'] = $group_name;
 708              }
 709          }
 710  
 711          // If this level is permanently in place, then $period_str and $group_name do not apply below...
 712          $type = $lang->sprintf($lang->$type, $period['time'], $period_str, $group_name);
 713  
 714          $table->construct_cell($type);
 715          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=edit_level&amp;lid={$level['lid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
 716          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=delete_level&amp;lid={$level['lid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_warning_level_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
 717          $table->construct_row();
 718      }
 719  
 720      if($table->num_rows() == 0)
 721      {
 722          $table->construct_cell($lang->no_warning_levels, array('colspan' => 4));
 723          $table->construct_row();
 724      }
 725  
 726      $table->output($lang->warning_levels);
 727  
 728      $page->output_footer();
 729  }
 730  
 731  if(!$mybb->input['action'])
 732  {
 733      $plugins->run_hooks("admin_config_warning_start");
 734  
 735      $page->output_header($lang->warning_types);
 736  
 737      $page->output_nav_tabs($sub_tabs, 'manage_types');
 738  
 739      $table = new Table;
 740      $table->construct_header($lang->warning_type);
 741      $table->construct_header($lang->points, array('width' => '5%', 'class' => 'align_center'));
 742      $table->construct_header($lang->expires_after, array('width' => '25%', 'class' => 'align_center'));
 743      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
 744  
 745      $query = $db->simple_select("warningtypes", "*", "", array('order_by' => 'title'));
 746      while($type = $db->fetch_array($query))
 747      {
 748          $type['name'] = htmlspecialchars_uni($type['title']);
 749          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}\"><strong>{$type['name']}</strong></a>");
 750          $table->construct_cell("{$type['points']}", array("class" => "align_center"));
 751          $expiration = fetch_friendly_expiration($type['expirationtime']);
 752          $lang_str = "expiration_".$expiration['period'];
 753          if($type['expirationtime'] > 0)
 754          {
 755              $table->construct_cell("{$expiration['time']} {$lang->$lang_str}", array("class" => "align_center"));
 756          }
 757          else
 758          {
 759              $table->construct_cell($lang->never, array("class" => "align_center"));
 760          }
 761          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
 762          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=delete_type&amp;tid={$type['tid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_warning_type_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
 763          $table->construct_row();
 764      }
 765  
 766      if($table->num_rows() == 0)
 767      {
 768          $table->construct_cell($lang->no_warning_types, array('colspan' => 5));
 769          $table->construct_row();
 770      }
 771  
 772      $table->output($lang->warning_types);
 773  
 774      $page->output_footer();
 775  }


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