Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin Dashboard Plugin Updates Available Tab #1107

Closed
wants to merge 10 commits into from
Closed
27 changes: 27 additions & 0 deletions admin/skins/default/templates/dashboard.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,30 @@ function drawChart() {
</fieldset>
</div>
</div>
{if $PLUGIN_UPDATES_AVAILABLE}
<div id="plugin_updates_available" class="tab_content">
<h3>{$LANG.dashboard.title_plugin_updates_available}</h3>
<table width="100%">
<thead>
<tr>
<th width="40%">{$LANG.dashboard.pua_heading_plugin_name}</th>
<th width="40%">{$LANG.dashboard.pua_heading_plugin_creator}</th>
<th width="10%" align="center">{$LANG.dashboard.pua_heading_installed_version}</th>
<th width="10%" align="center">{$LANG.dashboard.pua_heading_current_version}</th>
</tr>
</thead>
{foreach from=$PLUGIN_UPDATES item=plugin_update}
<tr>
<td>
<a href="{$plugin_update.plugin_href}" title="{$plugin_update.plugin_name}">{$plugin_update.plugin_name}</a> - <a href="{$plugin_update.plugin_update_url}" class="update_available" target="_blank" title="{$plugin_update.creator}">{$LANG.dashboard.update_available}</a>
</td>
<td>
<a href="{$plugin_update.plugin_creator_href}" title="{$plugin_update.plugin_creator_name}" target="_blank">{$plugin_update.plugin_creator_name}</a>
</td>
<td align="center">{$plugin_update.plugin_installed_version}</td>
<td align="center">{$plugin_update.plugin_current_version}</td>
</tr>
{/foreach}
</table>
</div>
{/if}
11 changes: 8 additions & 3 deletions admin/skins/default/templates/plugins.index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<tr>
<th width="10">{$LANG.common.status}</th>
<th>{$LANG.common.name_and_desc}</th>
<th>{$LANG.hooks.version}</th>
<th>{$LANG.module.installed_version}</th>
<th>{$LANG.module.current_version}</th>
<th>{$LANG.common.type}</th>
<th width="10">&nbsp;</th>
</tr>
Expand All @@ -42,8 +43,12 @@
<input type="hidden" id="status_{$module.basename}" name="status[{$module.basename}]" value="{$module.config.status}" class="toggle">
<input type="hidden" name="type[{$module.basename}]" value="{$module.type}" />
</td>
<td><a href="{$module.edit_url}">{$module.name}</a><br>{$module.description}</td>
<td>
<a href="{$module.edit_url}">{$module.name}</a>{if $module.update_available} - <a href="{$module.update_url}" class="update_available" target="_blank" title="{$module.creator}">{$LANG.module.update_available}</a>{/if}
<br>{$module.description}
</td>
<td>{$module.version}</td>
<td>{$module.current_version}</td>
<td>{$module.type|ucfirst}</td>
<td nowrap>
<a href="{$module.edit_url}" class="edit"><i class="fa fa-pencil-square-o" title="{$LANG.common.edit}"></i></a>
Expand Down Expand Up @@ -115,4 +120,4 @@
</tbody>
</table>
{/if}
</div>
</div>
46 changes: 46 additions & 0 deletions admin/sources/dashboard.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,50 @@

$GLOBALS['main']->addTabControl($lang['common']['search'], 'sidebar');

## Plugin Updates Available Tab
$plugin_updates_available = 0;
$plugin_updates_list = array();

$module_paths = glob("modules/*/*/config.xml");

foreach ($module_paths as $module_path) {
$xml = new SimpleXMLElement(file_get_contents($module_path));
$basename = (string)basename(str_replace('config.xml','', $module_path));
$installed_version = (string)$xml->info->version;
$version_check_url = (string)$xml->info->version_check_url;
if (!empty($version_check_url) && $request = new Request($version_check_url)) {
$request->skiplog(true);
$request->setMethod('get');
$request->cache(true);
$request->setSSL(true);
$request->setUserAgent('CubeCart');
$request->setData(array('plugin_version' => $installed_version));
if (($response = $request->send()) !== false) {
if (version_compare(trim($response), $installed_version, '>')) {
if (!empty($xml->info->update_url)) {
$update_url = (string)$xml->info->update_url;
} else {
$update_url = 'https://www.cubecart.com/extensions';
}
$plugin_updates_list[$basename] = array(
'plugin_href' => '?_g=plugins&type='.(string)$xml->info->type.'&module='.$basename,
'plugin_name' => (string)$xml->info->name,
'plugin_creator_href' => (string)$xml->info->homepage,
'plugin_creator_name' => (string)$xml->info->creator,
'plugin_installed_version' => $installed_version,
'plugin_current_version' => $response,
'plugin_update_url' => $update_url,
);
++$plugin_updates_available;
}
}
}
}

if ($plugin_updates_available > 0) {
$GLOBALS['main']->addTabControl($lang['dashboard']['title_plugin_updates_available_tab'], 'plugin_updates_available', null, null, $plugin_updates_available);
$GLOBALS['smarty']->assign('PLUGIN_UPDATES', $plugin_updates_list);
$GLOBALS['smarty']->assign('PLUGIN_UPDATES_AVAILABLE', true);
}

$page_content = $GLOBALS['smarty']->fetch('templates/dashboard.index.php');
40 changes: 39 additions & 1 deletion admin/sources/plugins.index.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
}

