소스 검색

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.