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 pathack.php
60 lines (48 loc) · 1.75 KB
/
ack.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");
$session = new Session($config);
$template = $config->getTemplate($session->getAuth());
$boardid = $_REQUEST["boardid"];
$messageid = isset($_REQUEST["messageid"]) ? $config->decodeMessageID($_REQUEST["messageid"]) : null;
$wertung = isset($_REQUEST["wertung"]) ? intval($_REQUEST["wertung"]) : +1;
try {
if ($session->getAuth()->isAnonymous()) {
throw new Exception("Diese Funktion steht anonymen Benutzern nicht zur Verfügung");
}
$board = $config->getBoard($boardid);
if (!$board->mayAcknowledge($session->getAuth())) {
throw new Exception("Keine Berechtigung!");
}
$connection = $board->getConnection();
if ($connection === null) {
throw new Exception("Board enthaelt keine Group!");
exit;
}
/* 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.");
exit;
}
// TODO mehrfache zustimmungen?
$ackid = $config->generateMessageID();
$autor = $session->getAuth()->getAddress();
$ack = new Acknowledge($ackid, $messageid, time(), $autor, $wertung);
$connection->open($session->getAuth());
$resp = $connection->postAcknowledge($ack, $message);
$connection->close();
if ($resp === "m") {
$template->viewacknowledgemoderated($board, $thread, $message, $ack);
} else {
$template->viewacknowledgesuccess($board, $thread, $message, $ack);
}
} catch (Exception $e) {
$template->viewexception($e);
}
?>