]
) . "@$emailDomain";
- $group = new CRM_Contact_BAO_Group();
- $group->id = $this->group_id;
- $group->find(TRUE);
-
$component = new CRM_Mailing_BAO_MailingComponent();
$component->is_default = 1;
$component->is_active = 1;
$bao->body_html = $html;
$templates = $bao->getTemplates();
- $html = CRM_Utils_Token::replaceSubscribeTokens($templates['html'], $group->title, $url, TRUE);
- $text = CRM_Utils_Token::replaceSubscribeTokens($templates['text'], $group->title, $url, FALSE);
+ $html = str_replace('{subscribe.url}', $url, $templates['html']);
+ $text = str_replace('{subscribe.url}', $url, $templates['text']);
// render the & entities in text mode, so that the links work
$text = str_replace('&', '&', $text);
$tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [
'controller' => __CLASS__,
'smarty' => FALSE,
- 'schema' => ['contactId'],
+ 'schema' => ['contactId', 'groupId'],
]);
$tokenProcessor->addMessage('body_html', $html, 'text/html');
$tokenProcessor->addMessage('body_text', $text, 'text/plain');
- $tokenProcessor->addRow(['contactId' => $this->contact_id]);
+ $tokenProcessor->addRow(['contactId' => $this->contact_id, 'groupId' => $this->group_id]);
$tokenProcessor->evaluate();
$html = $tokenProcessor->getRow(0)->render('body_html');
$text = $tokenProcessor->getRow(0)->render('body_text');
body_text = REPLACE(body_text, '{welcome.group}', '{group.frontend_title}'),
subject = REPLACE(subject, '{welcome.group}', '{group.frontend_title}')
WHERE component_type = 'Welcome';
+
+UPDATE civicrm_mailing_component
+SET body_html = REPLACE(body_html, '{subscribe.group}', '{group.frontend_title}'),
+body_text = REPLACE(body_text, '{subscribe.group}', '{group.frontend_title}'),
+subject = REPLACE(subject, '{subscribe.group}', '{group.frontend_title}')
+WHERE component_type = 'Subscribe';
{/literal}
UPDATE `civicrm_location_type` SET `is_reserved` = 0 WHERE `is_reserved` IS NULL;
/**
* Replace subscription-confirmation-request tokens
*
+ * @deprecated
+ *
* @param string $str
* The string with tokens to be replaced.
* @param string $group
* The processed string
*/
public static function &replaceSubscribeTokens($str, $group, $url, $html) {
+ CRM_Core_Error::deprecatedFunctionWarning('use token processor');
if (self::token_match('subscribe', 'group', $str)) {
self::token_replace('subscribe', 'group', $group, $str);
}
'name' => 'Test Group 1',
'domain_id' => 1,
'title' => 'New Test Group Created',
+ 'frontend_title' => 'Public group name',
'description' => 'New Test Group Created',
'is_active' => 1,
'visibility' => 'Public Pages',
<?php
-$subgroup = '{subscribe.group}';
+$subgroup = '{group.frontend_title}';
$suburl = '{subscribe.url}';
$welgroup = '{group.frontend_title}';
$unsubgroup = '{unsubscribe.group}';
INSERT INTO `civicrm_mailing_component` (`id`, `name`, `component_type`, `subject`, `body_html`, `body_text`, `is_default`, `is_active`) VALUES
(1,'Mailing Header','Header','Descriptive Title for this Header','Sample Header for HTML formatted content.','Sample Header for TEXT formatted content.',1,1),
(2,'Mailing Footer','Footer','Descriptive Title for this Footer.','Sample Footer for HTML formatted content<br/><a href=\"{action.optOutUrl}\">Unsubscribe</a> <br/> {domain.address}','to unsubscribe: {action.optOutUrl}\n{domain.address}',1,1),
- (3,'Subscribe Message','Subscribe','Subscription Confirmation Request','You have a pending subscription to the {subscribe.group} mailing list. To confirm this subscription, reply to this email or click <a href=\"{subscribe.url}\">here</a>.','You have a pending subscription to the {subscribe.group} mailing list. To confirm this subscription, reply to this email or click on this link: {subscribe.url}',1,1),
+ (3,'Subscribe Message','Subscribe','Subscription Confirmation Request','You have a pending subscription to the {group.frontend_title} mailing list. To confirm this subscription, reply to this email or click <a href=\"{subscribe.url}\">here</a>.','You have a pending subscription to the {group.frontend_title} mailing list. To confirm this subscription, reply to this email or click on this link: {subscribe.url}',1,1),
(4,'Welcome Message','Welcome','Your Subscription has been Activated','Welcome. Your subscription to the {group.frontend_title} mailing list has been activated.','Welcome. Your subscription to the {group.frontend_title} mailing list has been activated.',1,1),
(5,'Unsubscribe Message','Unsubscribe','Un-subscribe Confirmation','You have been un-subscribed from the following groups: {unsubscribe.group}. You can re-subscribe by mailing {action.resubscribe} or clicking <a href=\"{action.resubscribeUrl}\">here</a>.','You have been un-subscribed from the following groups: {unsubscribe.group}. You can re-subscribe by mailing {action.resubscribe} or clicking {action.resubscribeUrl}',1,1),
(6,'Resubscribe Message','Resubscribe','Re-subscribe Confirmation','You have been re-subscribed to the following groups: {resubscribe.group}. You can un-subscribe by mailing {action.unsubscribe} or clicking <a href=\"{action.unsubscribeUrl}\">here</a>.','You have been re-subscribed to the following groups: {resubscribe.group}. You can un-subscribe by mailing {action.unsubscribe} or clicking {action.unsubscribeUrl}',1,1),
* Test civicrm_mailing_group_event_subscribe with given contact ID.
*/
public function testMailerGroupSubscribeGivenContactID(): void {
+ $mailUtil = new CiviMailUtils($this);
$email = 'test@example.org';
$params = [
'first_name' => 'Test',
];
$result = $this->callAPISuccess('MailingEventSubscribe', 'create', $params);
$this->assertEquals($result['values'][$result['id']]['contact_id'], $contactID);
+ $mailUtil->checkAllMailLog(['You have a pending subscription to the Public group name mailing list']);
}
/**