Skip to content

Commit

Permalink
Merge pull request 3liz#4471 from Gustry/check-plugin-version-first
Browse files Browse the repository at this point in the history
For admin, check plugin version first, before checking for warnings
  • Loading branch information
Gustry authored May 24, 2024
2 parents 7be67c5 + a61a27a commit 2152626
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
20 changes: 16 additions & 4 deletions assets/src/modules/ExecuteJSFromServer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
export default function executeJSFromServer() {
lizMap.events.on({
uicreated: () => {
if (document.body.dataset.lizmapPluginWarningUrl) {
if (document.body.dataset.lizmapPluginUpdateWarningUrl) {
var message = lizDict['project.plugin.outdated.warning'];
message += `<br><a href="${document.body.dataset.lizmapPluginUpdateWarningUrl}">`;
message += lizDict['visit.admin.panel.project.page'];
message += '</a>';
message += '<br>';
message += lizDict['project.admin.panel.info'];
// The plugin can be easily updated, the popup can not be closed
lizMap.addMessage(message, 'warning', false).attr('id', 'lizmap-warning-message');
} else if (document.body.dataset.lizmapPluginHasWarningsUrl) {
var message = lizDict['project.has.warnings'];
message += `<br><a href="${document.body.dataset.lizmapPluginWarningUrl}">`;
message += lizDict['project.has.warnings.link'];
message += '</a>'
message += `<br><a href="${document.body.dataset.lizmapPluginHasWarningsUrl}">`;
message += lizDict['visit.admin.panel.project.page'];
message += '</a>';
message += '<br>';
message += lizDict['project.admin.panel.info'];
// It can take times to fix these issues, the popup can be closed
lizMap.addMessage(message, 'warning', true).attr('id', 'lizmap-warning-message');
}

Expand Down
9 changes: 6 additions & 3 deletions lizmap/modules/view/controllers/lizMap.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,12 @@ function f($x)
$assign['googleAnalyticsID'] = $lser->googleAnalyticsID;
}

$serverInfoAccess = (\jAcl2::check('lizmap.admin.access') || \jAcl2::check('lizmap.admin.server.information.view'));
if ($serverInfoAccess && ($lproj->projectCountCfgWarnings() >= 1 || $lproj->qgisLizmapPluginUpdateNeeded())) {
$rep->setBodyAttributes(array('data-lizmap-plugin-warning-url' => jUrl::get('admin~qgis_projects:index')));
if (\jAcl2::check('lizmap.admin.access') || \jAcl2::check('lizmap.admin.server.information.view')) {
if ($lproj->qgisLizmapPluginUpdateNeeded()) {
$rep->setBodyAttributes(array('data-lizmap-plugin-update-warning-url' => jUrl::get('admin~qgis_projects:index')));
} elseif ($lproj->projectCountCfgWarnings() >= 1) {
$rep->setBodyAttributes(array('data-lizmap-plugin-has-warnings-url' => jUrl::get('admin~qgis_projects:index')));
}
}

$rep->body->assign($assign);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
startup.error=An error occurred while loading this map. Some necessary resources may temporarily be unavailable. Please try again later.
startup.goToProject=Go back to the home page.

project.has.warnings=The project has some warnings in the QGIS desktop Lizmap plugin which must be fixed. Only administrators or publishers can see this message.
project.has.warnings.link=Visit the QGIS project page in the administration panel.
project.has.warnings=The project has some warnings in the QGIS desktop Lizmap plugin which must be fixed.
project.plugin.outdated.warning=The project has been recently updated in QGIS Desktop, but with an outdated version of the Lizmap plugin. You must upgrade your plugin in QGIS Desktop.
project.admin.panel.info=Only administrators or publishers can see this message.
visit.admin.panel.project.page=Visit the QGIS project page in the administration panel.

tree.button.checkbox=Display/Hide
tree.button.link=Open documentation
Expand Down

0 comments on commit 2152626

Please sign in to comment.