From 1069998c4298f25d9a3dfe2005a40c3c4996be55 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 15 Nov 2017 17:51:46 -0800 Subject: [PATCH] Issue #2818 Moved core database update check to ajax. --- e107_admin/admin.php | 2 + e107_admin/boot.php | 18 +++++++ e107_admin/e107_update.php | 2 + e107_admin/includes/flexpanel.php | 2 +- e107_admin/includes/infopanel.php | 48 +++++++++++++++++++ .../shortcodes/batch/admin_shortcodes.php | 17 ++++++- e107_themes/bootstrap3/admin_theme.php | 2 +- 7 files changed, 87 insertions(+), 4 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index 387e9deaa..f661c4698 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -285,6 +285,8 @@ class admin_start return null; } + return null; + $checked = e107::getSession()->get('core-update-checked'); diff --git a/e107_admin/boot.php b/e107_admin/boot.php index 659251352..1163d7b02 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -35,6 +35,24 @@ if(ADMIN && defset('e_ADMIN_UI') && varset($_POST['mode']) == 'sef' && !empty($_ exit; } +if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'core' && ($_GET['type'] == 'update')) +{ + + require_once(e_ADMIN.'update_routines.php'); + + e107::getSession()->set('core-update-checked',false); + + $status = (update_check() === true) ? true : false; + + e107::getSession()->set('core-update-status',$status); + + echo json_encode($status); + + exit; + +} + + if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'core' && ($_GET['type'] == 'feed')) { diff --git a/e107_admin/e107_update.php b/e107_admin/e107_update.php index 7daf35be3..ef080fcee 100644 --- a/e107_admin/e107_update.php +++ b/e107_admin/e107_update.php @@ -26,6 +26,8 @@ require_once ("update_routines.php"); new e107Update($dbupdate); +e107::getSession()->set('core-update-status', false); // reset update status. + require_once ("footer.php"); diff --git a/e107_admin/includes/flexpanel.php b/e107_admin/includes/flexpanel.php index f830747fa..f4b17c190 100644 --- a/e107_admin/includes/flexpanel.php +++ b/e107_admin/includes/flexpanel.php @@ -226,7 +226,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel // --------------------- Add-on updates --------------------------- $ns->setStyle('flexpanel'); $ns->setUniqueId('e-addon-updates'); - $addonUpdates = $tp->parseTemplate("{ADMIN_ADDON_UPDATES}", true, $admin_sc); + $addonUpdates = $admin_sc->sc_admin_addon_updates(); $info = $this->getMenuPosition('e-addon-updates'); $panels[$info['area']][$info['weight']] .= $addonUpdates; diff --git a/e107_admin/includes/infopanel.php b/e107_admin/includes/infopanel.php index d27d0d000..788fd39c2 100644 --- a/e107_admin/includes/infopanel.php +++ b/e107_admin/includes/infopanel.php @@ -29,13 +29,61 @@ class adminstyle_infopanel function __construct() { + + $coreUpdateCheck = ''; + + + if( e107::getSession()->get('core-update-status') !== true) + { + $coreUpdateCheck = " + $('#e-admin-core-update').html(''); + + $.get('".e_ADMIN."admin.php?mode=core&type=update', function( data ) { + + var res = $.parseJSON(data); + + if(res === true) + { + $('#e-admin-core-update').html(''); + + $('[data-toggle=\"popover\"]').popover('show'); + $('.popover').on('click', function() + { + $('[data-toggle=\"popover\"]').popover('hide'); + }); + } + else + { + $('#e-admin-core-update').text(''); + } + + }); + + "; + + } + + + + + $code = " jQuery(function($){ $('#e-adminfeed').load('".e_ADMIN."admin.php?mode=core&type=feed'); $('#e-adminfeed-plugin').load('".e_ADMIN."admin.php?mode=addons&type=plugin'); $('#e-adminfeed-theme').load('".e_ADMIN."admin.php?mode=addons&type=theme'); + + ".$coreUpdateCheck." + }); "; + + + + + + + e107::js('inline',$code,'jquery'); diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 5c7289d63..5b6669e2e 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -1393,6 +1393,7 @@ Inverse 10 10 return null; } + e107::getDb()->db_mark_time("sc_admin_addon_updates() // start"); $themes = $this->getUpdateable('theme'); $plugins = $this->getUpdateable('plugin'); @@ -1408,6 +1409,10 @@ Inverse 10 10 $tp = e107::getParser(); $ns->setUniqueId('e-addon-updates'); + + e107::getDb()->db_mark_time("sc_admin_addon_updates() // end"); + + return $ns->tablerender($tp->toGlyph('fa-arrow-circle-o-down').LAN_UPDATE_AVAILABLE,$text,'default',true); @@ -1429,7 +1434,7 @@ Inverse 10 10 { case "theme": $versions = $mp->getVersionList('theme'); - $list = e107::getTheme()->getThemeList('version'); + $list = e107::getTheme()->getList('version'); break; case "plugin": @@ -1884,9 +1889,17 @@ Inverse 10 10 if($parm == 'enav_popover') // @todo move to template and make generic. { + if('0' != ADMINPERMS) + { + return null; + } + $template = $$tmpl; - return $template['start']. '
  • '.$tp->toGlyph('fa-database').'
  • ' .$template['end']; + + $upStatus = (e107::getSession()->get('core-update-status') === true) ? "" : ''; + + return $template['start']. '
  • '.$upStatus.'
  • ' .$template['end']; } diff --git a/e107_themes/bootstrap3/admin_theme.php b/e107_themes/bootstrap3/admin_theme.php index 7c8bf7f17..3e30f76fa 100644 --- a/e107_themes/bootstrap3/admin_theme.php +++ b/e107_themes/bootstrap3/admin_theme.php @@ -281,4 +281,4 @@ $NEWSSTYLE = ' '; */ -?> +?> \ No newline at end of file