feat: complete parity with OC 3.0 (purgeAllData, backup restore, Gatekeeper V5 template, extension route proxies, updated distribution zip)
This commit is contained in:
parent
3f17a95f57
commit
73e19d98cb
Binary file not shown.
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
if (!defined('DIR_APPLICATION')) { exit; }
|
||||
if (!class_exists('ControllerModuleImgOpti')) {
|
||||
require_once(DIR_APPLICATION . 'controller/module/img_opti.php');
|
||||
}
|
||||
class ControllerExtensionModuleImgOpti extends ControllerModuleImgOpti {}
|
||||
|
|
@ -77,9 +77,27 @@ class ControllerModuleImgOpti extends Controller {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$posted_lic = isset($this->request->post['module_img_opti_token']) ? trim((string)$this->request->post['module_img_opti_token']) : '';
|
||||
$this->request->post['module_img_opti_token'] = $posted_lic;
|
||||
|
||||
$current_lic = (string)$this->config->get('module_img_opti_token');
|
||||
$is_activating = (!$this->checkLicense($current_lic) && $this->checkLicense($posted_lic));
|
||||
if ($is_activating || !isset($this->request->post['module_img_opti_status'])) {
|
||||
$this->request->post['module_img_opti_status'] = 1;
|
||||
} else {
|
||||
$this->request->post['module_img_opti_status'] = (int)$this->request->post['module_img_opti_status'];
|
||||
}
|
||||
|
||||
$this->request->post['img_opti_status'] = $this->request->post['module_img_opti_status'];
|
||||
$this->model_setting_setting->editSetting('module_img_opti', $this->request->post);
|
||||
$this->model_setting_setting->editSetting('img_opti', array('img_opti_status' => $this->request->post['module_img_opti_status']));
|
||||
|
||||
if ($posted_lic === '') {
|
||||
$this->model_setting_setting->deleteSetting('nat_image_optimizer_backup');
|
||||
} else {
|
||||
$this->model_setting_setting->editSetting('nat_image_optimizer_backup', $this->request->post);
|
||||
}
|
||||
|
||||
$this->cache->delete('img_opti_disk_stats');
|
||||
if ($quality_changed) {
|
||||
$cache_file = DIR_CACHE . 'img_opti_optimized.json';
|
||||
|
|
@ -119,6 +137,23 @@ class ControllerModuleImgOpti extends Controller {
|
|||
$data['action'] = $this->url->link('module/img_opti', $token_param, true);
|
||||
$data['cancel'] = $this->url->link('extension/module', $token_param, true);
|
||||
|
||||
$current_lic = (string)$this->config->get('module_img_opti_token');
|
||||
$has_deliberate_setting = ($this->config->get('module_img_opti_token') !== null);
|
||||
|
||||
if (!$has_deliberate_setting && (empty($current_lic) || !$this->checkLicense($current_lic))) {
|
||||
$restored = array();
|
||||
$bk_set = $this->model_setting_setting->getSetting('nat_image_optimizer_backup');
|
||||
if (!empty($bk_set) && is_array($bk_set) && !empty($bk_set['module_img_opti_token'])) {
|
||||
$restored = $bk_set;
|
||||
}
|
||||
if (!empty($restored) && !empty($restored['module_img_opti_token'])) {
|
||||
$this->model_setting_setting->editSetting('module_img_opti', $restored);
|
||||
foreach ($restored as $rk => $rv) {
|
||||
$this->config->set($rk, $rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array(
|
||||
'module_img_opti_status' => 1,
|
||||
'module_img_opti_wm_status' => 0,
|
||||
|
|
@ -419,7 +454,11 @@ class ControllerModuleImgOpti extends Controller {
|
|||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
$data['catalog_url'] = (defined('HTTPS_CATALOG') && HTTPS_CATALOG) ? HTTPS_CATALOG : (defined('HTTP_CATALOG') ? HTTP_CATALOG : '');
|
||||
$data['is_licensed'] = $this->checkLicense($data['module_img_opti_token']);
|
||||
$_h = defined('HTTP_CATALOG') ? parse_url(HTTP_CATALOG, PHP_URL_HOST) : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '');
|
||||
$_h = preg_replace('/:\d+$/', '', trim((string)$_h));
|
||||
$_h = preg_replace('/^www\./i', '', $_h);
|
||||
$data['nat_current_domain'] = strtolower($_h);
|
||||
$data['is_licensed'] = $this->checkLicense((string)$this->config->get('module_img_opti_token'));
|
||||
$data['catalog_dir'] = DIR_IMAGE . 'catalog';
|
||||
|
||||
$data['catalog_items'] = array();
|
||||
|
|
@ -600,6 +639,25 @@ class ControllerModuleImgOpti extends Controller {
|
|||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
public function purgeAllData() {
|
||||
$json = array();
|
||||
$perm_route = (version_compare(VERSION, '2.3.0.0', '>=')) ? 'extension/module/img_opti' : 'module/img_opti';
|
||||
if (!$this->user->hasPermission('modify', $perm_route)) {
|
||||
$json['error'] = 'Permission denied';
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
return;
|
||||
}
|
||||
$this->load->model('setting/setting');
|
||||
$this->model_setting_setting->deleteSetting('module_img_opti');
|
||||
$this->model_setting_setting->deleteSetting('img_opti');
|
||||
$this->model_setting_setting->deleteSetting('nat_image_optimizer_backup');
|
||||
|
||||
$json['success'] = true;
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
private function validate() {
|
||||
if (!$this->user->hasPermission('modify', 'module/img_opti')) {
|
||||
$this->error['warning'] = $this->language->get('error_permission');
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
if (!defined('DIR_APPLICATION')) { exit; }
|
||||
if (!class_exists('ControllerModuleImgOptiCron')) {
|
||||
require_once(DIR_APPLICATION . 'controller/module/img_opti_cron.php');
|
||||
}
|
||||
class ControllerExtensionModuleImgOptiCron extends ControllerModuleImgOptiCron {}
|
||||
Loading…
Reference in New Issue