Changeset 638 for trunk/admin/update.php


Ignore:
Timestamp:
Dec 5, 2004, 11:47:46 PM (19 years ago)
Author:
plg
Message:
  • ordering function moved from admin/update to admin/include/function
  • remote_site uses ordering and update_global_rank
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/update.php

    r633 r638  
    3636// |                              functions                                |
    3737// +-----------------------------------------------------------------------+
    38 
    39 /**
    40  * order categories (update categories.rank and global_rank database fields)
    41  *
    42  * the purpose of this function is to give a rank for all categories
    43  * (insides its sub-category), even the newer that have none at te
    44  * beginning. For this, ordering function selects all categories ordered by
    45  * rank ASC then name ASC for each uppercat.
    46  *
    47  * @returns void
    48  */
    49 function ordering()
    50 {
    51   $current_rank = 0;
    52   $current_uppercat = '';
    53                
    54   $query = '
    55 SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat
    56   FROM '.CATEGORIES_TABLE.'
    57   ORDER BY id_uppercat,rank,name
    58 ;';
    59   $result = pwg_query($query);
    60   $datas = array();
    61   while ($row = mysql_fetch_array($result))
    62   {
    63     if ($row['id_uppercat'] != $current_uppercat)
    64     {
    65       $current_rank = 0;
    66       $current_uppercat = $row['id_uppercat'];
    67     }
    68     $data = array('id' => $row['id'], 'rank' => ++$current_rank);
    69     array_push($datas, $data);
    70   }
    71 
    72   $fields = array('primary' => array('id'), 'update' => array('rank'));
    73   mass_updates(CATEGORIES_TABLE, $fields, $datas);
    74 }
    7538
    7639function insert_local_category($id_uppercat)
Note: See TracChangeset for help on using the changeset viewer.