Check requirements on plugin updates

This commit is contained in:
Squidly271 2022-06-03 08:58:40 -04:00
parent c62e3ecfff
commit 0639fe8a71
5 changed files with 46 additions and 6 deletions

Binary file not shown.

View File

@ -687,7 +687,7 @@ $(function(){
var icon = this;
iconHoverTimer = setTimeout(function() {
icon.click();
},4000);
},3000);
});
$("body").on("mouseout",".ca_displayIcon,.infoButton,displayIcon,.card_readmore",function() {
clearTimeout(iconHoverTimer);
@ -1126,7 +1126,31 @@ function closeSidebar(cookie=false,visible=false) {
$(".sidebar").fadeOut();
}
function installPlugin(pluginURL,update=false,comment="") {
function installPlugin(pluginURL,update=false,comment="",requires="") {
if ( update && requires ) {
post({action:"checkRequirements",requires:requires},function(data) {
if (! data.met) {
swal({
title: "<?tr("Requirements not met")?>",
text: "<?tr("The requirements for this upgrade have not been met on your system")?>",
allowOutsideClick: false,
showConfirmButton: true,
showCancelButton: false,
confirmButtonText: "<?tr("OK")?>",
type: "error"
},function(isConfirm) {
enableSearch();
});
} else {
actuallyInstallPlugin(pluginURL,update,comment);
}
});
} else {
actuallyInstallPlugin(pluginURL,update,comment);
}
}
function actuallyInstallPlugin(pluginURL,update=false,comment="") {
type = update ? "update" : "install";
title = update ? "<?tr("Update Plugin")?>" : "<?tr("Install Plugin")?>";
closeSidebar(true);

View File

@ -1,8 +1,8 @@
190537dc3141ea73a8b13282e4b3ae10 ./Apps.page
7e275d5cac72b90e52f4cf3372385b30 ./Apps.page
4e55f7483b661af21a25b677179baffe ./CA_notices.page
42a1658a916a3a3eed2a9f2af80603c4 ./ca_settings.page
e718d7825dbdc96a17a915079222b098 ./default.cfg
075e2f41f1ab506187a1deb5e5b89557 ./include/exec.php
eb2cdb14fcc188f6b3240247af9436ad ./include/exec.php
443a7e01447411322b706390a18d2bd5 ./include/helpers.php
fc87642746ba4f324537bc381b78e982 ./include/paths.php
532fffdf939594c143e679da02bd841e ./javascript/libraries.js
@ -21,4 +21,4 @@ da3b4f9b73c5c3bf65be6c42d68b51f9 ./scripts/showStatistics.php
34554a56611dfe625889c82afd5138de ./scripts/updatePluginSupport.php
ce8e45452d3b63b5943b6f39c817bbf9 ./skins/Narrow/css.php
c4d6ce8de3baff1c9de2b7f348b2f340 ./skins/Narrow/skin.html
6f419a8da191f6ffe71e6c676bc39857 ./skins/Narrow/skin.php
3e08499cb11f56f702ac7f833c21ce30 ./skins/Narrow/skin.php

View File

@ -193,6 +193,9 @@ switch ($_POST['action']) {
break;
case 'var_dump':
break;
case 'checkRequirements':
checkRequirements();
break;
###############################################
# Return an error if the action doesn't exist #
###############################################
@ -2391,6 +2394,19 @@ function enableActionCentre() {
postReturn(['status'=>"noaction"]);
}
}
###################################################
# Checks the requirements being met on an upgrade #
###################################################
function checkRequirements() {
$requiresFile = getPost("requires","");
if (! $requiresFile || ($requiresFile && is_file($requiresFile) ) ) {
postReturn(['met'=>true]);
} else {
postReturn(['met'=>""]);
}
}
#######################################
# Logs Javascript errors being caught #
#######################################

View File

@ -199,7 +199,7 @@ function my_display_apps($file,$pageNumber=1,$selectedApps=false,$startup=false)
if ( ( strcmp(plugin("version","/var/log/plugins/$pluginName"),$template['pluginVersion']) < 0 || $template['UpdateAvailable']) && $template['Name'] !== "Community Applications") {
@copy($caPaths['pluginTempDownload'],"/tmp/plugins/$pluginName");
$template['UpdateAvailable'] = true;
$actionsContext[] = array("icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"installPlugin('$pluginName',true);");
$actionsContext[] = array("icon"=>"ca_fa-update","text"=>tr("Update"),"action"=>"installPlugin('$pluginName',true,'','{$template['RequiresFile']}');");
} else {
if ( ! $template['UpdateAvailable'] ) # this handles if the feed hasn't caught up to the update yet
$template['UpdateAvailable'] = false;