[*] BO : optimization Upgrader and Admin Home
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9745 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -27,9 +27,11 @@
|
||||
<h1>{l s='Dashboard'}</h1>
|
||||
<hr style="background-color: #812143;color: #812143;" />
|
||||
{if $upgrade}
|
||||
<div id="blockNewVersionCheck">
|
||||
{if $upgrade->need_upgrade}
|
||||
<div class="warning warn" style="margin-bottom:10px;"><h3>{l s ='New PrestaShop version available'} : <a style="text-decoration: underline;" href="{$upgrade->link}" target="_blank">{l s ='Download'} {$upgrade->version_name}</a> !</h3></div>
|
||||
{/if}
|
||||
</div>
|
||||
{else}
|
||||
<p>{l s ='Update notification unavailable'}</p>
|
||||
<p> </p>
|
||||
@@ -51,11 +53,28 @@ $(document).ready(function() {
|
||||
if ($(this).is(':checked'))
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
async: true,
|
||||
url: 'ajax.php?toggleScreencast',
|
||||
type : 'POST',
|
||||
data : {
|
||||
ajax : '1',
|
||||
controller : 'AdminHome',
|
||||
token : '{$token}',
|
||||
id_employee : '{$employee->id}',
|
||||
action : 'hideScreencast',
|
||||
},
|
||||
url: 'ajax-tab.php',
|
||||
dataType : 'json',
|
||||
success: function(data) {
|
||||
if(!data)
|
||||
alert("TECHNICAL ERROR - no return status found");
|
||||
else if(data.status != "ok")
|
||||
alert("TECHNICAL ERROR: "+data.msg);
|
||||
|
||||
$('#adminpresentation').slideUp('slow');
|
||||
|
||||
},
|
||||
error: function(data, textStatus, errorThrown)
|
||||
{
|
||||
alert("TECHNICAL ERROR: "+data);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -88,6 +107,41 @@ $(document).ready(function() {
|
||||
<div class="clear"> </div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
if({$refresh_check_version})
|
||||
{
|
||||
$('#blockNewVersionCheck').hide();
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
data : {
|
||||
ajax : '1',
|
||||
controller : 'AdminHome',
|
||||
token : '{$token}',
|
||||
id_employee : '{$employee->id}',
|
||||
action : 'refreshCheckVersion',
|
||||
},
|
||||
url: 'ajax-tab.php',
|
||||
dataType : 'json',
|
||||
success: function(data) {
|
||||
if(!data)
|
||||
alert("TECHNICAL ERROR - no return status found");
|
||||
else if(data.status != "ok")
|
||||
alert("TECHNICAL ERROR: "+data.msg);
|
||||
if(data.upgrade.need_upgrade)
|
||||
{
|
||||
$('#blockNewVersionCheck').children("a").attr('href',data.upgrade.link);
|
||||
$('#blockNewVersionCheck').children("a").html(data.upgrade.link+"pouet");
|
||||
$('#blockNewVersionCheck').fadeIn('slow');
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
error: function(data, textStatus, errorThrown)
|
||||
{
|
||||
alert("TECHNICAL ERROR: "+data);
|
||||
}
|
||||
});
|
||||
}
|
||||
$.ajax({
|
||||
url: "ajax-tab.php",
|
||||
type: "POST",
|
||||
@@ -99,12 +153,12 @@ $(document).ready(function() {
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
|
||||
{if $employee->bo_show_screencast}
|
||||
if (json.screencast != 'NOK')
|
||||
$('#adminpresentation').fadeIn('slow');
|
||||
else
|
||||
$('#adminpresentation').fadeOut('slow');
|
||||
|
||||
{/if}
|
||||
$('#partner_preactivation').fadeOut('slow', function() {
|
||||
if (json.partner_preactivation != 'NOK')
|
||||
$('#partner_preactivation').html(json.partner_preactivation);
|
||||
@@ -123,7 +177,10 @@ $(document).ready(function() {
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown)
|
||||
{
|
||||
$('#adminpresentation').fadeOut('slow');
|
||||
// don't show/hide screencast if it's deactivated
|
||||
{if $employee->bo_show_screencast}
|
||||
$('#adminpresentation').fadeOut('slow');
|
||||
{/if}
|
||||
$('#partner_preactivation').fadeOut('slow');
|
||||
$('#discover_prestashop').fadeOut('slow');
|
||||
}
|
||||
|
||||
+45
-19
@@ -48,6 +48,15 @@ class UpgraderCore
|
||||
public $changelog;
|
||||
public $md5;
|
||||
|
||||
public function __construct($autoload = false)
|
||||
{
|
||||
if ($autoload)
|
||||
{
|
||||
$this->loadFromConfig();
|
||||
// checkPSVersion to get need_upgrade
|
||||
$this->checkPSVersion();
|
||||
}
|
||||
}
|
||||
public function __get($var)
|
||||
{
|
||||
if ($var == 'need_upgrade')
|
||||
@@ -130,25 +139,7 @@ class UpgraderCore
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_version_check = @unserialize(Configuration::get('PS_LAST_VERSION'));
|
||||
if (isset($last_version_check['name']))
|
||||
$this->version_name = $last_version_check['name'];
|
||||
if (isset($last_version_check['num']))
|
||||
$this->version_num = $last_version_check['num'];
|
||||
if (isset($last_version_check['link']))
|
||||
$this->link = $last_version_check['link'];
|
||||
if (isset($last_version_check['autoupgrade']))
|
||||
$this->autoupgrade = $last_version_check['autoupgrade'];
|
||||
if (isset($last_version_check['autoupgrade_module']))
|
||||
$this->autoupgrade_module = $last_version_check['autoupgrade_module'];
|
||||
if (isset($last_version_check['md5']))
|
||||
$this->md5 = $last_version_check['md5'];
|
||||
if (isset($last_version_check['desc']))
|
||||
$this->desc = $last_version_check['desc'];
|
||||
if (isset($last_version_check['changelog']))
|
||||
$this->changelog = $last_version_check['changelog'];
|
||||
}
|
||||
$this->loadFromConfig();
|
||||
}
|
||||
// retro-compatibility :
|
||||
// return array(name,link) if you don't use the last version
|
||||
@@ -162,6 +153,41 @@ class UpgraderCore
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* load the last version informations stocked in base
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function loadFromConfig()
|
||||
{
|
||||
$last_version_check = @unserialize(Configuration::get('PS_LAST_VERSION'));
|
||||
if($last_version_check)
|
||||
{
|
||||
if (isset($last_version_check['name']))
|
||||
$this->version_name = $last_version_check['name'];
|
||||
if (isset($last_version_check['num']))
|
||||
$this->version_num = $last_version_check['num'];
|
||||
if (isset($last_version_check['link']))
|
||||
$this->link = $last_version_check['link'];
|
||||
if (isset($last_version_check['autoupgrade']))
|
||||
$this->autoupgrade = $last_version_check['autoupgrade'];
|
||||
if (isset($last_version_check['autoupgrade_module']))
|
||||
$this->autoupgrade_module = $last_version_check['autoupgrade_module'];
|
||||
if (isset($last_version_check['md5']))
|
||||
$this->md5 = $last_version_check['md5'];
|
||||
if (isset($last_version_check['desc']))
|
||||
$this->desc = $last_version_check['desc'];
|
||||
if (isset($last_version_check['changelog']))
|
||||
$this->changelog = $last_version_check['changelog'];
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array of files
|
||||
* that the md5file does not match to the original md5file (provided by $rss_md5file_link_dir )
|
||||
* @return void
|
||||
*/
|
||||
public function getChangedFilesList()
|
||||
{
|
||||
if (count($this->changed_files) == 0)
|
||||
|
||||
@@ -374,7 +374,20 @@ class AdminHomeControllerCore extends AdminController
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
public function ajaxProcessRefreshCheckVersion()
|
||||
{
|
||||
$upgrade = new Upgrader(true);
|
||||
if ($upgrade)
|
||||
{
|
||||
$json['status'] = 'ok';
|
||||
$json['upgrade']['need_upgrade'] = $upgrade->need_upgrade;
|
||||
$json['upgrade']['link'] = $upgrade->link;
|
||||
$json['upgrade']['version_name'] = $upgrade->version_name;
|
||||
$this->content = Tools::jsonEncode($json);
|
||||
}
|
||||
else
|
||||
$this->content = '{"status":"error"}';
|
||||
}
|
||||
public function ajaxProcessHideOptimizationTips()
|
||||
{
|
||||
if (Configuration::updateValue('PS_HIDE_OPTIMIZATION_TIPS', 1))
|
||||
@@ -438,6 +451,20 @@ class AdminHomeControllerCore extends AdminController
|
||||
$this->content = Tools::jsonEncode($result);
|
||||
}
|
||||
|
||||
public function ajaxProcessHideScreencast()
|
||||
{
|
||||
if ($employee = new Employee((int)Tools::getValue('id_employee')))
|
||||
{
|
||||
$employee->bo_show_screencast = 0;
|
||||
if ($employee->save())
|
||||
$this->content = '{"status":"ok"}';
|
||||
else
|
||||
$this->content = '{"status":"error","msg":"not saved"}';
|
||||
}
|
||||
else
|
||||
$this->content = '{"status":"error", "msg":"employee does not exists"}';
|
||||
}
|
||||
|
||||
public function getBlockPartners()
|
||||
{
|
||||
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => AdminHomeController::TIPS_TIMEOUT)));
|
||||
@@ -504,24 +531,32 @@ class AdminHomeControllerCore extends AdminController
|
||||
$smarty->assign('isoUser',$isoUser);
|
||||
$currency = $this->context->currency;
|
||||
$upgrade = null;
|
||||
$tpl_vars['refresh_check_version'] = 0;
|
||||
if (@ini_get('allow_url_fopen'))
|
||||
{
|
||||
$upgrade = new Upgrader();
|
||||
$upgrade->checkPSVersion();
|
||||
$upgrade = new Upgrader(true);
|
||||
// if this information is outdated, the version will be checked after page loading
|
||||
if (Configuration::get('PS_LAST_VERSION_CHECK')
|
||||
< time() - (3600 * Upgrader::DEFAULT_CHECK_VERSION_DELAY_HOURS))
|
||||
$tpl_vars['refresh_check_version'] = 1;
|
||||
}
|
||||
|
||||
$smarty->assign('upgrade', $upgrade);
|
||||
$tpl_vars['upgrade'] = $upgrade;
|
||||
|
||||
$smarty->assign('show_screencast', $this->context->employee->show_screencast);
|
||||
$smarty->assign('quick_links', $this->getQuickLinks());
|
||||
$smarty->assign('monthly_statistics', $this->getMonthlyStatistics());
|
||||
$smarty->assign('customers_service', $this->getCustomersService());
|
||||
$smarty->assign('stats_sales', $this->getStatsSales());
|
||||
$smarty->assign('last_orders',$this->getLastOrders());
|
||||
$smarty->assign('tips_optimization', $this->_displayOptimizationTips());
|
||||
if ($this->context->employee->bo_show_screencast)
|
||||
$tpl_vars['employee_token'] = Tools::getAdminTokenLite('AdminEmployees');
|
||||
|
||||
$tpl_vars['employee'] = $this->context->employee;
|
||||
$tpl_vars['quick_links'] = $this->getQuickLinks();
|
||||
$tpl_vars['monthly_statistics'] = $this->getMonthlyStatistics();
|
||||
$tpl_vars['customers_service'] = $this->getCustomersService();
|
||||
$tpl_vars['stats_sales'] = $this->getStatsSales();
|
||||
$tpl_vars['last_orders'] =$this->getLastOrders();
|
||||
$tpl_vars['tips_optimization'] = $this->_displayOptimizationTips();
|
||||
|
||||
$HOOK_BACKOFFICEHOME = Module::hookExec('backOfficeHome');
|
||||
$smarty->assign('HOOK_BACKOFFICEHOME', $HOOK_BACKOFFICEHOME);
|
||||
$tpl_vars['HOOK_BACKOFFICEHOME'] = $HOOK_BACKOFFICEHOME;
|
||||
$smarty->assign($tpl_vars);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user