Changeset 23075


Ignore:
Timestamp:
06/06/13 16:02:33 (7 years ago)
Author:
plg
Message:

bug 2907 fixed (only on 2.5, rvelices did a deeper rewrite for 2.6): wrong number of sub-albums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/include/functions_user.inc.php

    r21236 r23075  
    405405      if ( !is_admin($userdata['status']) ) 
    406406      { // for non admins we forbid categories with no image (feature 1053) 
     407        $uppercats_of = null; 
    407408        $forbidden_ids = array(); 
    408409        foreach ($user_cache_cats as $cat) 
     
    412413            $forbidden_ids[] = $cat['cat_id']; 
    413414            unset( $user_cache_cats[$cat['cat_id']] ); 
     415 
     416            if (empty($uppercats_of)) 
     417            { 
     418              $query = ' 
     419SELECT 
     420    id, 
     421    uppercats 
     422  FROM '.CATEGORIES_TABLE.' 
     423;'; 
     424              $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats'); 
     425            } 
     426 
     427            // if child album is removed, we must decrease the number of 
     428            // sub-albums of all parent albums (to the root) 
     429            if (isset($uppercats_of[$cat['cat_id']])) 
     430            { 
     431              foreach (explode(',', $uppercats_of[$cat['cat_id']]) as $id) 
     432              { 
     433                // the last $id is the current album removed, it will always 
     434                // fail the following condition because it was removed a few 
     435                // lines before. 
     436                if (isset($user_cache_cats[$id])) 
     437                { 
     438                  $user_cache_cats[$id]['count_categories']--; 
     439                } 
     440              } 
     441            } 
    414442          } 
    415443        } 
Note: See TracChangeset for help on using the changeset viewer.