Ignore:
Timestamp:
Dec 27, 2004, 3:30:49 PM (20 years ago)
Author:
plg
Message:
  • admin/update : filesystem synchronization process completely rewritten. How to speed up sync ? by avoiding recursivity !
  • admin/update : option to display verbose information details
  • admin/update : option to simulate only. No database insert, delete or update will be made
  • bug fixed : in admin/cat_list, if you delete a virtual category, you may create a gap in the rank list. This gap will generate errors when trying to move a category on this gap. Fixed by calling ordering and update_global_rank at category deletion.
  • admin/cat_list, only one query to insert a new virtual category (no need of a second query to update uppercats and global_rank)
  • for a given category, even if empty, the representing element must not be the one of a forbidden category for the current user
  • generation time optionnaly displayed on the bottom of each page becomes more price : number of SQL queries and SQL time added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r647 r659  
    4444if (isset($_GET['delete']) and is_numeric($_GET['delete']))
    4545{
    46   $to_delete_categories = array();
    47   array_push($to_delete_categories,$_GET['delete']);
    48   delete_categories($to_delete_categories);
     46  delete_categories(array($_GET['delete']));
    4947  array_push($infos, $lang['cat_virtual_deleted']);
     48  ordering();
     49  update_global_rank();
    5050}
    5151// request to add a virtual category
     
    7777    }
    7878
     79    // what will be the inserted id ?
     80    $query = '
     81SELECT MAX(id)+1
     82  FROM '.CATEGORIES_TABLE.'
     83;';
     84    list($next_id) = mysql_fetch_array(pwg_query($query));
     85   
    7986    $insert = array();
     87    $insert{'id'} = $next_id++;
    8088    $insert{'name'} = $_POST['virtual_name'];
    8189    $insert{'rank'} = $_POST['rank'];
    8290    $insert{'commentable'} = $conf['newcat_default_commentable'];
    83     $insert{'uploadable'} = $conf['newcat_default_uploadable'];
     91
     92    // a virtual category can't be uploadable
     93    $insert{'uploadable'} = 'false';
    8494   
    8595    if (isset($parent))
    8696    {
    8797      $insert{'id_uppercat'} = $parent{'id'};
     98      $insert{'uppercats'}   = $parent{'uppercats'}.','.$insert{'id'};
     99      $insert{'global_rank'} = $parent{'global_rank'}.'.'.$insert{'rank'};
    88100      // at creation, must a category be visible or not ? Warning : if
    89101      // the parent category is invisible, the category is automatically
     
    113125      $insert{'visible'} = $conf['newcat_default_visible'];
    114126      $insert{'status'} = $conf['newcat_default_status'];
     127      $insert{'uppercats'} = $insert{'id'};
     128      $insert{'global_rank'} = $insert{'rank'};
    115129    }
    116130
     
    118132   
    119133    // we have then to add the virtual category
    120     $dbfields = array('site_id','name','id_uppercat','rank','commentable',
    121                       'uploadable','visible','status');
     134    $dbfields = array('id','site_id','name','id_uppercat','rank',
     135                      'commentable','uploadable','visible','status',
     136                      'uppercats','global_rank');
    122137    mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
    123    
    124     // And last we update the uppercats
    125     $query = '
    126 SELECT MAX(id)
    127   FROM '.CATEGORIES_TABLE.'
    128 ;';
    129     $my_id = array_pop(mysql_fetch_array(pwg_query($query)));
    130 
    131     $query = '
    132 UPDATE '.CATEGORIES_TABLE;
    133     if (isset($parent))
    134     {
    135       $query.= "
    136   SET uppercats = CONCAT('".$parent['uppercats']."',',',id)
    137     , global_rank = CONCAT('".$parent['global_rank']."','.',rank)";
    138     }
    139     else
    140     {
    141       $query.= '
    142   SET uppercats = id
    143     , global_rank = id';
    144     }
    145     $query.= '
    146   WHERE id = '.$my_id.'
    147 ;';
    148     pwg_query($query);
     138
    149139    array_push($infos, $lang['cat_virtual_added']);
    150140  }
Note: See TracChangeset for help on using the changeset viewer.