[ 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: functions_view_manager.php 5823 2012-05-03 15:40:09Z Tomm $ 10 */ 11 12 /** 13 * Builds the "view management" interface allowing administrators to edit their custom designed "views" 14 * 15 * @param string The base URL to this instance of the view manager 16 * @param string The internal type identifier for this view 17 * @param array Array of fields this view supports 18 * @param array Array of possible sort options this view supports if any 19 * @param string Optional callback function which generates list of "conditions" for this view 20 */ 21 function view_manager($base_url, $type, $fields, $sort_options=array(), $conditions_callback="") 22 { 23 global $mybb, $db, $page, $lang; 24 25 $sub_tabs['views'] = array( 26 'title' => $lang->views, 27 'link' => "{$base_url}&action=views", 28 'description' => $lang->views_desc 29 ); 30 31 $sub_tabs['create_view'] = array( 32 'title' => $lang->create_new_view, 33 'link' => "{$base_url}&action=views&do=add", 34 'description' => $lang->create_new_view_desc 35 ); 36 37 $page->add_breadcrumb_item($lang->view_manager, 'index.php?module=user-users&action=views'); 38 39 // Lang strings should be in global lang file 40 41 if($mybb->input['do'] == "set_default") 42 { 43 $query = $db->simple_select("adminviews", "vid, uid, visibility", "vid='".intval($mybb->input['vid'])."'"); 44 $admin_view = $db->fetch_array($query); 45 46 if(!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) 47 { 48 flash_message($lang->error_invalid_admin_view, 'error'); 49 admin_redirect($base_url."&action=views"); 50 } 51 52 set_default_view($type, $admin_view['vid']); 53 flash_message($lang->succuss_view_set_as_default, 'success'); 54 admin_redirect($base_url."&action=views"); 55 } 56 57 if($mybb->input['do'] == "add") 58 { 59 if($mybb->request_method == "post") 60 { 61 if(!trim($mybb->input['title'])) 62 { 63 $errors[] = $lang->error_missing_view_title; 64 } 65 if($mybb->input['fields_js']) 66 { 67 $mybb->input['fields'] = explode(",", $mybb->input['fields_js']); 68 } 69 if(count($mybb->input['fields']) <= 0) 70 { 71 $errors[] = $lang->error_no_view_fields; 72 } 73 74 if(intval($mybb->input['perpage']) <= 0) 75 { 76 $errors[] = $lang->error_invalid_view_perpage; 77 } 78 79 if(!in_array($mybb->input['sortby'], array_keys($sort_options))) 80 { 81 $errors[] = $lang->error_invalid_view_sortby; 82 } 83 84 if($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") 85 { 86 $errors[] = $lang->error_invalid_view_sortorder; 87 } 88 89 if($mybb->input['visibility'] == 0) 90 { 91 $mybb->input['visibility'] = 2; 92 } 93 94 if(!$errors) 95 { 96 $new_view = array( 97 "uid" => $mybb->user['uid'], 98 "title" => $db->escape_string($mybb->input['title']), 99 "type" => $type, 100 "visibility" => intval($mybb->input['visibility']), 101 "fields" => $db->escape_string(serialize($mybb->input['fields'])), 102 "conditions" => $db->escape_string(serialize($mybb->input['conditions'])), 103 "custom_profile_fields" => $db->escape_string(serialize($mybb->input['profile_fields'])), 104 "sortby" => $db->escape_string($mybb->input['sortby']), 105 "sortorder" => $db->escape_string($mybb->input['sortorder']), 106 "perpage" => intval($mybb->input['perpage']), 107 "view_type" => $db->escape_string($mybb->input['view_type']) 108 ); 109 110 $vid = $db->insert_query("adminviews", $new_view); 111 112 if($mybb->input['isdefault']) 113 { 114 set_default_view($type, $vid); 115 } 116 flash_message($lang->success_view_created, "success"); 117 admin_redirect($base_url."&vid={$vid}"); 118 } 119 } 120 else 121 { 122 $mybb->input = array( 123 "perpage" => 20, 124 ); 125 } 126 127 // Write in our JS based field selector 128 $page->extra_header .= "<script src=\"../jscripts/scriptaculous.js?load=effects,dragdrop\" type=\"text/javascript\"></script>\n"; 129 $page->extra_header .= "<script src=\"jscripts/view_manager.js\" type=\"text/javascript\"></script>\n"; 130 131 $page->add_breadcrumb_item($lang->create_new_view); 132 $page->output_header($lang->create_new_view); 133 134 $form = new Form($base_url."&action=views&do=add", "post"); 135 136 $page->output_nav_tabs($sub_tabs, 'create_view'); 137 138 // If we have any error messages, show them 139 if($errors) 140 { 141 $page->output_inline_error($errors); 142 } 143 144 $form_container = new FormContainer($lang->create_new_view); 145 $form_container->output_row($lang->title." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); 146 147 if($mybb->input['visibility'] == 2) 148 { 149 $visibility_public_checked = true; 150 } 151 else 152 { 153 $visibility_private_checked = true; 154 } 155 156 $visibility_options = array( 157 $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), 158 $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) 159 ); 160 $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options)); 161 162 $form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0))); 163 164 if(count($sort_options) > 0) 165 { 166 $sort_directions = array( 167 "asc" => $lang->ascending, 168 "desc" => $lang->descending 169 ); 170 $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('sortorder', $sort_directions, $mybb->input['sortorder'], array('id' => 'sortorder')), 'sortby'); 171 } 172 173 $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $mybb->input['perpage'], array('id' => 'perpage')), 'perpage'); 174 175 if($type == "user") 176 { 177 $form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => ($mybb->input['view_type'] != "card" ? true : false)))."<br />".$form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => ($mybb->input['view_type'] == "card" ? true : false)))); 178 } 179 180 $form_container->end(); 181 182 $field_select .= "<div class=\"view_fields\">\n"; 183 $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n"; 184 if(is_array($mybb->input['fields'])) 185 { 186 foreach($mybb->input['fields'] as $field) 187 { 188 if($fields[$field]) 189 { 190 $field_select .= "<li id=\"field-{$field}\">{$fields[$field]['title']}</li>"; 191 $active[$field] = 1; 192 } 193 } 194 } 195 $field_select .= "</ul></div>\n"; 196 $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n"; 197 foreach($fields as $key => $field) 198 { 199 if($active[$key]) 200 { 201 continue; 202 } 203 $field_select .= "<li id=\"field-{$key}\">{$field['title']}</li>"; 204 } 205 $field_select .= "</div></ul>\n"; 206 $field_select .= $form->generate_hidden_field("fields_js", @implode(",", @array_keys($active)), array('id' => 'fields_js')); 207 $field_select = str_replace("'", "\\'", $field_select); 208 $field_select = str_replace("\n", "", $field_select); 209 210 $field_select = "<script type=\"text/javascript\"> 211 //<![CDATA[ 212 document.write('".str_replace("/", "\/", $field_select)."'); 213 //]]> 214 </script>\n"; 215 216 foreach($fields as $key => $field) 217 { 218 $field_options[$key] = $field['title']; 219 } 220 221 $field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true))."</noscript>\n"; 222 223 $form_container = new FormContainer($lang->fields_to_show); 224 $form_container->output_row($lang->fields_to_show_desc, $description, $field_select); 225 $form_container->end(); 226 227 // Build the search conditions 228 if(function_exists($conditions_callback)) 229 { 230 $conditions_callback($mybb->input, $form); 231 } 232 233 $buttons[] = $form->generate_submit_button($lang->save_view); 234 $form->output_submit_wrapper($buttons); 235 236 $form->end(); 237 $page->output_footer(); 238 } 239 else if($mybb->input['do'] == "edit") 240 { 241 $query = $db->simple_select("adminviews", "*", "vid='".intval($mybb->input['vid'])."'"); 242 $admin_view = $db->fetch_array($query); 243 244 // Does the view not exist? 245 if(!$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) 246 { 247 flash_message($lang->error_invalid_admin_view, 'error'); 248 admin_redirect($base_url."&action=views"); 249 } 250 251 if($mybb->request_method == "post") 252 { 253 if(!trim($mybb->input['title'])) 254 { 255 $errors[] = $lang->error_missing_view_title; 256 } 257 if($mybb->input['fields_js']) 258 { 259 $mybb->input['fields'] = explode(",", $mybb->input['fields_js']); 260 } 261 262 if(count($mybb->input['fields']) <= 0) 263 { 264 $errors[] = $lang->error_no_view_fields; 265 } 266 267 if(intval($mybb->input['perpage']) <= 0) 268 { 269 $errors[] = $lang->error_invalid_view_perpage; 270 } 271 272 if(!in_array($mybb->input['sortby'], array_keys($sort_options))) 273 { 274 $errors[] = $lang->error_invalid_view_sortby; 275 } 276 277 if($mybb->input['sortorder'] != "asc" && $mybb->input['sortorder'] != "desc") 278 { 279 $errors[] = $lang->error_invalid_view_sortorder; 280 } 281 282 if($mybb->input['visibility'] == 0) 283 { 284 $mybb->input['visibility'] = 2; 285 } 286 287 if(!$errors) 288 { 289 $updated_view = array( 290 "title" => $db->escape_string($mybb->input['title']), 291 "type" => $type, 292 "visibility" => intval($mybb->input['visibility']), 293 "fields" => $db->escape_string(serialize($mybb->input['fields'])), 294 "conditions" => $db->escape_string(serialize($mybb->input['conditions'])), 295 "custom_profile_fields" => $db->escape_string(serialize($mybb->input['profile_fields'])), 296 "sortby" => $db->escape_string($mybb->input['sortby']), 297 "sortorder" => $db->escape_string($mybb->input['sortorder']), 298 "perpage" => intval($mybb->input['perpage']), 299 "view_type" => $db->escape_string($mybb->input['view_type']) 300 ); 301 $db->update_query("adminviews", $updated_view, "vid='{$admin_view['vid']}'"); 302 303 if($mybb->input['isdefault']) 304 { 305 set_default_view($type, $view['vid']); 306 } 307 308 flash_message($lang->success_view_updated, "success"); 309 admin_redirect($base_url."&vid={$admin_view['vid']}"); 310 } 311 } 312 313 // Write in our JS based field selector 314 $page->extra_header .= "<script src=\"../jscripts/scriptaculous.js?load=effects,dragdrop\" type=\"text/javascript\"></script>\n"; 315 $page->extra_header .= "<script src=\"jscripts/view_manager.js\" type=\"text/javascript\"></script>\n"; 316 317 $page->add_breadcrumb_item($lang->edit_view); 318 $page->output_header($lang->edit_view); 319 320 $form = new Form($base_url."&action=views&do=edit&vid={$admin_view['vid']}", "post"); 321 322 $sub_tabs = array(); 323 $sub_tabs['edit_view'] = array( 324 'title' => $lang->edit_view, 325 'link' => $base_url."&action=views&do=edit&vid={$admin_view['vid']}", 326 'description' => $lang->edit_view_desc 327 ); 328 329 $page->output_nav_tabs($sub_tabs, 'edit_view'); 330 331 // If we have any error messages, show them 332 if($errors) 333 { 334 $page->output_inline_error($errors); 335 } 336 else 337 { 338 $admin_view['conditions'] = unserialize($admin_view['conditions']); 339 $admin_view['fields'] = unserialize($admin_view['fields']); 340 $admin_view['profile_fields'] = unserialize($admin_view['custom_profile_fields']); 341 $mybb->input = $admin_view; 342 343 $mybb->input['isdefault'] = 0; 344 $default_view = fetch_default_view($type); 345 346 if($default_view == $admin_view['vid']) 347 { 348 $mybb->input['isdefault'] = 1; 349 } 350 } 351 352 $form_container = new FormContainer($lang->edit_view); 353 $form_container->output_row($lang->view." <em>*</em>", "", $form->generate_text_box('title', $mybb->input['title'], array('id' => 'title')), 'title'); 354 355 if($mybb->input['visibility'] == 2) 356 { 357 $visibility_public_checked = true; 358 } 359 else 360 { 361 $visibility_private_checked = true; 362 } 363 364 $visibility_options = array( 365 $form->generate_radio_button("visibility", "1", "<strong>{$lang->private}</strong> - {$lang->private_desc}", array("checked" => $visibility_private_checked)), 366 $form->generate_radio_button("visibility", "2", "<strong>{$lang->public}</strong> - {$lang->public_desc}", array("checked" => $visibility_public_checked)) 367 ); 368 $form_container->output_row($lang->visibility, "", implode("<br />", $visibility_options)); 369 370 $form_container->output_row($lang->set_as_default_view, "", $form->generate_yes_no_radio("isdefault", $mybb->input['isdefault'], array('yes' => 1, 'no' => 0))); 371 372 if(count($sort_options) > 0) 373 { 374 $sort_directions = array( 375 "asc" => $lang->ascending, 376 "desc" => $lang->descending 377 ); 378 $form_container->output_row($lang->sort_results_by, "", $form->generate_select_box('sortby', $sort_options, $mybb->input['sortby'], array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('sortorder', $sort_directions, $mybb->input['sortorder'], array('id' => 'sortorder')), 'sortby'); 379 } 380 381 $form_container->output_row($lang->results_per_page, "", $form->generate_text_box('perpage', $mybb->input['perpage'], array('id' => 'perpage')), 'perpage'); 382 383 if($type == "user") 384 { 385 $form_container->output_row($lang->display_results_as, "", $form->generate_radio_button('view_type', 'table', $lang->table, array('checked' => ($mybb->input['view_type'] != "card" ? true : false)))."<br />".$form->generate_radio_button('view_type', 'card', $lang->business_card, array('checked' => ($mybb->input['view_type'] == "card" ? true : false)))); 386 } 387 388 $form_container->end(); 389 390 $field_select .= "<div class=\"view_fields\">\n"; 391 $field_select .= "<div class=\"enabled\"><div class=\"fields_title\">{$lang->enabled}</div><ul id=\"fields_enabled\">\n"; 392 if(is_array($mybb->input['fields'])) 393 { 394 foreach($mybb->input['fields'] as $field) 395 { 396 if($fields[$field]) 397 { 398 $field_select .= "<li id=\"field-{$field}\">{$fields[$field]['title']}</li>"; 399 $active[$field] = 1; 400 } 401 } 402 } 403 $field_select .= "</ul></div>\n"; 404 $field_select .= "<div class=\"disabled\"><div class=\"fields_title\">{$lang->disabled}</div><ul id=\"fields_disabled\">\n"; 405 if(is_array($fields)) 406 { 407 foreach($fields as $key => $field) 408 { 409 if($active[$key]) 410 { 411 continue; 412 } 413 $field_select .= "<li id=\"field-{$key}\">{$field['title']}</li>"; 414 } 415 } 416 $field_select .= "</div></ul>\n"; 417 $field_select .= $form->generate_hidden_field("fields_js", @implode(",", @array_keys($active)), array('id' => 'fields_js')); 418 $field_select = str_replace("'", "\\'", $field_select); 419 $field_select = str_replace("\n", "", $field_select); 420 421 $field_select = "<script type=\"text/javascript\"> 422 //<![CDATA[ 423 document.write('".str_replace("/", "\/", $field_select)."'); 424 //]]></script>\n"; 425 426 foreach($fields as $key => $field) 427 { 428 $field_options[$key] = $field['title']; 429 } 430 431 $field_select .= "<noscript>".$form->generate_select_box('fields[]', $field_options, $mybb->input['fields'], array('id' => 'fields', 'multiple' => true))."</noscript>\n"; 432 433 $form_container = new FormContainer($lang->fields_to_show); 434 $form_container->output_row($lang->fields_to_show_desc, $description, $field_select); 435 $form_container->end(); 436 437 // Build the search conditions 438 if(function_exists($conditions_callback)) 439 { 440 $conditions_callback($mybb->input, $form); 441 } 442 443 444 $buttons[] = $form->generate_submit_button($lang->save_view); 445 $form->output_submit_wrapper($buttons); 446 447 $form->end(); 448 $page->output_footer(); 449 } 450 451 else if($mybb->input['do'] == "delete") 452 { 453 if($mybb->input['no']) 454 { 455 admin_redirect($base_url."&action=views"); 456 } 457 458 $query = $db->simple_select("adminviews", "COUNT(vid) as views"); 459 $views = $db->fetch_field($query, "views"); 460 461 if($views == 0) 462 { 463 flash_message($lang->error_cannot_delete_view, 'error'); 464 admin_redirect($base_url."&action=views"); 465 } 466 467 $vid = intval($mybb->input['vid']); 468 $query = $db->simple_select("adminviews", "vid, uid, visibility", "vid = '{$vid}'"); 469 $admin_view = $db->fetch_array($query); 470 471 if($vid == 1 || !$admin_view['vid'] || $admin_view['visibility'] == 1 && $mybb->user['uid'] != $admin_view['uid']) 472 { 473 flash_message($lang->error_invalid_view_delete, 'error'); 474 admin_redirect($base_url."&action=views"); 475 } 476 477 if($mybb->request_method == "post") 478 { 479 $db->delete_query("adminviews", "vid='{$admin_view['vid']}'"); 480 flash_message($lang->success_view_deleted, 'success'); 481 admin_redirect($base_url."&action=views"); 482 } 483 else 484 { 485 $page->output_confirm_action($base_url."&action=views&do=delete&vid={$admin_view['vid']}", $lang->confirm_view_deletion); 486 } 487 } 488 489 // Export views 490 else if($mybb->input['do'] == "export") 491 { 492 $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">\n"; 493 $xml = "<adminviews version=\"".$mybb->version_code."\" exported=\"".TIME_NOW."\">\n"; 494 495 if($mybb->input['type']) 496 { 497 $type_where = "type='".$db->escape_string($mybb->input['type'])."'"; 498 } 499 500 $query = $db->simple_select("adminviews", "*", $type_where); 501 while($admin_view = $db->fetch_array($query)) 502 { 503 $fields = unserialize($admin_view['fields']); 504 $conditions = unserialize($admin_view['conditions']); 505 $xml .= "\t<view vid=\"{$admin_view['vid']}\" uid=\"{$admin_view['uid']}\" type=\"{$admin_view['type']}\" visibility=\"{$admin_view['visibility']}\">\n"; 506 $xml .= "\t\t<title><![CDATA[{$admin_view['title']}]]></title>\n"; 507 $xml .= "\t\t<fields>\n"; 508 foreach($fields as $field) 509 { 510 $xml .= "\t\t\t<field name=\"{$field}\" />\n"; 511 } 512 $xml .= "\t\t</fields>\n"; 513 $xml .= "\t\t<conditions>\n"; 514 foreach($conditions as $name => $condition) 515 { 516 if(!$conditions) continue; 517 if(is_array($condition)) 518 { 519 $condition = serialize($condition); 520 $is_serialized = " is_serialized=\"1\""; 521 } 522 $xml .= "\t\t\t<condition name=\"{$name}\"{$is_serialized}><![CDATA[{$condition}]]></condition>\n"; 523 } 524 $xml .= "\t\t</conditions>\n"; 525 $xml .= "\t\t<sortby><![CDATA[{$admin_view['sortby']}]]></sortby>\n"; 526 $xml .= "\t\t<sortorder><![CDATA[{$admin_view['sortorder']}]]></sortorder>\n"; 527 $xml .= "\t\t<perpage><![CDATA[{$admin_view['perpage']}]]></perpage>\n"; 528 $xml .= "\t\t<view_type><![CDATA[{$admin_view['view_type']}]]></view_type>\n"; 529 $xml .= "\t</view>\n"; 530 } 531 $xml .= "</adminviews>\n"; 532 $mybb->settings['bbname'] = urlencode($mybb->settings['bbname']); 533 header("Content-disposition: filename=".$mybb->settings['bbname']."-views.xml"); 534 header("Content-Length: ".my_strlen($xml)); 535 header("Content-type: unknown/unknown"); 536 header("Pragma: no-cache"); 537 header("Expires: 0"); 538 echo $xml; 539 exit; 540 } 541 542 // Generate a listing of all current views 543 else 544 { 545 $page->output_header($lang->view_manager); 546 547 $page->output_nav_tabs($sub_tabs, 'views'); 548 549 $table = new Table; 550 $table->construct_header($lang->view); 551 $table->construct_header($lang->controls, array("class" => "align_center", "width" => 150)); 552 553 $default_view = fetch_default_view($type); 554 555 $query = $db->simple_select("adminviews", "COUNT(vid) as views"); 556 $views = $db->fetch_field($query, "views"); 557 558 $query = $db->query(" 559 SELECT v.*, u.username 560 FROM ".TABLE_PREFIX."adminviews v 561 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=v.uid) 562 WHERE v.visibility='2' OR (v.visibility='1' AND v.uid='{$mybb->user['uid']}') 563 ORDER BY title 564 "); 565 while($view = $db->fetch_array($query)) 566 { 567 $created = ""; 568 if($view['uid'] == 0) 569 { 570 $view_type = "default"; 571 $default_class = "grey"; 572 } 573 else if($view['visibility'] == 2) 574 { 575 $view_type = "group"; 576 if($view['username']) 577 { 578 $created = "<br /><small>{$lang->created_by} {$view['username']}</small>"; 579 } 580 } 581 else 582 { 583 $view_type = "user"; 584 } 585 586 $default_add = ''; 587 if($default_view == $view['vid']) 588 { 589 $default_add = " ({$lang->default})"; 590 } 591 592 593 $title_string = "view_title_{$view['vid']}"; 594 595 if($lang->$title_string) 596 { 597 $view['title'] = $lang->$title_string; 598 } 599 600 $table->construct_cell("<div class=\"float_right\"><img src=\"styles/{$page->style}/images/icons/{$view_type}.gif\" title=\"".$lang->sprintf($lang->this_is_a_view, $view_type)."\" alt=\"{$view_type}\" /></div><div class=\"{$default_class}\"><strong><a href=\"{$base_url}&action=views&do=edit&vid={$view['vid']}\" >{$view['title']}</a></strong>{$default_add}{$created}</div>"); 601 602 $popup = new PopupMenu("view_{$view['vid']}", $lang->options); 603 $popup->add_item($lang->edit_view, "{$base_url}&action=views&do=edit&vid={$view['vid']}"); 604 if($view['vid'] != $default_view) 605 { 606 $popup->add_item($lang->set_as_default, "{$base_url}&action=views&do=set_default&vid={$view['vid']}"); 607 } 608 609 if($views > 1 && $view['vid'] != 1) 610 { 611 $popup->add_item($lang->delete_view, "{$base_url}&action=views&do=delete&vid={$view['vid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_view_deletion}')"); 612 } 613 $controls = $popup->fetch(); 614 $table->construct_cell($controls, array("class" => "align_center")); 615 $table->construct_row(); 616 } 617 618 $table->output($lang->view); 619 620 echo <<<LEGEND 621 <br /> 622 <fieldset> 623 <legend>{$lang->legend}</legend> 624 <img src="styles/{$page->style}/images/icons/default.gif" alt="{$lang->default}" style="vertical-align: middle;" /> {$lang->default_view_desc}<br /> 625 <img src="styles/{$page->style}/images/icons/group.gif" alt="{$lang->public}" style="vertical-align: middle;" /> {$lang->public_view_desc}<br /> 626 <img src="styles/{$page->style}/images/icons/user.gif" alt="{$lang->private}" style="vertical-align: middle;" /> {$lang->private_view_desc}</fieldset> 627 LEGEND; 628 $page->output_footer(); 629 } 630 } 631 632 function set_default_view($type, $vid) 633 { 634 global $mybb, $db; 635 636 $query = $db->simple_select("adminoptions", "defaultviews", "uid='{$mybb->user['uid']}'"); 637 $default_views = unserialize($db->fetch_field($query, "defaultviews")); 638 if(!$db->num_rows($query)) 639 { 640 $create = true; 641 } 642 $default_views[$type] = $vid; 643 $default_views = serialize($default_views); 644 $updated_admin = array("defaultviews" => $db->escape_string($default_views)); 645 646 if($create == true) 647 { 648 $updated_admin['uid'] = $mybb->user['uid']; 649 $updated_admin['notes'] = ''; 650 $updated_admin['permissions'] = ''; 651 $db->insert_query("adminoptions", $updated_admin); 652 } 653 else 654 { 655 $db->update_query("adminoptions", $updated_admin, "uid='{$mybb->user['uid']}'"); 656 } 657 } 658 659 function fetch_default_view($type) 660 { 661 global $mybb, $db; 662 $query = $db->simple_select("adminoptions", "defaultviews", "uid='{$mybb->user['uid']}'"); 663 $default_views = unserialize($db->fetch_field($query, "defaultviews")); 664 if(!is_array($default_views)) 665 { 666 return false; 667 } 668 return $default_views[$type]; 669 } 670 ?>
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 |