[ Index ]

PHP Cross Reference of MyBB 1.8.21

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  
 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->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->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->input['action_1_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->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->input['action_2_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->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->input['action_3_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->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['lid'])
 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'] = $length['time'];
 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'] = $length['time'];
 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'] = $length['time'];
 316              $mybb->input['action_3_period'] = $length['period'];
 317          }
 318          $action_checked[$action['type']] = "checked=\"checked\"";
 319      }
 320  
 321      $form_container = new FormContainer($lang->edit_warning_level);
 322      $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');
 323  
 324      $query = $db->simple_select("usergroups", "*", "isbannedgroup=1");
 325      while($group = $db->fetch_array($query))
 326      {
 327          $banned_groups[$group['gid']] = $group['title'];
 328      }
 329  
 330      $periods = array(
 331          "hours" => $lang->expiration_hours,
 332          "days" => $lang->expiration_days,
 333          "weeks" => $lang->expiration_weeks,
 334          "months" => $lang->expiration_months,
 335          "never" => $lang->expiration_permanent
 336      );
 337  
 338      $actions = "<script type=\"text/javascript\">
 339  	function checkAction(id)
 340      {
 341          var checked = '';
 342  
 343          $('.'+id+'s_check').each(function(e, val)
 344          {
 345              if($(this).prop('checked') == true)
 346              {
 347                  checked = $(this).val();
 348              }
 349          });
 350          $('.'+id+'s').each(function(e)
 351          {
 352              $(this).hide();
 353          });
 354          if($('#'+id+'_'+checked))
 355          {
 356              $('#'+id+'_'+checked).show();
 357          }
 358      }
 359      </script>
 360      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%;\">
 361          <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>
 362          <dd style=\"margin-top: 4px;\" id=\"action_1\" class=\"actions\">
 363              <table cellpadding=\"4\">
 364                  <tr>
 365                      <td><small>{$lang->banned_group}</small></td>
 366                      <td>".$form->generate_select_box('action_1_usergroup', $banned_groups, $mybb->input['action_1_usergroup'])."</td>
 367                  </tr>
 368                  <tr>
 369                      <td><small>{$lang->ban_length}</small></td>
 370                      <td>".$form->generate_numeric_field('action_1_time', $mybb->input['action_1_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_1_period', $periods, $mybb->input['action_1_period'])."</td>
 371                  </tr>
 372              </table>
 373          </dd>
 374          <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>
 375          <dd style=\"margin-top: 4px;\" id=\"action_2\" class=\"actions\">
 376              <table cellpadding=\"4\">
 377                  <tr>
 378                      <td><small>{$lang->suspension_length}</small></td>
 379                      <td>".$form->generate_numeric_field('action_2_time', $mybb->input['action_2_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_2_period', $periods, $mybb->input['action_2_period'])."</td>
 380                  </tr>
 381              </table>
 382          </dd>
 383          <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>
 384          <dd style=\"margin-top: 4px;\" id=\"action_3\" class=\"actions\">
 385              <table cellpadding=\"4\">
 386                  <tr>
 387                      <td><small>{$lang->moderation_length}</small></td>
 388                      <td>".$form->generate_numeric_field('action_3_time', $mybb->input['action_3_time'], array('style' => 'width: 3em;', 'min' => 0))." ".$form->generate_select_box('action_3_period', $periods, $mybb->input['action_3_period'])."</td>
 389                  </tr>
 390              </table>
 391          </dd>
 392      </dl>
 393      <script type=\"text/javascript\">
 394      checkAction('action');
 395      </script>";
 396      $form_container->output_row($lang->action_to_be_taken, $lang->action_to_be_taken_desc, $actions);
 397      $form_container->end();
 398  
 399      $buttons[] = $form->generate_submit_button($lang->save_warning_level);
 400  
 401      $form->output_submit_wrapper($buttons);
 402      $form->end();
 403  
 404      $page->output_footer();
 405  }
 406  
 407  if($mybb->input['action'] == "delete_level")
 408  {
 409      $query = $db->simple_select("warninglevels", "*", "lid='".$mybb->get_input('lid', MyBB::INPUT_INT)."'");
 410      $level = $db->fetch_array($query);
 411  
 412      // Does the warning level not exist?
 413      if(!$level['lid'])
 414      {
 415          flash_message($lang->error_invalid_warning_level, 'error');
 416          admin_redirect("index.php?module=config-warning");
 417      }
 418  
 419      // User clicked no
 420      if($mybb->input['no'])
 421      {
 422          admin_redirect("index.php?module=config-warning");
 423      }
 424  
 425      $plugins->run_hooks("admin_config_warning_delete_level");
 426  
 427      if($mybb->request_method == "post")
 428      {
 429          // Delete the level
 430          $db->delete_query("warninglevels", "lid='{$level['lid']}'");
 431  
 432          $plugins->run_hooks("admin_config_warning_delete_level_commit");
 433  
 434          // Log admin action
 435          log_admin_action($level['lid'], $level['percentage']);
 436  
 437          flash_message($lang->success_warning_level_deleted, 'success');
 438          admin_redirect("index.php?module=config-warning");
 439      }
 440      else
 441      {
 442          $page->output_confirm_action("index.php?module=config-warning&amp;action=delete_level&amp;lid={$level['lid']}", $lang->confirm_warning_level_deletion);
 443      }
 444  }
 445  
 446  if($mybb->input['action'] == "add_type")
 447  {
 448      $plugins->run_hooks("admin_config_warning_add_type");
 449  
 450      if($mybb->request_method == "post")
 451      {
 452          if(!trim($mybb->input['title']))
 453          {
 454              $errors[] = $lang->error_missing_type_title;
 455          }
 456  
 457          if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] <= 0)
 458          {
 459              $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
 460          }
 461  
 462          if(!$errors)
 463          {
 464              $new_type = array(
 465                  "title" => $db->escape_string($mybb->input['title']),
 466                  "points" => $mybb->get_input('points', MyBB::INPUT_INT),
 467                  "expirationtime" =>  fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
 468              );
 469  
 470              $tid = $db->insert_query("warningtypes", $new_type);
 471  
 472              $plugins->run_hooks("admin_config_warning_add_type_commit");
 473  
 474              // Log admin action
 475              log_admin_action($tid, $mybb->input['title']);
 476  
 477              flash_message($lang->success_warning_type_created, 'success');
 478              admin_redirect("index.php?module=config-warning");
 479          }
 480      }
 481      else
 482      {
 483          $mybb->input = array_merge($mybb->input, array(
 484                  "points" => "2",
 485                  "expire_time" => 1,
 486                  "expire_period" => "days"
 487              )
 488          );
 489      }
 490  
 491      $page->add_breadcrumb_item($lang->add_warning_type);
 492      $page->output_header($lang->warning_types." - ".$lang->add_warning_type);
 493  
 494      $page->output_nav_tabs($sub_tabs, 'add_type');
 495      $form = new Form("index.php?module=config-warning&amp;action=add_type", "post");
 496  
 497  
 498      if($errors)
 499      {
 500          $page->output_inline_error($errors);
 501      }
 502  
 503      $form_container = new FormContainer($lang->add_warning_type);
 504      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 505      $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');
 506      $expiration_periods = array(
 507          "hours" => $lang->expiration_hours,
 508          "days" => $lang->expiration_days,
 509          "weeks" => $lang->expiration_weeks,
 510          "months" => $lang->expiration_months,
 511          "never" => $lang->expiration_never
 512      );
 513      $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');
 514      $form_container->end();
 515  
 516      $buttons[] = $form->generate_submit_button($lang->save_warning_type);
 517  
 518      $form->output_submit_wrapper($buttons);
 519      $form->end();
 520  
 521      $page->output_footer();
 522  }
 523  
 524  if($mybb->input['action'] == "edit_type")
 525  {
 526      $query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
 527      $type = $db->fetch_array($query);
 528  
 529      // Does the warning type not exist?
 530      if(!$type['tid'])
 531      {
 532          flash_message($lang->error_invalid_warning_type, 'error');
 533          admin_redirect("index.php?module=config-warning");
 534      }
 535  
 536      $plugins->run_hooks("admin_config_warning_edit_type");
 537  
 538      if($mybb->request_method == "post")
 539      {
 540          if(!trim($mybb->input['title']))
 541          {
 542              $errors[] = $lang->error_missing_type_title;
 543          }
 544  
 545          if(!is_numeric($mybb->input['points']) || $mybb->input['points'] > $mybb->settings['maxwarningpoints'] || $mybb->input['points'] < 0)
 546          {
 547              $errors[] = $lang->sprintf($lang->error_missing_type_points, $mybb->settings['maxwarningpoints']);
 548          }
 549  
 550          if(!$errors)
 551          {
 552              $updated_type = array(
 553                  "title" => $db->escape_string($mybb->input['title']),
 554                  "points" => $mybb->get_input('points', MyBB::INPUT_INT),
 555                  "expirationtime" =>  fetch_time_length($mybb->input['expire_time'], $mybb->input['expire_period'])
 556              );
 557  
 558              $plugins->run_hooks("admin_config_warning_edit_type_commit");
 559  
 560              $db->update_query("warningtypes", $updated_type, "tid='{$type['tid']}'");
 561  
 562              // Log admin action
 563              log_admin_action($type['tid'], $mybb->input['title']);
 564  
 565              flash_message($lang->success_warning_type_updated, 'success');
 566              admin_redirect("index.php?module=config-warning");
 567          }
 568      }
 569      else
 570      {
 571          $expiration = fetch_friendly_expiration($type['expirationtime']);
 572          $mybb->input = array_merge($mybb->input, array(
 573                  "title" => $type['title'],
 574                  "points" => $type['points'],
 575                  "expire_time" => $expiration['time'],
 576                  "expire_period" => $expiration['period']
 577              )
 578          );
 579      }
 580  
 581      $page->add_breadcrumb_item($lang->edit_warning_type);
 582      $page->output_header($lang->warning_types." - ".$lang->edit_warning_type);
 583  
 584      $sub_tabs['edit_type'] = array(
 585          'link' => "index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}",
 586          'title' => $lang->edit_warning_type,
 587          'description' => $lang->edit_warning_type_desc
 588      );
 589  
 590      $page->output_nav_tabs($sub_tabs, 'edit_type');
 591      $form = new Form("index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}", "post");
 592  
 593  
 594      if($errors)
 595      {
 596          $page->output_inline_error($errors);
 597      }
 598  
 599      $form_container = new FormContainer($lang->edit_warning_type);
 600      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 601      $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');
 602      $expiration_periods = array(
 603          "hours" => $lang->expiration_hours,
 604          "days" => $lang->expiration_days,
 605          "weeks" => $lang->expiration_weeks,
 606          "months" => $lang->expiration_months,
 607          "never" => $lang->expiration_never
 608      );
 609      $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');
 610      $form_container->end();
 611  
 612      $buttons[] = $form->generate_submit_button($lang->save_warning_type);
 613  
 614      $form->output_submit_wrapper($buttons);
 615      $form->end();
 616  
 617      $page->output_footer();
 618  }
 619  
 620  if($mybb->input['action'] == "delete_type")
 621  {
 622      $query = $db->simple_select("warningtypes", "*", "tid='".$mybb->get_input('tid', MyBB::INPUT_INT)."'");
 623      $type = $db->fetch_array($query);
 624  
 625      // Does the warning type not exist?
 626      if(!$type['tid'])
 627      {
 628          flash_message($lang->error_invalid_warning_type, 'error');
 629          admin_redirect("index.php?module=config-warning");
 630      }
 631  
 632      // User clicked no
 633      if($mybb->input['no'])
 634      {
 635          admin_redirect("index.php?module=config-warning");
 636      }
 637  
 638      $plugins->run_hooks("admin_config_warning_delete_type");
 639  
 640      if($mybb->request_method == "post")
 641      {
 642          // Delete the type
 643          $db->delete_query("warningtypes", "tid='{$type['tid']}'");
 644  
 645          $plugins->run_hooks("admin_config_warning_delete_type_commit");
 646  
 647          // Log admin action
 648          log_admin_action($type['tid'], $type['title']);
 649  
 650          flash_message($lang->success_warning_type_deleted, 'success');
 651          admin_redirect("index.php?module=config-warning");
 652      }
 653      else
 654      {
 655          $page->output_confirm_action("index.php?module=config-warning&amp;action=delete_type&amp;tid={$type['tid']}", $lang->confirm_warning_type_deletion);
 656      }
 657  }
 658  
 659  if($mybb->input['action'] == "levels")
 660  {
 661      $plugins->run_hooks("admin_config_warning_levels");
 662  
 663      $page->output_header($lang->warning_levels);
 664  
 665      $page->output_nav_tabs($sub_tabs, 'manage_levels');
 666  
 667      $table = new Table;
 668      $table->construct_header($lang->percentage, array('width' => '5%', 'class' => 'align_center'));
 669      $table->construct_header($lang->action_to_take);
 670      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
 671  
 672      $query = $db->simple_select("warninglevels", "*", "", array('order_by' => 'percentage'));
 673      while($level = $db->fetch_array($query))
 674      {
 675          $table->construct_cell("<strong>{$level['percentage']}%</strong>", array("class" => "align_center"));
 676          $action = my_unserialize($level['action']);
 677          $period = fetch_friendly_expiration($action['length']);
 678  
 679          // Get the right language for the ban period
 680          $lang_str = "expiration_".$period['period'];
 681          $period_str = $lang->$lang_str;
 682  
 683          if($action['type'] == 1)
 684          {
 685              $type = "move_banned_group";
 686              $group_name = $groupscache[$action['usergroup']]['title'];
 687          }
 688          elseif($action['type'] == 2)
 689          {
 690              $type = "suspend_posting";
 691          }
 692          elseif($action['type'] == 3)
 693          {
 694              $type = "moderate_new_posts";
 695          }
 696  
 697          if($period['period'] == "never")
 698          {
 699              $type .= "_permanent";
 700  
 701              if($group_name)
 702              {
 703                  // Permanently banned? Oh noes... switch group to the first sprintf replacement...
 704                  $period['time'] = $group_name;
 705              }
 706          }
 707  
 708          // If this level is permanently in place, then $period_str and $group_name do not apply below...
 709          $type = $lang->sprintf($lang->$type, $period['time'], $period_str, $group_name);
 710  
 711          $table->construct_cell($type);
 712          $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"));
 713          $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"));
 714          $table->construct_row();
 715      }
 716  
 717      if($table->num_rows() == 0)
 718      {
 719          $table->construct_cell($lang->no_warning_levels, array('colspan' => 4));
 720          $table->construct_row();
 721          $no_results = true;
 722      }
 723  
 724      $table->output($lang->warning_levels);
 725  
 726      $page->output_footer();
 727  }
 728  
 729  if(!$mybb->input['action'])
 730  {
 731      $plugins->run_hooks("admin_config_warning_start");
 732  
 733      $page->output_header($lang->warning_types);
 734  
 735      $page->output_nav_tabs($sub_tabs, 'manage_types');
 736  
 737      $table = new Table;
 738      $table->construct_header($lang->warning_type);
 739      $table->construct_header($lang->points, array('width' => '5%', 'class' => 'align_center'));
 740      $table->construct_header($lang->expires_after, array('width' => '25%', 'class' => 'align_center'));
 741      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2));
 742  
 743      $query = $db->simple_select("warningtypes", "*", "", array('order_by' => 'title'));
 744      while($type = $db->fetch_array($query))
 745      {
 746          $type['name'] = htmlspecialchars_uni($type['title']);
 747          $table->construct_cell("<a href=\"index.php?module=config-warning&amp;action=edit_type&amp;tid={$type['tid']}\"><strong>{$type['name']}</strong></a>");
 748          $table->construct_cell("{$type['points']}", array("class" => "align_center"));
 749          $expiration = fetch_friendly_expiration($type['expirationtime']);
 750          $lang_str = "expiration_".$expiration['period'];
 751          if($type['expirationtime'] > 0)
 752          {
 753              $table->construct_cell("{$expiration['time']} {$lang->$lang_str}", array("class" => "align_center"));
 754          }
 755          else
 756          {
 757              $table->construct_cell($lang->never, array("class" => "align_center"));
 758          }
 759          $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"));
 760          $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"));
 761          $table->construct_row();
 762      }
 763  
 764      if($table->num_rows() == 0)
 765      {
 766          $table->construct_cell($lang->no_warning_types, array('colspan' => 5));
 767          $table->construct_row();
 768          $no_results = true;
 769      }
 770  
 771      $table->output($lang->warning_types);
 772  
 773      $page->output_footer();
 774  }


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