Skip to content

Commit

Permalink
Flagging posts
Browse files Browse the repository at this point in the history
  • Loading branch information
s-gv committed Nov 15, 2017
1 parent db7f365 commit 1bc5817
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion templates/pm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const pmSrc = `
<div class="comment-title muted">
{{ if not .IsRead }}<span class="alert">&#x2757;</span>{{ end }}
<a href="/users?u={{ .From }}">{{ .From }}</a> {{ .CreatedDate }} |
<a href="/pm?quote={{ .ID }}">reply</a> |
<a href="/pm?quote={{ .ID }}#end">reply</a> |
<form method="post" action="/pm/delete" style="display: inline;">
<input type="hidden" name="csrf" value="{{ $.Common.CSRF }}">
<input type="hidden" name="id" value="{{ .ID }}">
Expand Down
8 changes: 7 additions & 1 deletion templates/topicindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ const topicindexSrc = `
{{ if .Comments }}
{{ range .Comments }}
<div class="comment-row" id="comment-{{ .ID }}">
<div class="comment-title muted"><a href="/users?u={{ .UserName }}">{{ .UserName }}</a> <a href="/comments?id={{ .ID }}">{{ .CreatedDate }}</a>{{ if or .IsOwner $.IsAdmin $.IsMod $.IsSuperAdmin }} | <a href="/comments/edit?id={{ .ID }}">edit</a>{{end}}{{ if not .IsDeleted }} | <a href="/comments/new?tid={{ $.TopicID }}&quote={{ .ID }}">quote</a>{{ end }}</div>
<div class="comment-title muted">
<a href="/users?u={{ .UserName }}">{{ .UserName }}</a>
<a href="/comments?id={{ .ID }}">{{ .CreatedDate }}</a>
{{ if or .IsOwner $.IsAdmin $.IsMod $.IsSuperAdmin }} | <a href="/comments/edit?id={{ .ID }}">edit</a>{{end}}
{{ if not .IsDeleted }} | <a href="/comments/new?tid={{ $.TopicID }}&quote={{ .ID }}">quote</a>{{ end }}
| <a href="/pm?flag={{ .ID }}#end">flag</a>
</div>
{{ if .IsDeleted }}
<div class="comment">[DELETED]</div>
{{ else }}
Expand Down
17 changes: 17 additions & 0 deletions views/pm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ var PrivateMessageHandler = A(func(w http.ResponseWriter, r *http.Request, sess
cont = formatReply(to, cont)
}

if flag := r.FormValue("flag"); flag != "" {
rows := db.Query(`SELECT users.username FROM mods
INNER JOIN users ON users.id=mods.userid
INNER JOIN topics ON topics.groupid=mods.groupid
INNER JOIN comments ON comments.topicid=topics.id
WHERE comments.id=?;`, flag)
for rows.Next() {
var mod string
rows.Scan(&mod)
if to != "" {
to = to + ", "
}
to = to + mod
}
cont = "Flagging " + "http://" + r.Host + "/comments?id="+flag
}

if lmd != "" && len(msgs) == 0 {
http.Redirect(w, r, "/pm", http.StatusSeeOther)
return
Expand Down

0 comments on commit 1bc5817

Please sign in to comment.