Skip to content
Snippets Groups Projects
Commit c616db87 authored by Jay Friendly's avatar Jay Friendly
Browse files

Fixing issues arising from merging 1.x of the module into 2.x

parent 6767a343
No related branches found
No related tags found
No related merge requests found
......@@ -150,20 +150,20 @@ Drupal.PrivateMessages.threadChange = {};
}
});
if (refreshRate) {
$.ajax({
url:drupalSettings.privateMessageThread.newMessageCheckUrl,
data: {threadid:threadId, messageid:newestId},
success:function (data) {
triggerCommands(data);
$.ajax({
url:drupalSettings.privateMessageThread.newMessageCheckUrl,
data: {threadid:threadId, messageid:newestId},
success:function (data) {
triggerCommands(data);
loadingNew = false;
loadingNew = false;
if (refreshRate) {
// Check for new messages again.
timeout = window.setTimeout(getNewMessages, refreshRate);
}
});
}
}
});
}
}
......
......@@ -432,110 +432,12 @@ function private_message_user_form_submit(array &$form, FormStateInterface $form
// Get the user whose account object is being modified.
$user = $formState->getFormObject()->getEntity();
$user_data = \Drupal::service('user.data');
// Save the submitted data to the user's UserData.
$user_data->set('private_message', $user->id(), 'receive_notification', $formState->getValue(['private_messages', 'receive_notification']));
$user_data->set('private_message', $user->id(), 'notify_when_using', $formState->getValue(['private_messages', 'notify_when_using']));
$user_data->set('private_message', $user->id(), 'number_of_seconds_considered_away', $formState->getValue(['private_messages', 'number_of_seconds_considered_away']));
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Adds private message emails to the configuration form so that administrators
* can modify the email as necessary.
*
* @see hook_form_alter()
* @see \Drupal\user\ProfileForm
*/
function private_message_form_user_admin_settings_alter(array &$form, FormStateInterface $form_state) {
$config = \Drupal::config('private_message.settings');
$mail_config = \Drupal::config('private_message.mail');
// Only add the email to the form if private message email notifications
// have been enabled.
if ($config->get('enable_email_notifications')) {
// List the available tokens.
$private_message_token_help = t('Available variables are: [site:name], [site:url], [user:display-name], [user:account-name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url], [private_message:id], [private_message:author-name], [private_message:message], [private_message:url], [private_message:created], [private_message_thread:id], [private_message_thread:], [private_message_thread:url], [private_message_thread:updated].');
$form['email_private_message'] = [
'#type' => 'details',
'#title' => t('Private message notification'),
'#description' => t('Edit the notification mail sent to users when they receive a private message') . $private_message_token_help,
'#group' => 'email',
'#tree' => TRUE,
];
$form['email_private_message']['settings'] = [
'#type' => 'container',
];
$form['email_private_message']['settings']['user_mail_private_message_notification_subject'] = [
'#type' => 'textfield',
'#title' => t('Subject'),
'#default_value' => $mail_config->get('message_notification.subject'),
'#maxlength' => 180,
];
$form['email_private_message']['settings']['user_mail_private_message_notification_body'] = [
'#type' => 'textarea',
'#title' => t('Body'),
'#rows' => 17,
'#default_value' => $mail_config->get('message_notification.body'),
];
$form['#submit'][] = 'private_message_user_admin_settings_submit';
}
}
/**
* Submit handler, saves alterations to private message emails.
*
* @see private_message_form_user_admin_settings_alter()
* @see \Drupal\user\ProfileForm
*/
function private_message_user_admin_settings_submit(array &$form, FormStateInterface $form_state) {
\Drupal::service('config.factory')->getEditable('private_message.mail')
->set('message_notification.subject', $form_state->getValue(
[
'email_private_message',
'settings',
'user_mail_private_message_notification_subject',
]
))
->set('message_notification.body', $form_state->getValue(
[
'email_private_message',
'settings',
'user_mail_private_message_notification_body',
]
))
->save();
}
/**
* Implements hook_mail().
*/
function private_message_mail($key, &$message, $params) {
if ($key == 'message_notification') {
$token = \Drupal::token();
$mail_config = \Drupal::config('private_message.mail');
$message_subject = $mail_config->get('message_notification.subject');
$message_body = $mail_config->get('message_notification.body');
$data['user'] = $params['member'];
$data['private_message'] = $params['private_message'];
$data['private_message_thread'] = $params['private_message_thread'];
$message['subject'] = $token->replace($message_subject, $data);
$body = $token->replace($message_body, $data);
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = SafeMarkup::checkPlain($message['subject']);
$message['body'][] = MailFormatHelper::htmlToText(Xss::filter($body));
}
>>>>>>> 8.x-1.x
}
/**
* Implements hook_theme().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment