Changeset 1159 in ExiteCMS for trunk/administration/downloads.php


Ignore:
Timestamp:
12/08/07 00:04:43 (4 years ago)
Author:
hverton
Message:

update all user queries to include the user_status, to select only active user accounts
removed download bar selection from the download module (should be in the download bars module)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/downloads.php

    r1071 r1159  
    1818// load the locale for this module 
    1919locale_load("admin.downloads"); 
    20  
    21 // TODO - WANWIZARD - 20070718 - NEED TO MOVE THIS TO SETTINGS 
    22 define('MAX_BARS', 9); 
    2320 
    2421//check if the user has a right to be here. If not, bail out 
     
    8986if (!isset($download_cat_id)) $download_cat_id = "-1"; 
    9087if (!isset($step)) $step = ""; 
    91 $barmsg = ""; 
    92 $bartitle = ""; 
    9388 
    9489// temp storage for template variables 
    9590$variables = array(); 
    9691 
    97 if(isset($_POST['save_bars'])) { 
    98     $barcontent = $_POST['download_bar']; 
    99     if (!is_array($barcontent)) fallback(BASEDIR."index.php"); 
    100     $bar_title = stripinput($_POST['bar_title']); 
    101     $result = dbquery("UPDATE ".$db_prefix."download_cats SET download_cat_name = '".$bar_title."' WHERE download_cat_id = '0'"); 
    102     // reset all bar indicators before setting new ones 
    103     $result = dbquery("UPDATE ".$db_prefix."downloads SET download_bar = '0'"); 
    104     foreach($barcontent as $key => $bar) { 
    105         if ($bar != 0) $result = dbquery("UPDATE ".$db_prefix."downloads SET download_bar = '".$key."' WHERE download_id = '".$bar."'"); 
    106     } 
    107     $barmsg = $locale['523']; 
    108 } 
    109  
    110 $result = dbquery("SELECT * FROM ".$db_prefix."download_cats"); 
     92// compose the query where clause based on the localisation method choosen 
     93switch ($settings['download_localisation']) { 
     94    case "none": 
     95        $where = ""; 
     96        $cat_locale = ""; 
     97        break; 
     98    case "single": 
     99        $where = ""; 
     100        $cat_locale = ""; 
     101        break; 
     102    case "multiple": 
     103        if (isset($cat_locale)) { 
     104            $result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_code = '".stripinput($cat_locale)."' AND locale_active = '1' LIMIT 1"); 
     105            if (!dbrows($result)) unset($cat_locale); 
     106        } 
     107        if (!isset($cat_locale)) $cat_locale = $settings['locale_code']; 
     108        $where = "download_cat_locale = '".$cat_locale."' "; 
     109        break; 
     110} 
     111$variables['cat_locale'] = $cat_locale; 
     112 
     113// get the installed locales 
     114$variables['locales'] = array(); 
     115$result = dbquery("SELECT * FROM ".$db_prefix."locale WHERE locale_active = '1'"); 
     116while ($data = dbarray($result)) { 
     117    $variables['locales'][$data['locale_code']] = $data['locale_name']; 
     118} 
     119 
     120$result = dbquery("SELECT * FROM ".$db_prefix."download_cats LIMIT 1"); 
    111121if (dbrows($result) != 0) { 
    112122    $variables['cats_found'] = true;     
     
    114124        $result = dbquery("DELETE FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 
    115125        if (dbcount("(*)", "downloads", "download_cat=$download_cat_id") == 0) { 
    116             redirect(FUSION_SELF.$aidlink); 
    117         } else { 
    118             redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat_id"); 
     126            redirect(FUSION_SELF.$aidlink."&cat_locale=$cat_locale"); 
     127        } else { 
     128            redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat_id&cat_locale=$cat_locale"); 
    119129        } 
    120130    } 
     
    130140            $download_datestamp = isset($_POST['update_datestamp']) ? ", download_datestamp='".time()."'" : ""; 
    131141            $result = dbquery("UPDATE ".$db_prefix."downloads SET download_title='$download_title', download_description='$download_description', download_url='$download_url', download_cat='$download_cat', download_license='$download_license', download_os='$download_os', download_version='$download_version', download_filesize='$download_filesize'".$download_datestamp." WHERE download_id='$download_id'"); 
    132             redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat"); 
     142            redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 
    133143        } else { 
    134144            $result = dbquery("INSERT INTO ".$db_prefix."downloads (download_title, download_description, download_url, download_cat, download_license, download_os, download_version, download_filesize, download_datestamp, download_count) VALUES ('$download_title', '$download_description', '$download_url', '$download_cat', '$download_license', '$download_os', '$download_version', '$download_filesize', '".time()."', '0')"); 
    135             redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat"); 
     145            redirect(FUSION_SELF.$aidlink."&download_cat_id=$download_cat&cat_locale=$cat_locale"); 
    136146        } 
    137147    } 
     
    161171    $variables['cats'] = array(); 
    162172    $variables['download_cats'] = array(); 
    163     $result2 = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ORDER BY download_cat_id*10000+download_parent"); 
     173    $result2 = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 ".($where==""?"":("AND ".$where))." ORDER BY download_cat_id*10000+download_parent"); 
    164174    while ($data2 = dbarray($result2)) { 
    165175        $variables['download_cats'][$data2['download_cat_id']] = $data2['download_cat_name']; 
     
    183193    } 
    184194    // Then recurse through the download categories 
    185     $result = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0 AND download_parent = 0 ORDER BY download_datestamp DESC"); 
     195    $result = dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id > 0  ".($where==""?"":("AND ".$where))." AND download_parent = 0 ORDER BY download_datestamp DESC"); 
    186196    while($data = dbarray($result)) { 
    187197        recurse_dc($data['download_cat_id'], 0); 
    188     } 
    189  
    190     // get the download bar panel title 
    191     $result = dbquery("SELECT download_cat_name FROM ".$db_prefix."download_cats WHERE download_cat_id='0'"); 
    192     if ($data = dbarray($result)) { 
    193         $bar_title = $data['download_cat_name']; 
    194     } else { 
    195         $result = dbquery("INSERT INTO ".$db_prefix."download_cats (download_cat_name, download_cat_access) VALUES ('', '255')"); 
    196         $bar_title_id = mysql_insert_id(); 
    197         $result = dbquery("UPDATE ".$db_prefix."download_cats SET download_cat_id = '0' WHERE download_cat_id = '".$bar_title_id."'"); 
    198         $bar_title = ""; 
    199198    } 
    200199 
     
    203202    $result = dbquery("SELECT * FROM ".$db_prefix."downloads ORDER BY download_id DESC"); 
    204203    while($data = dbarray($result)) { 
     204        // skip all downloads from filtered categories 
     205        if (!isset($variables['download_cats'][$data['download_cat']])) continue; 
    205206        if ($data['download_cat']) { 
    206207            $data['download_cat_name'] = $variables['download_cats'][$data['download_cat']]; 
     
    213214    // template variables 
    214215    $variables['step'] = $step; 
    215     $variables['formaction'] = $formaction; 
     216    $variables['formaction'] = $formaction.($cat_locale==""?"":("&cat_locale=".$cat_locale)); 
    216217    $variables['download_cat_id'] = $download_cat_id; 
    217218    $variables['download_title'] = $download_title; 
     
    222223    $variables['download_version'] = $download_version; 
    223224    $variables['download_filesize'] = $download_filesize; 
    224     $variables['barmsg'] = $barmsg; 
    225     $variables['bar_title'] = $bar_title; 
    226225 
    227226} else { 
Note: See TracChangeset for help on using the changeset viewer.