$GLOBALS['main']->addTabControl($lang['navigation']['nav_plugins'], 'plugins');
$GLOBALS['gui']->addBreadcrumb($lang['navigation']['nav_plugins'], currentPage());

if(isset($_GET['delete']) && $_GET['delete']==1) {
$dir = CC_ROOT_DIR.'/modules/'.$_GET['type'].'/'.$_GET['module'];
if(file_exists($dir)) {
Expand Down Expand Up @@ -206,6 +208,38 @@

$module_config = $GLOBALS['db']->select('CubeCart_modules','*',array('folder' => $basename, 'module' => (string)$xml->info->type));

$installed_version = (string)$xml->info->version;
$version_check_url = (string)$xml->info->version_check_url;

if (!empty($version_check_url) && $request = new Request($version_check_url)) {
$request->skiplog(true);
$request->setMethod('get');
$request->cache(true);
$request->setSSL(true);
$request->setUserAgent('CubeCart');
$request->setData(array('plugin_version' => $installed_version));
if (($response = $request->send()) !== false) {
$current_version = trim($response);
if (version_compare($current_version, $installed_version, '>')) {
$update_available = true;
} else {
$update_available = false;
}
} else {
$current_version = $lang['module']['unknown_version'];
$update_available = false;
}
} else {
$current_version = $lang['module']['unknown_version'];
$update_available = false;
}

if (!empty($xml->info->update_url)) {
$update_url = (string)$xml->info->update_url;
} else {
$update_url = 'https://www.cubecart.com/extensions';
}

$modules[$key] = array(
'uid' => (string)$xml->info->uid,
'type' => (string)$xml->info->type,
Expand All @@ -217,6 +251,10 @@
'maxVersion' => (string)$xml->info->maxVersion,
'creator' => (string)$xml->info->creator,
'homepage' => (string)$xml->info->homepage,
'version_check_url' => (string)$xml->info->version_check_url,
'current_version' => $current_version,
'update_available' => $update_available,
'update_url' => $update_url,
'block' => (string)$xml->info->block,
'basename' => $basename,
'config' => $module_config[0],
Expand Down Expand Up @@ -258,4 +296,4 @@
$GLOBALS['smarty']->assign('SKINS',$skins);
}

$page_content = $GLOBALS['smarty']->fetch('templates/plugins.index.php');
$page_content = $GLOBALS['smarty']->fetch('templates/plugins.index.php');
11 changes: 11 additions & 0 deletions language/definitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,13 @@
<string name="title_list" introduced="5.0.0"><![CDATA[Customer List]]></string>
</group>
<group name="dashboard">
<string name="title_plugin_updates_available_tab" introduced="6.0.12"><![CDATA[Plugin Updates]]></string>
<string name="title_plugin_updates_available" introduced="6.0.12"><![CDATA[Plugin Updates Available]]></string>
<string name="pua_heading_plugin_creator" introduced="6.0.12"><![CDATA[Plugin Creator]]></string>
<string name="pua_heading_plugin_name" introduced="6.0.12"><![CDATA[Plugin Name]]></string>
<string name="pua_heading_installed_version" introduced="6.0.12"><![CDATA[Installed Version]]></string>
<string name="pua_heading_current_version" introduced="6.0.12"><![CDATA[Current Version]]></string>
<string name="update_available" introduced="6.0.12"><![CDATA[Update Available!]]></string>
<string name="quick_tour" introduced="6.0.0"><![CDATA[Quick Tour]]></string>
<string name="tour_welcome" introduced="6.0.0"><![CDATA[Welcome to your store. Please follow this quick tour to help get you started.]]></string>
<string name="ok_go" introduced="6.0.0"><![CDATA[Ok, lets go!]]></string>
Expand Down Expand Up @@ -1354,6 +1361,10 @@
<string name="query_box" introduced="5.0.0"><![CDATA[Query Box]]></string>
</group>
<group name="module">
<string name="installed_version" introduced="6.0.12"><![CDATA[Installed Version]]></string>
<string name="current_version" introduced="6.0.12"><![CDATA[Current Version]]></string>
<string name="unknown_version" introduced="6.0.12"><![CDATA[Unknown]]></string>
<string name="update_available" introduced="6.0.12"><![CDATA[Update Available!]]></string>
<string name="package_fail" introduced="6.0.9"><![CDATA[Error: Failed to obtain package information. Please install via FTP.]]></string>
<string name="plugin_still_exists" introduced="6.0.0"><![CDATA[Plugin still exists. Please delete manually via FTP or hosting filemanager.]]></string>
<string name="plugin_deleted_successfully" introduced="6.0.0"><![CDATA[Plugin deleted succesfully.]]></string>
Expand Down