1<?php
2// This file is part of BOINC.
3// http://boinc.berkeley.edu
4// Copyright (C) 2014 University of California
5//
6// BOINC is free software; you can redistribute it and/or modify it
7// under the terms of the GNU Lesser General Public License
8// as published by the Free Software Foundation,
9// either version 3 of the License, or (at your option) any later version.
10//
11// BOINC is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14// See the GNU Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public License
17// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19// The form where a moderator decides what he is going to do to a post.
20// Submits information to forum_moderate_post_action.php for actual action
21// to be done.
22
23require_once('../inc/util.inc');
24require_once('../inc/forum.inc');
25
26if (DISABLE_FORUMS) error_page("Forums are disabled");
27
28check_get_args(array("id", "action", "userid", "tnow", "ttok"));
29
30$logged_in_user = get_logged_in_user();
31check_tokens($logged_in_user->authenticator);
32BoincForumPrefs::lookup($logged_in_user);
33$postid = get_int('id');
34$post = BoincPost::lookup_id($postid);
35$thread = BoincThread::lookup_id($post->thread);
36$forum = BoincForum::lookup_id($thread->forum);
37
38if (!get_str('action')) {
39    error_page("No action specified");
40}
41if (!is_moderator($logged_in_user, $forum)) {
42    error_page("You are not authorized to moderate this post.");
43}
44
45page_head(tra("Moderate post"));
46
47echo "<form action=\"forum_moderate_post_action.php?id=".$post->id."\" method=\"POST\">\n";
48echo form_tokens($logged_in_user->authenticator);
49start_table();
50
51$get_reason = true;
52if (get_str('action')=="hide") {
53    //display input that selects reason
54    echo "<input type=hidden name=action value=hide>";
55    row1(tra("Hide post"));
56    row2(tra("Reason"),
57        select_from_array('category',
58            array(
59                "",
60                tra("Obscene"),
61                tra("Flame/Hate mail"),
62                tra("Commercial spam"),
63                tra("Doublepost"),
64                tra("User Request"),
65                tra("Other"),
66            )
67        )
68    );
69} elseif (get_str('action')=="move") {
70    row1(tra("Move post"));
71    echo "<input type=hidden name=action value=move>";
72    row2(tra("Destination thread ID:"), "<input name=\"threadid\">");
73    // TODO: display where to move the post as a dropdown instead of having to get ID
74} elseif (get_str('action')=="banish_user") {
75    $userid = get_int('userid');
76    $user = BoincUser::lookup_id($userid);
77    BoincForumPrefs::lookup($user);
78    if (!$user) {
79        error_page("no user found");
80    }
81    $x = $user->prefs->banished_until;
82    if ($x>time()) {
83        error_page(tra("User is already banished"));
84    }
85    row1(tra("Banish user"));
86    row1(tra("Are you sure you want to banish %1?<br/>This will prevent %1 from posting for chosen time period.<br/>It should be done only if %1 has consistently exhibited trollish behavior.", $user->name));
87    row2(tra("Ban duration"), "<select class=\"form-control\" name=\"duration\">
88            <option value=\"21600\">".tra("6 hours")."</option>
89            <option value=\"43200\">".tra("12 hours")."</option>
90            <option value=\"86400\">".tra("1 day")."</option>
91            <option value=\"604800\">".tra("1 week")."</option>
92            <option value=\"1209600\" selected=\"selected\">".tra("2 weeks")."</option>
93            <option value=\"2592000\">".tra("1 month")."</option>
94            <option value=\"-1\">".tra("Forever")."</option>
95        </select>");
96    echo "<input type=\"hidden\" name=\"action\" value=\"banish_user\">\n";
97    echo "<input type=\"hidden\" name=\"id\" value=\"".$postid."\">\n";
98    echo "<input type=\"hidden\" name=\"userid\" value=\"".$userid."\">\n";
99    echo "<input type=\"hidden\" name=\"confirmed\" value=\"yes\">\n";
100} elseif (get_str('action')=="delete") {
101    echo "<input type=hidden name=action value=delete>";
102    row2(
103        "Are you sure want to delete this post?  This cannot be undone.",
104        "<input class=\"btn btn-danger\" type=\"submit\" name=\"submit\" value=\"".tra("OK")."\">"
105    );
106    $get_reason = false;
107} else {
108    error_page("Unknown action");
109}
110
111if ($get_reason) {
112    row2(tra("Optional explanation %1 This is included in email to user.%2", "<br><small>", "</small>"),
113        '<textarea name="reason" class="form-control" rows="10"></textarea>'
114    );
115    row2(
116        "",
117        "<input class=\"btn btn-primary\" type=\"submit\" name=\"submit\" value=\"".tra("OK")."\">"
118    );
119}
120
121end_table();
122
123echo "</form>";
124
125page_tail();
126
127?>
128