From 721ce41579743be18071a0b19ad1f8d62c9b4101 Mon Sep 17 00:00:00 2001 From: nworr <43475951+nworr@users.noreply.github.com> Date: Tue, 24 Sep 2024 15:06:13 +0200 Subject: [PATCH] Count user defined js , adapt message when js exception (#4776) * count user defined js and check if user is admin * check user defined script and adapt message on js exception * add no_user_defined_js=1 to url disable user script * add repoAdminLink to lizUrls --- assets/src/legacy/map.js | 10 ++++++++-- lizmap/modules/view/controllers/lizAjax.classic.php | 3 +++ lizmap/modules/view/controllers/lizMap.classic.php | 8 +++++++- .../view/locales/en_US/dictionnary.UTF-8.properties | 3 +++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/assets/src/legacy/map.js b/assets/src/legacy/map.js index 17879c4108..7ef6400289 100644 --- a/assets/src/legacy/map.js +++ b/assets/src/legacy/map.js @@ -3914,9 +3914,15 @@ window.lizMap = function() { }) .catch((error) => { console.error(error); - const errorMsg = ` + let errorMsg = `

${lizDict['startup.error']} -
${lizDict['startup.goToProject']}

`; +
${lizDict['startup.goToProject']}`; + if (document.body.dataset.lizmapUserDefinedJsCount > 0 && document.body.dataset.lizmapAdminUser == 1) { + errorMsg += '
'+`${lizDict['startup.user_defined_js']}
+ ${lizDict['startup.goToRepositoryAdmin']}
+ ${lizDict['startup.projectWithoutJSLink']}` + } + errorMsg += `

`; document.getElementById('header').insertAdjacentHTML('afterend', errorMsg); }) .finally(() => { diff --git a/lizmap/modules/view/controllers/lizAjax.classic.php b/lizmap/modules/view/controllers/lizAjax.classic.php index 33fdbd43d1..339137fda7 100644 --- a/lizmap/modules/view/controllers/lizAjax.classic.php +++ b/lizmap/modules/view/controllers/lizAjax.classic.php @@ -187,6 +187,9 @@ function f($x) $lizUrls['removeCache'] = jUrl::getFull('admin~maps:removeLayerCache'); } + if (jAcl2::check('lizmap.admin.access') || jAcl2::check('lizmap.admin.server.information.view')) { + $lizUrls['repositoryAdmin'] = jUrl::getFull('admin~maps:index'); + } $content = '