[ Index ]

PHP Cross Reference of MyBB 1.8.30

title

Body

[close]

/admin/modules/user/ -> titles.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->user_titles, "index.php?module=user-titles");
  18  
  19  if($mybb->input['action'] == "add" || !$mybb->input['action'])
  20  {
  21      $sub_tabs['manage_titles'] = array(
  22          'title' => $lang->user_titles,
  23          'link' => "index.php?module=user-titles",
  24          'description' => $lang->user_titles_desc
  25      );
  26      $sub_tabs['add_title'] = array(
  27          'title' => $lang->add_new_user_title,
  28          'link' => "index.php?module=user-titles&amp;action=add",
  29          'description' => $lang->add_new_user_title_desc
  30      );
  31  }
  32  
  33  $plugins->run_hooks("admin_user_titles_begin");
  34  
  35  if($mybb->input['action'] == "add")
  36  {
  37      $plugins->run_hooks("admin_user_titles_add");
  38  
  39      if($mybb->request_method == "post")
  40      {
  41          if(!trim($mybb->input['title']))
  42          {
  43              $errors[] = $lang->error_missing_title;
  44          }
  45  
  46          if(!isset($mybb->input['posts']))
  47          {
  48              $errors[] = $lang->error_missing_posts;
  49          }
  50  
  51          $query = $db->simple_select("usertitles", "utid", "posts= '".$mybb->get_input('posts', MyBB::INPUT_INT)."'");
  52          if($db->num_rows($query))
  53          {
  54              $errors[] = $lang->error_cannot_have_same_posts;
  55          }
  56  
  57          if(!$errors)
  58          {
  59              $new_title = array(
  60                  "title" => $db->escape_string($mybb->input['title']),
  61                  "posts" => $mybb->get_input('posts', MyBB::INPUT_INT),
  62                  "stars" => $mybb->get_input('stars', MyBB::INPUT_INT),
  63                  "starimage" => $db->escape_string($mybb->input['starimage'])
  64              );
  65  
  66              $utid = $db->insert_query("usertitles", $new_title);
  67  
  68              $plugins->run_hooks("admin_user_titles_add_commit");
  69  
  70              $cache->update_usertitles();
  71  
  72              // Log admin action
  73              log_admin_action($utid, $mybb->input['title'], $mybb->input['posts']);
  74  
  75              flash_message($lang->success_user_title_created, 'success');
  76              admin_redirect("index.php?module=user-titles");
  77          }
  78      }
  79      else
  80      {
  81          $mybb->input = array_merge($mybb->input, array(
  82                  'stars' => '1',
  83                  'starimage' => '{theme}/star.png',
  84              )
  85          );
  86      }
  87  
  88      $page->add_breadcrumb_item($lang->add_new_user_title);
  89      $page->output_header($lang->user_titles." - ".$lang->add_new_user_title);
  90  
  91      $page->output_nav_tabs($sub_tabs, 'add_title');
  92      $form = new Form("index.php?module=user-titles&amp;action=add", "post");
  93  
  94  
  95      if($errors)
  96      {
  97          $page->output_inline_error($errors);
  98      }
  99  
 100      $form_container = new FormContainer($lang->add_new_user_title);
 101      $form_container->output_row($lang->title_to_assign."<em>*</em>", $lang->title_to_assign_desc, $form->generate_text_box('title', $mybb->get_input('title'), array('id' => 'title')), 'title');
 102      $form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_numeric_field('posts', $mybb->get_input('posts'), array('id' => 'posts', 'min' => 0)), 'posts');
 103      $form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_numeric_field('stars', $mybb->get_input('stars'), array('id' => 'stars', 'min' => 0)), 'stars');
 104      $form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->get_input('starimage'), array('id' => 'starimage')), 'starimage');
 105      $form_container->end();
 106  
 107      $buttons[] = $form->generate_submit_button($lang->save_user_title);
 108  
 109      $form->output_submit_wrapper($buttons);
 110      $form->end();
 111  
 112      $page->output_footer();
 113  }
 114  
 115  if($mybb->input['action'] == "edit")
 116  {
 117      $query = $db->simple_select("usertitles", "*", "utid='".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
 118      $usertitle = $db->fetch_array($query);
 119  
 120      if(!$usertitle['utid'])
 121      {
 122          flash_message($lang->error_invalid_user_title, 'error');
 123          admin_redirect("index.php?module=user-titles");
 124      }
 125  
 126      $plugins->run_hooks("admin_user_titles_edit");
 127  
 128      if($mybb->request_method == "post")
 129      {
 130          if(!trim($mybb->input['title']))
 131          {
 132              $errors[] = $lang->error_missing_title;
 133          }
 134  
 135          if(!isset($mybb->input['posts']))
 136          {
 137              $errors[] = $lang->error_missing_posts;
 138          }
 139  
 140          $query = $db->simple_select("usertitles", "utid", "posts= '".$mybb->get_input('posts', MyBB::INPUT_INT)."' AND utid!= '".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
 141          if($db->num_rows($query))
 142          {
 143              $errors[] = $lang->error_cannot_have_same_posts;
 144          }
 145  
 146          if(!$errors)
 147          {
 148              $updated_title = array(
 149                  "title" => $db->escape_string($mybb->input['title']),
 150                  "posts" => $mybb->get_input('posts', MyBB::INPUT_INT),
 151                  "stars" => $mybb->get_input('stars', MyBB::INPUT_INT),
 152                  "starimage" => $db->escape_string($mybb->input['starimage'])
 153              );
 154  
 155              $plugins->run_hooks("admin_user_titles_edit_commit");
 156  
 157              $db->update_query("usertitles", $updated_title, "utid='{$usertitle['utid']}'");
 158  
 159              $cache->update_usertitles();
 160  
 161              // Log admin action
 162              log_admin_action($usertitle['utid'], $mybb->input['title'], $mybb->input['posts']);
 163  
 164              flash_message($lang->success_user_title_updated, 'success');
 165              admin_redirect("index.php?module=user-titles");
 166          }
 167      }
 168  
 169      $page->add_breadcrumb_item($lang->edit_user_title);
 170      $page->output_header($lang->user_titles." - ".$lang->edit_user_title);
 171  
 172      $sub_tabs['edit_title'] = array(
 173          'title' => $lang->edit_user_title,
 174          'link' => "index.php?module=user-titles&amp;action=edit&amp;utid=".$usertitle['utid'],
 175          'description' => $lang->edit_user_title_desc
 176      );
 177  
 178      $page->output_nav_tabs($sub_tabs, 'edit_title');
 179      $form = new Form("index.php?module=user-titles&amp;action=edit&amp;utid={$usertitle['utid']}", "post");
 180  
 181  
 182      if($errors)
 183      {
 184          $page->output_inline_error($errors);
 185      }
 186      else
 187      {
 188          $mybb->input = array_merge($mybb->input, $usertitle);
 189      }
 190  
 191      $form_container = new FormContainer($lang->edit_user_title);
 192      $form_container->output_row($lang->title_to_assign."<em>*</em>", $lang->title_to_assign_desc, $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title');
 193      $form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_numeric_field('posts', $mybb->input['posts'], array('id' => 'posts', 'min' => 0)), 'posts');
 194      $form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_numeric_field('stars', $mybb->input['stars'], array('id' => 'stars', 'min' => 0)), 'stars');
 195      $form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->input['starimage'], array('id' => 'starimage')), 'starimage');
 196      $form_container->end();
 197  
 198      $buttons[] = $form->generate_submit_button($lang->save_user_title);
 199  
 200      $form->output_submit_wrapper($buttons);
 201      $form->end();
 202  
 203      $page->output_footer();
 204  
 205  }
 206  
 207  if($mybb->input['action'] == "delete")
 208  {
 209      $query = $db->simple_select("usertitles", "*", "utid='".$mybb->get_input('utid', MyBB::INPUT_INT)."'");
 210      $usertitle = $db->fetch_array($query);
 211  
 212      if(!$usertitle['utid'])
 213      {
 214          flash_message($lang->error_invalid_user_title, 'error');
 215          admin_redirect("index.php?module=user-titles");
 216      }
 217  
 218      // User clicked no
 219      if($mybb->get_input('no'))
 220      {
 221          admin_redirect("index.php?module=user-titles");
 222      }
 223  
 224      $plugins->run_hooks("admin_user_titles_delete");
 225  
 226      if($mybb->request_method == "post")
 227      {
 228          $db->delete_query("usertitles", "utid='{$usertitle['utid']}'");
 229  
 230          $plugins->run_hooks("admin_user_titles_delete_commit");
 231  
 232          $cache->update_usertitles();
 233  
 234          // Log admin action
 235          log_admin_action($usertitle['utid'], $usertitle['title'], $usertitle['posts']);
 236  
 237          flash_message($lang->success_user_title_deleted, 'success');
 238          admin_redirect("index.php?module=user-titles");
 239      }
 240      else
 241      {
 242          $page->output_confirm_action("index.php?module=user-titles&amp;action=delete&amp;utid={$usertitle['utid']}", $lang->user_title_deletion_confirmation);
 243      }
 244  }
 245  
 246  if(!$mybb->input['action'])
 247  {
 248      $plugins->run_hooks("admin_user_titles_start");
 249  
 250      $page->output_header($lang->manage_user_titles);
 251  
 252      $page->output_nav_tabs($sub_tabs, 'manage_titles');
 253  
 254      $table = new Table;
 255      $table->construct_header($lang->user_title);
 256      $table->construct_header($lang->minimum_posts, array('width' => '130', 'class' => 'align_center'));
 257      $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
 258  
 259      $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts'));
 260      while($usertitle = $db->fetch_array($query))
 261      {
 262          $usertitle['title'] = htmlspecialchars_uni($usertitle['title']);
 263          $table->construct_cell("<a href=\"index.php?module=user-titles&amp;action=edit&amp;utid={$usertitle['utid']}\"><strong>{$usertitle['title']}</strong></a>");
 264          $table->construct_cell($usertitle['posts'], array("class" => "align_center"));
 265          $table->construct_cell("<a href=\"index.php?module=user-titles&amp;action=edit&amp;utid={$usertitle['utid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center"));
 266          $table->construct_cell("<a href=\"index.php?module=user-titles&amp;action=delete&amp;utid={$usertitle['utid']}&amp;my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->user_title_deletion_confirmation}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center"));
 267          $table->construct_row();
 268      }
 269  
 270      if($table->num_rows() == 0)
 271      {
 272          $table->construct_cell($lang->no_user_titles, array('colspan' => 4));
 273          $table->construct_row();
 274      }
 275  
 276      $table->output($lang->manage_user_titles);
 277  
 278      $page->output_footer();
 279  }


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