Add post flagging

develop
Sven Slootweg 11 years ago
parent 956edd63a9
commit 9410f6bd31

@ -0,0 +1,47 @@
<?php
/*
* projectname is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
class ForumFlag extends CPHPDatabaseRecordClass
{
public $table_name = "forum_flags";
public $fill_query = "SELECT * FROM forum_flags WHERE `Id` = :Id";
public $verify_query = "SELECT * FROM forum_flags WHERE `Id` = :Id";
public $prototype = array(
'string' => array(
'Reason' => "Reason"
),
'numeric' => array(
"UserId" => "UserId",
"PostId" => "PostId",
"ModeratorId" => "ModeratorId"
),
'boolean' => array(
"IsReviewed" => "Reviewed",
"IsValid" => "Valid"
),
'timestamp' => array(
"FlagDate" => "FlagDate",
"ReviewDate" => "ReviewDate"
),
'user' => array(
"User" => "UserId",
"Moderator" => "ModeratorId"
),
'forumpost' => array(
"Post" => "PostId"
)
);
}

@ -83,4 +83,14 @@ class ForumPost extends CPHPDatabaseRecordClass
$sThanks->InsertIntoDatabase();
}
}
public function Flag($user_id, $reason)
{
$sFlag = new ForumFlag(0);
$sFlag->uPostId = $this->sId;
$sFlag->uUserId = $user_id;
$sFlag->uFlagDate = time();
$sFlag->uReason = $reason;
$sFlag->InsertIntoDatabase();
}
}

@ -0,0 +1,36 @@
<?php
/*
* Box is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
try
{
$sForumPost = new ForumPost($router->uParameters[1]);
}
catch (NotFoundException $e)
{
die("No such post exists.");
}
$done = false;
if(strtolower($_SERVER['REQUEST_METHOD']) == "post")
{
$sForumPost->Flag($sCurrentUser->sId, $_POST['reason']);
$done = true;
}
echo(NewTemplater::Render("forum/flag", $locale->strings, array(
"snippet" => purify_html(Markdown(cut_text($sForumPost->uBody, 500))),
"done" => $done
)));

@ -88,6 +88,15 @@ $router->routes = array(
"^/forums/thank/([0-9]+)$" => array(
"methods" => "post",
"target" => "modules/forums/thank.php",
"authenticator" => "authenticators/user.php",
"auth_error" => "modules/account/login.php",
"_section" => "None"
),
"^/forums/flag/([0-9]+)$" => array(
"methods" => array("get", "post"),
"target" => "modules/forums/flag.php",
"authenticator" => "authenticators/user.php",
"auth_error" => "modules/account/login.php",
"_section" => "None"
),
"^/forums/discussion/([0-9]+)/[a-z0-9-]+(/p([0-9]))?$" => array(

@ -0,0 +1,120 @@
body
{
background-color: #E6FFE6;
font-family: sans-serif;
font-size: 14px;
}
h1
{
background-color: #24431F;
color: white;
font-size: 19px;
padding: 7px 9px;
}
p
{
padding: 0px 5px;
}
blockquote
{
border: 1px solid #609657;
padding: 5px 6px;
margin: 5px 0px;
font-size: 12px;
color: #585858;
max-height: 80px;
overflow: auto;
}
blockquote p
{
margin: 6px 0px;
}
blockquote blockquote
{
border: 0px;
padding: 5px 0px 5px 5px;
margin: 5px 0px 5px 4px;
border-left: 3px solid #80B380;
}
blockquote blockquote p
{
margin: 0px;
}
form .field
{
margin-bottom: 7px;
padding-left: 6px;
}
label, input, textarea, button
{
display: block;
box-sizing: border-box;
-moz-box-sizing: border-box;
}
label, input, select
{
float: left;
}
label
{
width: 15%;
font-size: 15px;
color: #397739;
font-weight: bold;
margin-top: 6px;
}
input, textarea, select
{
border: 1px solid #397739;
background-color: white;
border-radius: 1px;
margin-top: 5px;
}
input, select
{
width: 66%;
font-size: 15px;
padding: 1px 3px;
}
button
{
font-size: 14px;
font-weight: bold;
background: #f5fff2; /* Old browsers */
background: -moz-linear-gradient(top, #f5fff2 34%, #e9f7d7 74%, #ddefc9 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(34%,#f5fff2), color-stop(74%,#e9f7d7), color-stop(100%,#ddefc9)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f5fff2 34%,#e9f7d7 74%,#ddefc9 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f5fff2 34%,#e9f7d7 74%,#ddefc9 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #f5fff2 34%,#e9f7d7 74%,#ddefc9 100%); /* IE10+ */
background: linear-gradient(to bottom, #f5fff2 34%,#e9f7d7 74%,#ddefc9 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5fff2', endColorstr='#ddefc9',GradientType=0 ); /* IE6-9 */
color: #2E4F2B;
border: 1px solid silver;
border-radius: 4px;
padding: 4px 6px;
box-shadow: 0px 0px 4px 0px #c0dbba;
-webkit-box-shadow: 0px 0px 4px 0px #c0dbba;
-moz-box-shadow: 0px 0px 4px 0px #c0dbba;
-o-box-shadow: 0px 0px 4px 0px #c0dbba;
-ms-box-shadow: 0px 0px 4px 0px #c0dbba;
text-shadow: 1px 1px 0px #bbe6a6;
-webkit-text-shadow: 1px 1px 0px #bbe6a6;
-moz-text-shadow: 1px 1px 0px #bbe6a6;
-o-text-shadow: 1px 1px 0px #bbe6a6;
-ms-text-shadow: 1px 1px 0px #bbe6a6;
width: 15%;
float: right;
}

@ -43,11 +43,10 @@ $(function(){
$('a.flag').click(function(event){
$.fancybox.open([{
href: "/forums/flag/" + $(this).data("id"),
title: "Report a post"
href: "/forums/flag/" + $(this).data("id")
}],
{
padding: 24,
padding: 4,
autoSize: false,
width: 550,
height: 400,

@ -1,15 +1,41 @@
<!doctype html>
<head>
<title>Flag post</title>
<link rel="stylesheet" href="/static/style/flag.css">
<link rel="stylesheet" href="/static/css/flag.css?2">
</head>
<body>
<h1>Flag abusive post</h1>
<p>
If you believe this post violates the community
rules or should otherwise be removed, please fill
in a reason or explanation below and hit the Flag
button.
</p>
{%if done == false}
<blockquote>
{%?snippet}
</blockquote>
<p>
If you believe this post violates the community
rules or should otherwise be removed, please fill
in a reason or explanation below and hit the Flag
button.
</p>
<p>
We ask that you only flag posts that genuinely
break the community rules or are problematic
otherwise; we will not solve your personal conflicts,
and false reports will be ignored.
</p>
<form method="post">
<div class="field">
<label>Reason:</label>
<input name="reason">
<button type="submit">Flag</button>
</div>
</form>
{%else}
<p>
Thanks for your report! A moderator will review it soon.
</p>
{%/if}
</body>
</html>

@ -16,8 +16,10 @@
<span class="author">{%?post[author]}</span>
<form style="display: none;" id="csrf_form_{%?post[id]}"></form>
<a class="date" href="{%?post[permalink]}">{%?post[date]}</a>
<a class="thanks" href="#" target="_blank" data-id="{%?post[id]}">Thanks</a>
<a class="flag" href="/forums/flag/{%?post[id]}" target="_blank" data-id="{%?post[id]}">Flag</a>
{%if logged-in == true}
<a class="thanks" href="#" target="_blank" data-id="{%?post[id]}">Thanks</a>
<a class="flag" href="/forums/flag/{%?post[id]}" target="_blank" data-id="{%?post[id]}">Flag</a>
{%/if}
</div>
<div class="status">{%?post[author-status]}</div>
</div>

Loading…
Cancel
Save