feat(php): implement delete all files method

This commit is contained in:
Serik Ibragimov
2024-03-06 13:42:41 +05:00
parent 5775f44f27
commit 81ad7f7a64
4 changed files with 55 additions and 6 deletions

View File

@ -594,6 +594,29 @@ footer table tr td:first-child {
width: 4%;
}
.storedHeader {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}
.storedHeaderClearAll {
padding-right: 52px;
}
.clear-all {
display: inline-block;
width: 100px;
padding: 2px;
outline: 1px solid #E5E5E5;
text-align: center;
cursor:pointer;
text-transform: uppercase;
background-color: #F5F5F5;
color: #666666;
}
.select-user {
color: #444444;
font-family: Open Sans;

View File

@ -310,6 +310,22 @@ if (typeof jQuery != "undefined") {
});
});
jq(document).on("click", ".clear-all", function () {
if (confirm("Delete all the files?")) {
jq.ajax({
async: true,
contentType: "text/xml",
type: "delete",
url: "delete",
complete: function (data) {
if (JSON.parse(data.responseText).status == 'success') {
window.location.reload(true);
}
}
});
}
});
jq(document).on("click", "#createSample", function () {
jq(".try-editor").each(function () {
var href = jq(this).attr("href");

View File

@ -299,12 +299,15 @@ function convert()
function delete()
{
try {
$fileName = basename($_GET["fileName"]);
if(isset($_GET["fileName"]) && !empty($_GET["fileName"])) {
$fileName = basename($_GET["fileName"]);
$filePath = getStoragePath($fileName);
$filePath = getStoragePath($fileName);
unlink($filePath); // delete a file
delTree(getHistoryDir($filePath)); // delete all the elements from the history directory
unlink($filePath); // delete a file
delTree(getHistoryDir($filePath)); // delete all the elements from the history directory
} else {
delTree(getStoragePath('')); // delete the user's folder and all the containing files
}
} catch (Exception $e) {
sendlog("Deletion ".$e->getMessage(), "webedior-ajax.log");
$result["error"] = "error: " . $e->getMessage();

View File

@ -1,5 +1,12 @@
<div class="stored-list">
<span class="header-list">Your documents</span>
<div class="storedHeader">
<div class="storedHeaderText">
<span class="header-list">Your documents</span>
</div>
<div class="storedHeaderClearAll">
<div class="clear-all">Clear all</div>
</div>
</div>
<table class="tableHeader" cellspacing="0" cellpadding="0" width="100%">
<thead>
<tr>