Changeset 702 for trunk/forum/includes/acp/auth.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/auth.php
r400 r702 3 3 * 4 4 * @package phpBB3 5 * @version $Id : auth.php 8479 2008-03-29 00:22:48Z naderman$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 59 59 } 60 60 } 61 61 62 62 /** 63 63 * Get permission mask … … 141 141 } 142 142 143 143 144 144 $hold_ary[$userdata['user_id']] = array(); 145 145 foreach ($forum_ids as $f_id) … … 346 346 // Build js roles array (role data assignments) 347 347 $s_role_js_array = ''; 348 348 349 349 if (sizeof($roles)) 350 350 { … … 697 697 $cur_options = array(); 698 698 699 // Determine current options 699 700 $sql = 'SELECT auth_option, is_global, is_local 700 701 FROM ' . ACL_OPTIONS_TABLE . ' … … 704 705 while ($row = $db->sql_fetchrow($result)) 705 706 { 706 if ($row['is_global']) 707 { 708 $cur_options['global'][] = $row['auth_option']; 709 } 710 711 if ($row['is_local']) 712 { 713 $cur_options['local'][] = $row['auth_option']; 714 } 707 $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); 715 708 } 716 709 $db->sql_freeresult($result); … … 727 720 foreach ($option_ary as $option_value) 728 721 { 729 if (!in_array($option_value, $cur_options[$type])) 730 { 731 $new_options[$type][] = $option_value; 732 } 722 $new_options[$type][] = $option_value; 733 723 734 724 $flag = substr($option_value, 0, strpos($option_value, '_') + 1); 735 725 736 if (!in_array($flag, $ cur_options[$type]) && !in_array($flag, $new_options[$type]))726 if (!in_array($flag, $new_options[$type])) 737 727 { 738 728 $new_options[$type][] = $flag; … … 745 735 $options['local'] = array_diff($new_options['local'], $new_options['global']); 746 736 $options['global'] = array_diff($new_options['global'], $new_options['local']); 747 $options['local_global'] = array_intersect($new_options['local'], $new_options['global']); 748 749 $sql_ary = array(); 750 737 $options['both'] = array_intersect($new_options['local'], $new_options['global']); 738 739 // Now check which options to add/update 740 $add_options = $update_options = array(); 741 742 // First local ones... 751 743 foreach ($options as $type => $option_ary) 752 744 { 753 745 foreach ($option_ary as $option) 754 746 { 755 $sql_ary[] = array( 756 'auth_option' => (string) $option, 757 'is_global' => ($type == 'global' || $type == 'local_global') ? 1 : 0, 758 'is_local' => ($type == 'local' || $type == 'local_global') ? 1 : 0 759 ); 760 } 761 } 762 763 $db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); 747 if (!isset($cur_options[$option])) 748 { 749 $add_options[] = array( 750 'auth_option' => (string) $option, 751 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, 752 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 753 ); 754 755 continue; 756 } 757 758 // Else, update existing entry if it is changed... 759 if ($type === $cur_options[$option]) 760 { 761 continue; 762 } 763 764 // New type is always both: 765 // If is now both, we set both. 766 // If it was global the new one is local and we need to set it to both 767 // If it was local the new one is global and we need to set it to both 768 $update_options[] = $option; 769 } 770 } 771 772 if (!empty($add_options)) 773 { 774 $db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); 775 } 776 777 if (!empty($update_options)) 778 { 779 $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' 780 SET is_global = 1, is_local = 1 781 WHERE ' . $db->sql_in_set('auth_option', $update_options); 782 $db->sql_query($sql); 783 } 764 784 765 785 $cache->destroy('_acl_options'); … … 803 823 $flag = key($auth); 804 824 $flag = substr($flag, 0, strpos($flag, '_') + 1); 805 825 806 826 // This ID (the any-flag) is set if one or more permissions are true... 807 827 $any_option_id = (int) $this->acl_options['id'][$flag]; … … 917 937 $flag = key($auth); 918 938 $flag = substr($flag, 0, strpos($flag, '_') + 1); 919 939 920 940 // Remove any-flag from auth ary 921 941 if (isset($auth[$flag])) … … 1068 1088 $where_sql[] = $db->sql_in_set('auth_option_id', array_map('intval', $option_id_ary)); 1069 1089 } 1070 1090 1071 1091 $sql = "DELETE FROM $table 1072 1092 WHERE " . implode(' AND ', $where_sql); … … 1091 1111 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, 1092 1112 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, 1093 1113 1094 1114 'CAT_NAME' => $user->lang['permission_cat'][$cat]) 1095 1115 ); … … 1180 1200 ); 1181 1201 } 1182 1202 1183 1203 $cat = $user->lang['acl_' . $permission]['cat']; 1184 1204 1185 1205 // Build our categories array 1186 1206 if (!isset($categories[$cat]))
Note:
See TracChangeset
for help on using the changeset viewer.