[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

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

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


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1