浏览代码

Add comment moderation in admin

master
nano 6 天前
父节点
当前提交
b8ee17263e
共有 1 个文件被更改,包括 66 次插入0 次删除
  1. +66
    -0
      app/controllers/AdminController.asp

+ 66
- 0
app/controllers/AdminController.asp 查看文件

@@ -58,6 +58,18 @@ Class AdminController_Class
<%
End Sub

'---------------------------------------------------------------
' Action: Comments
'---------------------------------------------------------------
Public Sub Comments()
m_title = "Manage Comments"
Dim comments
Set comments = CommentsRepository().Find(Empty, "CreatedDate")
%>
<!--#include file="../views/Admin/comments.asp" -->
<%
End Sub

'---------------------------------------------------------------
' Action: AIPrompt
'---------------------------------------------------------------
@@ -144,6 +156,41 @@ Class AdminController_Class
Response.Redirect "/admin/posts"
End Sub

'---------------------------------------------------------------
' Action: ApproveComment
'---------------------------------------------------------------
Public Sub ApproveComment(ByVal id)
UpdateCommentApproval id, 1, "Comment approved."
End Sub

'---------------------------------------------------------------
' Action: UnapproveComment
'---------------------------------------------------------------
Public Sub UnapproveComment(ByVal id)
UpdateCommentApproval id, 0, "Comment unapproved."
End Sub

'---------------------------------------------------------------
' Action: DeleteComment
'---------------------------------------------------------------
Public Sub DeleteComment(ByVal id)
Dim comment
On Error Resume Next
Set comment = CommentsRepository().FindByID(id)
If Err.Number <> 0 Then
Err.Clear
On Error GoTo 0
Flash().AddError "Comment not found."
Response.Redirect "/admin/comments"
Exit Sub
End If
On Error GoTo 0

CommentsRepository().Delete id
Flash().Success = "Comment deleted."
Response.Redirect "/admin/comments"
End Sub

'---------------------------------------------------------------
' Action: GenerateAIContent
'---------------------------------------------------------------
@@ -241,6 +288,25 @@ Class AdminController_Class
If parsed.data.Exists("body") Then generatedBody = Trim(CStr(parsed.data.Item("body")))
End Sub

Private Sub UpdateCommentApproval(ByVal id, ByVal isApproved, ByVal successMessage)
Dim comment
On Error Resume Next
Set comment = CommentsRepository().FindByID(id)
If Err.Number <> 0 Then
Err.Clear
On Error GoTo 0
Flash().AddError "Comment not found."
Response.Redirect "/admin/comments"
Exit Sub
End If
On Error GoTo 0

comment.IsApproved = isApproved
CommentsRepository().Update comment
Flash().Success = successMessage
Response.Redirect "/admin/comments"
End Sub

Private Function HttpPostJson(ByVal url, ByVal apiKey, ByVal payload)
Dim http
Set http = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")


正在加载...
取消
保存

Powered by TurnKey Linux.