Changeset 1060


Ignore:
Timestamp:
Mar 1, 2006, 1:48:29 AM (18 years ago)
Author:
rvelices
Message:

fix: replaced UPDATE ... LEFT JOIN for compatibility with MySql 3

File:
1 edited

Legend:

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

    r1048 r1060  
    6464
    6565  $prefix_length = strlen($conf['prefix_thumbnail']);
    66  
     66
    6767  $thumbnails = array();
    6868  if ($opendir = @opendir($dir.'/thumbnail'))
     
    122122  }
    123123  delete_categories($category_ids);
    124                
     124
    125125  // destruction of the site
    126126  $query = '
     
    130130  pwg_query($query);
    131131}
    132        
     132
    133133
    134134// The function delete_categories deletes the categories identified by the
     
    150150  // sub-categories must be so
    151151  $ids = get_subcat_ids($ids);
    152  
     152
    153153  // destruction of all the related elements
    154154  $query = '
     
    215215    return;
    216216  }
    217  
     217
    218218  // destruction of the comments on the image
    219219  $query = '
     
    255255;';
    256256  pwg_query($query);
    257                
     257
    258258  // destruction of the image
    259259  $query = '
     
    280280{
    281281  global $conf;
    282  
     282
    283283  // destruction of the access linked to the user
    284284  $query = '
     
    350350{
    351351  global $conf;
    352  
     352
    353353  // retrieving all categories to update
    354354  $cat_ids = array();
    355  
     355
    356356  $query = '
    357357SELECT id
     
    390390    return false;
    391391  }
    392  
     392
    393393  // calculate informations about categories retrieved
    394394  $query = '
     
    416416    array_push($datas, array('id' => $id, 'nb_images' => 0));
    417417  }
    418  
     418
    419419  $fields = array('primary' => array('id'),
    420420                  'update'  => array('date_last', 'nb_images'));
     
    468468        $to_rand = array_diff($wrong_representant, $to_null);
    469469      }
    470      
     470
    471471      if (count($to_null) > 0)
    472472      {
     
    478478        pwg_query($query);
    479479      }
    480      
     480
    481481      // If the random representant is not allowed, we need to find
    482482      // categories with elements and with no representant. Those categories
     
    497497            )
    498498          );
    499      
     499
    500500      if (count($to_rand) > 0)
    501501      {
     
    553553{
    554554  $dirs = array();
    555  
     555
    556556  if (is_dir($path))
    557557  {
     
    611611        $query.= ',';
    612612      }
    613      
     613
    614614      if (!isset($insert[$dbfield]) or $insert[$dbfield] == '')
    615615      {
     
    710710      }
    711711    }
    712    
     712
    713713    $temporary_tablename = $tablename.'_'.micro_seconds();
    714    
     714
    715715    $query = '
    716716CREATE TABLE '.$temporary_tablename.'
     
    781781    $uppercats_array[$row['id']] =  $row['uppercats'];
    782782  }
    783  
     783
    784784  $datas = array();
    785785  foreach ($uppercats_array as $id => $uppercats)
     
    886886    return array();
    887887  }
    888  
     888
    889889  $uppercats = array();
    890890
     
    947947  $current_rank = 0;
    948948  $current_uppercat = '';
    949                
     949
    950950  $query = '
    951951SELECT id, if(id_uppercat is null,\'\',id_uppercat) AS id_uppercat
     
    982982    return array();
    983983  }
    984  
     984
    985985  // caching directories of existing categories
    986986  $query = '
     
    10101010  // categories : id, site_id, uppercats
    10111011  $categories = array();
    1012  
     1012
    10131013  $query = '
    10141014SELECT id, uppercats, site_id
     
    10221022    array_push($categories, $row);
    10231023  }
    1024  
     1024
    10251025  // filling $cat_fulldirs
    10261026  $cat_fulldirs = array();
     
    10731073        {
    10741074          $extension = get_extension($node);
    1075          
     1075
    10761076//          if (in_array($extension, $conf['picture_ext']))
    10771077          if (isset($conf['flip_picture_ext'][$extension]))
     
    11141114      $fs['elements']        = array_merge($fs['elements'],
    11151115                                           $tmp_fs['elements']);
    1116      
     1116
    11171117      $fs['thumbnails']      = array_merge($fs['thumbnails'],
    11181118                                           $tmp_fs['thumbnails']);
    1119      
     1119
    11201120      $fs['representatives'] = array_merge($fs['representatives'],
    11211121                                           $tmp_fs['representatives']);
     
    11491149{
    11501150  global $conf;
    1151  
     1151
    11521152  $query = '
    11531153SELECT '.$conf['user_fields']['id'].' AS id
     
    12181218        $base_users
    12191219        );
    1220    
     1220
    12211221    if (count($to_delete) > 0)
    12221222    {
     
    12401240{
    12411241  $uppercat_ids = array();
    1242  
     1242
    12431243  $query = '
    12441244SELECT id, id_uppercat
     
    12511251      !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL';
    12521252  }
    1253  
     1253
    12541254  // uppercats array associates a category id to the list of uppercats id.
    12551255  $uppercats = array();
    1256  
     1256
    12571257  foreach (array_keys($uppercat_ids) as $id)
    12581258  {
     
    12981298  $cat_ids = array_from_query($query, 'storage_category_id');
    12991299  $fulldirs = get_fulldirs($cat_ids);
    1300  
     1300
    13011301  foreach ($cat_ids as $cat_id)
    13021302  {
     
    13261326  }
    13271327  $query .= ' GROUP BY element_id;';
    1328  
     1328
    13291329  $result = pwg_query($query);
    13301330
    13311331  $datas = array();
    1332  
     1332
    13331333  while ($row = mysql_fetch_array($result))
    13341334  {
     
    13411341      );
    13421342  }
    1343  
     1343
    13441344  mass_updates(
    13451345    IMAGES_TABLE,
     
    13521352
    13531353  $query='
    1354 UPDATE '.IMAGES_TABLE .'
     1354SELECT id FROM '.IMAGES_TABLE .'
    13551355  LEFT JOIN '.RATE_TABLE.' ON id=element_id
     1356  WHERE element_id IS NULL AND average_rate IS NOT NULL';
     1357  if ( $element_id != -1 )
     1358  {
     1359    $query .= ' AND id=' . $element_id;
     1360  }
     1361  $to_update = array_from_query( $query, 'id');
     1362
     1363  if ( !empty($to_update) )
     1364  {
     1365    $query='
     1366UPDATE '.IMAGES_TABLE .'
    13561367  SET average_rate=NULL
    1357   WHERE element_id IS NULL';
    1358   if ( $element_id != -1 )
    1359   {
    1360     $query .= ' AND id=' . $element_id;
    1361   }
    1362   pwg_query($query);
     1368  WHERE id IN (' . implode(',',$to_update) . ')';
     1369    pwg_query($query);
     1370  }
    13631371}
    13641372
     
    13831391
    13841392  $categories = array();
    1385  
     1393
    13861394  $query = '
    13871395SELECT id, id_uppercat, status, uppercats
     
    13991407        );
    14001408  }
    1401  
     1409
    14021410  // is the movement possible? The movement is impossible if you try to move
    14031411  // a category in a sub-category or itself
     
    14251433    }
    14261434  }
    1427  
     1435
    14281436  $tables =
    14291437    array(
     
    14311439      GROUP_ACCESS_TABLE => 'group_id'
    14321440      );
    1433  
     1441
    14341442  $query = '
    14351443UPDATE '.CATEGORIES_TABLE.'
     
    14721480        {
    14731481          $subcats = get_subcat_ids(array($cat_id));
    1474        
     1482
    14751483          foreach ($tables as $table => $field)
    14761484          {
     
    14881496;';
    14891497            $parent_access = array_from_query($query, $field);
    1490          
     1498
    14911499            $to_delete = array_diff($parent_access, $category_access);
    1492          
     1500
    14931501            if (count($to_delete) > 0)
    14941502            {
Note: See TracChangeset for help on using the changeset viewer.