Updated: Install request method and admin css

Co-authored-by: Name <azharbhat.qlo098@webkul.in>
This commit is contained in:
shazar rahman
2026-11-04 12:30:18 +05:30
parent c87a624cfc
commit a94868438b
7 changed files with 66 additions and 48 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -101,6 +101,11 @@ function scroll_if_anchor(href, fromTop = 120) {
}
$(document).ready(function() {
// refresh the upgrade info cache in background, result is shown on next page load
if (typeof upgrade_check_needed !== 'undefined' && upgrade_check_needed) {
$.ajax({url: upgrade_check_url, type: 'GET'});
}
//set main navigation aside
/* global employee_token */
function navSidebar(){

View File

@@ -1,8 +1,5 @@
// Make sure the charset is set appropriately
@charset "UTF-8"
//Compass is required to pre-compile this stylesheets to .css
@import "compass"
@import "modules/colors"
@import "modules/variables"
@import "modules/mixins"

View File

@@ -3384,7 +3384,7 @@ exit;
'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))),
'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(),
'shop_url_ssl' => isset($params['shop_url_ssl']) ? $params['shop_url_ssl'] : Tools::getShopDomainSsl(),
'physical_uri' => Context::getContext()->shop->physical_uri,
'physical_uri' => isset($params['physical_uri']) ? $params['physical_uri'] : Context::getContext()->shop->physical_uri,
'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL')
));
@@ -3449,6 +3449,9 @@ exit;
$post_data .= (isset($params['controller']) ? $params['controller'] : Context::getContext()->controller->controller_name);
$post_data .= defined('_PS_HOST_MODE_') ? '-od' : '';
break;
case 'notification':
$post_data .= '&method=notification&data='.urlencode(json_encode($params['notification_data']));
break;
case 'check-version':
$post_data .= '&method=check-version&autoupgrade='.(int)(Module::isInstalled('qloautoupgrade') && Module::isEnabled('qloautoupgrade'));
break;

View File

@@ -1117,6 +1117,26 @@ class AdminControllerCore extends Controller
$this->context->cookie->$cookieKey = (int) Tools::getValue('is_visible');
}
/**
* Refreshes the upgrade available cache from api.qloapps.com in the background.
* A failed or invalid response never replaces the existing cache.
*/
protected function ajaxProcessCheckUpgrade()
{
if (Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_)) {
return;
}
$cacheFile = _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE;
$content = Tools::addonsRequest('check-version');
if ($content && @simplexml_load_string($content)) {
file_put_contents($cacheFile, $content);
} elseif (file_exists($cacheFile) && filesize($cacheFile) > 0) {
// API unreachable: keep the last known info and retry after the cache lifetime
@touch($cacheFile);
}
}
protected function ajaxProcessSaveKpiView()
{
$cookieKey = 'kpi_wrapping_'.$this->context->controller->className;
@@ -3091,10 +3111,11 @@ class AdminControllerCore extends Controller
'submit_form_ajax' => (int)Tools::getValue('submitFormAjax')
));
// get upgrade available info
if (!Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_)) {
file_put_contents(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE, Tools::addonsRequest('check-version'));
}
// get upgrade available info from cache only, the cache is refreshed in background by ajaxProcessCheckUpgrade()
Media::addJsDef(array(
'upgrade_check_needed' => !Tools::isFresh(Upgrader::CACHE_FILE_UPGRADE_AVAILABE, _TIME_1_DAY_),
'upgrade_check_url' => 'index.php?controller='.$this->controller_name.'&ajax=1&action=checkUpgrade&token='.$this->token,
));
if (file_exists(_PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE)) {
$content = Tools::file_get_contents( _PS_ROOT_DIR_.Upgrader::CACHE_FILE_UPGRADE_AVAILABE);
$upgradeInfo = simplexml_load_string($content);

View File

@@ -628,30 +628,22 @@ class InstallModelInstall extends InstallAbstractModel
return true;
}
/**
* @param array $notificationData
* @return bool
*/
public function setNotification($notificationData)
{
if (function_exists('curl_version')) {
$url = _QLO_API_URL_.'/getNotification.php';
$params = [
'method' => 'POST',
'headers' => array('Content-Type: application/json'),
'postdata' => json_encode($notificationData),
];
$curlInit = curl_init();
curl_setopt($curlInit, CURLOPT_URL, $url);
curl_setopt($curlInit, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curlInit, CURLOPT_HTTPHEADER, $params['headers']);
curl_setopt($curlInit, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curlInit, CURLOPT_CUSTOMREQUEST, $params['method']);
curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, 1);
if (isset($params['postdata'])) {
curl_setopt($curlInit, CURLOPT_POSTFIELDS, $params['postdata']);
}
$response = curl_exec($curlInit);
} else {
// Mail Code
}
Tools::addonsRequest('notification', array(
'notification_data' => $notificationData,
'version' => _QLO_INSTALL_VERSION_,
'iso_lang' => $this->language->getLanguageIso(),
'iso_country' => $notificationData['countryCode'],
'shop_url' => $notificationData['shopDomain'],
'shop_url_ssl' => $notificationData['shopDomainSsl'],
'physical_uri' => $notificationData['physicalUri'],
'email' => $notificationData['email'],
));
return true;
}