site(org): each .com inquiry also e-mailed to rajames440@gmail.com, Reply-To the visitor (#161) [skip ci]
PublicInquiry files the inquiry as before, then mails it through the wiki's mail service: plain text, the subject fixed but for the topic (line breaks removed), Reply-To the visitor's checked address, a link to the filed entry. If it is not sent the inquiry is filed all the same; a new class field, mailed (E-mailed to Captain Bob), says which, shown on the entry's sheet. Installed on the .org; a guest's test inquiry filed and thanked, mailed 0 -- the wiki has no SMTP account yet (Mail.MailConfig: no host), which Captain Bob sets in Administration > Email. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
@@ -15,6 +15,7 @@ Needs the programming right.
|
|||||||
#if (!$c.get('announcements'))#set ($d = $c.addBooleanField('announcements', 'Wants announcements', 'yesno'))#set ($changed = true)#end
|
#if (!$c.get('announcements'))#set ($d = $c.addBooleanField('announcements', 'Wants announcements', 'yesno'))#set ($changed = true)#end
|
||||||
#if (!$c.get('source'))#set ($d = $c.addTextField('source', 'Source', 60))#set ($changed = true)#end
|
#if (!$c.get('source'))#set ($d = $c.addTextField('source', 'Source', 60))#set ($changed = true)#end
|
||||||
#if (!$c.get('status'))#set ($d = $c.addStaticListField('status', 'Status', 1, false, 'new|read|answered|closed'))#set ($changed = true)#end
|
#if (!$c.get('status'))#set ($d = $c.addStaticListField('status', 'Status', 1, false, 'new|read|answered|closed'))#set ($changed = true)#end
|
||||||
|
#if (!$c.get('mailed'))#set ($d = $c.addBooleanField('mailed', 'E-mailed to Captain Bob', 'yesno'))#set ($changed = true)#end
|
||||||
#if ($changed)
|
#if ($changed)
|
||||||
#set ($d = $xdoc.setTitle('Inquiry class'))
|
#set ($d = $xdoc.setTitle('Inquiry class'))
|
||||||
#set ($d = $xwiki.getXWiki().saveDocument($xdoc, 'The inquiry fields', $xcontext.getContext()))
|
#set ($d = $xwiki.getXWiki().saveDocument($xdoc, 'The inquiry fields', $xcontext.getContext()))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ This page holds no inquiry.
|
|||||||
|=Organization|$doc.display('organization', $o)
|
|=Organization|$doc.display('organization', $o)
|
||||||
|=Topic|$doc.display('topic', $o)
|
|=Topic|$doc.display('topic', $o)
|
||||||
|=Announcements|$doc.display('announcements', $o)
|
|=Announcements|$doc.display('announcements', $o)
|
||||||
|
|=E-mailed|$doc.display('mailed', $o)
|
||||||
|=Source|$doc.display('source', $o)
|
|=Source|$doc.display('source', $o)
|
||||||
|
|
||||||
== Message ==
|
== Message ==
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
## rights (getDocumentAsAuthor, saveAsAuthor): a guest can reach nothing but this. Nothing a visitor
|
## rights (getDocumentAsAuthor, saveAsAuthor): a guest can reach nothing but this. Nothing a visitor
|
||||||
## sends is ever written into this page's output or an entry's title: with this author's rights,
|
## sends is ever written into this page's output or an entry's title: with this author's rights,
|
||||||
## text that reached the wiki markup could run a macro.
|
## text that reached the wiki markup could run a macro.
|
||||||
|
## Each inquiry filed is also e-mailed to Captain Bob (#161; ruled 2026-11-10: "server emails each
|
||||||
|
## one"), plain text, through the wiki's mail service (Administration > Email > Mail Sending: the
|
||||||
|
## SMTP account is set there, not here). Reply-To is the visitor's address, which has passed the
|
||||||
|
## address check above; the subject is fixed but for the topic, its line breaks removed. If the
|
||||||
|
## mail is not sent the inquiry is filed all the same, and its entry says so (its E-mailed field: no).
|
||||||
#macro (field $n $max)#set ($v = "$!request.getParameter($n)")#set ($v = $v.trim())#if ($v.length() > $max)#set ($v = $v.substring(0, $max))#end#end
|
#macro (field $n $max)#set ($v = "$!request.getParameter($n)")#set ($v = $v.trim())#if ($v.length() > $max)#set ($v = $v.substring(0, $max))#end#end
|
||||||
#if ($request.method != 'POST')
|
#if ($request.method != 'POST')
|
||||||
This page receives the inquiry form on [[starshipos-f18.com>>https://starshipos-f18.com/bin/view/Inquiries/]].
|
This page receives the inquiry form on [[starshipos-f18.com>>https://starshipos-f18.com/bin/view/Inquiries/]].
|
||||||
@@ -35,6 +40,33 @@ This page receives the inquiry form on [[starshipos-f18.com>>https://starshipos-
|
|||||||
#set ($d = $o.set('source', 'starshipos-f18.com'))
|
#set ($d = $o.set('source', 'starshipos-f18.com'))
|
||||||
#set ($d = $o.set('status', 'new'))
|
#set ($d = $o.set('status', 'new'))
|
||||||
#set ($d = $entry.saveAsAuthor('An inquiry from the .com form'))
|
#set ($d = $entry.saveAsAuthor('An inquiry from the .com form'))
|
||||||
|
## the e-mail: every visitor-given value is plain text in a text/plain part, never markup
|
||||||
|
#set ($subjectTopic = $topic.replaceAll('[\r\n]+', ' '))
|
||||||
|
#set ($body = "A new inquiry from starshipos-f18.com, filed as ${ref}:
|
||||||
|
${xwiki.getURL($ref, 'view')}
|
||||||
|
|
||||||
|
Name: $name
|
||||||
|
E-mail: $email
|
||||||
|
Organization: $org
|
||||||
|
Topic: $topic
|
||||||
|
Announcements: #if ($wants)yes#{else}no#end
|
||||||
|
|
||||||
|
|
||||||
|
$message
|
||||||
|
")
|
||||||
|
#set ($mail = $services.mail.sender.createMessage('rajames440@gmail.com', "Inquiry from starshipos-f18.com: $subjectTopic"))
|
||||||
|
#if ($mail)
|
||||||
|
#set ($d = $mail.addPart('text/plain', $body))
|
||||||
|
#set ($d = $mail.setHeader('Reply-To', $email))
|
||||||
|
#set ($sent = $services.mail.sender.send($mail))
|
||||||
|
#set ($ok = $sent && !$services.mail.sender.lastError)
|
||||||
|
#if ($ok)#set ($ok = $sent.statusResult.waitTillProcessed(30000))#set ($ok = !$sent.statusResult.allErrors.hasNext())#end
|
||||||
|
#else
|
||||||
|
#set ($ok = false)
|
||||||
|
#end
|
||||||
|
#set ($e2 = $xwiki.getDocumentAsAuthor($ref))
|
||||||
|
#set ($o2 = $e2.getObject('Inquiries.Code.InquiryClass'))
|
||||||
|
#if ($o2)#if ($ok)#set ($d = $o2.set('mailed', 1))#else#set ($d = $o2.set('mailed', 0))#end#set ($d = $e2.saveAsAuthor('Whether the inquiry was e-mailed'))#end
|
||||||
{{html}}<p>Thank you. Your inquiry has been received; every message is read by a human, and replies usually come within a few days.</p><p><a href="https://starshipos-f18.com/">Back to starshipos-f18.com</a></p>{{/html}}
|
{{html}}<p>Thank you. Your inquiry has been received; every message is read by a human, and replies usually come within a few days.</p><p><a href="https://starshipos-f18.com/">Back to starshipos-f18.com</a></p>{{/html}}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|||||||
Reference in New Issue
Block a user