jdarwood007 commited on 2019-11-09 17:12:32
Showing 3 changed files, with 52 additions and 12 deletions.
... | ... |
@@ -58,15 +58,6 @@ foreach (sd_get_install_tables() as $table) |
58 | 58 |
); |
59 | 59 |
} |
60 | 60 |
|
61 |
-// Another row we might want to add is package server. Except we may have to remove a pre-existing plugins one, because the version may be wrong. |
|
62 |
-$query = $smcFunc['db_query']('', ' |
|
63 |
- DELETE FROM {db_prefix}package_servers |
|
64 |
- WHERE url LIKE {string:plugins}', |
|
65 |
- array( |
|
66 |
- 'plugins' => 'http://www.simpledesk.net/download%', |
|
67 |
- ) |
|
68 |
-); |
|
69 |
- |
|
70 | 61 |
// Create new rows, if any |
71 | 62 |
foreach (sd_get_install_rows() as $row) |
72 | 63 |
$smcFunc['db_insert']($row['method'], $row['table_name'], $row['columns'], $row['data'], $row['keys']); |
... | ... |
@@ -189,6 +180,9 @@ function sd_get_install_modSettings($getAll = false) |
189 | 180 |
*/ |
190 | 181 |
function sd_get_install_rows() |
191 | 182 |
{ |
183 |
+ global $smcFunc; |
|
184 |
+ static $current_package_server_url = 'https://www.simpledesk.net/download/plugins/2.0'; |
|
185 |
+ |
|
192 | 186 |
$rows = array(); |
193 | 187 |
$rows[] = array( |
194 | 188 |
'method' => 'replace', |
... | ... |
@@ -212,6 +206,53 @@ function sd_get_install_rows() |
212 | 206 |
'keys' => array('task'), |
213 | 207 |
); |
214 | 208 |
|
209 |
+ |
|
210 |
+ // Another row we might want to add is package server. Except we may have to remove a pre-existing plugins one, because the version may be wrong. |
|
211 |
+ $query = $smcFunc['db_query']('', ' |
|
212 |
+ DELETE FROM {db_prefix}package_servers |
|
213 |
+ WHERE |
|
214 |
+ ( |
|
215 |
+ url LIKE {string:plugins_http_wild} |
|
216 |
+ OR url LIKE {string:plugins_https_wild} |
|
217 |
+ ) |
|
218 |
+ AND URL != {string:plugins}', |
|
219 |
+ array( |
|
220 |
+ 'plugins' => $current_package_server_url, |
|
221 |
+ 'plugins_http_wild' => 'http://www.simpledesk.net/download%', |
|
222 |
+ 'plugins_https_wild' => 'https://www.simpledesk.net/download%', |
|
223 |
+ ) |
|
224 |
+ ); |
|
225 |
+ |
|
226 |
+ // Do we have lots of extras? |
|
227 |
+ $request = $smcFunc['db_query']('', ' |
|
228 |
+ SELECT |
|
229 |
+ COUNT(url) as total, |
|
230 |
+ MAX(id_server) AS lastID |
|
231 |
+ FROM {db_prefix}package_servers |
|
232 |
+ WHERE url LIKE {string:plugins}', |
|
233 |
+ array( |
|
234 |
+ 'plugins' => $current_package_server_url, |
|
235 |
+ ) |
|
236 |
+ ); |
|
237 |
+ $results = $smcFunc['db_fetch_assoc']($request); |
|
238 |
+ $smcFunc['db_free_result']($request); |
|
239 |
+ |
|
240 |
+ // Get rid of any duplicates. |
|
241 |
+ if ($results['total'] > 1 && !empty($results['lastID'])) |
|
242 |
+ $query = $smcFunc['db_query']('', ' |
|
243 |
+ DELETE FROM {db_prefix}package_servers |
|
244 |
+ WHERE |
|
245 |
+ url LIKE {string:plugins_wild} |
|
246 |
+ OR url LIKE {string:plugins_https_wild} |
|
247 |
+ AND id_server != {int:current_server}', |
|
248 |
+ array( |
|
249 |
+ 'current_server' => $results['lastID'], |
|
250 |
+ 'plugins_wild' => 'http://www.simpledesk.net/download%', |
|
251 |
+ 'plugins_https_wild' => 'https://www.simpledesk.net/download%', |
|
252 |
+ ) |
|
253 |
+ ); |
|
254 |
+ // No results, need to add a entry. |
|
255 |
+ elseif (empty($results) || empty($results['total'])) |
|
215 | 256 |
$rows[] = array( |
216 | 257 |
'method' => 'insert', |
217 | 258 |
'table_name' => '{db_prefix}package_servers', |
... | ... |
@@ -221,7 +262,7 @@ function sd_get_install_rows() |
221 | 262 |
), |
222 | 263 |
'data' => array( |
223 | 264 |
'SimpleDesk Plugins', |
224 |
- 'https://www.simpledesk.net/download/plugins/2.0', // !!! This should be updated in later releases! |
|
265 |
+ $current_package_server_url, // !!! This should be updated in later releases! |
|
225 | 266 |
), |
226 | 267 |
'keys' => array('id_server'), |
227 | 268 |
); |
... | ... |
@@ -134,7 +134,7 @@ shd_plugins.prototype.togglePlugin = function (e) |
134 | 134 |
this.itemID = e.currentTarget.dataset.plugin; |
135 | 135 |
|
136 | 136 |
// Toggle the hidden item. |
137 |
- this.oItemValueHandle = $('#' + this.opt.sFeatureClass.replace('%itemid%', itemID)); |
|
137 |
+ this.oItemValueHandle = $('#' + this.opt.sFeatureClass.replace('%itemid%', this.itemID)); |
|
138 | 138 |
this.bItemValue = this.oItemValueHandle.val() == '0' ? 1 : 0; |
139 | 139 |
|
140 | 140 |
// Change the image, alternative text and the title. |
141 | 141 |