Skip to content

Commit

Permalink
Merge pull request #1130 from NatLibFi/issue1093-feedback-form-should…
Browse files Browse the repository at this point in the history
…-have-a-headline_or_subject

Issue1093 feedback form should have a headline or subject
Fixes #1093
  • Loading branch information
miguelvaara authored Mar 4, 2021
2 parents 2de49eb + f67a739 commit 1fc53b3
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 28 deletions.
19 changes: 7 additions & 12 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,16 @@ public function invokeFeedbackForm($request)
}
$feedbackName = $request->getQueryParamPOST('name');
$feedbackEmail = $request->getQueryParamPOST('email');
$msgSubject = $request->getQueryParamPOST('msgsubject');
$feedbackVocab = $request->getQueryParamPOST('vocab');

$feedbackVocabEmail = ($feedbackVocab !== null && $feedbackVocab !== '') ?
$this->model->getVocabulary($feedbackVocab)->getConfig()->getFeedbackRecipient() : null;

// if the hidden field has been set a value we have found a spam bot
// and we do not actually send the message.
if ($this->honeypot->validateHoneypot($request->getQueryParamPOST('item-description')) &&
$this->honeypot->validateHoneytime($request->getQueryParamPOST('user-captcha'), $this->model->getConfig()->getHoneypotTime())) {
$this->sendFeedback($request, $feedbackMsg, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
$this->sendFeedback($request, $feedbackMsg, $msgSubject, $feedbackName, $feedbackEmail, $feedbackVocab, $feedbackVocabEmail);
}

echo $template->render(
array(
'languages' => $this->languages,
Expand All @@ -245,46 +243,43 @@ private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
if (!empty($fromEmail)) {
$headers .= "Reply-To: $fromName <$fromEmail>\r\n";
}

$service = $this->model->getConfig()->getServiceName();
return $headers . "From: $fromName via $service <$sender>";
}

/**
* Sends the user entered message through the php's mailer.
* @param string $message only required parameter is the actual message.
* @param string $message content given by user.
* @param string $messageSubject subject line given by user.
* @param string $fromName senders own name.
* @param string $fromEmail senders email address.
* @param string $fromVocab which vocabulary is the feedback related to.
*/
public function sendFeedback($request, $message, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
public function sendFeedback($request, $message, $messageSubject, $fromName = null, $fromEmail = null, $fromVocab = null, $toMail = null)
{
$toAddress = ($toMail) ? $toMail : $this->model->getConfig()->getFeedbackAddress();
$messageSubject = "[" . $this->model->getConfig()->getServiceName() . "] " . $messageSubject;
if ($fromVocab !== null && $fromVocab !== '') {
$message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
}

$envelopeSender = $this->model->getConfig()->getFeedbackEnvelopeSender();
$subject = $this->model->getConfig()->getServiceName() . " feedback";
// determine the sender address of the message
$sender = $this->model->getConfig()->getFeedbackSender();
if (empty($sender)) $sender = $envelopeSender;
if (empty($sender)) $sender = $this->model->getConfig()->getFeedbackAddress();

// determine sender name - default to "anonymous user" if not given by user
if (empty($fromName)) $fromName = "anonymous user";

$headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender);
$params = empty($envelopeSender) ? '' : "-f $envelopeSender";

// adding some information about the user for debugging purposes.
$message = $message . "<br /><br /> Debugging information:"
. "<br />Timestamp: " . date(DATE_RFC2822)
. "<br />User agent: " . $request->getServerConstant('HTTP_USER_AGENT')
. "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');

try {
mail($toAddress, $subject, $message, $headers, $params);
mail($toAddress, $messageSubject, $message, $headers, $params);
} catch (Exception $e) {
header("HTTP/1.0 404 Not Found");
$template = $this->twig->loadTemplate('error-page.twig');
Expand Down
18 changes: 11 additions & 7 deletions resource/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ li, td > a {
font-size: 14px;
}

label {
font-weight: normal;
}

h1, .prefLabel, .prefLabelLang, .notation {
font-family: 'Fira Sans', sans-serif;
font-size: 24px;
Expand Down Expand Up @@ -667,7 +671,7 @@ span.xl-pref-label > img {
.welcome-box, .right-box, #vocabulary-list {
vertical-align: top;
}

.welcome-box {
background-color: #ffffff;
display: inline-block;
Expand Down Expand Up @@ -2000,7 +2004,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
margin: 2px 0 0 0;
line-height: 30px;
}

.concept-main > .row > .property-label-pref {
margin-top: 10px;
line-height: 20px;
Expand All @@ -2022,7 +2026,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
margin: 0;
width: 100%;
}

.headerbar-coloured {
overflow: hidden;
}
Expand All @@ -2034,7 +2038,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
}

@media (max-width: 800px) {

.twitter-typeahead {
width: 100%;
}
Expand Down Expand Up @@ -2103,7 +2107,7 @@ body, .versal, h1, h2, h3, p, .versal-bold {
.right-box {
display: inline;
}

.voclist-wide > .right-box {
left: 0;
top: 425px;
Expand Down Expand Up @@ -2161,12 +2165,12 @@ body, .versal, h1, h2, h3, p, .versal-bold {
.frontpage > .welcome-box, .frontpage > .right-box {
width: 200px;
}

.voclist #vocabulary-list {
margin-left: 20px;
width: calc(100% - 225px);
}

.voclist-right #vocabulary-list {
margin-left: 20px;
width: auto;
Expand Down
Binary file modified resource/translations/en/LC_MESSAGES/skosmos.mo
Binary file not shown.
Binary file modified resource/translations/fi/LC_MESSAGES/skosmos.mo
Binary file not shown.
9 changes: 9 additions & 0 deletions resource/translations/skosmos_en.po
Original file line number Diff line number Diff line change
Expand Up @@ -839,3 +839,12 @@ msgstr "Search results"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sidebar listing: list and traverse vocabulary contents by a criterion"

msgid "Subject:"
msgstr "Subject:"

msgid "Write a subject"
msgstr "Write a subject"

msgid "Select a vocabulary"
msgstr "You can select a vocabulary"
9 changes: 9 additions & 0 deletions resource/translations/skosmos_fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -838,3 +838,12 @@ msgstr "Hakutulokset"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sivupalkin lista: listaa ja selaa käsitteitä eri kriteerien mukaan"

msgid "Subject:"
msgstr "Aihe:"

msgid "Write a subject"
msgstr "Kirjoita aihe"

msgid "Select a vocabulary"
msgstr "Voit valita halutessasi sanaston"
9 changes: 9 additions & 0 deletions resource/translations/skosmos_sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -836,3 +836,12 @@ msgstr "Sökresultat"

msgid "Sidebar listing: list and traverse vocabulary contents by a criterion"
msgstr "Sidofältlista: ordna och bläddra begrepp efter kriterier"

msgid "Subject:"
msgstr "Ämne:"

msgid "Write a subject"
msgstr "Skriv ett ämne"

msgid "Select a vocabulary"
msgstr "Du kan välja en vokabulär"
Binary file modified resource/translations/sv/LC_MESSAGES/skosmos.mo
Binary file not shown.
3 changes: 1 addition & 2 deletions tests/testconfig-fordefaults.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
skos:prefLabel "Test ontology"@en ;
skosmos:arrayClass isothes:ThesaurusArray ;
skosmos:defaultLanguage "en";
skosmos:feedbackRecipient "developer@vocabulary.org";
skosmos:feedbackRecipient "developer@vocabulary.org";
skosmos:groupClass skos:Collection;
skosmos:language "en";
skosmos:showTopConcepts "true";
Expand All @@ -48,4 +48,3 @@ mdrtype:THESAURUS a skos:Concept ;

mdrtype:ONTOLOGY a skos:Concept ;
skos:prefLabel "Онтология"@bg, "Ontologie"@cs, "Ontologi"@da, "Ontologie"@de, "Οντολογία"@el, "Ontology"@en, "Ontoloogia"@et, "Ontologia"@fi, "Ontologie"@fr, "Ontologija"@hr, "Ontológia"@hu, "Ontologia"@it, "Ontoloģija"@lv, "Ontologija"@lt, "Ontoloġija"@mt, "Ontologie"@nl, "Ontologi"@no, "Struktura pojęciowa"@pl, "Ontologia"@pt, "Ontologie"@ro, "Ontológia"@sk, "Ontologija"@sl, "Ontología"@es, "Ontologi"@sv .

21 changes: 14 additions & 7 deletions view/feedback.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{% if vocabList %}
<input id="feedback-vocid-input" name="vocab" type="hidden"{% if request.vocabid %} value="{{ request.vocabid }}"{% endif %}>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="feedback-vocid" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<button class="btn btn-default dropdown-toggle" type="button" id="feedback-vocid" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" aria-label="{% trans %}Select a vocabulary{% endtrans %}">
{% if request.vocabid %}{{ request.vocab.title }}{% else %}{% trans %}Not to a specific vocabulary{% endtrans %}{% endif %}
<span class="caret"></span>
</button>
Expand All @@ -30,12 +30,19 @@
</div>
{% endif %}
<p>{% trans "feedback_enter_name_email" %}</p>

<p>{% trans %}Name:{% endtrans %}</p>
<input id="name" class="form-control" type ="text" size="40" name="name" placeholder="{% trans %}Enter your name{% endtrans %}">
<p>{% trans %}E-mail:{% endtrans %}</p>
<input id="email" class="form-control" type ="text" size="40" name="email" placeholder="{% trans %}Enter your e-mail address{% endtrans %}">
<p>{% trans %}Message:{% endtrans %} *</p>
<p>
<label for="name">{% trans %}Name:{% endtrans %}</label>
<input id="name" class="form-control" type="text" size="40" name="name" placeholder="{% trans %}Enter your name{% endtrans %}">
</p>
<p>
<label for="email">{% trans %}E-mail:{% endtrans %}</label>
<input id="email" class="form-control" type="text" size="40" name="email" placeholder="{% trans %}Enter your e-mail address{% endtrans %}">
</p>
<p>
<label for="msgsubject">{% trans %}Subject:{% endtrans %}</label>
<input id="msgsubject" class="form-control" type="text" size="40" name="msgsubject" placeholder="{% trans %}Write a subject{% endtrans %}">
</p>
<label for="message">{% trans %}Message:{% endtrans %}</label>
<textarea id="message" class="form-control" name="message"></textarea>
{{ honeypot.generate('item-description', 'user-captcha')|raw }}
<button type="submit" class="btn btn-primary" id="send-feedback">{% trans %}Send feedback{% endtrans %}</button>
Expand Down

0 comments on commit 1fc53b3

Please sign in to comment.