related to #1503 You cant activate/deactivate plugins as admin now

This commit is contained in:
Matthieu Leproux
2021-10-05 15:46:10 +02:00
parent d2ea8fa3cc
commit 4600fab331
5 changed files with 64 additions and 34 deletions
+3 -29
View File
@@ -44,36 +44,9 @@ $action_url = $base_url.'&plugin='.'%s'.'&pwg_token='.$pwg_token;
$plugins = new plugins();
//--------------------------------------------------perform requested actions
if (isset($_GET['action']) and isset($_GET['plugin']))
if (!is_webmaster())
{
if (!is_webmaster())
{
$page['errors'][] = l10n('Webmaster status is required.');
}
else
{
check_pwg_token();
$page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']);
if (empty($page['errors']))
{
if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate')
{
$template->delete_compiled_templates();
$persistent_cache->purge(true);
}
$redirect_url = $base_url;
if ('activate' == $_GET['action'])
{
$redirect_url.= '&show_inactive';
}
redirect($redirect_url);
}
}
$page['errors'][] = l10n('Webmaster status is required.');
}
//--------------------------------------------------------Incompatible Plugins
@@ -218,6 +191,7 @@ $template->assign(
'base_url' => $base_url,
'show_details' => $show_details,
'max_inactive_before_hide' => isset($_GET['show_inactive']) ? 999 : 8,
'isWebmaster' => (is_webmaster()) ? 1 : 0,
)
);
+20 -4
View File
@@ -95,7 +95,7 @@ function activatePlugin(id) {
actualizeFilterBadges();
}
},
error: function () {
error: function (e) {
console.log(e);
console.log("It didn't work");
$("#" + id + " .pluginNotif").stop(false, true);
@@ -136,7 +136,7 @@ function disactivatePlugin(id) {
actualizeFilterBadges(nb_plugin.all, nb_plugin.active, nb_plugin.inactive, nb_plugin.other)
}
},
error: function () {
error: function (e) {
console.log(e);
console.log("It didn't work");
$("#" + id + " .pluginNotif").stop(false, true);
@@ -347,7 +347,10 @@ $(document).ready(function () {
/**
* Activate / Deactivate
*/
$(".switch").change(function () {
if (isWebmaster != 0) {
$(".switch").change(function () {
$(".pluginMiniBox").addClass("usable");
if ($(this).find("#toggleSelectionMode").is(':checked')) {
activatePlugin($(this).parent().parent().attr("id"));
console.log("activatePlugin");
@@ -365,7 +368,20 @@ $(document).ready(function () {
}
actualizeFilter();
})
})
} else {
$(".pluginMiniBox").addClass("notUsable");
$(".plugin-active").find(".slider").addClass("desactivate_disabled");
$(".plugin-inactive").find(".slider").addClass("activate_disabled");
$(".switch input").on("click", function (event) {
$(this).addClass("disabled");
event.preventDefault();
event.stopPropagation();
setTimeout(function(){
$(".switch input").removeClass("disabled");
}, 400); //Same duration as the animation "desactivate_disabled" in css
})
}
/**
* Delete
@@ -33,6 +33,7 @@ const plugin_added_str = '{'Activated'|@translate}';
const plugin_deactivated_str = '{'Deactivated'|@translate}';
const plugin_restored_str = '{'Restored'|@translate}';
const plugin_action_error = '{'an error happened'|@translate}';
const isWebmaster = {$isWebmaster};
{literal}
var queuedManager = jQuery.manageAjax.create('queued', {
queue: true,
+35 -1
View File
@@ -3807,12 +3807,46 @@ input[type="text"].dError {border-color:#ff7070; background-color:#FFe5e5;}
transition: .4s;
}
input:checked + .slider:before {
.plugin-active input:checked + .slider:before {
-webkit-transform: translateX(33px);
-ms-transform: translateX(33px);
transform: translateX(33px);
}
.notUsable input.disabled + .slider.activate_disabled:before {
animation: activate_disabled .4s linear;
}
@keyframes activate_disabled {
50% {
-webkit-transform: translateX(5px);
-ms-transform: translateX(5px);
transform: translateX(5px);
}
100% {
-webkit-transform: translateX(0px);
-ms-transform: translateX(0px);
transform: translateX(0);
}
}
.notUsable input:checked + .slider.desactivate_disabled:before {
animation: desactivate_disabled .4s linear;
}
@keyframes desactivate_disabled {
50% {
-webkit-transform: translateX(28px);
-ms-transform: translateX(28px);
transform: translateX(28px);
}
100% {
-webkit-transform: translateX(33px);
-ms-transform: translateX(33px);
transform: translateX(33px);
}
}
.slider.round {
border-radius: 34px;
}
+5
View File
@@ -59,6 +59,11 @@ function ws_plugins_performAction($params, $service)
return new PwgError(403, 'Invalid security token');
}
if (!is_webmaster())
{
return new PwgError(403, l10n('Webmaster status is required.'));
}
define('IN_ADMIN', true);
include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');