1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 16:33:00 +00:00

A real fix for #36.

This commit is contained in:
Starbeamrainbowlabs 2015-11-12 09:59:08 +00:00
parent 839767ad62
commit 414eb58850
3 changed files with 7 additions and 19 deletions

View file

@ -1233,23 +1233,17 @@ register_module([
// They check out ok, toggle the page's protection. // They check out ok, toggle the page's protection.
$page = $env->page; $page = $env->page;
$toggled = false;
if(!isset($pageindex->$page->protect)) if(!isset($pageindex->$page->protect))
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
$toggled = true;
} }
else if($pageindex->$page->protect === true)
if(!$toggled && $pageindex->$page->protect === true)
{ {
$pageindex->$page->protect = false; $pageindex->$page->protect = false;
$toggled = false;
} }
else if($pageindex->$page->protect === false)
if(!$toggled && $pageindex->$page->protect === false)
{ {
$pageindex->$page->protected = true; $pageindex->$page->protect = true;
$toggled = true;
} }
// Save the pageindex // Save the pageindex

View file

@ -14,7 +14,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.", "description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.",
"id": "action-protect", "id": "action-protect",
"lastupdate": 1447320607, "lastupdate": 1447322278,
"optional": false "optional": false
}, },
{ {

View file

@ -15,23 +15,17 @@ register_module([
// They check out ok, toggle the page's protection. // They check out ok, toggle the page's protection.
$page = $env->page; $page = $env->page;
$toggled = false;
if(!isset($pageindex->$page->protect)) if(!isset($pageindex->$page->protect))
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
$toggled = true;
} }
else if($pageindex->$page->protect === true)
if(!$toggled && $pageindex->$page->protect === true)
{ {
$pageindex->$page->protect = false; $pageindex->$page->protect = false;
$toggled = false;
} }
else if($pageindex->$page->protect === false)
if(!$toggled && $pageindex->$page->protect === false)
{ {
$pageindex->$page->protected = true; $pageindex->$page->protect = true;
$toggled = true;
} }
// Save the pageindex // Save the pageindex