Skip to content
Snippets Groups Projects

Resolve #3373487 "Implement hookhelp"

4 unresolved threads
Files
8
@@ -142,24 +142,33 @@ class EmailManualSendByRole extends EmailSettings {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $emailToSend = NULL) {
public function buildForm(array $form, FormStateInterface $form_state, $email_to_send = NULL) {
$form = parent::buildForm($form, $form_state);
// Save the parameter.
$this->emailToSend = $email_to_send;
// Get user role from query.
$this->userRole = (string) $this->currentRouteMatch->getRawParameter('role');
// If the specified email does not exist, throw an error.
$specifiedEmail = $form['emails'][$emailToSend] ?? FALSE;
$specifiedEmail = $form['emails'][$this->emailToSend] ?? FALSE;
if (!$specifiedEmail) {
$this->logger('send_emails_manual')->notice(
"Tried accessing Manual Send Emails with invalid template @template (and user role @userrole)",
['@template' => $email_to_send, '@userrole' => $this->userRole]);
throw new NotFoundHttpException();
}
// Get user role from query.
$this->userRole = (string) $this->currentRouteMatch->getRawParameter('role');
// Check if user role exists.
$userRoleName = 'User';
if (!empty($this->userRole)) {
$userRolesList = $this->getUserRoles();
$userRoleName = $userRolesList[$this->userRole] ?? FALSE;
if (!$userRoleName) {
$this->logger('send_emails_manual')->notice(
"Tried accessing Manual Send Emails with invalid user role @userrole (and template @template)",
['@template' => $email_to_send, '@userrole' => $this->userRole]);
throw new NotFoundHttpException();
}
@@ -167,7 +176,7 @@ class EmailManualSendByRole extends EmailSettings {
$form['#title'] = $this->t(
'Send %type Email to the %role role',
[
'%type' => ucwords(str_replace('_', ' ', $emailToSend)),
'%type' => ucwords(str_replace('_', ' ', $this->emailToSend)),
'%role' => $userRoleName,
]
);
@@ -177,14 +186,11 @@ class EmailManualSendByRole extends EmailSettings {
$form['#title'] = $this->t(
'Send %type Email to a User Role',
[
'%type' => ucwords(str_replace('_', ' ', $emailToSend)),
'%type' => ucwords(str_replace('_', ' ', $this->emailToSend)),
]
);
}
// Save the parameter.
$this->email_to_send = $emailToSend;
// Adjust current form.
unset($form['emails_definitions']);
@@ -193,7 +199,7 @@ class EmailManualSendByRole extends EmailSettings {
// Remove all emails except the specified one.
unset($form['emails']);
$form['emails'][$emailToSend] = $specifiedEmail;
$form['emails'][$this->emailToSend] = $specifiedEmail;
// Choose the role.
if (empty($this->userRole)) {
@@ -253,14 +259,14 @@ class EmailManualSendByRole extends EmailSettings {
}
// Email template to send.
$emailTemplate = $this->email_to_send;
$emailTemplate = $this->emailToSend;
// Get the form field values for sending emails.
$destination = $form_state->getValue([
$this->email_to_send,
$this->emailToSend,
'destination',
]);
$replyTo = $form_state->getValue([$this->email_to_send, 'replyTo']);
$replyTo = $form_state->getValue([$this->emailToSend, 'replyTo']);
if (!empty($notificationRoles)) {
$userRolesList = $this->getUserRoles();
Loading