-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
delete messages using async ajax and replace link to toggle admin rou…
…ndmail by checkbox
- Loading branch information
1 parent
7afc2c5
commit 45d0d58
Showing
8 changed files
with
102 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* | ||
* MIT Licence | ||
* Copyright (c) 2023 Simon Frankenberger | ||
* | ||
* Please see LICENCE.md for complete licence text. | ||
*/ | ||
require_once __DIR__ . '/../include/functions.inc.php'; | ||
require_once __DIR__ . '/../include/database.class.php'; | ||
|
||
ob_start(); | ||
|
||
$db = Database::getInstance(); | ||
switch (getOrDefault($_POST, 'a', 0)) { | ||
// delete message | ||
case 1: | ||
requireLogin(); | ||
restrictSitter('Nachrichten'); | ||
requireXsrfToken('/?p=nachrichten_liste'); | ||
$id = getOrDefault($_POST, 'id', 0); | ||
$data = $db->getMessageByIdAndAnOrVonEquals($id, $_SESSION['blm_user']); | ||
|
||
// verify that the message exists | ||
if ($data === null || (is_array($data) && count($data) == 0)) { | ||
http_response_code(404); | ||
die(); | ||
} | ||
|
||
// only allow deletion of outgoing messages if the receiver hasn't read the message yet | ||
if ($data['Von'] == $_SESSION['blm_user'] && $data['Gelesen'] == 1) { | ||
http_response_code(401); | ||
} | ||
|
||
// delete the message | ||
$db->begin(); | ||
if ($db->deleteTableEntry(Database::TABLE_MESSAGES, $id) === null) { | ||
$db->rollBack(); | ||
http_response_code(500); | ||
} | ||
$db->commit(); | ||
break; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters