[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 /** 15 * @ignore 16 */ 17 if (!defined('IN_PHPBB')) 18 { 19 exit; 20 } 21 22 class acp_permissions 23 { 24 var $u_action; 25 var $permission_dropdown; 26 protected $permissions; 27 28 function main($id, $mode) 29 { 30 global $db, $user, $auth, $template, $cache, $phpbb_container; 31 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; 32 33 if (!function_exists('user_get_id_name')) 34 { 35 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 36 } 37 38 if (!class_exists('auth_admin')) 39 { 40 include($phpbb_root_path . 'includes/acp/auth.' . $phpEx); 41 } 42 43 $this->permissions = $phpbb_container->get('acl.permissions'); 44 45 $auth_admin = new auth_admin(); 46 47 $user->add_lang('acp/permissions'); 48 add_permission_language(); 49 50 $this->tpl_name = 'acp_permissions'; 51 52 // Trace has other vars 53 if ($mode == 'trace') 54 { 55 $user_id = request_var('u', 0); 56 $forum_id = request_var('f', 0); 57 $permission = request_var('auth', ''); 58 59 $this->tpl_name = 'permission_trace'; 60 61 if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) 62 { 63 $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $this->permissions->get_permission_lang($permission)); 64 $this->permission_trace($user_id, $forum_id, $permission); 65 return; 66 } 67 trigger_error('NO_MODE', E_USER_ERROR); 68 } 69 70 // Copy forum permissions 71 if ($mode == 'setting_forum_copy') 72 { 73 $this->tpl_name = 'permission_forum_copy'; 74 75 if ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) 76 { 77 $this->page_title = 'ACP_FORUM_PERMISSIONS_COPY'; 78 $this->copy_forum_permissions(); 79 return; 80 } 81 82 trigger_error('NO_MODE', E_USER_ERROR); 83 } 84 85 // Set some vars 86 $action = request_var('action', array('' => 0)); 87 $action = key($action); 88 $action = (isset($_POST['psubmit'])) ? 'apply_permissions' : $action; 89 90 $all_forums = request_var('all_forums', 0); 91 $subforum_id = request_var('subforum_id', 0); 92 $forum_id = request_var('forum_id', array(0)); 93 94 $username = request_var('username', array(''), true); 95 $usernames = request_var('usernames', '', true); 96 $user_id = request_var('user_id', array(0)); 97 98 $group_id = request_var('group_id', array(0)); 99 $select_all_groups = request_var('select_all_groups', 0); 100 101 $form_name = 'acp_permissions'; 102 add_form_key($form_name); 103 104 // If select all groups is set, we pre-build the group id array (this option is used for other screens to link to the permission settings screen) 105 if ($select_all_groups) 106 { 107 // Add default groups to selection 108 $sql_and = (!$config['coppa_enable']) ? " AND group_name <> 'REGISTERED_COPPA'" : ''; 109 110 $sql = 'SELECT group_id 111 FROM ' . GROUPS_TABLE . ' 112 WHERE group_type = ' . GROUP_SPECIAL . " 113 $sql_and"; 114 $result = $db->sql_query($sql); 115 116 while ($row = $db->sql_fetchrow($result)) 117 { 118 $group_id[] = $row['group_id']; 119 } 120 $db->sql_freeresult($result); 121 } 122 123 // Map usernames to ids and vice versa 124 if ($usernames) 125 { 126 $username = explode("\n", $usernames); 127 } 128 unset($usernames); 129 130 if (sizeof($username) && !sizeof($user_id)) 131 { 132 user_get_id_name($user_id, $username); 133 134 if (!sizeof($user_id)) 135 { 136 trigger_error($user->lang['SELECTED_USER_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 137 } 138 } 139 unset($username); 140 141 // Build forum ids (of all forums are checked or subforum listing used) 142 if ($all_forums) 143 { 144 $sql = 'SELECT forum_id 145 FROM ' . FORUMS_TABLE . ' 146 ORDER BY left_id'; 147 $result = $db->sql_query($sql); 148 149 $forum_id = array(); 150 while ($row = $db->sql_fetchrow($result)) 151 { 152 $forum_id[] = (int) $row['forum_id']; 153 } 154 $db->sql_freeresult($result); 155 } 156 else if ($subforum_id) 157 { 158 $forum_id = array(); 159 foreach (get_forum_branch($subforum_id, 'children') as $row) 160 { 161 $forum_id[] = (int) $row['forum_id']; 162 } 163 } 164 165 // Define some common variables for every mode 166 $error = array(); 167 168 $permission_scope = (strpos($mode, '_global') !== false) ? 'global' : 'local'; 169 170 // Showing introductionary page? 171 if ($mode == 'intro') 172 { 173 $this->page_title = 'ACP_PERMISSIONS'; 174 175 $template->assign_vars(array( 176 'S_INTRO' => true) 177 ); 178 179 return; 180 } 181 182 switch ($mode) 183 { 184 case 'setting_user_global': 185 case 'setting_group_global': 186 $this->permission_dropdown = array('u_', 'm_', 'a_'); 187 $permission_victim = ($mode == 'setting_user_global') ? array('user') : array('group'); 188 $this->page_title = ($mode == 'setting_user_global') ? 'ACP_USERS_PERMISSIONS' : 'ACP_GROUPS_PERMISSIONS'; 189 break; 190 191 case 'setting_user_local': 192 case 'setting_group_local': 193 $this->permission_dropdown = array('f_', 'm_'); 194 $permission_victim = ($mode == 'setting_user_local') ? array('user', 'forums') : array('group', 'forums'); 195 $this->page_title = ($mode == 'setting_user_local') ? 'ACP_USERS_FORUM_PERMISSIONS' : 'ACP_GROUPS_FORUM_PERMISSIONS'; 196 break; 197 198 case 'setting_admin_global': 199 case 'setting_mod_global': 200 $this->permission_dropdown = (strpos($mode, '_admin_') !== false) ? array('a_') : array('m_'); 201 $permission_victim = array('usergroup'); 202 $this->page_title = ($mode == 'setting_admin_global') ? 'ACP_ADMINISTRATORS' : 'ACP_GLOBAL_MODERATORS'; 203 break; 204 205 case 'setting_mod_local': 206 case 'setting_forum_local': 207 $this->permission_dropdown = ($mode == 'setting_mod_local') ? array('m_') : array('f_'); 208 $permission_victim = array('forums', 'usergroup'); 209 $this->page_title = ($mode == 'setting_mod_local') ? 'ACP_FORUM_MODERATORS' : 'ACP_FORUM_PERMISSIONS'; 210 break; 211 212 case 'view_admin_global': 213 case 'view_user_global': 214 case 'view_mod_global': 215 $this->permission_dropdown = ($mode == 'view_admin_global') ? array('a_') : (($mode == 'view_user_global') ? array('u_') : array('m_')); 216 $permission_victim = array('usergroup_view'); 217 $this->page_title = ($mode == 'view_admin_global') ? 'ACP_VIEW_ADMIN_PERMISSIONS' : (($mode == 'view_user_global') ? 'ACP_VIEW_USER_PERMISSIONS' : 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS'); 218 break; 219 220 case 'view_mod_local': 221 case 'view_forum_local': 222 $this->permission_dropdown = ($mode == 'view_mod_local') ? array('m_') : array('f_'); 223 $permission_victim = array('forums', 'usergroup_view'); 224 $this->page_title = ($mode == 'view_mod_local') ? 'ACP_VIEW_FORUM_MOD_PERMISSIONS' : 'ACP_VIEW_FORUM_PERMISSIONS'; 225 break; 226 227 default: 228 trigger_error('NO_MODE', E_USER_ERROR); 229 break; 230 } 231 232 $template->assign_vars(array( 233 'L_TITLE' => $user->lang[$this->page_title], 234 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN']) 235 ); 236 237 // Get permission type 238 $permission_type = request_var('type', $this->permission_dropdown[0]); 239 240 if (!in_array($permission_type, $this->permission_dropdown)) 241 { 242 trigger_error($user->lang['WRONG_PERMISSION_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING); 243 } 244 245 // Handle actions 246 if (strpos($mode, 'setting_') === 0 && $action) 247 { 248 switch ($action) 249 { 250 case 'delete': 251 if (confirm_box(true)) 252 { 253 // All users/groups selected? 254 $all_users = (isset($_POST['all_users'])) ? true : false; 255 $all_groups = (isset($_POST['all_groups'])) ? true : false; 256 257 if ($all_users || $all_groups) 258 { 259 $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); 260 261 if ($all_users && sizeof($items['user_ids'])) 262 { 263 $user_id = $items['user_ids']; 264 } 265 else if ($all_groups && sizeof($items['group_ids'])) 266 { 267 $group_id = $items['group_ids']; 268 } 269 } 270 271 if (sizeof($user_id) || sizeof($group_id)) 272 { 273 $this->remove_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id, $forum_id); 274 } 275 else 276 { 277 trigger_error($user->lang['NO_USER_GROUP_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); 278 } 279 } 280 else 281 { 282 if (isset($_POST['cancel'])) 283 { 284 $u_redirect = $this->u_action . '&type=' . $permission_type; 285 foreach ($forum_id as $fid) 286 { 287 $u_redirect .= '&forum_id[]=' . $fid; 288 } 289 redirect($u_redirect); 290 } 291 292 $s_hidden_fields = array( 293 'i' => $id, 294 'mode' => $mode, 295 'action' => array($action => 1), 296 'user_id' => $user_id, 297 'group_id' => $group_id, 298 'forum_id' => $forum_id, 299 'type' => $permission_type, 300 ); 301 if (isset($_POST['all_users'])) 302 { 303 $s_hidden_fields['all_users'] = 1; 304 } 305 if (isset($_POST['all_groups'])) 306 { 307 $s_hidden_fields['all_groups'] = 1; 308 } 309 confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); 310 } 311 break; 312 313 case 'apply_permissions': 314 if (!isset($_POST['setting'])) 315 { 316 trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); 317 } 318 if (!check_form_key($form_name)) 319 { 320 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); 321 } 322 323 $this->set_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); 324 break; 325 326 case 'apply_all_permissions': 327 if (!isset($_POST['setting'])) 328 { 329 trigger_error($user->lang['NO_AUTH_SETTING_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); 330 } 331 if (!check_form_key($form_name)) 332 { 333 trigger_error($user->lang['FORM_INVALID']. adm_back_link($this->u_action), E_USER_WARNING); 334 } 335 336 $this->set_all_permissions($mode, $permission_type, $auth_admin, $user_id, $group_id); 337 break; 338 } 339 } 340 341 // Go through the screens/options needed and present them in correct order 342 foreach ($permission_victim as $victim) 343 { 344 switch ($victim) 345 { 346 case 'forum_dropdown': 347 348 if (sizeof($forum_id)) 349 { 350 $this->check_existence('forum', $forum_id); 351 continue 2; 352 } 353 354 $template->assign_vars(array( 355 'S_SELECT_FORUM' => true, 356 'S_FORUM_OPTIONS' => make_forum_select(false, false, true, false, false)) 357 ); 358 359 break; 360 361 case 'forums': 362 363 if (sizeof($forum_id)) 364 { 365 $this->check_existence('forum', $forum_id); 366 continue 2; 367 } 368 369 $forum_list = make_forum_select(false, false, true, false, false, false, true); 370 371 // Build forum options 372 $s_forum_options = ''; 373 foreach ($forum_list as $f_id => $f_row) 374 { 375 $s_forum_options .= '<option value="' . $f_id . '"' . (($f_row['selected']) ? ' selected="selected"' : '') . (($f_row['disabled']) ? ' disabled="disabled" class="disabled-option"' : '') . '>' . $f_row['padding'] . $f_row['forum_name'] . '</option>'; 376 } 377 378 // Build subforum options 379 $s_subforum_options = $this->build_subforum_options($forum_list); 380 381 $template->assign_vars(array( 382 'S_SELECT_FORUM' => true, 383 'S_FORUM_OPTIONS' => $s_forum_options, 384 'S_SUBFORUM_OPTIONS' => $s_subforum_options, 385 'S_FORUM_ALL' => true, 386 'S_FORUM_MULTIPLE' => true) 387 ); 388 389 break; 390 391 case 'user': 392 393 if (sizeof($user_id)) 394 { 395 $this->check_existence('user', $user_id); 396 continue 2; 397 } 398 399 $template->assign_vars(array( 400 'S_SELECT_USER' => true, 401 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=select_victim&field=username&select_single=true'), 402 )); 403 404 break; 405 406 case 'group': 407 408 if (sizeof($group_id)) 409 { 410 $this->check_existence('group', $group_id); 411 continue 2; 412 } 413 414 $template->assign_vars(array( 415 'S_SELECT_GROUP' => true, 416 'S_GROUP_OPTIONS' => group_select_options(false, false, false), // Show all groups 417 )); 418 419 break; 420 421 case 'usergroup': 422 case 'usergroup_view': 423 424 $all_users = (isset($_POST['all_users'])) ? true : false; 425 $all_groups = (isset($_POST['all_groups'])) ? true : false; 426 427 if ((sizeof($user_id) && !$all_users) || (sizeof($group_id) && !$all_groups)) 428 { 429 if (sizeof($user_id)) 430 { 431 $this->check_existence('user', $user_id); 432 } 433 434 if (sizeof($group_id)) 435 { 436 $this->check_existence('group', $group_id); 437 } 438 439 continue 2; 440 } 441 442 // Now we check the users... because the "all"-selection is different here (all defined users/groups) 443 $items = $this->retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type); 444 445 if ($all_users && sizeof($items['user_ids'])) 446 { 447 $user_id = $items['user_ids']; 448 continue 2; 449 } 450 451 if ($all_groups && sizeof($items['group_ids'])) 452 { 453 $group_id = $items['group_ids']; 454 continue 2; 455 } 456 457 $template->assign_vars(array( 458 'S_SELECT_USERGROUP' => ($victim == 'usergroup') ? true : false, 459 'S_SELECT_USERGROUP_VIEW' => ($victim == 'usergroup_view') ? true : false, 460 'S_DEFINED_USER_OPTIONS' => $items['user_ids_options'], 461 'S_DEFINED_GROUP_OPTIONS' => $items['group_ids_options'], 462 'S_ADD_GROUP_OPTIONS' => group_select_options(false, $items['group_ids'], false), // Show all groups 463 'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=add_user&field=username&select_single=true'), 464 )); 465 466 break; 467 } 468 469 // The S_ALLOW_SELECT parameter below is a measure to lower memory usage. 470 // If there are more than 5 forums selected the admin is not able to select all users/groups too. 471 // We need to see if the number of forums can be increased or need to be decreased. 472 473 // Setting permissions screen 474 $s_hidden_fields = build_hidden_fields(array( 475 'user_id' => $user_id, 476 'group_id' => $group_id, 477 'forum_id' => $forum_id, 478 'type' => $permission_type, 479 )); 480 481 $template->assign_vars(array( 482 'U_ACTION' => $this->u_action, 483 'ANONYMOUS_USER_ID' => ANONYMOUS, 484 485 'S_SELECT_VICTIM' => true, 486 'S_ALLOW_ALL_SELECT' => (sizeof($forum_id) > 5) ? false : true, 487 'S_CAN_SELECT_USER' => ($auth->acl_get('a_authusers')) ? true : false, 488 'S_CAN_SELECT_GROUP' => ($auth->acl_get('a_authgroups')) ? true : false, 489 'S_HIDDEN_FIELDS' => $s_hidden_fields) 490 ); 491 492 // Let the forum names being displayed 493 if (sizeof($forum_id)) 494 { 495 $sql = 'SELECT forum_name 496 FROM ' . FORUMS_TABLE . ' 497 WHERE ' . $db->sql_in_set('forum_id', $forum_id) . ' 498 ORDER BY left_id ASC'; 499 $result = $db->sql_query($sql); 500 501 $forum_names = array(); 502 while ($row = $db->sql_fetchrow($result)) 503 { 504 $forum_names[] = $row['forum_name']; 505 } 506 $db->sql_freeresult($result); 507 508 $template->assign_vars(array( 509 'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false, 510 'FORUM_NAMES' => implode($user->lang['COMMA_SEPARATOR'], $forum_names)) 511 ); 512 } 513 514 return; 515 } 516 517 // Setting permissions screen 518 $s_hidden_fields = build_hidden_fields(array( 519 'user_id' => $user_id, 520 'group_id' => $group_id, 521 'forum_id' => $forum_id, 522 'type' => $permission_type, 523 )); 524 525 // Do not allow forum_ids being set and no other setting defined (will bog down the server too much) 526 if (sizeof($forum_id) && !sizeof($user_id) && !sizeof($group_id)) 527 { 528 trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); 529 } 530 531 $template->assign_vars(array( 532 'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, 533 'L_PERMISSION_TYPE' => $this->permissions->get_type_lang($permission_type), 534 535 'U_ACTION' => $this->u_action, 536 'S_HIDDEN_FIELDS' => $s_hidden_fields) 537 ); 538 539 if (strpos($mode, 'setting_') === 0) 540 { 541 $template->assign_vars(array( 542 'S_SETTING_PERMISSIONS' => true) 543 ); 544 545 $hold_ary = $auth_admin->get_mask('set', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NO); 546 $auth_admin->display_mask('set', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); 547 } 548 else 549 { 550 $template->assign_vars(array( 551 'S_VIEWING_PERMISSIONS' => true) 552 ); 553 554 $hold_ary = $auth_admin->get_mask('view', (sizeof($user_id)) ? $user_id : false, (sizeof($group_id)) ? $group_id : false, (sizeof($forum_id)) ? $forum_id : false, $permission_type, $permission_scope, ACL_NEVER); 555 $auth_admin->display_mask('view', $permission_type, $hold_ary, ((sizeof($user_id)) ? 'user' : 'group'), (($permission_scope == 'local') ? true : false)); 556 } 557 } 558 559 /** 560 * Build +subforum options 561 */ 562 function build_subforum_options($forum_list) 563 { 564 global $user; 565 566 $s_options = ''; 567 568 $forum_list = array_merge($forum_list); 569 570 foreach ($forum_list as $key => $row) 571 { 572 if ($row['disabled']) 573 { 574 continue; 575 } 576 577 $s_options .= '<option value="' . $row['forum_id'] . '"' . (($row['selected']) ? ' selected="selected"' : '') . '>' . $row['padding'] . $row['forum_name']; 578 579 // We check if a branch is there... 580 $branch_there = false; 581 582 foreach (array_slice($forum_list, $key + 1) as $temp_row) 583 { 584 if ($temp_row['left_id'] > $row['left_id'] && $temp_row['left_id'] < $row['right_id']) 585 { 586 $branch_there = true; 587 break; 588 } 589 continue; 590 } 591 592 if ($branch_there) 593 { 594 $s_options .= ' [' . $user->lang['PLUS_SUBFORUMS'] . ']'; 595 } 596 597 $s_options .= '</option>'; 598 } 599 600 return $s_options; 601 } 602 603 /** 604 * Build dropdown field for changing permission types 605 */ 606 function build_permission_dropdown($options, $default_option, $permission_scope) 607 { 608 global $auth; 609 610 $s_dropdown_options = ''; 611 foreach ($options as $setting) 612 { 613 if (!$auth->acl_get('a_' . str_replace('_', '', $setting) . 'auth')) 614 { 615 continue; 616 } 617 618 $selected = ($setting == $default_option) ? ' selected="selected"' : ''; 619 $l_setting = $this->permissions->get_type_lang($setting, $permission_scope); 620 $s_dropdown_options .= '<option value="' . $setting . '"' . $selected . '>' . $l_setting . '</option>'; 621 } 622 623 return $s_dropdown_options; 624 } 625 626 /** 627 * Check if selected items exist. Remove not found ids and if empty return error. 628 */ 629 function check_existence($mode, &$ids) 630 { 631 global $db, $user; 632 633 switch ($mode) 634 { 635 case 'user': 636 $table = USERS_TABLE; 637 $sql_id = 'user_id'; 638 break; 639 640 case 'group': 641 $table = GROUPS_TABLE; 642 $sql_id = 'group_id'; 643 break; 644 645 case 'forum': 646 $table = FORUMS_TABLE; 647 $sql_id = 'forum_id'; 648 break; 649 } 650 651 if (sizeof($ids)) 652 { 653 $sql = "SELECT $sql_id 654 FROM $table 655 WHERE " . $db->sql_in_set($sql_id, $ids); 656 $result = $db->sql_query($sql); 657 658 $ids = array(); 659 while ($row = $db->sql_fetchrow($result)) 660 { 661 $ids[] = (int) $row[$sql_id]; 662 } 663 $db->sql_freeresult($result); 664 } 665 666 if (!sizeof($ids)) 667 { 668 trigger_error($user->lang['SELECTED_' . strtoupper($mode) . '_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 669 } 670 } 671 672 /** 673 * Apply permissions 674 */ 675 function set_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) 676 { 677 global $db, $cache, $user, $auth; 678 global $request; 679 680 $psubmit = request_var('psubmit', array(0 => array(0 => 0))); 681 682 // User or group to be set? 683 $ug_type = (sizeof($user_id)) ? 'user' : 'group'; 684 685 // Check the permission setting again 686 if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) 687 { 688 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); 689 } 690 691 $ug_id = $forum_id = 0; 692 693 // We loop through the auth settings defined in our submit 694 list($ug_id, ) = each($psubmit); 695 list($forum_id, ) = each($psubmit[$ug_id]); 696 697 $settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); 698 if (empty($settings) || empty($settings[$ug_id]) || empty($settings[$ug_id][$forum_id])) 699 { 700 trigger_error('WRONG_PERMISSION_SETTING_FORMAT', E_USER_WARNING); 701 } 702 703 $auth_settings = $settings[$ug_id][$forum_id]; 704 705 // Do we have a role we want to set? 706 $roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); 707 $assigned_role = (isset($roles[$ug_id][$forum_id])) ? (int) $roles[$ug_id][$forum_id] : 0; 708 709 // Do the admin want to set these permissions to other items too? 710 $inherit = request_var('inherit', array(0 => array(0))); 711 712 $ug_id = array($ug_id); 713 $forum_id = array($forum_id); 714 715 if (sizeof($inherit)) 716 { 717 foreach ($inherit as $_ug_id => $forum_id_ary) 718 { 719 // Inherit users/groups? 720 if (!in_array($_ug_id, $ug_id)) 721 { 722 $ug_id[] = $_ug_id; 723 } 724 725 // Inherit forums? 726 $forum_id = array_merge($forum_id, array_keys($forum_id_ary)); 727 } 728 } 729 730 $forum_id = array_unique($forum_id); 731 732 // If the auth settings differ from the assigned role, then do not set a role... 733 if ($assigned_role) 734 { 735 if (!$this->check_assigned_role($assigned_role, $auth_settings)) 736 { 737 $assigned_role = 0; 738 } 739 } 740 741 // Update the permission set... 742 $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_settings, $assigned_role); 743 744 // Do we need to recache the moderator lists? 745 if ($permission_type == 'm_') 746 { 747 phpbb_cache_moderators($db, $cache, $auth); 748 } 749 750 // Remove users who are now moderators or admins from everyones foes list 751 if ($permission_type == 'm_' || $permission_type == 'a_') 752 { 753 phpbb_update_foes($db, $auth, $group_id, $user_id); 754 } 755 756 $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_id, $forum_id); 757 758 meta_refresh(5, $this->u_action); 759 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 760 } 761 762 /** 763 * Apply all permissions 764 */ 765 function set_all_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id) 766 { 767 global $db, $cache, $user, $auth; 768 global $request; 769 770 // User or group to be set? 771 $ug_type = (sizeof($user_id)) ? 'user' : 'group'; 772 773 // Check the permission setting again 774 if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) 775 { 776 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); 777 } 778 779 $auth_settings = $request->variable('setting', array(0 => array(0 => array('' => 0))), false, \phpbb\request\request_interface::POST); 780 $auth_roles = $request->variable('role', array(0 => array(0 => 0)), false, \phpbb\request\request_interface::POST); 781 $ug_ids = $forum_ids = array(); 782 783 // We need to go through the auth settings 784 foreach ($auth_settings as $ug_id => $forum_auth_row) 785 { 786 $ug_id = (int) $ug_id; 787 $ug_ids[] = $ug_id; 788 789 foreach ($forum_auth_row as $forum_id => $auth_options) 790 { 791 $forum_id = (int) $forum_id; 792 $forum_ids[] = $forum_id; 793 794 // Check role... 795 $assigned_role = (isset($auth_roles[$ug_id][$forum_id])) ? (int) $auth_roles[$ug_id][$forum_id] : 0; 796 797 // If the auth settings differ from the assigned role, then do not set a role... 798 if ($assigned_role) 799 { 800 if (!$this->check_assigned_role($assigned_role, $auth_options)) 801 { 802 $assigned_role = 0; 803 } 804 } 805 806 // Update the permission set... 807 $auth_admin->acl_set($ug_type, $forum_id, $ug_id, $auth_options, $assigned_role, false); 808 } 809 } 810 811 $auth_admin->acl_clear_prefetch(); 812 813 // Do we need to recache the moderator lists? 814 if ($permission_type == 'm_') 815 { 816 phpbb_cache_moderators($db, $cache, $auth); 817 } 818 819 // Remove users who are now moderators or admins from everyones foes list 820 if ($permission_type == 'm_' || $permission_type == 'a_') 821 { 822 phpbb_update_foes($db, $auth, $group_id, $user_id); 823 } 824 825 $this->log_action($mode, 'add', $permission_type, $ug_type, $ug_ids, $forum_ids); 826 827 if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') 828 { 829 meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids)); 830 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_ids))); 831 } 832 else 833 { 834 meta_refresh(5, $this->u_action); 835 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 836 } 837 } 838 839 /** 840 * Compare auth settings with auth settings from role 841 * returns false if they differ, true if they are equal 842 */ 843 function check_assigned_role($role_id, &$auth_settings) 844 { 845 global $db; 846 847 $sql = 'SELECT o.auth_option, r.auth_setting 848 FROM ' . ACL_OPTIONS_TABLE . ' o, ' . ACL_ROLES_DATA_TABLE . ' r 849 WHERE o.auth_option_id = r.auth_option_id 850 AND r.role_id = ' . $role_id; 851 $result = $db->sql_query($sql); 852 853 $test_auth_settings = array(); 854 while ($row = $db->sql_fetchrow($result)) 855 { 856 $test_auth_settings[$row['auth_option']] = $row['auth_setting']; 857 } 858 $db->sql_freeresult($result); 859 860 // We need to add any ACL_NO setting from auth_settings to compare correctly 861 foreach ($auth_settings as $option => $setting) 862 { 863 if ($setting == ACL_NO) 864 { 865 $test_auth_settings[$option] = $setting; 866 } 867 } 868 869 if (sizeof(array_diff_assoc($auth_settings, $test_auth_settings))) 870 { 871 return false; 872 } 873 874 return true; 875 } 876 877 /** 878 * Remove permissions 879 */ 880 function remove_permissions($mode, $permission_type, &$auth_admin, &$user_id, &$group_id, &$forum_id) 881 { 882 global $user, $db, $cache, $auth; 883 884 // User or group to be set? 885 $ug_type = (sizeof($user_id)) ? 'user' : 'group'; 886 887 // Check the permission setting again 888 if (!$auth->acl_get('a_' . str_replace('_', '', $permission_type) . 'auth') || !$auth->acl_get('a_auth' . $ug_type . 's')) 889 { 890 trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); 891 } 892 893 $auth_admin->acl_delete($ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : false), $permission_type); 894 895 // Do we need to recache the moderator lists? 896 if ($permission_type == 'm_') 897 { 898 phpbb_cache_moderators($db, $cache, $auth); 899 } 900 901 $this->log_action($mode, 'del', $permission_type, $ug_type, (($ug_type == 'user') ? $user_id : $group_id), (sizeof($forum_id) ? $forum_id : array(0 => 0))); 902 903 if ($mode == 'setting_forum_local' || $mode == 'setting_mod_local') 904 { 905 meta_refresh(5, $this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id)); 906 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action . '&forum_id[]=' . implode('&forum_id[]=', $forum_id))); 907 } 908 else 909 { 910 meta_refresh(5, $this->u_action); 911 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 912 } 913 } 914 915 /** 916 * Log permission changes 917 */ 918 function log_action($mode, $action, $permission_type, $ug_type, $ug_id, $forum_id) 919 { 920 global $db, $user; 921 922 if (!is_array($ug_id)) 923 { 924 $ug_id = array($ug_id); 925 } 926 927 if (!is_array($forum_id)) 928 { 929 $forum_id = array($forum_id); 930 } 931 932 // Logging ... first grab user or groupnames ... 933 $sql = ($ug_type == 'group') ? 'SELECT group_name as name, group_type FROM ' . GROUPS_TABLE . ' WHERE ' : 'SELECT username as name FROM ' . USERS_TABLE . ' WHERE '; 934 $sql .= $db->sql_in_set(($ug_type == 'group') ? 'group_id' : 'user_id', array_map('intval', $ug_id)); 935 $result = $db->sql_query($sql); 936 937 $l_ug_list = ''; 938 while ($row = $db->sql_fetchrow($result)) 939 { 940 $l_ug_list .= (($l_ug_list != '') ? ', ' : '') . ((isset($row['group_type']) && $row['group_type'] == GROUP_SPECIAL) ? '<span class="sep">' . $user->lang['G_' . $row['name']] . '</span>' : $row['name']); 941 } 942 $db->sql_freeresult($result); 943 944 $mode = str_replace('setting_', '', $mode); 945 946 if ($forum_id[0] == 0) 947 { 948 add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_ug_list); 949 } 950 else 951 { 952 // Grab the forum details if non-zero forum_id 953 $sql = 'SELECT forum_name 954 FROM ' . FORUMS_TABLE . ' 955 WHERE ' . $db->sql_in_set('forum_id', $forum_id); 956 $result = $db->sql_query($sql); 957 958 $l_forum_list = ''; 959 while ($row = $db->sql_fetchrow($result)) 960 { 961 $l_forum_list .= (($l_forum_list != '') ? ', ' : '') . $row['forum_name']; 962 } 963 $db->sql_freeresult($result); 964 965 add_log('admin', 'LOG_ACL_' . strtoupper($action) . '_' . strtoupper($mode) . '_' . strtoupper($permission_type), $l_forum_list, $l_ug_list); 966 } 967 } 968 969 /** 970 * Display a complete trace tree for the selected permission to determine where settings are set/unset 971 */ 972 function permission_trace($user_id, $forum_id, $permission) 973 { 974 global $db, $template, $user, $auth; 975 976 if ($user_id != $user->data['user_id']) 977 { 978 $userdata = $auth->obtain_user_data($user_id); 979 } 980 else 981 { 982 $userdata = $user->data; 983 } 984 985 if (!$userdata) 986 { 987 trigger_error('NO_USERS', E_USER_ERROR); 988 } 989 990 $forum_name = false; 991 992 if ($forum_id) 993 { 994 $sql = 'SELECT forum_name 995 FROM ' . FORUMS_TABLE . " 996 WHERE forum_id = $forum_id"; 997 $result = $db->sql_query($sql, 3600); 998 $forum_name = $db->sql_fetchfield('forum_name'); 999 $db->sql_freeresult($result); 1000 } 1001 1002 $back = request_var('back', 0); 1003 1004 $template->assign_vars(array( 1005 'PERMISSION' => $this->permissions->get_permission_lang($permission), 1006 'PERMISSION_USERNAME' => $userdata['username'], 1007 'FORUM_NAME' => $forum_name, 1008 1009 'S_GLOBAL_TRACE' => ($forum_id) ? false : true, 1010 1011 'U_BACK' => ($back) ? build_url(array('f', 'back')) . "&f=$back" : '') 1012 ); 1013 1014 $template->assign_block_vars('trace', array( 1015 'WHO' => $user->lang['DEFAULT'], 1016 'INFORMATION' => $user->lang['TRACE_DEFAULT'], 1017 1018 'S_SETTING_NO' => true, 1019 'S_TOTAL_NO' => true) 1020 ); 1021 1022 $sql = 'SELECT DISTINCT g.group_name, g.group_id, g.group_type 1023 FROM ' . GROUPS_TABLE . ' g 1024 LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (ug.group_id = g.group_id) 1025 WHERE ug.user_id = ' . $user_id . ' 1026 AND ug.user_pending = 0 1027 AND NOT (ug.group_leader = 1 AND g.group_skip_auth = 1) 1028 ORDER BY g.group_type DESC, g.group_id DESC'; 1029 $result = $db->sql_query($sql); 1030 1031 $groups = array(); 1032 while ($row = $db->sql_fetchrow($result)) 1033 { 1034 $groups[$row['group_id']] = array( 1035 'auth_setting' => ACL_NO, 1036 'group_name' => ($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name'] 1037 ); 1038 } 1039 $db->sql_freeresult($result); 1040 1041 $total = ACL_NO; 1042 $add_key = (($forum_id) ? '_LOCAL' : ''); 1043 1044 if (sizeof($groups)) 1045 { 1046 // Get group auth settings 1047 $hold_ary = $auth->acl_group_raw_data(array_keys($groups), $permission, $forum_id); 1048 1049 foreach ($hold_ary as $group_id => $forum_ary) 1050 { 1051 $groups[$group_id]['auth_setting'] = $hold_ary[$group_id][$forum_id][$permission]; 1052 } 1053 unset($hold_ary); 1054 1055 foreach ($groups as $id => $row) 1056 { 1057 switch ($row['auth_setting']) 1058 { 1059 case ACL_NO: 1060 $information = $user->lang['TRACE_GROUP_NO' . $add_key]; 1061 break; 1062 1063 case ACL_YES: 1064 $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_YES_TOTAL_NO' . $add_key]); 1065 $total = ($total == ACL_NO) ? ACL_YES : $total; 1066 break; 1067 1068 case ACL_NEVER: 1069 $information = ($total == ACL_YES) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_GROUP_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_GROUP_NEVER_TOTAL_NO' . $add_key]); 1070 $total = ACL_NEVER; 1071 break; 1072 } 1073 1074 $template->assign_block_vars('trace', array( 1075 'WHO' => $row['group_name'], 1076 'INFORMATION' => $information, 1077 1078 'S_SETTING_NO' => ($row['auth_setting'] == ACL_NO) ? true : false, 1079 'S_SETTING_YES' => ($row['auth_setting'] == ACL_YES) ? true : false, 1080 'S_SETTING_NEVER' => ($row['auth_setting'] == ACL_NEVER) ? true : false, 1081 'S_TOTAL_NO' => ($total == ACL_NO) ? true : false, 1082 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, 1083 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) 1084 ); 1085 } 1086 } 1087 1088 // Get user specific permission... globally or for this forum 1089 $hold_ary = $auth->acl_user_raw_data($user_id, $permission, $forum_id); 1090 $auth_setting = (!sizeof($hold_ary)) ? ACL_NO : $hold_ary[$user_id][$forum_id][$permission]; 1091 1092 switch ($auth_setting) 1093 { 1094 case ACL_NO: 1095 $information = ($total == ACL_NO) ? $user->lang['TRACE_USER_NO_TOTAL_NO' . $add_key] : $user->lang['TRACE_USER_KEPT' . $add_key]; 1096 $total = ($total == ACL_NO) ? ACL_NEVER : $total; 1097 break; 1098 1099 case ACL_YES: 1100 $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_YES_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_YES_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_YES_TOTAL_NO' . $add_key]); 1101 $total = ($total == ACL_NO) ? ACL_YES : $total; 1102 break; 1103 1104 case ACL_NEVER: 1105 $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_NEVER_TOTAL_YES' . $add_key] : (($total == ACL_NEVER) ? $user->lang['TRACE_USER_NEVER_TOTAL_NEVER' . $add_key] : $user->lang['TRACE_USER_NEVER_TOTAL_NO' . $add_key]); 1106 $total = ACL_NEVER; 1107 break; 1108 } 1109 1110 $template->assign_block_vars('trace', array( 1111 'WHO' => $userdata['username'], 1112 'INFORMATION' => $information, 1113 1114 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, 1115 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, 1116 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, 1117 'S_TOTAL_NO' => false, 1118 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, 1119 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) 1120 ); 1121 1122 if ($forum_id != 0 && isset($auth->acl_options['global'][$permission])) 1123 { 1124 if ($user_id != $user->data['user_id']) 1125 { 1126 $auth2 = new \phpbb\auth\auth(); 1127 $auth2->acl($userdata); 1128 $auth_setting = $auth2->acl_get($permission); 1129 } 1130 else 1131 { 1132 $auth_setting = $auth->acl_get($permission); 1133 } 1134 1135 if ($auth_setting) 1136 { 1137 $information = ($total == ACL_YES) ? $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_YES'] : $user->lang['TRACE_USER_GLOBAL_YES_TOTAL_NEVER']; 1138 $total = ACL_YES; 1139 } 1140 else 1141 { 1142 $information = $user->lang['TRACE_USER_GLOBAL_NEVER_TOTAL_KEPT']; 1143 } 1144 1145 // If there is no auth information we do not need to worry the user by showing non-relevant data. 1146 if ($auth_setting) 1147 { 1148 $template->assign_block_vars('trace', array( 1149 'WHO' => sprintf($user->lang['TRACE_GLOBAL_SETTING'], $userdata['username']), 1150 'INFORMATION' => sprintf($information, '<a href="' . $this->u_action . "&u=$user_id&f=0&auth=$permission&back=$forum_id\">", '</a>'), 1151 1152 'S_SETTING_NO' => false, 1153 'S_SETTING_YES' => $auth_setting, 1154 'S_SETTING_NEVER' => !$auth_setting, 1155 'S_TOTAL_NO' => false, 1156 'S_TOTAL_YES' => ($total == ACL_YES) ? true : false, 1157 'S_TOTAL_NEVER' => ($total == ACL_NEVER) ? true : false) 1158 ); 1159 } 1160 } 1161 1162 // Take founder status into account, overwriting the default values 1163 if ($userdata['user_type'] == USER_FOUNDER && strpos($permission, 'a_') === 0) 1164 { 1165 $template->assign_block_vars('trace', array( 1166 'WHO' => $userdata['username'], 1167 'INFORMATION' => $user->lang['TRACE_USER_FOUNDER'], 1168 1169 'S_SETTING_NO' => ($auth_setting == ACL_NO) ? true : false, 1170 'S_SETTING_YES' => ($auth_setting == ACL_YES) ? true : false, 1171 'S_SETTING_NEVER' => ($auth_setting == ACL_NEVER) ? true : false, 1172 'S_TOTAL_NO' => false, 1173 'S_TOTAL_YES' => true, 1174 'S_TOTAL_NEVER' => false) 1175 ); 1176 1177 $total = ACL_YES; 1178 } 1179 1180 // Total value... 1181 $template->assign_vars(array( 1182 'S_RESULT_NO' => ($total == ACL_NO) ? true : false, 1183 'S_RESULT_YES' => ($total == ACL_YES) ? true : false, 1184 'S_RESULT_NEVER' => ($total == ACL_NEVER) ? true : false, 1185 )); 1186 } 1187 1188 /** 1189 * Handles copying permissions from one forum to others 1190 */ 1191 function copy_forum_permissions() 1192 { 1193 global $db, $auth, $cache, $template, $user; 1194 1195 $user->add_lang('acp/forums'); 1196 1197 $submit = isset($_POST['submit']) ? true : false; 1198 1199 if ($submit) 1200 { 1201 $src = request_var('src_forum_id', 0); 1202 $dest = request_var('dest_forum_ids', array(0)); 1203 1204 if (confirm_box(true)) 1205 { 1206 if (copy_forum_permissions($src, $dest)) 1207 { 1208 phpbb_cache_moderators($db, $cache, $auth); 1209 1210 $auth->acl_clear_prefetch(); 1211 $cache->destroy('sql', FORUMS_TABLE); 1212 1213 trigger_error($user->lang['AUTH_UPDATED'] . adm_back_link($this->u_action)); 1214 } 1215 else 1216 { 1217 trigger_error($user->lang['SELECTED_FORUM_NOT_EXIST'] . adm_back_link($this->u_action), E_USER_WARNING); 1218 } 1219 } 1220 else 1221 { 1222 $s_hidden_fields = array( 1223 'submit' => $submit, 1224 'src_forum_id' => $src, 1225 'dest_forum_ids' => $dest, 1226 ); 1227 1228 $s_hidden_fields = build_hidden_fields($s_hidden_fields); 1229 1230 confirm_box(false, $user->lang['COPY_PERMISSIONS_CONFIRM'], $s_hidden_fields); 1231 } 1232 } 1233 1234 $template->assign_vars(array( 1235 'S_FORUM_OPTIONS' => make_forum_select(false, false, false, false, false), 1236 )); 1237 } 1238 1239 /** 1240 * Get already assigned users/groups 1241 */ 1242 function retrieve_defined_user_groups($permission_scope, $forum_id, $permission_type) 1243 { 1244 global $db, $user; 1245 1246 $sql_forum_id = ($permission_scope == 'global') ? 'AND a.forum_id = 0' : ((sizeof($forum_id)) ? 'AND ' . $db->sql_in_set('a.forum_id', $forum_id) : 'AND a.forum_id <> 0'); 1247 1248 // Permission options are only able to be a permission set... therefore we will pre-fetch the possible options and also the possible roles 1249 $option_ids = $role_ids = array(); 1250 1251 $sql = 'SELECT auth_option_id 1252 FROM ' . ACL_OPTIONS_TABLE . ' 1253 WHERE auth_option ' . $db->sql_like_expression($permission_type . $db->get_any_char()); 1254 $result = $db->sql_query($sql); 1255 1256 while ($row = $db->sql_fetchrow($result)) 1257 { 1258 $option_ids[] = (int) $row['auth_option_id']; 1259 } 1260 $db->sql_freeresult($result); 1261 1262 if (sizeof($option_ids)) 1263 { 1264 $sql = 'SELECT DISTINCT role_id 1265 FROM ' . ACL_ROLES_DATA_TABLE . ' 1266 WHERE ' . $db->sql_in_set('auth_option_id', $option_ids); 1267 $result = $db->sql_query($sql); 1268 1269 while ($row = $db->sql_fetchrow($result)) 1270 { 1271 $role_ids[] = (int) $row['role_id']; 1272 } 1273 $db->sql_freeresult($result); 1274 } 1275 1276 if (sizeof($option_ids) && sizeof($role_ids)) 1277 { 1278 $sql_where = 'AND (' . $db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . $db->sql_in_set('a.auth_role_id', $role_ids) . ')'; 1279 } 1280 else if (sizeof($role_ids)) 1281 { 1282 $sql_where = 'AND ' . $db->sql_in_set('a.auth_role_id', $role_ids); 1283 } 1284 else if (sizeof($option_ids)) 1285 { 1286 $sql_where = 'AND ' . $db->sql_in_set('a.auth_option_id', $option_ids); 1287 } 1288 1289 // Not ideal, due to the filesort, non-use of indexes, etc. 1290 $sql = 'SELECT DISTINCT u.user_id, u.username, u.username_clean, u.user_regdate 1291 FROM ' . USERS_TABLE . ' u, ' . ACL_USERS_TABLE . " a 1292 WHERE u.user_id = a.user_id 1293 $sql_forum_id 1294 $sql_where 1295 ORDER BY u.username_clean, u.user_regdate ASC"; 1296 $result = $db->sql_query($sql); 1297 1298 $s_defined_user_options = ''; 1299 $defined_user_ids = array(); 1300 while ($row = $db->sql_fetchrow($result)) 1301 { 1302 $s_defined_user_options .= '<option value="' . $row['user_id'] . '">' . $row['username'] . '</option>'; 1303 $defined_user_ids[] = $row['user_id']; 1304 } 1305 $db->sql_freeresult($result); 1306 1307 $sql = 'SELECT DISTINCT g.group_type, g.group_name, g.group_id 1308 FROM ' . GROUPS_TABLE . ' g, ' . ACL_GROUPS_TABLE . " a 1309 WHERE g.group_id = a.group_id 1310 $sql_forum_id 1311 $sql_where 1312 ORDER BY g.group_type DESC, g.group_name ASC"; 1313 $result = $db->sql_query($sql); 1314 1315 $s_defined_group_options = ''; 1316 $defined_group_ids = array(); 1317 while ($row = $db->sql_fetchrow($result)) 1318 { 1319 $s_defined_group_options .= '<option' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '">' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>'; 1320 $defined_group_ids[] = $row['group_id']; 1321 } 1322 $db->sql_freeresult($result); 1323 1324 return array( 1325 'group_ids' => $defined_group_ids, 1326 'group_ids_options' => $s_defined_group_options, 1327 'user_ids' => $defined_user_ids, 1328 'user_ids_options' => $s_defined_user_options 1329 ); 1330 } 1331 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |