[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
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->calendars, "index.php?module=config-calendars"); 18 19 if($mybb->input['action'] == "add" || $mybb->input['action'] == "permissions" || !$mybb->input['action']) 20 { 21 $sub_tabs['manage_calendars'] = array( 22 'title' => $lang->manage_calendars, 23 'link' => "index.php?module=config-calendars", 24 'description' => $lang->manage_calendars_desc 25 ); 26 $sub_tabs['add_calendar'] = array( 27 'title' => $lang->add_calendar, 28 'link' => "index.php?module=config-calendars&action=add", 29 'description' => $lang->add_calendar_desc 30 ); 31 } 32 33 $plugins->run_hooks("admin_config_calendars_begin"); 34 35 if($mybb->input['action'] == "add") 36 { 37 $plugins->run_hooks("admin_config_calendars_add"); 38 39 if($mybb->request_method == "post") 40 { 41 $plugins->run_hooks("admin_config_calendars_add_commit"); 42 43 if(!trim($mybb->input['name'])) 44 { 45 $errors[] = $lang->error_missing_name; 46 } 47 48 if(!isset($mybb->input['disporder'])) 49 { 50 $errors[] = $lang->error_missing_order; 51 } 52 53 if(!$errors) 54 { 55 $calendar = array( 56 "name" => $db->escape_string($mybb->input['name']), 57 "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT), 58 "startofweek" => $mybb->get_input('startofweek', MyBB::INPUT_INT), 59 "eventlimit" => $mybb->get_input('eventlimit', MyBB::INPUT_INT), 60 "showbirthdays" => $mybb->get_input('showbirthdays', MyBB::INPUT_INT), 61 "moderation" => $mybb->get_input('moderation', MyBB::INPUT_INT), 62 "allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT), 63 "allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT), 64 "allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT), 65 "allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT), 66 "allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT) 67 ); 68 69 $plugins->run_hooks("admin_config_calendars_add_commit_start"); 70 71 $cid = $db->insert_query("calendars", $calendar); 72 73 $plugins->run_hooks("admin_config_calendars_add_commit_end"); 74 75 // Log admin action 76 log_admin_action($cid, $mybb->input['name']); 77 78 flash_message($lang->success_calendar_created, 'success'); 79 admin_redirect("index.php?module=config-calendars"); 80 } 81 } 82 else 83 { 84 $mybb->input = array_merge($mybb->input, array( 85 "allowhtml" => 0, 86 "eventlimit" => 4, 87 "disporder" => 1, 88 "moderation" => 0 89 ) 90 ); 91 } 92 93 $page->add_breadcrumb_item($lang->add_calendar); 94 $page->output_header($lang->calendars." - ".$lang->add_calendar); 95 96 $page->output_nav_tabs($sub_tabs, 'add_calendar'); 97 $form = new Form("index.php?module=config-calendars&action=add", "post"); 98 99 if($errors) 100 { 101 $page->output_inline_error($errors); 102 } 103 104 $form_container = new FormContainer($lang->add_calendar); 105 $form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->get_input('name'), array('id' => 'name')), 'name'); 106 $form_container->output_row($lang->display_order, $lang->display_order_desc, $form->generate_numeric_field('disporder', $mybb->get_input('disporder'), array('id' => 'disporder', 'min' => 0)), 'disporder'); 107 $select_list = array($lang->sunday, $lang->monday, $lang->tuesday, $lang->wednesday, $lang->thursday, $lang->friday, $lang->saturday); 108 $form_container->output_row($lang->week_start, $lang->week_start_desc, $form->generate_select_box('startofweek', $select_list, $mybb->get_input('startofweek'), array('id' => 'startofweek')), 'startofweek'); 109 $form_container->output_row($lang->event_limit, $lang->event_limit_desc, $form->generate_numeric_field('eventlimit', $mybb->get_input('eventlimit'), array('id' => 'eventlimit', 'min' => 0)), 'eventlimit'); 110 $form_container->output_row($lang->show_birthdays, $lang->show_birthdays_desc, $form->generate_yes_no_radio('showbirthdays', $mybb->get_input('showbirthdays'), true)); 111 $form_container->output_row($lang->moderate_events, $lang->moderate_events_desc, $form->generate_yes_no_radio('moderation', $mybb->get_input('moderation'), true)); 112 $form_container->output_row($lang->allow_html, "", $form->generate_yes_no_radio('allowhtml', $mybb->get_input('allowhtml'))); 113 $form_container->output_row($lang->allow_mycode, "", $form->generate_yes_no_radio('allowmycode', $mybb->get_input('allowmycode'))); 114 $form_container->output_row($lang->allow_img, "", $form->generate_yes_no_radio('allowimgcode', $mybb->get_input('allowimgcode'))); 115 $form_container->output_row($lang->allow_video, "", $form->generate_yes_no_radio('allowvideocode', $mybb->get_input('allowvideocode'))); 116 $form_container->output_row($lang->allow_smilies, "", $form->generate_yes_no_radio('allowsmilies', $mybb->get_input('allowsmilies'))); 117 $form_container->end(); 118 119 $buttons[] = $form->generate_submit_button($lang->save_calendar); 120 121 $form->output_submit_wrapper($buttons); 122 $form->end(); 123 124 $page->output_footer(); 125 } 126 127 if($mybb->input['action'] == "permissions") 128 { 129 $usergroups = array(); 130 131 $query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'"); 132 $calendar = $db->fetch_array($query); 133 134 // Does the calendar not exist? 135 if(!$calendar) 136 { 137 flash_message($lang->error_invalid_calendar, 'error'); 138 admin_redirect("index.php?module=config-calendars"); 139 } 140 141 $plugins->run_hooks("admin_config_calendars_permissions"); 142 143 $query = $db->simple_select("usergroups", "*", "", array("order" => "name")); 144 while($usergroup = $db->fetch_array($query)) 145 { 146 $usergroups[$usergroup['gid']] = $usergroup; 147 } 148 149 $existing_permissions = array(); 150 151 $query = $db->simple_select("calendarpermissions", "*", "cid='{$calendar['cid']}'"); 152 while($existing = $db->fetch_array($query)) 153 { 154 $existing_permissions[$existing['gid']] = $existing; 155 } 156 157 if($mybb->request_method == "post") 158 { 159 foreach(array_keys($usergroups) as $group_id) 160 { 161 if(isset($mybb->input['permissions'][$group_id])) 162 { 163 $permissions = $mybb->input['permissions'][$group_id]; 164 } 165 else 166 { 167 $permissions = array(); 168 } 169 170 $db->delete_query("calendarpermissions", "cid='{$calendar['cid']}' AND gid='".(int)$group_id."'"); 171 172 if(empty($mybb->input['default_permissions'][$group_id])) 173 { 174 foreach(array('canviewcalendar','canaddevents','canbypasseventmod','canmoderateevents') as $calendar_permission) 175 { 176 if(!empty($permissions[$calendar_permission])) 177 { 178 $permissions_array[$calendar_permission] = 1; 179 } 180 else 181 { 182 $permissions_array[$calendar_permission] = 0; 183 } 184 } 185 $permissions_array['gid'] = (int)$group_id; 186 $permissions_array['cid'] = $calendar['cid']; 187 $db->insert_query("calendarpermissions", $permissions_array); 188 } 189 } 190 191 $plugins->run_hooks("admin_config_calendars_permissions_commit"); 192 193 // Log admin action 194 log_admin_action($calendar['cid'], $calendar['name']); 195 196 flash_message($lang->success_calendar_permissions_updated, 'success'); 197 admin_redirect("index.php?module=config-calendars"); 198 } 199 200 $calendar['name'] = htmlspecialchars_uni($calendar['name']); 201 $page->add_breadcrumb_item($calendar['name'], "index.php?module=config-calendars&action=edit&cid={$calendar['cid']}"); 202 $page->add_breadcrumb_item($lang->permissions); 203 $page->output_header($lang->calendars." - ".$lang->edit_permissions); 204 205 $form = new Form("index.php?module=config-calendars&action=permissions", "post"); 206 echo $form->generate_hidden_field("cid", $calendar['cid']); 207 208 $table = new Table; 209 $table->construct_header($lang->permissions_group); 210 $table->construct_header($lang->permissions_view, array("class" => "align_center", "width" => "10%")); 211 $table->construct_header($lang->permissions_post_events, array("class" => "align_center", "width" => "10%")); 212 $table->construct_header($lang->permissions_bypass_moderation, array("class" => "align_center", "width" => "10%")); 213 $table->construct_header($lang->permissions_moderator, array("class" => "align_center", "width" => "10%")); 214 $table->construct_header($lang->permissions_all, array("class" => "align_center", "width" => "10%")); 215 216 foreach($usergroups as $usergroup) 217 { 218 if(!empty($existing_permissions[$usergroup['gid']])) 219 { 220 $perms = $existing_permissions[$usergroup['gid']]; 221 $default_checked = false; 222 } 223 else 224 { 225 $perms = $usergroup; 226 $default_checked = true; 227 } 228 $perm_check = $all_check = ""; 229 $all_checked = true; 230 foreach(array('canviewcalendar','canaddevents','canbypasseventmod','canmoderateevents') as $calendar_permission) 231 { 232 if($usergroup[$calendar_permission] == 1) 233 { 234 $value = "this.checked"; 235 } 236 else 237 { 238 $value = "false"; 239 } 240 if($perms[$calendar_permission] != 1) 241 { 242 $all_checked = false; 243 } 244 if($perms[$calendar_permission] == 1) 245 { 246 $perms_checked[$calendar_permission] = 1; 247 } 248 else 249 { 250 $perms_checked[$calendar_permission] = 0; 251 } 252 $all_check .= "\$('#permissions_{$usergroup['gid']}_{$calendar_permission}').prop('checked', this.checked);\n"; 253 $perm_check .= "\$('#permissions_{$usergroup['gid']}_{$calendar_permission}').prop('checked', $value);\n"; 254 } 255 $default_click = "if(\$(this).is(':checked')) { $perm_check }"; 256 $reset_default = "if(!\$(this).is(':checked')) { \$('#permissions_{$usergroup['gid']}_all').prop('checked', false); }\n"; 257 $usergroup['title'] = htmlspecialchars_uni($usergroup['title']); 258 $table->construct_cell("<strong>{$usergroup['title']}</strong><br /><small style=\"vertical-align: middle;\">".$form->generate_check_box("default_permissions[{$usergroup['gid']}];", 1, "", array("id" => "default_permissions_{$usergroup['gid']}", "checked" => $default_checked, "onclick" => $default_click))." <label for=\"default_permissions_{$usergroup['gid']}\">{$lang->permissions_use_group_default}</label></small>"); 259 $table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canviewcalendar]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canviewcalendar", "checked" => $perms_checked['canviewcalendar'], "onclick" => $reset_default)), array('class' => 'align_center')); 260 $table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canaddevents]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canaddevents", "checked" => $perms_checked['canaddevents'], "onclick" => $reset_default)), array('class' => 'align_center')); 261 $table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canbypasseventmod]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canbypasseventmod", "checked" => $perms_checked['canbypasseventmod'], "onclick" => $reset_default)), array('class' => 'align_center')); 262 $table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][canmoderateevents]", 1, "", array("id" => "permissions_{$usergroup['gid']}_canmoderateevents", "checked" => $perms_checked['canmoderateevents'], "onclick" => $reset_default)), array('class' => 'align_center')); 263 $table->construct_cell($form->generate_check_box("permissions[{$usergroup['gid']}][all]", 1, "", array("id" => "permissions_{$usergroup['gid']}_all", "checked" => $all_checked, "onclick" => $all_check)), array('class' => 'align_center')); 264 $table->construct_row(); 265 } 266 $table->output("{$lang->calendar_permissions_for} {$calendar['name']}"); 267 268 $buttons[] = $form->generate_submit_button($lang->save_permissions); 269 $form->output_submit_wrapper($buttons); 270 271 $form->end(); 272 273 $page->output_footer(); 274 275 } 276 277 if($mybb->input['action'] == "edit") 278 { 279 $query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'"); 280 $calendar = $db->fetch_array($query); 281 282 // Does the calendar not exist? 283 if(!$calendar) 284 { 285 flash_message($lang->error_invalid_calendar, 'error'); 286 admin_redirect("index.php?module=config-calendars"); 287 } 288 289 $plugins->run_hooks("admin_config_calendars_edit"); 290 291 if($mybb->request_method == "post") 292 { 293 if(!trim($mybb->input['name'])) 294 { 295 $errors[] = $lang->error_missing_name; 296 } 297 298 if(!isset($mybb->input['disporder'])) 299 { 300 $errors[] = $lang->error_missing_order; 301 } 302 303 if(!$errors) 304 { 305 $updated_calendar = array( 306 "name" => $db->escape_string($mybb->input['name']), 307 "disporder" => $mybb->get_input('disporder', MyBB::INPUT_INT), 308 "startofweek" => $mybb->get_input('startofweek', MyBB::INPUT_INT), 309 "eventlimit" => $mybb->get_input('eventlimit', MyBB::INPUT_INT), 310 "showbirthdays" => $mybb->get_input('showbirthdays', MyBB::INPUT_INT), 311 "moderation" => $mybb->get_input('moderation', MyBB::INPUT_INT), 312 "allowhtml" => $mybb->get_input('allowhtml', MyBB::INPUT_INT), 313 "allowmycode" => $mybb->get_input('allowmycode', MyBB::INPUT_INT), 314 "allowimgcode" => $mybb->get_input('allowimgcode', MyBB::INPUT_INT), 315 "allowvideocode" => $mybb->get_input('allowvideocode', MyBB::INPUT_INT), 316 "allowsmilies" => $mybb->get_input('allowsmilies', MyBB::INPUT_INT) 317 ); 318 319 $plugins->run_hooks("admin_config_calendars_edit_commit"); 320 321 $db->update_query("calendars", $updated_calendar, "cid='{$calendar['cid']}'"); 322 323 // Log admin action 324 log_admin_action($calendar['cid'], $mybb->input['name']); 325 326 flash_message($lang->success_calendar_updated, 'success'); 327 admin_redirect("index.php?module=config-calendars"); 328 } 329 } 330 331 $page->add_breadcrumb_item($lang->edit_calendar); 332 $page->output_header($lang->calendars." - ".$lang->edit_calendar); 333 334 $sub_tabs['edit_calendar'] = array( 335 'title' => $lang->edit_calendar, 336 'link' => "index.php?module=config-calendars&action=edit", 337 'description' => $lang->edit_calendar_desc 338 ); 339 340 $page->output_nav_tabs($sub_tabs, 'edit_calendar'); 341 $form = new Form("index.php?module=config-calendars&action=edit", "post"); 342 343 echo $form->generate_hidden_field("cid", $calendar['cid']); 344 345 if($errors) 346 { 347 $page->output_inline_error($errors); 348 } 349 else 350 { 351 $mybb->input = $calendar; 352 } 353 354 $form_container = new FormContainer($lang->edit_calendar); 355 $form_container->output_row($lang->name." <em>*</em>", "", $form->generate_text_box('name', $mybb->input['name'], array('id' => 'name')), 'name'); 356 $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'); 357 $select_list = array($lang->sunday, $lang->monday, $lang->tuesday, $lang->wednesday, $lang->thursday, $lang->friday, $lang->saturday); 358 $form_container->output_row($lang->week_start, $lang->week_start_desc, $form->generate_select_box('startofweek', $select_list, $mybb->input['startofweek'], array('id' => 'startofweek')), 'startofweek'); 359 $form_container->output_row($lang->event_limit, $lang->event_limit_desc, $form->generate_numeric_field('eventlimit', $mybb->input['eventlimit'], array('id' => 'eventlimit', 'min' => 0)), 'eventlimit'); 360 $form_container->output_row($lang->show_birthdays, $lang->show_birthdays_desc, $form->generate_yes_no_radio('showbirthdays', $mybb->input['showbirthdays'], true)); 361 $form_container->output_row($lang->moderate_events, $lang->moderate_events_desc, $form->generate_yes_no_radio('moderation', $mybb->input['moderation'], true)); 362 $form_container->output_row($lang->allow_html, "", $form->generate_yes_no_radio('allowhtml', $mybb->input['allowhtml'])); 363 $form_container->output_row($lang->allow_mycode, "", $form->generate_yes_no_radio('allowmycode', $mybb->input['allowmycode'])); 364 $form_container->output_row($lang->allow_img, "", $form->generate_yes_no_radio('allowimgcode', $mybb->input['allowimgcode'])); 365 $form_container->output_row($lang->allow_video, "", $form->generate_yes_no_radio('allowvideocode', $mybb->input['allowvideocode'])); 366 $form_container->output_row($lang->allow_smilies, "", $form->generate_yes_no_radio('allowsmilies', $mybb->input['allowsmilies'])); 367 $form_container->end(); 368 369 $buttons[] = $form->generate_submit_button($lang->save_calendar); 370 371 $form->output_submit_wrapper($buttons); 372 $form->end(); 373 374 $page->output_footer(); 375 } 376 377 if($mybb->input['action'] == "delete") 378 { 379 $query = $db->simple_select("calendars", "*", "cid='".$mybb->get_input('cid', MyBB::INPUT_INT)."'"); 380 $calendar = $db->fetch_array($query); 381 382 // Does the calendar not exist? 383 if(!$calendar) 384 { 385 flash_message($lang->error_invalid_calendar, 'error'); 386 admin_redirect("index.php?module=config-calendars"); 387 } 388 389 $plugins->run_hooks("admin_config_calendars_delete"); 390 391 // User clicked no 392 if($mybb->get_input('no')) 393 { 394 admin_redirect("index.php?module=config-calendars"); 395 } 396 397 if($mybb->request_method == "post") 398 { 399 // Delete the calendar 400 $db->delete_query("calendars", "cid='{$calendar['cid']}'"); 401 $db->delete_query("calendarpermissions", "cid='{$calendar['cid']}'"); 402 $db->delete_query("events", "cid='{$calendar['cid']}'"); 403 404 $plugins->run_hooks("admin_config_calendars_delete_commit"); 405 406 // Log admin action 407 log_admin_action($calendar['cid'], $calendar['name']); 408 409 flash_message($lang->success_calendar_deleted, 'success'); 410 admin_redirect("index.php?module=config-calendars"); 411 } 412 else 413 { 414 $page->output_confirm_action("index.php?module=config-calendars&action=delete&cid={$calendar['cid']}", $lang->confirm_calendar_deletion); 415 } 416 } 417 418 if($mybb->input['action'] == "update_order" && $mybb->request_method == "post") 419 { 420 if(!is_array($mybb->input['disporder'])) 421 { 422 admin_redirect("index.php?module=config-calendars"); 423 } 424 425 $plugins->run_hooks("admin_config_calendars_update_order"); 426 427 foreach($mybb->input['disporder'] as $cid => $order) 428 { 429 $update_query = array( 430 "disporder" => (int)$order 431 ); 432 $db->update_query("calendars", $update_query, "cid='".(int)$cid."'"); 433 } 434 435 $plugins->run_hooks("admin_config_calendars_update_order_commit"); 436 437 // Log admin action 438 log_admin_action(); 439 440 flash_message($lang->success_calendar_orders_updated, 'success'); 441 admin_redirect("index.php?module=config-calendars"); 442 } 443 444 if(!$mybb->input['action']) 445 { 446 $page->output_header($lang->manage_calendars); 447 448 $page->output_nav_tabs($sub_tabs, 'manage_calendars'); 449 450 $form = new Form("index.php?module=config-calendars&action=update_order", "post"); 451 $table = new Table; 452 $table->construct_header($lang->calendar); 453 $table->construct_header($lang->order, array('width' => '5%', 'class' => 'align_center')); 454 $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3, "width" => 300)); 455 456 $query = $db->simple_select("calendars", "*", "", array('order_by' => 'disporder')); 457 while($calendar = $db->fetch_array($query)) 458 { 459 $calendar['name'] = htmlspecialchars_uni($calendar['name']); 460 $table->construct_cell("<a href=\"index.php?module=config-calendars&action=edit&cid={$calendar['cid']}\"><strong>{$calendar['name']}</strong></a>"); 461 $table->construct_cell($form->generate_numeric_field("disporder[{$calendar['cid']}]", $calendar['disporder'], array('id' => 'disporder', 'style' => 'width: 80%', 'class' => 'align_center', 'min' => 0))); 462 $table->construct_cell("<a href=\"index.php?module=config-calendars&action=edit&cid={$calendar['cid']}\">{$lang->edit}</a>", array("width" => 100, "class" => "align_center")); 463 $table->construct_cell("<a href=\"index.php?module=config-calendars&action=permissions&cid={$calendar['cid']}\">{$lang->permissions}</a>", array("width" => 100, "class" => "align_center")); 464 $table->construct_cell("<a href=\"index.php?module=config-calendars&action=delete&cid={$calendar['cid']}&my_post_key={$mybb->post_code}\" onclick=\"return AdminCP.deleteConfirmation(this, '{$lang->confirm_calendar_deletion}')\">{$lang->delete}</a>", array("width" => 100, "class" => "align_center")); 465 $table->construct_row(); 466 } 467 468 $no_results = false; 469 if($table->num_rows() == 0) 470 { 471 $table->construct_cell($lang->no_calendars, array('colspan' => 5)); 472 $table->construct_row(); 473 $no_results = true; 474 } 475 476 $table->output($lang->manage_calendars); 477 478 if(!$no_results) 479 { 480 $buttons[] = $form->generate_submit_button($lang->save_calendar_orders); 481 $form->output_submit_wrapper($buttons); 482 } 483 484 $form->end(); 485 486 $page->output_footer(); 487 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |