This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcancel.php
60 lines (46 loc) · 1.72 KB
/
cancel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once(dirname(__FILE__)."/config.inc.php");
require_once(dirname(__FILE__)."/classes/session.class.php");
require_once(dirname(__FILE__)."/classes/cancel.class.php");
$session = new Session($config);
$template = $config->getTemplate($session->getAuth());
$boardid = $_REQUEST["boardid"];
$messageid = isset($_REQUEST["messageid"]) ? $config->decodeMessageID($_REQUEST["messageid"]) : null;
try {
if ($session->getAuth()->isAnonymous()) {
throw new Exception("Diese Funktion steht anonymen Benutzern nicht zur Verfügung");
}
$board = $config->getBoard($boardid);
$connection = $board->getConnection();
if ($connection === null) {
throw new Exception("Board enthaelt keine Group!");
}
/* Thread laden */
// Sobald die Verbindung geoeffnet ist, beginnen wir einen Kritischen Abschnitt!
$connection->open($session->getAuth());
$group = $connection->getGroup();
$connection->close();
$message = $group->getMessage($messageid);
$thread = $group->getThread($messageid);
if (!($message instanceof Message)) {
throw new Exception("Message konnte nicht zugeordnet werden.");
}
if (!$session->getAuth()->mayCancel($message)) {
throw new Exception("Keine Berechtigung!");
}
// TODO Zustimmungs-Posts canceln?
$cancelid = $config->generateMessageID();
$author = $session->getAuth()->getAddress();
$cancel = new Cancel($cancelid, $messageid, time(), $author, $wertung);
$connection->open($session->getAuth());
$resp = $connection->postCancel($cancel, $message);
$connection->close();
if ($resp === "m") {
$template->viewcancelmoderated($board, $thread, $message, $cancel);
} else {
$template->viewcancelsuccess($board, $thread, $message, $cancel);
}
} catch (Exception $e) {
$template->viewexception($e);
}
?>