Skip to content

Commit

Permalink
Fixes #3711 - check local themes/plugins against author names as well…
Browse files Browse the repository at this point in the history
… as versions before suggesting updates.
  • Loading branch information
CaMer0n committed Apr 11, 2019
1 parent f148e20 commit 18a8571
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
6 changes: 4 additions & 2 deletions e107_admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions e107_admin/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
{
e107::getSession()->set('addons-update-checked',true);

/** @var admin_shortcodes $sc */
$sc = e107::getScBatch('admin');

$themes = $sc->getUpdateable('theme');
Expand All @@ -64,6 +65,7 @@
$text = $sc->renderAddonUpdate($plugins);
$text .= $sc->renderAddonUpdate($themes);


if(empty($text))
{
exit;
Expand Down
7 changes: 6 additions & 1 deletion e107_admin/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ private function pluginUpgrade()
if(file_exists($_path.'plugin.xml'))
{
$plugin->install_plugin_xml($id, 'upgrade');
$text = LAN_UPGRADE_SUCCESSFUL;
}
else
{
Expand Down Expand Up @@ -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');
}

Expand Down
6 changes: 5 additions & 1 deletion e107_admin/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
27 changes: 20 additions & 7 deletions e107_core/shortcodes/batch/admin_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1131,7 +1133,7 @@ function sc_admin_siteinfo($parm='')

$text .= $themeinfo ? "<br />".FOOTLAN_7.": ".$themeinfo : '';

$sqlMode = str_replace(",", ", ",e107::getDB()->getMode());
$sqlMode = str_replace(",", ", ", e107::getDb()->getMode());

$text .= "<br /><br />
<b>".FOOTLAN_8."</b>
Expand All @@ -1152,10 +1154,10 @@ function sc_admin_siteinfo($parm='')
<br /><br />
<b>".FOOTLAN_12."</b>
<br />
".e107::getDB()->getServerInfo(). // mySqlServerInfo.
".e107::getDb()->getServerInfo(). // mySqlServerInfo.

"<br />".FOOTLAN_16.": ".$mySQLdefaultdb."
<br />PDO: ".((e107::getDB()->getPDO() === true) ? LAN_ENABLED : LAN_DISABLED)."
<br />PDO: ".((e107::getDb()->getPDO() === true) ? LAN_ENABLED : LAN_DISABLED)."
<br />Mode: <small>".$sqlMode."</small>
<br /><br />
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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']);
}

}
Expand Down
2 changes: 1 addition & 1 deletion e107_handlers/theme_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

}
Expand Down

0 comments on commit 18a8571

Please sign in to comment.