| @@ -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.