1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 17:23:00 +00:00

Delete associated file when deleting page. Fixes #23

This commit is contained in:
Starbeamrainbowlabs 2015-10-25 11:11:04 +00:00
parent fe978fa980
commit 7577a6669c
3 changed files with 18 additions and 5 deletions

View file

@ -1648,7 +1648,7 @@ register_module([
register_module([
"name" => "Page deleter",
"version" => "0.6",
"version" => "0.7",
"author" => "Starbeamrainbowlabs",
"description" => "Adds an action to allow administrators to delete pages.",
"id" => "page-delete",
@ -1674,6 +1674,11 @@ register_module([
<p><a href='index.php?action=view&page=$env->page'>Click here to go back.</a>"));
}
$page = $env->page;
// Delete the associated file if it exists
if(!empty($pageindex->$page->uploadedfile))
{
unlink($pageindex->$page->uploadedfilepath);
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("./$env->page.md"); //delete the page from the disk
@ -2208,10 +2213,13 @@ register_module([
$pageindex->$new_name->$key = $value;
}
unset($pageindex->$page);
$pageindex->$new_name->filename = $new_name;
// If this page has an associated file, then we should move that too
if(isset($pageindex->$new_name->uploadedfile) and
$pageindex->$new_name->uploadedfile == true)
{
// Update the filepath to point to the description and not the image
$pageindex->$new_name->filename = $pageindex->$new_name->filename . ".md";
// Move the file in the pageindex
$pageindex->$new_name->uploadedfilepath = $new_name;
// Move the file on disk

View file

@ -64,11 +64,11 @@
},
{
"name": "Page deleter",
"version": "0.6",
"version": "0.7",
"author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to delete pages.",
"id": "page-delete",
"lastupdate": 1445170746,
"lastupdate": 1445771075,
"optional": false
},
{
@ -131,7 +131,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to move pages.",
"id": "page-move",
"lastupdate": 1445770963,
"lastupdate": 1445771285,
"optional": false
},
{

View file

@ -1,7 +1,7 @@
<?php
register_module([
"name" => "Page deleter",
"version" => "0.6",
"version" => "0.7",
"author" => "Starbeamrainbowlabs",
"description" => "Adds an action to allow administrators to delete pages.",
"id" => "page-delete",
@ -27,6 +27,11 @@ register_module([
<p><a href='index.php?action=view&page=$env->page'>Click here to go back.</a>"));
}
$page = $env->page;
// Delete the associated file if it exists
if(!empty($pageindex->$page->uploadedfile))
{
unlink($pageindex->$page->uploadedfilepath);
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("./$env->page.md"); //delete the page from the disk