[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

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

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  // Disallow direct access to this file for security reasons
  12  if(!defined("IN_MYBB"))
  13  {
  14      die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
  15  }
  16  
  17  $page->add_breadcrumb_item($lang->attachment_types, "index.php?module=config-attachment_types");
  18  
  19  $plugins->run_hooks("admin_config_attachment_types_begin");
  20  
  21  if($mybb->input['action'] == "add")
  22  {
  23      $plugins->run_hooks("admin_config_attachment_types_add");
  24  
  25      if($mybb->request_method == "post")
  26      {
  27          if(!trim($mybb->input['mimetype']) && !trim($mybb->input['extension']))
  28          {
  29              $errors[] = $lang->error_missing_mime_type;
  30          }
  31  
  32          if(!trim($mybb->input['extension']) && !trim($mybb->input['mimetype']))
  33          {
  34              $errors[] = $lang->error_missing_extension;
  35          }
  36  
  37          if(!$errors)
  38          {
  39              if($mybb->input['mimetype'] == "images/attachtypes/")
  40              {
  41                  $mybb->input['mimetype'] = '';
  42              }
  43  
  44              if(substr($mybb->input['extension'], 0, 1) == '.')
  45              {
  46                  $mybb->input['extension'] = substr($mybb->input['extension'], 1);
  47              }
  48  
  49              foreach(array('groups', 'forums') as $key)
  50              {
  51                  if($mybb->input[$key] == 'all')
  52                  {
  53                      $mybb->input[$key] = -1;
  54                  }
  55                  elseif($mybb->input[$key] == 'custom')
  56                  {
  57                      if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
  58                      {
  59                          foreach($mybb->input['select'][$key] as &$val)
  60                          {
  61                              $val = (int)$val;
  62                          }
  63                          unset($val);
  64  
  65                          $mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
  66                      }
  67                      else
  68                      {
  69                          $mybb->input[$key] = '';
  70                      }
  71                  }
  72                  else
  73                  {
  74                      $mybb->input[$key] = '';
  75                  }
  76              }
  77  
  78              $maxsize = $mybb->get_input('maxsize', MyBB::INPUT_INT);
  79  
  80              if($maxsize == 0)
  81              {
  82                  $maxsize = "";
  83              }
  84  
  85              $new_type = array(
  86                  "name" => $db->escape_string($mybb->input['name']),
  87                  "mimetype" => $db->escape_string($mybb->input['mimetype']),
  88                  "extension" => $db->escape_string($mybb->input['extension']),
  89                  "maxsize" => $maxsize,
  90                  "icon" => $db->escape_string($mybb->input['icon']),
  91                  'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT),
  92                  'forcedownload' => $mybb->get_input('forcedownload', MyBB::INPUT_INT),
  93                  'groups' => $db->escape_string($mybb->get_input('groups')),
  94                  'forums' => $db->escape_string($mybb->get_input('forums')),
  95                  'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT)
  96              );
  97  
  98              $atid = $db->insert_query("attachtypes", $new_type);
  99  
 100              $plugins->run_hooks("admin_config_attachment_types_add_commit");
 101  
 102              // Log admin action
 103              log_admin_action($atid, $mybb->input['extension']);
 104  
 105              $cache->update_attachtypes();
 106  
 107              flash_message($lang->success_attachment_type_created, 'success');
 108              admin_redirect("index.php?module=config-attachment_types");
 109          }
 110      }
 111  
 112      $page->add_breadcrumb_item($lang->add_new_attachment_type);
 113      $page->output_header($lang->attachment_types." - ".$lang->add_new_attachment_type);
 114  
 115      $sub_tabs['attachment_types'] = array(
 116          'title' => $lang->attachment_types,
 117          'link' => "index.php?module=config-attachment_types"
 118      );
 119  
 120      $sub_tabs['add_attachment_type'] = array(
 121          'title' => $lang->add_new_attachment_type,
 122          'link' => "index.php?module=config-attachment_types&amp;action=add",
 123          'description' => $lang->add_attachment_type_desc
 124      );
 125  
 126      $page->output_nav_tabs($sub_tabs, 'add_attachment_type');
 127  
 128      $form = new Form("index.php?module=config-attachment_types&amp;action=add", "post", "add");
 129  
 130      if($errors)
 131      {
 132          switch($mybb->input['groups'])
 133          {
 134              case 'all':
 135                  $mybb->input['groups'] = -1;
 136                  break;
 137              case 'custom':
 138                  $mybb->input['groups'] = implode(',', (array)$mybb->input['select']['groups']);
 139                  break;
 140              default:
 141                  $mybb->input['groups'] = '';
 142                  break;
 143          }
 144  
 145          switch($mybb->input['forums'])
 146          {
 147              case 'all':
 148                  $mybb->input['forums'] = -1;
 149                  break;
 150              case 'custom':
 151                  $mybb->input['forums'] = implode(',', (array)$mybb->input['select']['forums']);
 152                  break;
 153              default:
 154                  $mybb->input['forums'] = '';
 155                  break;
 156          }
 157  
 158          $page->output_inline_error($errors);
 159      }
 160      else
 161      {
 162          $mybb->input['maxsize'] = '1024';
 163          $mybb->input['icon'] = "images/attachtypes/";
 164      }
 165  
 166      if(empty($mybb->input['groups']))
 167      {
 168          $mybb->input['groups'] = '';
 169      }
 170  
 171      if(empty($mybb->input['forums']))
 172      {
 173          $mybb->input['forums'] = '';
 174      }
 175  
 176      // PHP settings
 177      $upload_max_filesize = @ini_get('upload_max_filesize');
 178      $post_max_size = @ini_get('post_max_size');
 179      $limit_string = '';
 180      if($upload_max_filesize || $post_max_size)
 181      {
 182          $limit_string = '<br /><br />'.$lang->limit_intro;
 183          if($upload_max_filesize)
 184          {
 185              $limit_string .= '<br />'.$lang->sprintf($lang->limit_upload_max_filesize, $upload_max_filesize);
 186          }
 187          if($post_max_size)
 188          {
 189              $limit_string .= '<br />'.$lang->sprintf($lang->limit_post_max_size, $post_max_size);
 190          }
 191      }
 192  
 193      $selected_values = '';
 194      if($mybb->input['groups'] != '' && $mybb->input['groups'] != -1)
 195      {
 196          $selected_values = explode(',', $mybb->get_input('groups'));
 197  
 198          foreach($selected_values as &$value)
 199          {
 200              $value = (int)$value;
 201          }
 202          unset($value);
 203      }
 204  
 205      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 206      if($mybb->input['groups'] == -1)
 207      {
 208          $group_checked['all'] = 'checked="checked"';
 209      }
 210      elseif($mybb->input['groups'] != '')
 211      {
 212          $group_checked['custom'] = 'checked="checked"';
 213      }
 214      else
 215      {
 216          $group_checked['none'] = 'checked="checked"';
 217      }
 218  
 219      print_selection_javascript();
 220  
 221      $groups_select_code = "
 222      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 223          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"all\" {$group_checked['all']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 224          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"custom\" {$group_checked['custom']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 225          <dd style=\"margin-top: 4px;\" id=\"groups_forums_groups_custom\" class=\"groups_forums_groups\">
 226              <table cellpadding=\"4\">
 227                  <tr>
 228                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 229                      <td>".$form->generate_group_select('select[groups][]', $selected_values, array('id' => 'groups', 'multiple' => true, 'size' => 5))."</td>
 230                  </tr>
 231              </table>
 232          </dd>
 233          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"none\" {$group_checked['none']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 234      </dl>
 235      <script type=\"text/javascript\">
 236          checkAction('groups');
 237      </script>";
 238  
 239      $selected_values = '';
 240      if($mybb->input['forums'] != '' && $mybb->input['forums'] != -1)
 241      {
 242          $selected_values = explode(',', $mybb->get_input('forums'));
 243  
 244          foreach($selected_values as &$value)
 245          {
 246              $value = (int)$value;
 247          }
 248          unset($value);
 249      }
 250  
 251      $forum_checked = array('all' => '', 'custom' => '', 'none' => '');
 252      if($mybb->input['forums'] == -1)
 253      {
 254          $forum_checked['all'] = 'checked="checked"';
 255      }
 256      elseif($mybb->input['forums'] != '')
 257      {
 258          $forum_checked['custom'] = 'checked="checked"';
 259      }
 260      else
 261      {
 262          $forum_checked['none'] = 'checked="checked"';
 263      }
 264  
 265      $forums_select_code = "
 266      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 267          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"all\" {$forum_checked['all']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
 268          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"custom\" {$forum_checked['custom']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
 269          <dd style=\"margin-top: 4px;\" id=\"forums_forums_groups_custom\" class=\"forums_forums_groups\">
 270              <table cellpadding=\"4\">
 271                  <tr>
 272                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
 273                      <td>".$form->generate_forum_select('select[forums][]', $selected_values, array('id' => 'forums', 'multiple' => true, 'size' => 5))."</td>
 274                  </tr>
 275              </table>
 276          </dd>
 277          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"none\" {$forum_checked['none']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 278      </dl>
 279      <script type=\"text/javascript\">
 280          checkAction('forums');
 281      </script>";
 282      
 283      $mybb->input['forcedownload'] = $mybb->get_input('forcedownload', MyBB::INPUT_INT);
 284  
 285      $form_container = new FormContainer($lang->add_new_attachment_type);
 286      $form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->get_input('name'), array('id' => 'name')), 'name');
 287      $form_container->output_row($lang->file_extension." <em>*</em>", $lang->file_extension_desc, $form->generate_text_box('extension', $mybb->get_input('extension'), array('id' => 'extension')), 'extension');
 288      $form_container->output_row($lang->mime_type." <em>*</em>", $lang->mime_type_desc, $form->generate_text_box('mimetype', $mybb->get_input('mimetype'), array('id' => 'mimetype')), 'mimetype');
 289      $form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->get_input('maxsize'), array('id' => 'maxsize', 'min' => 0)), 'maxsize');
 290      $form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->get_input('icon'), array('id' => 'icon')), 'icon');
 291      $form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->get_input('enabled')), 'enabled');
 292      $form_container->output_row($lang->forcedownload, $lang->forcedownload_desc, $form->generate_yes_no_radio('forcedownload', $mybb->get_input('forcedownload')), 'forcedownload');
 293      $form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups'));
 294      $form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums'));
 295      $form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->get_input('avatarfile')), 'avatarfile');
 296  
 297      $form_container->end();
 298  
 299      $buttons[] = $form->generate_submit_button($lang->save_attachment_type);
 300  
 301      $form->output_submit_wrapper($buttons);
 302      $form->end();
 303  
 304      $page->output_footer();
 305  }
 306  
 307  if($mybb->input['action'] == "edit")
 308  {
 309      $query = $db->simple_select("attachtypes", "*", "atid='".$mybb->get_input('atid', MyBB::INPUT_INT)."'");
 310      $attachment_type = $db->fetch_array($query);
 311  
 312      if(!$attachment_type['atid'])
 313      {
 314          flash_message($lang->error_invalid_attachment_type, 'error');
 315          admin_redirect("index.php?module=config-attachment_types");
 316      }
 317  
 318      $plugins->run_hooks("admin_config_attachment_types_edit");
 319  
 320      if($mybb->request_method == "post")
 321      {
 322          if(!trim($mybb->input['mimetype']) && !trim($mybb->input['extension']))
 323          {
 324              $errors[] = $lang->error_missing_mime_type;
 325          }
 326  
 327          if(!trim($mybb->input['extension']) && !trim($mybb->input['mimetype']))
 328          {
 329              $errors[] = $lang->error_missing_extension;
 330          }
 331  
 332          if(!$errors)
 333          {
 334              if($mybb->input['mimetype'] == "images/attachtypes/")
 335              {
 336                  $mybb->input['mimetype'] = '';
 337              }
 338  
 339              if(substr($mybb->input['extension'], 0, 1) == '.')
 340              {
 341                  $mybb->input['extension'] = substr($mybb->input['extension'], 1);
 342              }
 343  
 344              foreach(array('groups', 'forums') as $key)
 345              {
 346                  if($mybb->input[$key] == 'all')
 347                  {
 348                      $mybb->input[$key] = -1;
 349                  }
 350                  elseif($mybb->input[$key] == 'custom')
 351                  {
 352                      if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
 353                      {
 354                          foreach($mybb->input['select'][$key] as &$val)
 355                          {
 356                              $val = (int)$val;
 357                          }
 358                          unset($val);
 359  
 360                          $mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
 361                      }
 362                      else
 363                      {
 364                          $mybb->input[$key] = '';
 365                      }
 366                  }
 367                  else
 368                  {
 369                      $mybb->input[$key] = '';
 370                  }
 371              }
 372  
 373              $updated_type = array(
 374                  "name" => $db->escape_string($mybb->input['name']),
 375                  "mimetype" => $db->escape_string($mybb->input['mimetype']),
 376                  "extension" => $db->escape_string($mybb->input['extension']),
 377                  "maxsize" => $mybb->get_input('maxsize', MyBB::INPUT_INT),
 378                  "icon" => $db->escape_string($mybb->input['icon']),
 379                  'enabled' => $mybb->get_input('enabled', MyBB::INPUT_INT),
 380                  'forcedownload' => $mybb->get_input('forcedownload', MyBB::INPUT_INT),
 381                  'groups' => $db->escape_string($mybb->get_input('groups')),
 382                  'forums' => $db->escape_string($mybb->get_input('forums')),
 383                  'avatarfile' => $mybb->get_input('avatarfile', MyBB::INPUT_INT)
 384              );
 385  
 386              $plugins->run_hooks("admin_config_attachment_types_edit_commit");
 387  
 388              $db->update_query("attachtypes", $updated_type, "atid='{$attachment_type['atid']}'");
 389  
 390              // Log admin action
 391              log_admin_action($attachment_type['atid'], $mybb->input['extension']);
 392  
 393              $cache->update_attachtypes();
 394  
 395              flash_message($lang->success_attachment_type_updated, 'success');
 396              admin_redirect("index.php?module=config-attachment_types");
 397          }
 398      }
 399  
 400      $page->add_breadcrumb_item($lang->edit_attachment_type);
 401      $page->output_header($lang->attachment_types." - ".$lang->edit_attachment_type);
 402  
 403      $sub_tabs['edit_attachment_type'] = array(
 404          'title' => $lang->edit_attachment_type,
 405          'link' => "index.php?module=config-attachment_types&amp;action=edit&amp;atid={$attachment_type['atid']}",
 406          'description' => $lang->edit_attachment_type_desc
 407      );
 408  
 409      $page->output_nav_tabs($sub_tabs, 'edit_attachment_type');
 410  
 411      $form = new Form("index.php?module=config-attachment_types&amp;action=edit&amp;atid={$attachment_type['atid']}", "post", "add");
 412  
 413      if($errors)
 414      {
 415          switch($mybb->input['groups'])
 416          {
 417              case 'all':
 418                  $mybb->input['groups'] = -1;
 419                  break;
 420              case 'custom':
 421                  $mybb->input['groups'] = implode(',', (array)$mybb->input['select']['groups']);
 422                  break;
 423              default:
 424                  $mybb->input['groups'] = '';
 425                  break;
 426          }
 427  
 428          switch($mybb->input['forums'])
 429          {
 430              case 'all':
 431                  $mybb->input['forums'] = -1;
 432                  break;
 433              case 'custom':
 434                  $mybb->input['forums'] = implode(',', (array)$mybb->input['select']['forums']);
 435                  break;
 436              default:
 437                  $mybb->input['forums'] = '';
 438                  break;
 439          }
 440      
 441          $page->output_inline_error($errors);
 442      }
 443      else
 444      {
 445          $mybb->input = array_merge($mybb->input, $attachment_type);
 446      }
 447  
 448      if(empty($mybb->input['groups']))
 449      {
 450          $mybb->input['groups'] = '';
 451      }
 452  
 453      if(empty($mybb->input['forums']))
 454      {
 455          $mybb->input['forums'] = '';
 456      }
 457  
 458      // PHP settings
 459      $upload_max_filesize = @ini_get('upload_max_filesize');
 460      $post_max_size = @ini_get('post_max_size');
 461      $limit_string = '';
 462      if($upload_max_filesize || $post_max_size)
 463      {
 464          $limit_string = '<br /><br />'.$lang->limit_intro;
 465          if($upload_max_filesize)
 466          {
 467              $limit_string .= '<br />'.$lang->sprintf($lang->limit_upload_max_filesize, $upload_max_filesize);
 468          }
 469          if($post_max_size)
 470          {
 471              $limit_string .= '<br />'.$lang->sprintf($lang->limit_post_max_size, $post_max_size);
 472          }
 473      }
 474  
 475      $selected_values = '';
 476      if($mybb->input['groups'] != '' && $mybb->input['groups'] != -1)
 477      {
 478          $selected_values = explode(',', $mybb->get_input('groups'));
 479  
 480          foreach($selected_values as &$value)
 481          {
 482              $value = (int)$value;
 483          }
 484          unset($value);
 485      }
 486  
 487      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 488      if($mybb->input['groups'] == -1)
 489      {
 490          $group_checked['all'] = 'checked="checked"';
 491      }
 492      elseif($mybb->input['groups'] != '')
 493      {
 494          $group_checked['custom'] = 'checked="checked"';
 495      }
 496      else
 497      {
 498          $group_checked['none'] = 'checked="checked"';
 499      }
 500  
 501      print_selection_javascript();
 502  
 503      $groups_select_code = "
 504      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 505          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"all\" {$group_checked['all']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 506          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"custom\" {$group_checked['custom']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 507          <dd style=\"margin-top: 4px;\" id=\"groups_forums_groups_custom\" class=\"groups_forums_groups\">
 508              <table cellpadding=\"4\">
 509                  <tr>
 510                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 511                      <td>".$form->generate_group_select('select[groups][]', $selected_values, array('id' => 'groups', 'multiple' => true, 'size' => 5))."</td>
 512                  </tr>
 513              </table>
 514          </dd>
 515          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"groups\" value=\"none\" {$group_checked['none']} class=\"groups_forums_groups_check\" onclick=\"checkAction('groups');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 516      </dl>
 517      <script type=\"text/javascript\">
 518          checkAction('groups');
 519      </script>";
 520  
 521      $selected_values = '';
 522      if($mybb->input['forums'] != '' && $mybb->input['forums'] != -1)
 523      {
 524          $selected_values = explode(',', $mybb->get_input('forums'));
 525  
 526          foreach($selected_values as &$value)
 527          {
 528              $value = (int)$value;
 529          }
 530          unset($value);
 531      }
 532  
 533      $forum_checked = array('all' => '', 'custom' => '', 'none' => '');
 534      if($mybb->input['forums'] == -1)
 535      {
 536          $forum_checked['all'] = 'checked="checked"';
 537      }
 538      elseif($mybb->input['forums'] != '')
 539      {
 540          $forum_checked['custom'] = 'checked="checked"';
 541      }
 542      else
 543      {
 544          $forum_checked['none'] = 'checked="checked"';
 545      }
 546  
 547      $forums_select_code = "
 548      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 549          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"all\" {$forum_checked['all']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_forums}</strong></label></dt>
 550          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"custom\" {$forum_checked['custom']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_forums}</strong></label></dt>
 551          <dd style=\"margin-top: 4px;\" id=\"forums_forums_groups_custom\" class=\"forums_forums_groups\">
 552              <table cellpadding=\"4\">
 553                  <tr>
 554                      <td valign=\"top\"><small>{$lang->forums_colon}</small></td>
 555                      <td>".$form->generate_forum_select('select[forums][]', $selected_values, array('id' => 'forums', 'multiple' => true, 'size' => 5))."</td>
 556                  </tr>
 557              </table>
 558          </dd>
 559          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"forums\" value=\"none\" {$forum_checked['none']} class=\"forums_forums_groups_check\" onclick=\"checkAction('forums');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 560      </dl>
 561      <script type=\"text/javascript\">
 562          checkAction('forums');
 563      </script>";
 564  
 565      $mybb->input['forcedownload'] = $mybb->get_input('forcedownload', MyBB::INPUT_INT);
 566  
 567      $form_container = new FormContainer($lang->edit_attachment_type);
 568      $form_container->output_row($lang->name, $lang->name_desc, $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 569      $form_container->output_row($lang->file_extension." <em>*</em>", $lang->file_extension_desc, $form->generate_text_box('extension', $mybb->input['extension'], array('id' => 'extension')), 'extension');
 570      $form_container->output_row($lang->mime_type." <em>*</em>", $lang->mime_type_desc, $form->generate_text_box('mimetype', $mybb->input['mimetype'], array('id' => 'mimetype')), 'mimetype');
 571      $form_container->output_row($lang->maximum_file_size, $lang->maximum_file_size_desc.$limit_string, $form->generate_numeric_field('maxsize', $mybb->input['maxsize'], array('id' => 'maxsize', 'min' => 0)), 'maxsize');
 572      $form_container->output_row($lang->attachment_icon, $lang->attachment_icon_desc, $form->generate_text_box('icon', $mybb->input['icon'], array('id' => 'icon')), 'icon');
 573      $form_container->output_row($lang->enabled, '', $form->generate_yes_no_radio('enabled', $mybb->input['enabled']), 'enabled');
 574      $form_container->output_row($lang->forcedownload, $lang->forcedownload_desc, $form->generate_yes_no_radio('forcedownload', $mybb->input['forcedownload']), 'forcedownload');
 575      $form_container->output_row($lang->available_to_groups, '', $groups_select_code, '', array(), array('id' => 'row_groups'));
 576      $form_container->output_row($lang->available_in_forums, '', $forums_select_code, '', array(), array('id' => 'row_forums'));
 577      $form_container->output_row($lang->avatar_file, $lang->avatar_file_desc, $form->generate_yes_no_radio('avatarfile', $mybb->input['avatarfile']), 'avatarfile');
 578  
 579      $form_container->end();
 580  
 581      $buttons[] = $form->generate_submit_button($lang->save_attachment_type);
 582  
 583      $form->output_submit_wrapper($buttons);
 584      $form->end();
 585  
 586      $page->output_footer();
 587  }
 588  
 589  if($mybb->input['action'] == "delete")
 590  {
 591      if($mybb->get_input('no'))
 592      {
 593          admin_redirect("index.php?module=config-attachment_types");
 594      }
 595  
 596      $query = $db->simple_select("attachtypes", "*", "atid='".$mybb->get_input('atid', MyBB::INPUT_INT)."'");
 597      $attachment_type = $db->fetch_array($query);
 598  
 599      if(!$attachment_type['atid'])
 600      {
 601          flash_message($lang->error_invalid_attachment_type, 'error');
 602          admin_redirect("index.php?module=config-attachment_types");
 603      }
 604  
 605      $plugins->run_hooks("admin_config_attachment_types_delete");
 606  
 607      if($mybb->request_method == "post")
 608      {
 609          $db->delete_query("attachtypes", "atid='{$attachment_type['atid']}'");
 610  
 611          $plugins->run_hooks("admin_config_attachment_types_delete_commit");
 612  
 613          $cache->update_attachtypes();
 614  
 615          // Log admin action
 616          log_admin_action($attachment_type['atid'], $attachment_type['extension']);
 617  
 618          flash_message($lang->success_attachment_type_deleted, 'success');
 619          admin_redirect("index.php?module=config-attachment_types");
 620      }
 621      else
 622      {
 623          $page->output_confirm_action("index.php?module=config-attachment_types&amp;action=delete&amp;atid={$attachment_type['atid']}", $lang->confirm_attachment_type_deletion);
 624      }
 625  }
 626  
 627  if($mybb->input['action'] == 'toggle_status')
 628  {
 629      if(!verify_post_check($mybb->get_input('my_post_key')))
 630      {
 631          flash_message($lang->invalid_post_verify_key2, 'error');
 632          admin_redirect('index.php?module=config-attachment_types');
 633      }
 634  
 635      $atid = $mybb->get_input('atid', MyBB::INPUT_INT);
 636  
 637      $query = $db->simple_select('attachtypes', '*', "atid='{$atid}'");
 638      $attachment_type = $db->fetch_array($query);
 639  
 640      if(!$attachment_type['atid'])
 641      {
 642          flash_message($lang->error_invalid_mycode, 'error');
 643          admin_redirect('index.php?module=config-attachment_types');
 644      }
 645  
 646      $plugins->run_hooks('admin_config_attachment_types_toggle_status');
 647  
 648      $update_array = array('enabled' => 1);
 649      $phrase = $lang->success_activated_attachment_type;
 650      if($attachment_type['enabled'] == 1)
 651      {
 652          $update_array['enabled'] = 0;
 653          $phrase = $lang->success_deactivated_attachment_type;
 654      }
 655  
 656      $plugins->run_hooks('admin_config_attachment_types_toggle_status_commit');
 657  
 658      $db->update_query('attachtypes', $update_array, "atid='{$atid}'");
 659  
 660      $cache->update_attachtypes();
 661  
 662      // Log admin action
 663      log_admin_action($atid, $attachment_type['extension'], $update_array['enabled']);
 664  
 665      flash_message($phrase, 'success');
 666      admin_redirect('index.php?module=config-attachment_types');
 667  }
 668  
 669  if(!$mybb->input['action'])
 670  {
 671      $page->output_header($lang->attachment_types);
 672  
 673      $sub_tabs['attachment_types'] = array(
 674          'title' => $lang->attachment_types,
 675          'link' => "index.php?module=config-attachment_types",
 676          'description' => $lang->attachment_types_desc
 677      );
 678      $sub_tabs['add_attachment_type'] = array(
 679          'title' => $lang->add_new_attachment_type,
 680          'link' => "index.php?module=config-attachment_types&amp;action=add",
 681      );
 682  
 683      $plugins->run_hooks("admin_config_attachment_types_start");
 684  
 685      $page->output_nav_tabs($sub_tabs, 'attachment_types');
 686  
 687      $query = $db->simple_select("attachtypes", "COUNT(atid) AS attachtypes");
 688      $total_rows = $db->fetch_field($query, "attachtypes");
 689  
 690      $pagenum = $mybb->get_input('page', MyBB::INPUT_INT);
 691      if($pagenum)
 692      {
 693          $start = ($pagenum - 1) * 20;
 694          $pages = ceil($total_rows / 20);
 695          if($pagenum > $pages)
 696          {
 697              $start = 0;
 698              $pagenum = 1;
 699          }
 700      }
 701      else
 702      {
 703          $start = 0;
 704          $pagenum = 1;
 705      }
 706  
 707      $table = new Table;
 708      $table->construct_header($lang->extension, array("colspan" => 2));
 709      $table->construct_header($lang->mime_type);
 710      $table->construct_header($lang->alt_enabled, array('class' => 'align_center'));
 711      $table->construct_header($lang->maximum_size, array("class" => "align_center"));
 712      $table->construct_header($lang->controls, array("class" => "align_center"));
 713  
 714      $query = $db->simple_select("attachtypes", "*", "", array('limit_start' => $start, 'limit' => 20, 'order_by' => 'extension'));
 715      while($attachment_type = $db->fetch_array($query))
 716      {
 717          // Just show default icons in ACP
 718          $attachment_type['icon'] = htmlspecialchars_uni(str_replace("{theme}", "images", $attachment_type['icon']));
 719          if(my_validate_url($attachment_type['icon'], true))
 720          {
 721              $image = $attachment_type['icon'];
 722          }
 723          else
 724          {
 725              $image = "../".$attachment_type['icon'];
 726          }
 727  
 728          if(!$attachment_type['icon'] || $attachment_type['icon'] == "images/attachtypes/")
 729          {
 730              $attachment_type['icon'] = "&nbsp;";
 731          }
 732          else
 733          {
 734              $attachment_type['name'] = htmlspecialchars_uni($attachment_type['name']);
 735              $attachment_type['icon'] = "<img src=\"{$image}\" title=\"{$attachment_type['name']}\" alt=\"\" />";
 736          }
 737  
 738          if($attachment_type['enabled'])
 739          {
 740              $phrase = $lang->disable;
 741              $icon = "on.png\" alt=\"({$lang->alt_enabled})\" title=\"{$lang->alt_enabled}";
 742          }
 743          else
 744          {
 745              $phrase = $lang->enable;
 746              $icon = "off.png\" alt=\"({$lang->alt_disabled})\" title=\"{$lang->alt_disabled}";
 747          }
 748  
 749          $attachment_type['extension'] = htmlspecialchars_uni($attachment_type['extension']);
 750  
 751          $table->construct_cell($attachment_type['icon'], array("width" => 1));
 752          $table->construct_cell("<strong>.{$attachment_type['extension']}</strong>");
 753          $table->construct_cell(htmlspecialchars_uni($attachment_type['mimetype']));
 754          $table->construct_cell("<img src=\"styles/{$page->style}/images/icons/bullet_{$icon}\" style=\"vertical-align: middle;\" />", array("class" => "align_center"));
 755          $table->construct_cell(get_friendly_size(($attachment_type['maxsize']*1024)), array("class" => "align_center"));
 756  
 757          $popup = new PopupMenu("attachment_type_{$attachment_type['atid']}", $lang->options);
 758          $popup->add_item($lang->edit, "index.php?module=config-attachment_types&amp;action=edit&amp;atid={$attachment_type['atid']}");
 759          $popup->add_item($phrase, "index.php?module=config-attachment_types&amp;action=toggle_status&amp;atid={$attachment_type['atid']}&amp;my_post_key={$mybb->post_code}");
 760          $popup->add_item($lang->delete, "index.php?module=config-attachment_types&amp;action=delete&amp;atid={$attachment_type['atid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_attachment_type_deletion}')");
 761          $table->construct_cell($popup->fetch(), array('class' => 'align_center'));
 762  
 763          $table->construct_row();
 764      }
 765  
 766      if($table->num_rows() == 0)
 767      {
 768          $table->construct_cell($lang->no_attachment_types, array('colspan' => 6));
 769          $table->construct_row();
 770      }
 771  
 772      $table->output($lang->attachment_types);
 773  
 774      echo "<br />".draw_admin_pagination($pagenum, "20", $total_rows, "index.php?module=config-attachment_types&amp;page={page}");
 775  
 776      $page->output_footer();
 777  }


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