blob: e5bd6d0198de1c3531d4b811a767a82ed81b23f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))
(in-package :woodriverlessons)
(defclass messages-service (auth-service)
((title :initarg :title
:initform nil
:accessor title)
(form :initarg :form
:initform nil
:accessor form))
(:documentation ""))
(defun messages-json ()
(with-auth (instance messages-service "messages-view")
(setf (title instance) "Messages Administration")
(setf (form instance) (make-form "messages-select-mode-form"
nil
nil
`((:name "read" :field-type "hidden" :required "required" :value ,(session-value :messages-read))
(:label "View Unread" :field-type "button" :onclick "on_messages_mode_clicked('unread')")
(:label "View Read" :field-type "button" :onclick "on_messages_mode_clicked('read')"))))))
(defclass messages/results-service (messages-service)
((results :initarg :results
:initform nil
:accessor results)
(location-p :initform nil))
(:documentation ""))
(defun messages-results-json (read)
(with-auth (instance messages/results-service "messages-view")
(when read (setf (session-value :messages-read) read))
(with-woodriverlessons-database
(let ((contact-pkg (make-instance 'contact-pkg)))
(setf (results instance) (get-contact-us-posts contact-pkg
(id (get-user))
(string= (session-value :messages-read) "read")))))
(sanitize-rest-json instance)
(loop for result in (results instance) do
(sanitize-json result))))
(defclass messages/mark-service (messages-service)
((location-p :initform nil))
(:documentation ""))
(defun messages-mark-json (read id)
(with-auth (instance messages/mark-service "messages-view")
(with-woodriverlessons-database
(handler-case
(let ((contact-pkg (make-instance 'contact-pkg)))
(mark-contact-us-post contact-pkg id (id (get-user)) (string= read "read"))
(setf (session-value :message) (format nil "Message marked ~a successfully." read)))
(error (e)
(declare (ignore e))
(setf (session-value :errormsg) (format nil "Error marking message ~a." read)))))))
|