Changeset 25244 for trunk/admin/include/functions.php
- Timestamp:
- Oct 30, 2013, 9:14:32 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r25019 r25244 2256 2256 2257 2257 // make sure categories are private and select uppercats or subcats 2258 $cat_ids = (isset($_POST['apply_on_sub'])) ? implode(',', get_subcat_ids($category_ids)).",".implode(',', get_uppercat_ids($category_ids)) : implode(',', get_uppercat_ids($category_ids)); 2259 $query = ' 2260 SELECT 2261 id 2258 $cat_ids = get_uppercat_ids($category_ids); 2259 if (isset($_POST['apply_on_sub'])) 2260 { 2261 $cat_ids = array_merge($cat_ids, get_subcat_ids($category_ids)); 2262 } 2263 2264 $query = ' 2265 SELECT id 2262 2266 FROM '.CATEGORIES_TABLE.' 2263 WHERE id IN ('. $cat_ids.')2267 WHERE id IN ('.implode(',', $cat_ids).') 2264 2268 AND status = \'private\' 2265 2269 ;'; … … 2270 2274 return; 2271 2275 } 2272 2273 // We must not reinsert already existing lines in user_access table 2274 $granteds = array(); 2276 2277 $inserts = array(); 2275 2278 foreach ($private_cats as $cat_id) 2276 2279 { 2277 $granteds[$cat_id] = array(); 2278 } 2279 2280 $query = ' 2281 SELECT 2282 user_id, 2283 cat_id 2284 FROM '.USER_ACCESS_TABLE.' 2285 WHERE cat_id IN ('.implode(',', $private_cats).') 2286 AND user_id IN ('.implode(',', $user_ids).') 2287 ;'; 2288 $result = pwg_query($query); 2289 while ($row = pwg_db_fetch_assoc($result)) 2290 { 2291 $granteds[ $row['cat_id'] ][] = $row['user_id']; 2292 } 2293 2294 $inserts = array(); 2295 2296 foreach ($private_cats as $cat_id) 2297 { 2298 $grant_to_users = array_diff($user_ids, $granteds[$cat_id]); 2299 2300 foreach ($grant_to_users as $user_id) 2280 foreach ($user_ids as $user_id) 2301 2281 { 2302 2282 $inserts[] = array( … … 2306 2286 } 2307 2287 } 2308 2309 if (count($inserts) > 0) 2310 { 2311 mass_inserts(USER_ACCESS_TABLE, array_keys($inserts[0]), $inserts); 2312 } 2288 2289 mass_inserts( 2290 USER_ACCESS_TABLE, 2291 array('user_id','cat_id'), 2292 $inserts, 2293 array('ignore'=>true) 2294 ); 2313 2295 } 2314 2296
Note: See TracChangeset
for help on using the changeset viewer.