Changeset 11729 for trunk/admin/cat_perm.php
- Timestamp:
- Jul 13, 2011, 4:04:02 PM (13 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.