Changeset 614 for trunk/admin/update.php


Ignore:
Timestamp:
Nov 23, 2004, 11:31:24 PM (20 years ago)
Author:
plg
Message:
  • global categories' options : instead of N horizontal tabs on a single page, N options in the left menu (but the same backend)
  • categories.global_rank : new calculated field. It gives a global rank of the category among all others (updated during ordering)
  • category.php page : menu is generated faster thanks to categories.global_rank, recursivity becomes useless :-)
  • new function to display select box with a set of categories : display_select_cat_wrapper
  • cat_options : instead of using 1 multiselect for true/false items, using 1 multiselect for true, and another one for false. The form provides buttons with arrows to switch categories from one multiselect to another
  • deletion of obsolete function display_categories (working with the old template system)
  • deletion of obsolete functions get_user_plain_structure, create_user_structure, get_user_subcat_ids, update_structure, count_images : useless thanks to global_rank
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/update.php

    r610 r614  
    3838
    3939/**
    40  * order categories (update categories.rank database field)
     40 * order categories (update categories.rank and global_rank database fields)
    4141 *
    4242 * the purpose of this function is to give a rank for all categories
    4343 * (insides its sub-category), even the newer that have none at te
    4444 * beginning. For this, ordering function selects all categories ordered by
    45  * rank ASC then name ASC for each uppercat.
     45 * rank ASC then name ASC for each uppercat. It also updates the global rank
     46 * which is able to order any two categorie in the whole tree
    4647 *
    4748 * @returns void
     
    6970  SET rank = '.++$current_rank.'
    7071  WHERE id = '.$row['id'].'
     72;';
     73    pwg_query($query);
     74  }
     75  // global rank update
     76  $query = '
     77UPDATE '.CATEGORIES_TABLE.'
     78  SET global_rank = rank
     79  WHERE id_uppercat IS NULL
     80;';
     81  pwg_query($query);
     82
     83  $query = '
     84SELECT DISTINCT(id_uppercat)
     85  FROM '.CATEGORIES_TABLE.'
     86  WHERE id_uppercat IS NOT NULL
     87;';
     88  $result = pwg_query($query);
     89  while ($row = mysql_fetch_array($result))
     90  {
     91    $query = '
     92SELECT global_rank
     93  FROM '.CATEGORIES_TABLE.'
     94  WHERE id = '.$row['id_uppercat'].'
     95;';
     96    list($uppercat_global_rank) = mysql_fetch_array(pwg_query($query));
     97    $query = '
     98UPDATE '.CATEGORIES_TABLE.'
     99  SET global_rank = CONCAT(\''.$uppercat_global_rank.'\', \'.\', rank)
     100  WHERE id_uppercat = '.$row['id_uppercat'].'
    71101;';
    72102    pwg_query($query);
     
    572602
    573603  $query = '
    574 SELECT id
     604SELECT id,name,uppercats,global_rank
    575605  FROM '.CATEGORIES_TABLE.'
    576   WHERE site_id != 1
    577 ;';
    578   $result = pwg_query($query);
    579   while ($row = mysql_fetch_array($result))
    580   {
    581     array_push($user['restrictions'], $row['id']);
    582   }
    583   $user['forbidden_categories'] = implode(',', $user['restrictions']);
    584   $user['expand'] = true;
    585   $structure = create_user_structure('');
    586   display_select_categories($structure,
    587                             ' ',
    588                             array(),
    589                             'introduction.category_option',
    590                             array());
     606  WHERE site_id = 1
     607;';
     608  display_select_cat_wrapper($query,
     609                             array(),
     610                             'introduction.category_option',
     611                             false);
    591612}
    592613// +-----------------------------------------------------------------------+
Note: See TracChangeset for help on using the changeset viewer.