Changeset 1159 in ExiteCMS for trunk/administration/downloads.php
- Timestamp:
- 12/08/07 00:04:43 (4 years ago)
- File:
-
- 1 edited
-
trunk/administration/downloads.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/administration/downloads.php
r1071 r1159 18 18 // load the locale for this module 19 19 locale_load("admin.downloads"); 20 21 // TODO - WANWIZARD - 20070718 - NEED TO MOVE THIS TO SETTINGS22 define('MAX_BARS', 9);23 20 24 21 //check if the user has a right to be here. If not, bail out … … 89 86 if (!isset($download_cat_id)) $download_cat_id = "-1"; 90 87 if (!isset($step)) $step = ""; 91 $barmsg = "";92 $bartitle = "";93 88 94 89 // temp storage for template variables 95 90 $variables = array(); 96 91 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 93 switch ($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'"); 116 while ($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"); 111 121 if (dbrows($result) != 0) { 112 122 $variables['cats_found'] = true; … … 114 124 $result = dbquery("DELETE FROM ".$db_prefix."downloads WHERE download_id='$download_id'"); 115 125 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"); 119 129 } 120 130 } … … 130 140 $download_datestamp = isset($_POST['update_datestamp']) ? ", download_datestamp='".time()."'" : ""; 131 141 $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"); 133 143 } else { 134 144 $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"); 136 146 } 137 147 } … … 161 171 $variables['cats'] = array(); 162 172 $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"); 164 174 while ($data2 = dbarray($result2)) { 165 175 $variables['download_cats'][$data2['download_cat_id']] = $data2['download_cat_name']; … … 183 193 } 184 194 // 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"); 186 196 while($data = dbarray($result)) { 187 197 recurse_dc($data['download_cat_id'], 0); 188 }189 190 // get the download bar panel title191 $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 = "";199 198 } 200 199 … … 203 202 $result = dbquery("SELECT * FROM ".$db_prefix."downloads ORDER BY download_id DESC"); 204 203 while($data = dbarray($result)) { 204 // skip all downloads from filtered categories 205 if (!isset($variables['download_cats'][$data['download_cat']])) continue; 205 206 if ($data['download_cat']) { 206 207 $data['download_cat_name'] = $variables['download_cats'][$data['download_cat']]; … … 213 214 // template variables 214 215 $variables['step'] = $step; 215 $variables['formaction'] = $formaction ;216 $variables['formaction'] = $formaction.($cat_locale==""?"":("&cat_locale=".$cat_locale)); 216 217 $variables['download_cat_id'] = $download_cat_id; 217 218 $variables['download_title'] = $download_title; … … 222 223 $variables['download_version'] = $download_version; 223 224 $variables['download_filesize'] = $download_filesize; 224 $variables['barmsg'] = $barmsg;225 $variables['bar_title'] = $bar_title;226 225 227 226 } else {
Note: See TracChangeset
for help on using the changeset viewer.
