Changeset 11729
- Timestamp:
- Jul 13, 2011, 4:04:02 PM (13 years ago)
- Location:
- trunk/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_perm.php
r8728 r11729 144 144 pwg_query($query); 145 145 } 146 else if (isset($_POST['grant_users_submit']) 147 and isset($_POST['grant_users']) 148 and count($_POST['grant_users']) > 0) 149 { 150 $query = ' 151 SELECT id 152 FROM '.CATEGORIES_TABLE.' 153 WHERE id IN ('.implode(',', get_uppercat_ids(array($page['cat']))).') 154 AND status = \'private\' 155 ;'; 156 $private_uppercats = array_from_query($query, 'id'); 157 158 // We must not reinsert already existing lines in user_access table 159 $granteds = array(); 160 foreach ($private_uppercats as $cat_id) 161 { 162 $granteds[$cat_id] = array(); 163 } 164 165 $query = ' 166 SELECT user_id, cat_id 167 FROM '.USER_ACCESS_TABLE.' 168 WHERE cat_id IN ('.implode(',', $private_uppercats).') 169 AND user_id IN ('.implode(',', $_POST['grant_users']).') 170 ;'; 171 $result = pwg_query($query); 172 while ($row = pwg_db_fetch_assoc($result)) 173 { 174 array_push($granteds[$row['cat_id']], $row['user_id']); 175 } 176 177 $inserts = array(); 178 179 foreach ($private_uppercats as $cat_id) 180 { 181 $user_ids = array_diff($_POST['grant_users'], $granteds[$cat_id]); 182 foreach ($user_ids as $user_id) 183 { 184 array_push($inserts, array('user_id' => $user_id, 185 'cat_id' => $cat_id)); 186 } 187 } 188 189 mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts); 146 else if (isset($_POST['grant_users_submit'])) 147 { 148 add_permission_on_category($page['cat'], $_POST['grant_users']); 190 149 } 191 150 -
trunk/admin/user_perm.php
r8728 r11729 65 65 pwg_query($query); 66 66 } 67 else if (isset($_POST['trueify']) 68 and isset($_POST['cat_false']) 69 and count($_POST['cat_false']) > 0) 67 else if (isset($_POST['trueify'])) 70 68 { 71 $uppercats = get_uppercat_ids($_POST['cat_false']); 72 $private_uppercats = array(); 73 74 $query = ' 75 SELECT id 76 FROM '.CATEGORIES_TABLE.' 77 WHERE id IN ('.implode(',', $uppercats).') 78 AND status = \'private\' 79 ;'; 80 $result = pwg_query($query); 81 while ($row = pwg_db_fetch_assoc($result)) 82 { 83 array_push($private_uppercats, $row['id']); 84 } 85 86 // retrying to authorize a category which is already authorized may cause 87 // an error (in SQL statement), so we need to know which categories are 88 // accesible 89 $authorized_ids = array(); 90 91 $query = ' 92 SELECT cat_id 93 FROM '.USER_ACCESS_TABLE.' 94 WHERE user_id = '.$page['user'].' 95 ;'; 96 $result = pwg_query($query); 97 98 while ($row = pwg_db_fetch_assoc($result)) 99 { 100 array_push($authorized_ids, $row['cat_id']); 101 } 102 103 $inserts = array(); 104 $to_autorize_ids = array_diff($private_uppercats, $authorized_ids); 105 foreach ($to_autorize_ids as $to_autorize_id) 106 { 107 array_push($inserts, array('user_id' => $page['user'], 108 'cat_id' => $to_autorize_id)); 109 } 110 111 mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts); 69 add_permission_on_category($_POST['cat_false'], $page['user']); 112 70 } 113 71
Note: See TracChangeset
for help on using the changeset viewer.