Skip to content

Commit

Permalink
Merge branch 'master' of github.com:writecrow/rest_feedback_endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
markfullmer committed Oct 4, 2020
2 parents b524ad1 + 72bce26 commit 4b5be00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rest_feedback_endpoint.module
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function rest_feedback_endpoint_mail($key, &$message, $params) {

switch ($key) {
case 'rest_feedback_endpoint':
$message['subject'] = t('Crow interface bug report: @title', ['@title' => $params['title']], $options);
$message['subject'] = t('@title', ['@title' => $params['title']], $options);
$message['body'][] = $params['message'];
break;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Form/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#description' => $this->t('Single email only'),
'#default_value' => $config->get('notification_email'),
];
$form['subject_line_prefix'] = [
'#type' => 'textfield',
'#title' => $this->t('Subject line prefix'),
'#description' => $this->t('Prepend the subject line of the email (e.g. "Mysite user feedback: ".'),
'#default_value' => $config->get('subject_line_prefix'),
];
return parent::buildForm($form, $form_state);
}

Expand All @@ -60,6 +66,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$this->configFactory->getEditable(static::SETTINGS)
->set('on', $form_state->getValue('on'))
->set('notification_email', $form_state->getValue('notification_email'))
->set('subject_line_prefix', $form_state->getValue('subject_line_prefix'))
->save();
parent::submitForm($form, $form_state);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/rest/resource/SubmitIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function post($data) {
$module = 'rest_feedback_endpoint';
$key = 'rest_feedback_endpoint';
$to = $config->get('notification_email');
$params['message'] = 'The user ' . $name . ' has reported an issue with the Crow web interface.' . PHP_EOL . PHP_EOL;
$params['message'] = 'The user ' . $name . ' has reported an issue with the interface.' . PHP_EOL . PHP_EOL;
$params['message'] .= 'SOURCE PAGE: ' . $data['url'] . PHP_EOL . PHP_EOL;
$params['message'] .= 'DESCRIPTION: ' . Html::escape($data['description']) . PHP_EOL . PHP_EOL;
$params['message'] .= 'USER ACCESS LEVEL: ' . implode(', ', $reported_roles) . PHP_EOL . PHP_EOL;
Expand All @@ -106,7 +106,7 @@ public function post($data) {
else {
$params['message'] .= 'CONTACT USER WITH UPDATES ABOUT THE ISSUE: no' . PHP_EOL . PHP_EOL;
}
$params['title'] = Html::escape($data['title']);
$params['title'] = $config->get('subject_line_prefix') . Html::escape($data['title']);
$langcode = \Drupal::currentUser()->getPreferredLangcode();
$send = TRUE;
$response_status['status'] = $mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);
Expand Down

0 comments on commit 4b5be00

Please sign in to comment.