[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id: titles.php 5828 2012-05-08 16:06:16Z Tomm $ 10 */ 11 12 // Disallow direct access to this file for security reasons 13 if(!defined("IN_MYBB")) 14 { 15 die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); 16 } 17 18 $page->add_breadcrumb_item($lang->user_titles, "index.php?module=user-titles"); 19 20 if($mybb->input['action'] == "add" || !$mybb->input['action']) 21 { 22 $sub_tabs['manage_titles'] = array( 23 'title' => $lang->user_titles, 24 'link' => "index.php?module=user-titles", 25 'description' => $lang->user_titles_desc 26 ); 27 $sub_tabs['add_title'] = array( 28 'title' => $lang->add_new_user_title, 29 'link' => "index.php?module=user-titles&action=add", 30 'description' => $lang->add_new_user_title_desc 31 ); 32 } 33 34 $plugins->run_hooks("admin_user_titles_begin"); 35 36 if($mybb->input['action'] == "add") 37 { 38 $plugins->run_hooks("admin_user_titles_add"); 39 40 if($mybb->request_method == "post") 41 { 42 if(!trim($mybb->input['title'])) 43 { 44 $errors[] = $lang->error_missing_title; 45 } 46 47 if(!isset($mybb->input['posts'])) 48 { 49 $errors[] = $lang->error_missing_posts; 50 } 51 52 if(!$errors) 53 { 54 $new_title = array( 55 "title" => $db->escape_string($mybb->input['title']), 56 "posts" => intval($mybb->input['posts']), 57 "stars" => intval($mybb->input['stars']), 58 "starimage" => $db->escape_string($mybb->input['starimage']) 59 ); 60 61 $utid = $db->insert_query("usertitles", $new_title); 62 63 $cache->update_usertitles(); 64 65 $plugins->run_hooks("admin_user_titles_add_commit"); 66 67 // Log admin action 68 log_admin_action($utid, $mybb->input['title'], $mybb->input['posts']); 69 70 flash_message($lang->success_user_title_created, 'success'); 71 admin_redirect("index.php?module=user-titles"); 72 } 73 } 74 else 75 { 76 $mybb->input = array( 77 'stars' => '1', 78 'starimage' => '{theme}/star.gif', 79 ); 80 } 81 82 $page->add_breadcrumb_item($lang->add_new_user_title); 83 $page->output_header($lang->user_titles." - ".$lang->add_new_user_title); 84 85 $page->output_nav_tabs($sub_tabs, 'add_title'); 86 $form = new Form("index.php?module=user-titles&action=add", "post"); 87 88 89 if($errors) 90 { 91 $page->output_inline_error($errors); 92 } 93 94 $form_container = new FormContainer($lang->add_new_user_title); 95 $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'); 96 $form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_text_box('posts', $mybb->input['posts'], array('id' => 'posts')), 'posts'); 97 $form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_text_box('stars', $mybb->input['stars'], array('id' => 'stars')), 'stars'); 98 $form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->input['starimage'], array('id' => 'starimage')), 'starimage'); 99 $form_container->end(); 100 101 $buttons[] = $form->generate_submit_button($lang->save_user_title); 102 103 $form->output_submit_wrapper($buttons); 104 $form->end(); 105 106 $page->output_footer(); 107 } 108 109 if($mybb->input['action'] == "edit") 110 { 111 $plugins->run_hooks("admin_user_titles_edit"); 112 113 $query = $db->simple_select("usertitles", "*", "utid='".intval($mybb->input['utid'])."'"); 114 $usertitle = $db->fetch_array($query); 115 116 if(!$usertitle['utid']) 117 { 118 flash_message($lang->error_invalid_user_title, 'error'); 119 admin_redirect("index.php?module=user-titles"); 120 } 121 122 if($mybb->request_method == "post") 123 { 124 if(!trim($mybb->input['title'])) 125 { 126 $errors[] = $lang->error_missing_title; 127 } 128 129 if(!isset($mybb->input['posts'])) 130 { 131 $errors[] = $lang->error_missing_posts; 132 } 133 134 if(!$errors) 135 { 136 $updated_title = array( 137 "title" => $db->escape_string($mybb->input['title']), 138 "posts" => intval($mybb->input['posts']), 139 "stars" => intval($mybb->input['stars']), 140 "starimage" => $db->escape_string($mybb->input['starimage']) 141 ); 142 143 $db->update_query("usertitles", $updated_title, "utid='{$usertitle['utid']}'"); 144 145 $cache->update_usertitles(); 146 147 $plugins->run_hooks("admin_user_titles_edit_commit"); 148 149 // Log admin action 150 log_admin_action($usertitle['utid'], $mybb->input['title'], $mybb->input['posts']); 151 152 flash_message($lang->success_user_title_updated, 'success'); 153 admin_redirect("index.php?module=user-titles"); 154 } 155 } 156 157 $page->add_breadcrumb_item($lang->edit_user_title); 158 $page->output_header($lang->user_titles." - ".$lang->edit_user_title); 159 160 $sub_tabs['edit_title'] = array( 161 'title' => $lang->edit_user_title, 162 'link' => "index.php?module=user-titles&action=edit&uid=".$mybb->input['uid'], 163 'description' => $lang->edit_user_title_desc 164 ); 165 166 $page->output_nav_tabs($sub_tabs, 'edit_title'); 167 $form = new Form("index.php?module=user-titles&action=edit&utid={$usertitle['utid']}", "post"); 168 169 170 if($errors) 171 { 172 $page->output_inline_error($errors); 173 } 174 else 175 { 176 $mybb->input = $usertitle; 177 } 178 179 $form_container = new FormContainer($lang->edit_user_title); 180 $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'); 181 $form_container->output_row($lang->minimum_posts, $lang->minimum_posts_desc, $form->generate_text_box('posts', $mybb->input['posts'], array('id' => 'posts')), 'posts'); 182 $form_container->output_row($lang->number_of_stars, $lang->number_of_stars_desc, $form->generate_text_box('stars', $mybb->input['stars'], array('id' => 'stars')), 'stars'); 183 $form_container->output_row($lang->star_image, $lang->star_image_desc, $form->generate_text_box('starimage', $mybb->input['starimage'], array('id' => 'starimage')), 'starimage'); 184 $form_container->end(); 185 186 $buttons[] = $form->generate_submit_button($lang->save_user_title); 187 188 $form->output_submit_wrapper($buttons); 189 $form->end(); 190 191 $page->output_footer(); 192 193 } 194 195 if($mybb->input['action'] == "delete") 196 { 197 $plugins->run_hooks("admin_user_titles_delete"); 198 199 $query = $db->simple_select("usertitles", "*", "utid='".intval($mybb->input['utid'])."'"); 200 $usertitle = $db->fetch_array($query); 201 202 if(!$usertitle['utid']) 203 { 204 flash_message($lang->error_invalid_user_title, 'error'); 205 admin_redirect("index.php?module=user-titles"); 206 } 207 208 // User clicked no 209 if($mybb->input['no']) 210 { 211 admin_redirect("index.php?module=user-titles"); 212 } 213 214 if($mybb->request_method == "post") 215 { 216 $db->delete_query("usertitles", "utid='{$usertitle['utid']}'"); 217 218 $plugins->run_hooks("admin_user_titles_delete_commit"); 219 220 // Log admin action 221 log_admin_action($usertitle['utid'], $usertitle['title'], $usertitle['posts']); 222 223 flash_message($lang->success_user_title_deleted, 'success'); 224 admin_redirect("index.php?module=user-titles"); 225 } 226 else 227 { 228 $page->output_confirm_action("index.php?module=user-titles&action=delete&utid={$usertitle['utid']}", $lang->user_title_deletion_confirmation); 229 } 230 } 231 232 if(!$mybb->input['action']) 233 { 234 $plugins->run_hooks("admin_user_titles_start"); 235 236 $page->output_header($lang->manage_user_titles); 237 238 $page->output_nav_tabs($sub_tabs, 'manage_titles'); 239 240 $table = new Table; 241 $table->construct_header($lang->user_title); 242 $table->construct_header($lang->minimum_posts, array('width' => '130', 'class' => 'align_center')); 243 $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200)); 244 245 $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts')); 246 while($usertitle = $db->fetch_array($query)) 247 { 248 $usertitle['title'] = htmlspecialchars_uni($usertitle['title']); 249 $table->construct_cell("<a href=\"index.php?module=user-titles&action=edit&utid={$usertitle['utid']}\"><strong>{$usertitle['title']}</strong></a>"); 250 $table->construct_cell($usertitle['posts'], array("class" => "align_center")); 251 $table->construct_cell("<a href=\"index.php?module=user-titles&action=edit&utid={$usertitle['utid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center")); 252 $table->construct_cell("<a href=\"index.php?module=user-titles&action=delete&utid={$usertitle['utid']}&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")); 253 $table->construct_row(); 254 } 255 256 if($table->num_rows() == 0) 257 { 258 $table->construct_cell($lang->no_user_titles, array('colspan' => 4)); 259 $table->construct_row(); 260 $no_results = true; 261 } 262 263 $table->output($lang->manage_user_titles); 264 265 $page->output_footer(); 266 } 267 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |