[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/admin/modules/config/ -> profile_fields.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->custom_profile_fields, "index.php?module=config-profile_fields");
  18  
  19  $plugins->run_hooks("admin_config_profile_fields_begin");
  20  
  21  if($mybb->input['action'] == "add")
  22  {
  23      $plugins->run_hooks("admin_config_profile_fields_add");
  24  
  25      if($mybb->request_method == "post")
  26      {
  27          if(!trim($mybb->input['name']))
  28          {
  29              $errors[] = $lang->error_missing_name;
  30          }
  31  
  32          if(!trim($mybb->input['description']))
  33          {
  34              $errors[] = $lang->error_missing_description;
  35          }
  36  
  37          if(!trim($mybb->input['fieldtype']))
  38          {
  39              $errors[] = $lang->error_missing_fieldtype;
  40          }
  41  
  42          if(!$errors)
  43          {
  44              $type = $mybb->input['fieldtype'];
  45              $options = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['options']));
  46              if($type != "text" && $type != "textarea")
  47              {
  48                  $thing = "$type\n$options";
  49              }
  50              else
  51              {
  52                  $thing = $type;
  53              }
  54  
  55              foreach(array('viewableby', 'editableby') as $key)
  56              {
  57                  if($mybb->input[$key] == 'all')
  58                  {
  59                      $mybb->input[$key] = -1;
  60                  }
  61                  elseif($mybb->input[$key] == 'custom')
  62                  {
  63                      if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
  64                      {
  65                          foreach($mybb->input['select'][$key] as &$val)
  66                          {
  67                              $val = (int)$val;
  68                          }
  69                          unset($val);
  70  
  71                          $mybb->input[$key] = implode(',', (array)$mybb->input['select'][$key]);
  72                      }
  73                      else
  74                      {
  75                          $mybb->input[$key] = '';
  76                      }
  77                  }
  78                  else
  79                  {
  80                      $mybb->input[$key] = '';
  81                  }
  82              }
  83  
  84              $new_profile_field = array(
  85                  "name" => $db->escape_string($mybb->input['name']),
  86                  "description" => $db->escape_string($mybb->input['description']),
  87                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
  88                  "type" => $db->escape_string($thing),
  89                  "regex" => $db->escape_string($mybb->input['regex']),
  90                  "length" => $mybb->get_input('length', MyBB::INPUT_INT),
  91                  "maxlength" => $mybb->get_input('maxlength', MyBB::INPUT_INT),
  92                  "required" => $mybb->get_input('required', MyBB::INPUT_INT),
  93                  "registration" => $mybb->get_input('registration', MyBB::INPUT_INT),
  94                  "profile" => $mybb->get_input('profile', MyBB::INPUT_INT),
  95                  "viewableby" => $db->escape_string($mybb->input['viewableby']),
  96                  "editableby" => $db->escape_string($mybb->input['editableby']),
  97                  "postbit" => $mybb->get_input('postbit', MyBB::INPUT_INT),
  98                  "postnum" => $mybb->get_input('postnum', MyBB::INPUT_INT),
  99                  "allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
 100                  "allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
 101                  "allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT),
 102                  "allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
 103                  "allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT)
 104              );
 105  
 106              $fid = $db->insert_query("profilefields", $new_profile_field);
 107  
 108              $db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields ADD fid{$fid} TEXT");
 109  
 110              $plugins->run_hooks("admin_config_profile_fields_add_commit");
 111  
 112              $cache->update_profilefields();
 113  
 114              // Log admin action
 115              log_admin_action($fid, $mybb->input['name']);
 116  
 117              flash_message($lang->success_profile_field_added, 'success');
 118              admin_redirect("index.php?module=config-profile_fields");
 119          }
 120      }
 121  
 122      $page->add_breadcrumb_item($lang->add_new_profile_field);
 123      $page->output_header($lang->custom_profile_fields." - ".$lang->add_new_profile_field);
 124  
 125      $sub_tabs['custom_profile_fields'] = array(
 126          'title' => $lang->custom_profile_fields,
 127          'link' => "index.php?module=config-profile_fields"
 128      );
 129  
 130      $sub_tabs['add_profile_field'] = array(
 131          'title' => $lang->add_new_profile_field,
 132          'link' => "index.php?module=config-profile_fields&amp;action=add",
 133          'description' => $lang->add_new_profile_field_desc
 134      );
 135  
 136      $page->output_nav_tabs($sub_tabs, 'add_profile_field');
 137      $form = new Form("index.php?module=config-profile_fields&amp;action=add", "post", "add");
 138  
 139      if($errors)
 140      {
 141          switch($mybb->input['viewableby'])
 142          {
 143              case 'all':
 144                  $mybb->input['viewableby'] = -1;
 145                  break;
 146              case 'custom':
 147                  $mybb->input['viewableby'] = implode(',', (array)$mybb->input['select']['viewableby']);
 148                  break;
 149              default:
 150                  $mybb->input['viewableby'] = '';
 151                  break;
 152          }
 153  
 154          switch($mybb->input['editableby'])
 155          {
 156              case 'all':
 157                  $mybb->input['editableby'] = -1;
 158                  break;
 159              case 'custom':
 160                  $mybb->input['editableby'] = implode(',', (array)$mybb->input['select']['editableby']);
 161                  break;
 162              default:
 163                  $mybb->input['editableby'] = '';
 164                  break;
 165          }
 166  
 167          $page->output_inline_error($errors);
 168      }
 169      else
 170      {
 171          $mybb->input['fieldtype'] = 'textbox';
 172          $mybb->input['required'] = 0;
 173          $mybb->input['registration'] = 0;
 174          $mybb->input['editable'] = 1;
 175          $mybb->input['hidden'] = 0;
 176          $mybb->input['postbit'] = 0;
 177      }
 178  
 179      if(empty($mybb->input['viewableby']))
 180      {
 181          $mybb->input['viewableby'] = '';
 182      }
 183  
 184      if(empty($mybb->input['editableby']))
 185      {
 186          $mybb->input['editableby'] = '';
 187      }
 188  
 189      $form_container = new FormContainer($lang->add_new_profile_field);
 190      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->get_input('name'), array('id' => 'name')), 'name');
 191      $form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->get_input('description'), array('id' => 'description')), 'description');
 192      $select_list = array(
 193          "text" => $lang->text,
 194          "textarea" => $lang->textarea,
 195          "select" => $lang->select,
 196          "multiselect" => $lang->multiselect,
 197          "radio" => $lang->radio,
 198          "checkbox" => $lang->checkbox
 199      );
 200      $form_container->output_row($lang->field_type." <em>*</em>", $lang->field_type_desc, $form->generate_select_box('fieldtype', $select_list, $mybb->get_input('fieldtype'), array('id' => 'fieldtype')), 'fieldtype');
 201      $form_container->output_row($lang->field_regex, $lang->field_regex_desc, $form->generate_text_box('regex', $mybb->get_input('regex'), array('id' => 'regex')), 'regex', array(), array('id' => 'row_regex'));
 202      $form_container->output_row($lang->maximum_length, $lang->maximum_length_desc, $form->generate_numeric_field('maxlength', $mybb->get_input('maxlength'), array('id' => 'maxlength', 'min' => 0)), 'maxlength', array(), array('id' => 'row_maxlength'));
 203      $form_container->output_row($lang->field_length, $lang->field_length_desc, $form->generate_numeric_field('length', $mybb->get_input('length'), array('id' => 'length', 'min' => 0)), 'length', array(), array('id' => 'row_fieldlength'));
 204      $form_container->output_row($lang->selectable_options, $lang->selectable_options_desc, $form->generate_text_area('options', $mybb->get_input('options'), array('id' => 'options')), 'options', array(), array('id' => 'row_options'));
 205      $form_container->output_row($lang->min_posts_enabled, $lang->min_posts_enabled_desc, $form->generate_numeric_field('postnum', $mybb->get_input('postnum'), array('id' => 'postnum', 'min' => 0)), 'postnum');
 206      $form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->get_input('disporder'), array('id' => 'disporder', 'min' => 0)), 'disporder');
 207      $form_container->output_row($lang->required." <em>*</em>", $lang->required_desc, $form->generate_yes_no_radio('required', $mybb->get_input('required')));
 208      $form_container->output_row($lang->show_on_registration." <em>*</em>", $lang->show_on_registration_desc, $form->generate_yes_no_radio('registration', $mybb->get_input('registration')));
 209      $form_container->output_row($lang->display_on_profile." <em>*</em>", $lang->display_on_profile_desc, $form->generate_yes_no_radio('profile', $mybb->get_input('profile')));
 210      $form_container->output_row($lang->display_on_postbit." <em>*</em>", $lang->display_on_postbit_desc, $form->generate_yes_no_radio('postbit', $mybb->get_input('postbit')));
 211  
 212      $selected_values = '';
 213      if($mybb->input['viewableby'] != '' && $mybb->input['viewableby'] != -1)
 214      {
 215          $selected_values = explode(',', $mybb->get_input('viewableby'));
 216  
 217          foreach($selected_values as &$value)
 218          {
 219              $value = (int)$value;
 220          }
 221          unset($value);
 222      }
 223  
 224      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 225      if($mybb->input['viewableby'] == -1)
 226      {
 227          $group_checked['all'] = 'checked="checked"';
 228      }
 229      elseif($mybb->input['viewableby'] != '')
 230      {
 231          $group_checked['custom'] = 'checked="checked"';
 232      }
 233      else
 234      {
 235          $group_checked['none'] = 'checked="checked"';
 236      }
 237  
 238      print_selection_javascript();
 239  
 240      $select_code = "
 241      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 242          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"all\" {$group_checked['all']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 243          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"custom\" {$group_checked['custom']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 244          <dd style=\"margin-top: 4px;\" id=\"viewableby_forums_groups_custom\" class=\"viewableby_forums_groups\">
 245              <table cellpadding=\"4\">
 246                  <tr>
 247                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 248                      <td>".$form->generate_group_select('select[viewableby][]', $selected_values, array('id' => 'viewableby', 'multiple' => true, 'size' => 5))."</td>
 249                  </tr>
 250              </table>
 251          </dd>
 252          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"none\" {$group_checked['none']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 253      </dl>
 254      <script type=\"text/javascript\">
 255          checkAction('viewableby');
 256      </script>";
 257      $form_container->output_row($lang->viewableby, $lang->viewableby_desc, $select_code, '', array(), array('id' => 'row_viewableby'));
 258  
 259      $selected_values = '';
 260      if($mybb->input['editableby'] != '' && $mybb->input['editableby'] != -1)
 261      {
 262          $selected_values = explode(',', $mybb->get_input('editableby'));
 263  
 264          foreach($selected_values as &$value)
 265          {
 266              $value = (int)$value;
 267          }
 268          unset($value);
 269      }
 270  
 271      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 272      if($mybb->input['editableby'] == -1)
 273      {
 274          $group_checked['all'] = 'checked="checked"';
 275      }
 276      elseif($mybb->input['editableby'] != '')
 277      {
 278          $group_checked['custom'] = 'checked="checked"';
 279      }
 280      else
 281      {
 282          $group_checked['none'] = 'checked="checked"';
 283      }
 284  
 285      print_selection_javascript();
 286  
 287      $select_code = "
 288      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 289          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"all\" {$group_checked['all']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 290          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"custom\" {$group_checked['custom']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 291          <dd style=\"margin-top: 4px;\" id=\"editableby_forums_groups_custom\" class=\"editableby_forums_groups\">
 292              <table cellpadding=\"4\">
 293                  <tr>
 294                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 295                      <td>".$form->generate_group_select('select[editableby][]', $selected_values, array('id' => 'editableby', 'multiple' => true, 'size' => 5))."</td>
 296                  </tr>
 297              </table>
 298          </dd>
 299          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"none\" {$group_checked['none']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 300      </dl>
 301      <script type=\"text/javascript\">
 302          checkAction('editableby');
 303      </script>";
 304      $form_container->output_row($lang->editableby, $lang->editableby_desc, $select_code, '', array(), array('id' => 'row_editableby'));
 305  
 306      $parser_options = array(
 307          $form->generate_check_box('allowhtml', 1, $lang->parse_allowhtml, array('checked' => $mybb->get_input('allowhtml'), 'id' => 'allowhtml')),
 308          $form->generate_check_box('allowmycode', 1, $lang->parse_allowmycode, array('checked' => $mybb->get_input('allowmycode'), 'id' => 'allowmycode')),
 309          $form->generate_check_box('allowsmilies', 1, $lang->parse_allowsmilies, array('checked' => $mybb->get_input('allowsmilies'), 'id' => 'allowsmilies')),
 310          $form->generate_check_box('allowimgcode', 1, $lang->parse_allowimgcode, array('checked' => $mybb->get_input('allowimgcode'), 'id' => 'allowimgcode')),
 311          $form->generate_check_box('allowvideocode', 1, $lang->parse_allowvideocode, array('checked' => $mybb->get_input('allowvideocode'), 'id' => 'allowvideocode'))
 312      );
 313      $form_container->output_row($lang->parser_options, '', implode('<br />', $parser_options), '', array(), array('id' => 'row_parser_options'));
 314      $form_container->end();
 315  
 316      $buttons[] = $form->generate_submit_button($lang->save_profile_field);
 317  
 318      $form->output_submit_wrapper($buttons);
 319      $form->end();
 320  
 321      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 322      <script type="text/javascript">
 323          $(function() {
 324                  new Peeker($("#fieldtype"), $("#row_maxlength, #row_regex, #row_parser_options"), /text|textarea/, false);
 325                  new Peeker($("#fieldtype"), $("#row_fieldlength"), /select|multiselect/, false);
 326                  new Peeker($("#fieldtype"), $("#row_options"), /select|radio|checkbox/, false);
 327                  // Add a star to the extra row since the "extra" is required if the box is shown
 328                  add_star("row_maxlength");
 329                  add_star("row_fieldlength");
 330                  add_star("row_options");
 331          });
 332      </script>';
 333  
 334      $page->output_footer();
 335  }
 336  
 337  if($mybb->input['action'] == "edit")
 338  {
 339      $query = $db->simple_select("profilefields", "*", "fid = '".$mybb->get_input('fid', MyBB::INPUT_INT)."'");
 340      $profile_field = $db->fetch_array($query);
 341  
 342      if(!$profile_field['fid'])
 343      {
 344          flash_message($lang->error_invalid_fid, 'error');
 345          admin_redirect("index.php?module=config-profile_fields");
 346      }
 347  
 348      $plugins->run_hooks("admin_config_profile_fields_edit");
 349  
 350      if($mybb->request_method == "post")
 351      {
 352          if(!trim($mybb->input['name']))
 353          {
 354              $errors[] = $lang->error_missing_name;
 355          }
 356  
 357          if(!trim($mybb->input['description']))
 358          {
 359              $errors[] = $lang->error_missing_description;
 360          }
 361  
 362          if(!trim($mybb->input['fieldtype']))
 363          {
 364              $errors[] = $lang->error_missing_fieldtype;
 365          }
 366  
 367          $type = $mybb->input['fieldtype'];
 368          $options = preg_replace("#(\r\n|\r|\n)#s", "\n", trim($mybb->input['options']));
 369          if($type != "text" && $type != "textarea")
 370          {
 371              $type = "$type\n$options";
 372          }
 373  
 374          if(!$errors)
 375          {
 376              foreach(array('viewableby', 'editableby') as $key)
 377              {
 378                  if($mybb->input[$key] == 'all')
 379                  {
 380                      $mybb->input[$key] = -1;
 381                  }
 382                  elseif($mybb->input[$key] == 'custom')
 383                  {
 384                      if(isset($mybb->input['select'][$key]) && is_array($mybb->input['select'][$key]))
 385                      {
 386                          foreach($mybb->input['select'][$key] as &$val)
 387                          {
 388                              $val = (int)$val;
 389                          }
 390                          unset($val);
 391  
 392                          $mybb->input[$key] = implode(',', $mybb->input['select'][$key]);
 393                      }
 394                      else
 395                      {
 396                          $mybb->input[$key] = '';
 397                      }
 398                  }
 399                  else
 400                  {
 401                      $mybb->input[$key] = '';
 402                  }
 403              }
 404  
 405              $updated_profile_field = array(
 406                  "name" => $db->escape_string($mybb->input['name']),
 407                  "description" => $db->escape_string($mybb->input['description']),
 408                  "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT),
 409                  "type" => $db->escape_string($type),
 410                  "regex" => $db->escape_string($mybb->input['regex']),
 411                  "length" => $mybb->get_input('length', MyBB::INPUT_INT),
 412                  "maxlength" => $mybb->get_input('maxlength', MyBB::INPUT_INT),
 413                  "required" => $mybb->get_input('required', MyBB::INPUT_INT),
 414                  "registration" => $mybb->get_input('registration', MyBB::INPUT_INT),
 415                  "profile" => $mybb->get_input('profile', MyBB::INPUT_INT),
 416                  "viewableby" => $db->escape_string($mybb->input['viewableby']),
 417                  "editableby" => $db->escape_string($mybb->input['editableby']),
 418                  "postbit" => $mybb->get_input('postbit', MyBB::INPUT_INT),
 419                  "postnum" => $mybb->get_input('postnum', MyBB::INPUT_INT),
 420                  "allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT),
 421                  "allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT),
 422                  "allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT),
 423                  "allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT),
 424                  "allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT)
 425              );
 426  
 427              $plugins->run_hooks("admin_config_profile_fields_edit_commit");
 428  
 429              $db->update_query("profilefields", $updated_profile_field, "fid='{$profile_field['fid']}'");
 430  
 431              $cache->update_profilefields();
 432  
 433              // Log admin action
 434              log_admin_action($profile_field['fid'], $mybb->input['name']);
 435  
 436              flash_message($lang->success_profile_field_saved, 'success');
 437              admin_redirect("index.php?module=config-profile_fields");
 438          }
 439      }
 440  
 441      $page->add_breadcrumb_item($lang->edit_profile_field);
 442      $page->output_header($lang->custom_profile_fields." - ".$lang->edit_profile_field);
 443  
 444      $sub_tabs['edit_profile_field'] = array(
 445          'title' => $lang->edit_profile_field,
 446          'link' => "index.php?module=config-profile_fields&amp;action=edit&amp;fid={$profile_field['fid']}",
 447          'description' => $lang->edit_profile_field_desc
 448      );
 449  
 450      $page->output_nav_tabs($sub_tabs, 'edit_profile_field');
 451      $form = new Form("index.php?module=config-profile_fields&amp;action=edit", "post", "edit");
 452  
 453  
 454      echo $form->generate_hidden_field("fid", $profile_field['fid']);
 455  
 456      if($errors)
 457      {
 458          switch($mybb->input['viewableby'])
 459          {
 460              case 'all':
 461                  $mybb->input['viewableby'] = -1;
 462                  break;
 463              case 'custom':
 464                  $mybb->input['viewableby'] = implode(',', (array)$mybb->input['select']['viewableby']);
 465                  break;
 466              default:
 467                  $mybb->input['viewableby'] = '';
 468                  break;
 469          }
 470  
 471          switch($mybb->input['editableby'])
 472          {
 473              case 'all':
 474                  $mybb->input['editableby'] = -1;
 475                  break;
 476              case 'custom':
 477                  $mybb->input['editableby'] = implode(',', (array)$mybb->input['select']['editableby']);
 478                  break;
 479              default:
 480                  $mybb->input['editableby'] = '';
 481                  break;
 482          }
 483  
 484          $page->output_inline_error($errors);
 485      }
 486      else
 487      {
 488          $type = explode("\n", $profile_field['type'], "2");
 489  
 490          $mybb->input = $profile_field;
 491          $mybb->input['fieldtype'] = $type[0];
 492          $mybb->input['options'] = isset($type[1]) ? $type[1] : null;
 493      }
 494  
 495      if(empty($mybb->input['viewableby']))
 496      {
 497          $mybb->input['viewableby'] = '';
 498      }
 499  
 500      if(empty($mybb->input['editableby']))
 501      {
 502          $mybb->input['editableby'] = '';
 503      }
 504  
 505      $form_container = new FormContainer($lang->edit_profile_field);
 506      $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name');
 507      $form_container->output_row($lang->short_description." <em>*</em>", "", $form->generate_text_box('description', $mybb->input['description'], array('id' => 'description')), 'description');
 508      $select_list = array(
 509          "text" => $lang->text,
 510          "textarea" => $lang->textarea,
 511          "select" => $lang->select,
 512          "multiselect" => $lang->multiselect,
 513          "radio" => $lang->radio,
 514          "checkbox" => $lang->checkbox
 515      );
 516      $form_container->output_row($lang->field_type." <em>*</em>", $lang->field_type_desc, $form->generate_select_box('fieldtype', $select_list, $mybb->input['fieldtype'], array('id' => 'fieldtype')), 'fieldtype');
 517      $form_container->output_row($lang->field_regex, $lang->field_regex_desc, $form->generate_text_box('regex', $mybb->input['regex'], array('id' => 'regex')), 'regex', array(), array('id' => 'row_regex'));
 518      $form_container->output_row($lang->maximum_length, $lang->maximum_length_desc, $form->generate_numeric_field('maxlength', $mybb->input['maxlength'], array('id' => 'maxlength', 'min' => 0)), 'maxlength', array(), array('id' => 'row_maxlength'));
 519      $form_container->output_row($lang->field_length, $lang->field_length_desc, $form->generate_numeric_field('length', $mybb->input['length'], array('id' => 'length', 'min' => 0)), 'length', array(), array('id' => 'row_fieldlength'));
 520      $form_container->output_row($lang->selectable_options, $lang->selectable_options_desc, $form->generate_text_area('options', $mybb->input['options'], array('id' => 'options')), 'options', array(), array('id' => 'row_options'));
 521      $form_container->output_row($lang->min_posts_enabled, $lang->min_posts_enabled_desc, $form->generate_numeric_field('postnum', $mybb->input['postnum'], array('id' => 'postnum', 'min' => 0)), 'postnum');
 522      $form_container->output_row($lang->display_order." <em>*</em>", $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->input['disporder'], array('id' => 'disporder', 'min' => 0)), 'disporder');
 523      $form_container->output_row($lang->required." <em>*</em>", $lang->required_desc, $form->generate_yes_no_radio('required', $mybb->input['required']));
 524      $form_container->output_row($lang->show_on_registration." <em>*</em>", $lang->show_on_registration_desc, $form->generate_yes_no_radio('registration', $mybb->input['registration']));
 525      $form_container->output_row($lang->display_on_profile." <em>*</em>", $lang->display_on_profile_desc, $form->generate_yes_no_radio('profile', $mybb->input['profile']));
 526      $form_container->output_row($lang->display_on_postbit." <em>*</em>", $lang->display_on_postbit_desc, $form->generate_yes_no_radio('postbit', $mybb->input['postbit']));
 527  
 528      $selected_values = '';
 529      if($mybb->input['viewableby'] != '' && $mybb->input['viewableby'] != -1)
 530      {
 531          $selected_values = explode(',', $mybb->get_input('viewableby'));
 532  
 533          foreach($selected_values as &$value)
 534          {
 535              $value = (int)$value;
 536          }
 537          unset($value);
 538      }
 539  
 540      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 541      if($mybb->input['viewableby'] == -1)
 542      {
 543          $group_checked['all'] = 'checked="checked"';
 544      }
 545      elseif($mybb->input['viewableby'] != '')
 546      {
 547          $group_checked['custom'] = 'checked="checked"';
 548      }
 549      else
 550      {
 551          $group_checked['none'] = 'checked="checked"';
 552      }
 553  
 554      print_selection_javascript();
 555  
 556      $select_code = "
 557      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 558          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"all\" {$group_checked['all']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 559          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"custom\" {$group_checked['custom']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 560          <dd style=\"margin-top: 4px;\" id=\"viewableby_forums_groups_custom\" class=\"viewableby_forums_groups\">
 561              <table cellpadding=\"4\">
 562                  <tr>
 563                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 564                      <td>".$form->generate_group_select('select[viewableby][]', $selected_values, array('id' => 'viewableby', 'multiple' => true, 'size' => 5))."</td>
 565                  </tr>
 566              </table>
 567          </dd>
 568          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"viewableby\" value=\"none\" {$group_checked['none']} class=\"viewableby_forums_groups_check\" onclick=\"checkAction('viewableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 569      </dl>
 570      <script type=\"text/javascript\">
 571          checkAction('viewableby');
 572      </script>";
 573      $form_container->output_row($lang->viewableby, $lang->viewableby_desc, $select_code, '', array(), array('id' => 'row_viewableby'));
 574  
 575      $selected_values = '';
 576      if($mybb->input['editableby'] != '' && $mybb->input['editableby'] != -1)
 577      {
 578          $selected_values = explode(',', $mybb->get_input('editableby'));
 579  
 580          foreach($selected_values as &$value)
 581          {
 582              $value = (int)$value;
 583          }
 584          unset($value);
 585      }
 586  
 587      $group_checked = array('all' => '', 'custom' => '', 'none' => '');
 588      if($mybb->input['editableby'] == -1)
 589      {
 590          $group_checked['all'] = 'checked="checked"';
 591      }
 592      elseif($mybb->input['editableby'] != '')
 593      {
 594          $group_checked['custom'] = 'checked="checked"';
 595      }
 596      else
 597      {
 598          $group_checked['none'] = 'checked="checked"';
 599      }
 600  
 601      print_selection_javascript();
 602  
 603      $select_code = "
 604      <dl style=\"margin-top: 0; margin-bottom: 0; width: 100%\">
 605          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"all\" {$group_checked['all']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->all_groups}</strong></label></dt>
 606          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"custom\" {$group_checked['custom']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->select_groups}</strong></label></dt>
 607          <dd style=\"margin-top: 4px;\" id=\"editableby_forums_groups_custom\" class=\"editableby_forums_groups\">
 608              <table cellpadding=\"4\">
 609                  <tr>
 610                      <td valign=\"top\"><small>{$lang->groups_colon}</small></td>
 611                      <td>".$form->generate_group_select('select[editableby][]', $selected_values, array('id' => 'editableby', 'multiple' => true, 'size' => 5))."</td>
 612                  </tr>
 613              </table>
 614          </dd>
 615          <dt><label style=\"display: block;\"><input type=\"radio\" name=\"editableby\" value=\"none\" {$group_checked['none']} class=\"editableby_forums_groups_check\" onclick=\"checkAction('editableby');\" style=\"vertical-align: middle;\" /> <strong>{$lang->none}</strong></label></dt>
 616      </dl>
 617      <script type=\"text/javascript\">
 618          checkAction('editableby');
 619      </script>";
 620      $form_container->output_row($lang->editableby, $lang->editableby_desc, $select_code, '', array(), array('id' => 'row_editableby'));
 621  
 622      $parser_options = array(
 623          $form->generate_check_box('allowhtml', 1, $lang->parse_allowhtml, array('checked' => $mybb->input['allowhtml'], 'id' => 'allowhtml')),
 624          $form->generate_check_box('allowmycode', 1, $lang->parse_allowmycode, array('checked' => $mybb->input['allowmycode'], 'id' => 'allowmycode')),
 625          $form->generate_check_box('allowsmilies', 1, $lang->parse_allowsmilies, array('checked' => $mybb->input['allowsmilies'], 'id' => 'allowsmilies')),
 626          $form->generate_check_box('allowimgcode', 1, $lang->parse_allowimgcode, array('checked' => $mybb->input['allowimgcode'], 'id' => 'allowimgcode')),
 627          $form->generate_check_box('allowvideocode', 1, $lang->parse_allowvideocode, array('checked' => $mybb->input['allowvideocode'], 'id' => 'allowvideocode'))
 628      );
 629      $form_container->output_row($lang->parser_options, '', implode('<br />', $parser_options), '', array(), array('id' => 'row_parser_options'));
 630      $form_container->end();
 631  
 632      $buttons[] = $form->generate_submit_button($lang->save_profile_field);
 633  
 634      $form->output_submit_wrapper($buttons);
 635      $form->end();
 636  
 637      echo '<script type="text/javascript" src="./jscripts/peeker.js?ver=1821"></script>
 638      <script type="text/javascript">
 639          $(function() {
 640                  new Peeker($("#fieldtype"), $("#row_maxlength, #row_regex, #row_parser_options"), /text|textarea/);
 641                  new Peeker($("#fieldtype"), $("#row_fieldlength"), /select|multiselect/);
 642                  new Peeker($("#fieldtype"), $("#row_options"), /select|radio|checkbox/);
 643                  // Add a star to the extra row since the "extra" is required if the box is shown
 644                  add_star("row_maxlength");
 645                  add_star("row_fieldlength");
 646                  add_star("row_options");
 647          });
 648      </script>';
 649  
 650      $page->output_footer();
 651  }
 652  
 653  if($mybb->input['action'] == "delete")
 654  {
 655      $query = $db->simple_select("profilefields", "*", "fid='".$mybb->get_input('fid', MyBB::INPUT_INT)."'");
 656      $profile_field = $db->fetch_array($query);
 657  
 658      // Does the profile field not exist?
 659      if(!$profile_field['fid'])
 660      {
 661          flash_message($lang->error_invalid_fid, 'error');
 662          admin_redirect("index.php?module=config-profile_fields");
 663      }
 664  
 665      // User clicked no
 666      if($mybb->get_input('no'))
 667      {
 668          admin_redirect("index.php?module=config-profile_fields");
 669      }
 670  
 671      $plugins->run_hooks("admin_config_profile_fields_delete");
 672  
 673      if($mybb->request_method == "post")
 674      {
 675          // Delete the profile field
 676          $db->delete_query("profilefields", "fid='{$profile_field['fid']}'");
 677          $db->write_query("ALTER TABLE ".TABLE_PREFIX."userfields DROP fid{$profile_field['fid']}");
 678  
 679          $plugins->run_hooks("admin_config_profile_fields_delete_commit");
 680  
 681          $cache->update_profilefields();
 682  
 683          // Log admin action
 684          log_admin_action($profile_field['fid'], $profile_field['name']);
 685  
 686          flash_message($lang->success_profile_field_deleted, 'success');
 687          admin_redirect("index.php?module=config-profile_fields");
 688      }
 689      else
 690      {
 691          $page->output_confirm_action("index.php?module=config-profile_fields&amp;action=delete&amp;fid={$profile_field['fid']}", $lang->confirm_profile_field_deletion);
 692      }
 693  }
 694  
 695  if(!$mybb->input['action'])
 696  {
 697      $plugins->run_hooks("admin_config_profile_fields_start");
 698  
 699      $page->output_header($lang->custom_profile_fields);
 700  
 701      $sub_tabs['custom_profile_fields'] = array(
 702          'title' => $lang->custom_profile_fields,
 703          'link' => "index.php?module=config-profile_fields",
 704          'description' => $lang->custom_profile_fields_desc
 705      );
 706  
 707      $sub_tabs['add_profile_field'] = array(
 708          'title' => $lang->add_new_profile_field,
 709          'link' => "index.php?module=config-profile_fields&amp;action=add",
 710      );
 711  
 712  
 713      $page->output_nav_tabs($sub_tabs, 'custom_profile_fields');
 714  
 715      $table = new Table;
 716      $table->construct_header($lang->name);
 717      $table->construct_header($lang->required, array("class" => "align_center"));
 718      $table->construct_header($lang->registration, array("class" => "align_center"));
 719      $table->construct_header($lang->editable, array("class" => "align_center"));
 720      $table->construct_header($lang->profile, array("class" => "align_center"));
 721      $table->construct_header($lang->postbit, array("class" => "align_center"));
 722      $table->construct_header($lang->controls, array("class" => "align_center"));
 723  
 724      $query = $db->simple_select("profilefields", "*", "", array('order_by' => 'disporder'));
 725      while($field = $db->fetch_array($query))
 726      {
 727          if($field['required'])
 728          {
 729              $required = $lang->yes;
 730          }
 731          else
 732          {
 733              $required = $lang->no;
 734          }
 735  
 736          if($field['registration'])
 737          {
 738              $registration = $lang->yes;
 739          }
 740          else
 741          {
 742              $registration = $lang->no;
 743          }
 744  
 745          if($field['editableby'] == '')
 746          {
 747              $editable = $lang->no;
 748          }
 749          else
 750          {
 751              $editable = $lang->yes;
 752          }
 753  
 754          if($field['profile'])
 755          {
 756              $profile = $lang->yes;
 757          }
 758          else
 759          {
 760              $profile = $lang->no;
 761          }
 762  
 763          if($field['postbit'])
 764          {
 765              $postbit = $lang->yes;
 766          }
 767          else
 768          {
 769              $postbit = $lang->no;
 770          }
 771  
 772          $table->construct_cell("<strong><a href=\"index.php?module=config-profile_fields&amp;action=edit&amp;fid={$field['fid']}\">".htmlspecialchars_uni($field['name'])."</a></strong><br /><small>".htmlspecialchars_uni($field['description'])."</small>", array('width' => '35%'));
 773          $table->construct_cell($required, array("class" => "align_center", 'width' => '10%'));
 774          $table->construct_cell($registration, array("class" => "align_center", 'width' => '10%'));
 775          $table->construct_cell($editable, array("class" => "align_center", 'width' => '10%'));
 776          $table->construct_cell($profile, array("class" => "align_center", 'width' => '10%'));
 777          $table->construct_cell($postbit, array("class" => "align_center", 'width' => '10%')); 
 778  
 779          $popup = new PopupMenu("field_{$field['fid']}", $lang->options);
 780          $popup->add_item($lang->edit_field, "index.php?module=config-profile_fields&amp;action=edit&amp;fid={$field['fid']}");
 781          $popup->add_item($lang->delete_field, "index.php?module=config-profile_fields&amp;action=delete&amp;fid={$field['fid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_profile_field_deletion}')");
 782          $table->construct_cell($popup->fetch(), array("class" => "align_center", 'width' => '20%'));
 783          $table->construct_row();
 784      }
 785  
 786      if($table->num_rows() == 0)
 787      {
 788          $table->construct_cell($lang->no_profile_fields, array('colspan' => 7));
 789          $table->construct_row();
 790      }
 791  
 792      $table->output($lang->custom_profile_fields);
 793  
 794      $page->output_footer();
 795  }


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