Changeset 2304


Ignore:
Timestamp:
Apr 19, 2008, 5:00:11 AM (16 years ago)
Author:
rvelices
Message:

merge -r 2303 from branch-1_7 to trunk

  • removed some unused code
  • mass_updates function does not need SELECT VERSION()
  • rewrote update_uppercats to avoid db update if no change
Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r2299 r2304  
    6060function delete_categories($ids)
    6161{
    62   global $counts;
    63 
    6462  if (count($ids) == 0)
    6563  {
     
    122120  pwg_query($query);
    123121
    124   if (isset($counts['del_categories']))
    125   {
    126     $counts['del_categories']+= count($ids);
    127   }
    128122  trigger_action('delete_categories', $ids);
    129123}
     
    136130function delete_elements($ids)
    137131{
    138   global $counts;
    139 
    140132  if (count($ids) == 0)
    141133  {
     
    199191  pwg_query($query);
    200192
    201   if (isset($counts['del_elements']))
    202   {
    203     $counts['del_elements']+= count($ids);
    204   }
    205193  trigger_action('delete_elements', $ids);
    206194}
     
    437425}
    438426
    439 function date_convert_back( $date )
    440 {
    441   // date arrives at this format : YYYY-MM-DD
    442   // It must be transformed in DD/MM/YYYY
    443   if ( $date != '' )
    444   {
    445     list($year,$month,$day) = explode( '-', $date );
    446     return $day.'/'.$month.'/'.$year;
    447   }
    448   else
    449   {
    450     return '';
    451   }
    452 }
    453 
    454427/**
    455428 * returns an array containing sub-directories which can be a category,
     
    576549    // depending on the MySQL version, we use the multi table update or N
    577550    // update queries
    578     $query = 'SELECT VERSION() AS version;';
    579     list($mysql_version) = mysql_fetch_array(pwg_query($query));
    580     if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0)
     551    if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0)
    581552    {
    582553      // MySQL is prior to version 4.0.4, multi table update feature is not
     
    11851156function update_uppercats()
    11861157{
    1187   $uppercat_ids = array();
    1188 
    1189   $query = '
    1190 SELECT id, id_uppercat
     1158  $query = '
     1159SELECT id, id_uppercat, uppercats
    11911160  FROM '.CATEGORIES_TABLE.'
    11921161;';
    1193   $result = pwg_query($query);
    1194   while ($row = mysql_fetch_array($result))
    1195   {
    1196     $uppercat_ids[$row['id']] =
    1197       !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL';
    1198   }
    1199 
    1200   // uppercats array associates a category id to the list of uppercats id.
    1201   $uppercats = array();
    1202 
    1203   foreach (array_keys($uppercat_ids) as $id)
    1204   {
    1205     $uppercats[$id] = array();
     1162  $cat_map = hash_from_query($query, 'id');
     1163
     1164  $datas = array();
     1165  foreach ($cat_map as $id => $cat)
     1166  {
     1167    $upper_list = array();
    12061168
    12071169    $uppercat = $id;
    1208 
    1209     while ($uppercat != 'NULL')
    1210     {
    1211       array_push($uppercats[$id], $uppercat);
    1212       $uppercat = $uppercat_ids[$uppercat];
    1213     }
    1214   }
    1215 
    1216   $datas = array();
    1217 
    1218   foreach ($uppercats as $id => $list)
    1219   {
    1220     array_push(
    1221       $datas,
    1222       array(
    1223         'id' => $id,
    1224         'uppercats' => implode(',', array_reverse($list))
    1225         )
    1226       );
    1227   }
    1228 
     1170    while ($uppercat)
     1171    {
     1172      array_push($upper_list, $uppercat);
     1173      $uppercat = $cat_map[$uppercat]['id_uppercat'];
     1174    }
     1175
     1176    $new_uppercats = implode(',', array_reverse($upper_list));
     1177    if ($new_uppercats != $cat['uppercats'])
     1178    {
     1179      array_push(
     1180        $datas,
     1181        array(
     1182          'id' => $id,
     1183          'uppercats' => $new_uppercats
     1184          )
     1185        );
     1186    }
     1187  }
    12291188  $fields = array('primary' => array('id'), 'update' => array('uppercats'));
    12301189  mass_updates(CATEGORIES_TABLE, $fields, $datas);
  • trunk/admin/picture_modify.php

    r2299 r2304  
    189189$selected_tags = array_from_query($query, 'tag_id');
    190190
    191 // Navigation path
    192 
    193 $date = isset($_POST['date_creation']) && empty($page['errors'])
    194 ?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
    195 
    196191// +-----------------------------------------------------------------------+
    197192// |                             template init                             |
     
    225220  array(
    226221    'U_SYNC' =>
    227         PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
     222        get_root_url().'admin.php?page=picture_modify'.
    228223        '&amp;image_id='.$_GET['image_id'].
    229224        (isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '').
     
    247242    'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'],
    248243
    249     'CREATION_DATE' => $date,
    250 
    251244    'TAG_SELECTION' => $tag_selection,
    252245
     
    256249
    257250    'F_ACTION' =>
    258         PHPWG_ROOT_PATH.'admin.php'
     251        get_root_url().'admin.php'
    259252        .get_query_string_diff(array('sync_metadata'))
    260253    )
Note: See TracChangeset for help on using the changeset viewer.