API for plugins to test and display a new version message

`<?if (plugin_update_available('commmunity.applications')):?>
$(function() {
showNotice('The plugin <b>community.applications</b> requires an
update!');
});
<?endif;?>`
This commit is contained in:
bergware
2016-03-29 11:44:16 +02:00
parent 081599c7d8
commit ff3147b10e
2 changed files with 11 additions and 1 deletions
@@ -148,6 +148,9 @@ function showFooter(data, id) {
if (id !== undefined) $('#'+id).remove();
$('#copyright').prepend(data);
}
function showNotice(data) {
$('#user-notice').html(data.replace(/<[ab]>(.*?)<\/[ab]>/,"<a href='/Plugins'>$1</a>"));
}
function notifier() {
$.post('/webGui/include/Notify.php',{cmd:'get'},function(data) {
if (data) {
@@ -308,7 +311,7 @@ default:
}
echo "</span>&bullet;&nbsp;<span class='bitstream'>Dynamix webGui v";
echo exec("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin version /var/log/plugins/dynamix.plg");
echo "</span></span><span id='countdown'></span><span id='copyright'>unRAID&trade; webGui &copy; 2015, Lime Technology, Inc.";
echo "</span></span><span id='countdown'></span><span id='user-notice' class='red-text'></span><span id='copyright'>unRAID&trade; webGui &copy; 2015, Lime Technology, Inc.";
if (isset($myPage['Author'])) {
echo "&nbsp;|&nbsp;Page author: {$myPage['Author']}";
if (isset($myPage['Version'])) echo ", version: {$myPage['Version']}";
+7
View File
@@ -32,4 +32,11 @@ function agent_fullname($agent, $state) {
default : return $agent;
}
}
function plugin_update_available($plugin) {
$script = '/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin';
$local = file_exists("/var/log/plugins/$plugin.plg") ? exec("$script version /var/log/plugins/$plugin.plg") : "";
$remote = file_exists("/tmp/plugins/$plugin.plg") ? exec("$script version /tmp/plugins/$plugin.plg") : "";
return strcmp($remote,$local)>0;
}
?>