Skip to content

Commit

Permalink
Change feedback message headers to use Reply-To and make name and e-m…
Browse files Browse the repository at this point in the history
…ail optional. Fixes #761
  • Loading branch information
osma committed May 23, 2018
1 parent 164acc3 commit 7b517f1
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 440 deletions.
5 changes: 4 additions & 1 deletion config.inc.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ define("TEMPLATE_CACHE", "/tmp/skosmos-template-cache");
// set to "JenaText" instead if you use Fuseki with jena-text index
define("DEFAULT_SPARQL_DIALECT", "Generic");

// default email address to send the feedback
// default email address where to send the feedback
define("FEEDBACK_ADDRESS", "");

// email address to set as the sender for feedback messages
define("FEEDBACK_SENDER", "");

// email address to set as the envelope sender for feedback messages
define("FEEDBACK_ENVELOPE_SENDER", "");

Expand Down
25 changes: 18 additions & 7 deletions controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,19 @@ public function invokeFeedbackForm($request)
));
}

private function createFeedbackHeaders($fromName, $fromEmail, $toMail)
private function createFeedbackHeaders($fromName, $fromEmail, $toMail, $sender)
{
$headers = "MIME-Version: 1.0″ . '\r\n";
$headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
if ($toMail) {
if (!empty($toMail)) {
$headers .= "Cc: " . $this->model->getConfig()->getFeedbackAddress() . "\r\n";
}
if (!empty($fromEmail)) {
$headers .= "Reply-To: $fromName <$fromEmail>\r\n";
}

$headers .= "From: $fromName <$fromEmail>" . "\r\n" . 'X-Mailer: PHP/' . phpversion();
$service = $this->model->getConfig()->getServiceName();
$headers .= "From: $fromName via $service <$sender>";
return $headers;
}

Expand All @@ -299,16 +303,23 @@ public function sendFeedback($request, $message, $fromName = null, $fromEmail =
$message = 'Feedback from vocab: ' . strtoupper($fromVocab) . "<br />" . $message;
}

$subject = SERVICE_NAME . " feedback";
$headers = $this->createFeedbackHeaders($fromName, $fromEmail, $toMail);
$envelopeSender = FEEDBACK_ENVELOPE_SENDER;
$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 = $toAddress;

// 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 />IP address: " . $request->getServerConstant('REMOTE_ADDR')
. "<br />Referer: " . $request->getServerConstant('HTTP_REFERER');

try {
Expand Down
18 changes: 18 additions & 0 deletions model/GlobalConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ public function getFeedbackAddress()
return $this->getConstant('FEEDBACK_ADDRESS', null);
}

/**
* Returns the feedback sender address defined in the configuration.
* @return string
*/
public function getFeedbackSender()
{
return $this->getConstant('FEEDBACK_SENDER', null);
}

/**
* Returns the feedback envelope sender address defined in the configuration.
* @return string
*/
public function getFeedbackEnvelopeSender()
{
return $this->getConstant('FEEDBACK_ENVELOPE_SENDER', null);
}

/**
* Returns true if exception logging has been configured.
* @return boolean
Expand Down
2 changes: 1 addition & 1 deletion resource/js/docready.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ $(function() { // DOCUMENT READY
var emailMessageVal = $("#message").val();
var emailAddress = $("#email").val();
var requiredFields = true;
if (emailAddress === '' || emailAddress.indexOf('@') === -1) {
if (emailAddress != '' && emailAddress.indexOf('@') === -1) {
$("#email").addClass('missing-value');
requiredFields = false;
}
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.
54 changes: 4 additions & 50 deletions resource/translations/skosmos_en.po
Original file line number Diff line number Diff line change
Expand Up @@ -761,53 +761,7 @@ msgstr ""
"if the truncation symbol is not entered manually: thus, cat will yield the "
"same results as cat*."

#~ msgid "dc11:contributor"
#~ msgstr "Contributor"

#~ msgid "dc11:creator"
#~ msgstr "Creator"

#~ msgid "dc11:description"
#~ msgstr "Description"

#~ msgid "dc11:license"
#~ msgstr "License"

#~ msgid "dc11:publisher"
#~ msgstr "Publisher"

#~ msgid "dc11:relation"
#~ msgstr "Relation"

#~ msgid "dc11:rights"
#~ msgstr "Rights"

#~ msgid "dc11:source"
#~ msgstr "Source"

#~ msgid "dc11:title"
#~ msgstr "Title"

#~ msgid "Error: the vocabulary does not contain terms beginning with"
#~ msgstr "The vocabulary does not contain terms beginning with"

#~ msgid "Vocabularies on the server"
#~ msgstr "Available vocabularies and ontologies"

#~ msgid "Modified concepts"
#~ msgstr "Modified concepts"

#~ msgid "New concepts"
#~ msgstr "New concepts"

#~ msgid "All"
#~ msgstr "All"

#~ msgid "results"
#~ msgstr "results:"

#~ msgid "results for"
#~ msgstr "results for"

#~ msgid "Language literal"
#~ msgstr "In English"
msgid "feedback_enter_name_email"
msgstr ""
"Please enter your name and email address if you wish to receive a direct "
"response. You also have the option to submit your feedback anonymously."
197 changes: 4 additions & 193 deletions resource/translations/skosmos_fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -760,196 +760,7 @@ msgstr ""
"esimerkiksi: *eläimet tai: *patentti*. Jos et käytä tähtimerkkiä haku "
"tehdään käyttäen loppukatkaisua."

#~ msgid "dc11:contributor"
#~ msgstr "Muu tekijä"

#~ msgid "dc11:creator"
#~ msgstr "Tekijä"

#~ msgid "dc11:description"
#~ msgstr "Kuvaus"

#~ msgid "dc11:license"
#~ msgstr "Lisenssi"

#~ msgid "dc11:publisher"
#~ msgstr "Julkaisija"

#~ msgid "dc11:relation"
#~ msgstr "Suhde"

#~ msgid "dc11:rights"
#~ msgstr "Oikeudet"

#~ msgid "dc11:source"
#~ msgstr "Lähde"

#~ msgid "dc11:title"
#~ msgstr "Nimi"

#~ msgid "Error: the vocabulary does not contain terms beginning with"
#~ msgstr "Sanasto ei sisällä termejä jotka alkavat kirjaimella"

#~ msgid "Vocabularies on the server"
#~ msgstr "Sanastot ja ontologiat"

#~ msgid "Modified concepts"
#~ msgstr "Muokatut käsitteet"

#~ msgid "New concepts"
#~ msgstr "Uudet käsitteet"

#~ msgid "All"
#~ msgstr "Näytetään kaikki"

#~ msgid "results"
#~ msgstr " hakutulosta (haku"

#~ msgid "results for"
#~ msgstr " tulosta haulle"

#~ msgid "Language literal"
#~ msgstr "suomeksi"

#~ msgid "isothes:subGroup"
#~ msgstr "Alaryhmä"

#~ msgid "skos:hiddenLabel"
#~ msgstr "Piilokäsitteet"

#~ msgid "concepts within the group"
#~ msgstr "Ryhmän sisältämät käsitteet"

#~ msgid "dc11:created"
#~ msgstr "Luontipäivä"

#~ msgid "dc11:modified"
#~ msgstr "Muokkauspäivä"

#~ msgid "language_changed_message"
#~ msgstr ""
#~ "Valitsemaasi kieltä ei ollut tuettuna tässä sanastossa. Siksi emme näytä "
#~ "sivua suomeksi."

#~ msgid "Show matches in any language"
#~ msgstr "Näytä myös muunkieliset osumat"

#~ msgid "ar"
#~ msgstr "arabiaksi"

#~ msgid "bg"
#~ msgstr "bulgariaksi"

#~ msgid "cs"
#~ msgstr "tšekiksi"

#~ msgid "da"
#~ msgstr "tanskaksi"

#~ msgid "de"
#~ msgstr "saksaksi"

#~ msgid "el"
#~ msgstr "nykykreikaksi"

#~ msgid "en"
#~ msgstr "englanniksi"

#~ msgid "es"
#~ msgstr "espanjaksi"

#~ msgid "et"
#~ msgstr "eestiksi"

#~ msgid "fa"
#~ msgstr "persiaksi"

#~ msgid "fi"
#~ msgstr "suomeksi"

#~ msgid "fr"
#~ msgstr "ranskaksi"

#~ msgid "hi"
#~ msgstr "hindiksi"

#~ msgid "hr"
#~ msgstr "kroatiaksi"

#~ msgid "hu"
#~ msgstr "unkariksi"

#~ msgid "it"
#~ msgstr "italiaksi"

#~ msgid "ja"
#~ msgstr "japaniksi"

#~ msgid "ko"
#~ msgstr "koreaksi"

#~ msgid "la"
#~ msgstr "latinaksi"

#~ msgid "lo"
#~ msgstr "laoksi"

#~ msgid "lt"
#~ msgstr "liettuaksi"

#~ msgid "lv"
#~ msgstr "latviaksi"

#~ msgid "mt"
#~ msgstr "maltaksi"

#~ msgid "nl"
#~ msgstr "hollanniksi"

#~ msgid "pl"
#~ msgstr "puolaksi"

#~ msgid "pt"
#~ msgstr "portugaliksi"

#~ msgid "ro"
#~ msgstr "romaniaksi"

#~ msgid "ru"
#~ msgstr "venäjäksi"

#~ msgid "sk"
#~ msgstr "slovakiksi"

#~ msgid "sl"
#~ msgstr "sloveniaksi"

#~ msgid "sr"
#~ msgstr "serbiaksi"

#~ msgid "sv"
#~ msgstr "ruotsiksi"

#~ msgid "te"
#~ msgstr "teluguksi"

#~ msgid "th"
#~ msgstr "thaiksi"

#~ msgid "tr"
#~ msgstr "turkiksi"

#~ msgid "zh"
#~ msgstr "kiinaksi"

#~ msgid "Download"
#~ msgstr "Lataa"

#~ msgid "Instructions"
#~ msgstr "Ohje"

#~ msgid "skos:prefLabel_help"
#~ msgstr "Käsitteestä käytettävän termin kirjoitusasu."

#~ msgid "short_search_example"
#~ msgstr "esim. kissa tai *talous"
msgid "feedback_enter_name_email"
msgstr ""
"Kerro nimesi ja sähköpostiosoitteesi, niin vastaamme sinulle "
"henkilökohtaisesti. Voit halutessasi jättää palautteen myös nimettömänä."
Loading

0 comments on commit 7b517f1

Please sign in to comment.