From 18a8571ed35379c4baefc4da80c02c5447b2aec8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 11 Apr 2019 12:28:14 -0700 Subject: [PATCH] Fixes #3711 - check local themes/plugins against author names as well as versions before suggesting updates. --- e107_admin/admin.php | 6 +++-- e107_admin/boot.php | 2 ++ e107_admin/plugin.php | 7 ++++- e107_admin/theme.php | 6 ++++- .../shortcodes/batch/admin_shortcodes.php | 27 ++++++++++++++----- e107_handlers/theme_handler.php | 2 +- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/e107_admin/admin.php b/e107_admin/admin.php index f0ed6e9b3a..426f7449d3 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -62,8 +62,10 @@ } } - - +// DEBUG THE ADDON_UPDATED INFOPANEL +//e107::getCache()->clear('Infopanel_plugin', true); +//e107::getSession()->clear('addons-update-status'); +//e107::getSession()->set('addons-update-checked',false); // set to recheck it. define('e_ADMIN_HOME', true); // used by some admin shortcodes. diff --git a/e107_admin/boot.php b/e107_admin/boot.php index 9fad469967..b019c6ceaf 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -56,6 +56,7 @@ { e107::getSession()->set('addons-update-checked',true); + /** @var admin_shortcodes $sc */ $sc = e107::getScBatch('admin'); $themes = $sc->getUpdateable('theme'); @@ -64,6 +65,7 @@ $text = $sc->renderAddonUpdate($plugins); $text .= $sc->renderAddonUpdate($themes); + if(empty($text)) { exit; diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index f8e451815f..5c79f37a55 100755 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -572,6 +572,7 @@ private function pluginUpgrade() if(file_exists($_path.'plugin.xml')) { $plugin->install_plugin_xml($id, 'upgrade'); + $text = LAN_UPGRADE_SUCCESSFUL; } else { @@ -656,13 +657,17 @@ private function pluginUpgrade() e107::getConfig('core')->save(); } - $mes->addSuccess($text); //$plugin->save_addon_prefs('update'); // make sure ALL plugin/addon pref lists get update and are current e107::getPlug()->clearCache()->buildAddonPrefLists(); + // clear infopanel in admin dashboard. + e107::getCache()->clear('Infopanel_plugin', true); + e107::getSession()->clear('addons-update-status'); + e107::getSession()->set('addons-update-checked',false); // set to recheck it. + $this->redirectAction('list'); } diff --git a/e107_admin/theme.php b/e107_admin/theme.php index 70bf88c8a7..876ad32833 100644 --- a/e107_admin/theme.php +++ b/e107_admin/theme.php @@ -290,8 +290,12 @@ public function ChooseObserver() // action = choose if($this->themeObj->setTheme($id)) { - $mes->addSuccess($message); + + // clear infopanel in admin dashboard. + e107::getCache()->clear('Infopanel_theme', true); + e107::getSession()->clear('addons-update-status'); + e107::getSession()->set('addons-update-checked',false); // set to recheck it. } else { diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 437edaa0fd..cc31b84776 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -131,6 +131,8 @@ function sc_admin_docs() $e107_var['x'.$key]['link'] = e_ADMIN.'docs.php?'.$key; } + $act = null; // FIXME + $text = show_admin_menu(FOOTLAN_14, $act, $e107_var, FALSE, TRUE, TRUE); return $ns -> tablerender(FOOTLAN_14,$text, array('id' => 'admin_docs', 'style' => 'button_menu'), TRUE); } @@ -1131,7 +1133,7 @@ function sc_admin_siteinfo($parm='') $text .= $themeinfo ? "
".FOOTLAN_7.": ".$themeinfo : ''; - $sqlMode = str_replace(",", ", ",e107::getDB()->getMode()); + $sqlMode = str_replace(",", ", ", e107::getDb()->getMode()); $text .= "

".FOOTLAN_8." @@ -1152,10 +1154,10 @@ function sc_admin_siteinfo($parm='')

".FOOTLAN_12."
- ".e107::getDB()->getServerInfo(). // mySqlServerInfo. + ".e107::getDb()->getServerInfo(). // mySqlServerInfo. "
".FOOTLAN_16.": ".$mySQLdefaultdb." -
PDO: ".((e107::getDB()->getPDO() === true) ? LAN_ENABLED : LAN_DISABLED)." +
PDO: ".((e107::getDb()->getPDO() === true) ? LAN_ENABLED : LAN_DISABLED)."
Mode: ".$sqlMode."

@@ -1411,7 +1413,7 @@ function sc_admin_addon_updates() $res = e107::getSession()->get('addons-update-status'); - if($res !== null) + if($res !== null) // cached version. { return $res; } @@ -1469,20 +1471,31 @@ public function getUpdateable($type) case "plugin": $versions = $mp->getVersionList('plugin'); - $list = e107::getPref('plug_installed'); + $plg = e107::getPlug(); + $tmp = $plg->getInstalled(); + $list = array(); + foreach($tmp as $folder=>$version) + { + $plg->load($folder); + $list[$folder] = array('version'=>$version, 'author'=>$plg->getAuthor()); + } + break; } $ret = array(); - foreach($list as $folder=>$version) + foreach($list as $folder=>$var) { + $version = $var['version']; + $author = $var['author']; - if(!empty($versions[$folder]['version']) && version_compare( $version, $versions[$folder]['version'], '<')) + if(!empty($versions[$folder]['version']) && version_compare( $version, $versions[$folder]['version'], '<') && ($versions[$folder]['author'] === $author)) { $versions[$folder]['modalDownload'] = $mp->getDownloadModal($type, $versions[$folder]); $ret[] = $versions[$folder]; e107::getMessage()->addDebug("Local version: ".$version." Remote version: ".$versions[$folder]['version']); + e107::getMessage()->addDebug("Local author: ".$$author." Remote author: ".$versions[$folder]['author']); } } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 275e4ad566..2b94d5751a 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -447,7 +447,7 @@ public function getList($mode=null) { foreach($this->_data as $dir=>$v) { - $arr[$dir] = $v['version']; + $arr[$dir] = array('version'=>$v['version'], 'author'=>$v['author']); } }