[ Index ]

PHP Cross Reference of MyBB 1.8.21

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


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