function newsletter_create_examples in Newsletter 7
1 call to newsletter_create_examples()
- newsletter_install in ./
newsletter.install - Implements hook_install().
File
- ./
newsletter.install, line 529 - Contains install,uninstall and update functions for Newsletter module.
Code
function newsletter_create_examples() {
$controller = entity_get_controller('newsletter_template');
$confirmation_body = "Hello [newsletter:subscriber_email],<br />\n\n";
$confirmation_body .= "We received your request for information from [site:name] <br />\n";
$confirmation_body .= "Before we begin sending you the information you requested, we want to be certain we have your permission.<br />\n";
$confirmation_body .= "Click the link below to give us permission to send you information. It's fast and easy! If you cannot click the full URL below, please copy the URL and paste it into your web browser.<br /><br />\n\n";
$confirmation_body .= "Confirm by clicking the URL below:<br /><br />\n";
$confirmation_body .= "<a href=\"[newsletter:confirmation_url]\">[newsletter:confirmation_url]</a><br /><br />\n\n";
$confirmation_body .= "If you do not want to subscribe, simply ignore this message.<br /><br />\n\n";
$confirmation_body .= "Best Regards,<br />\n";
$confirmation_body .= "[site:name]<br />\n";
$confirmation_body .= "[site:url]<br /><br />\n\n";
$confirmation_body .= "Request generated by:<br />\n";
$confirmation_body .= "IP: [newsletter:subscription_ip]<br />\n";
$confirmation_body .= "Date: [newsletter:subscription_time]<br />\n";
$template = $controller
->create();
$template->basic = 1;
$template->subject = 'Newsletter confirmation';
$template->field_newsletter_body[LANGUAGE_NONE][0] = array(
'value' => $confirmation_body,
'format' => 'filtered_html',
);
$controller
->save($template);
$welcome_body = "Hello [newsletter:subscriber_email],<br /><br />\n\n";
$welcome_body .= "Thank you for your subscription. You are now signed up to our newsletter!<br />\n";
$welcome_body .= "We will keep your personal information private and secure. We will not share your email address with any third parties. <br />\n";
$welcome_body .= "To ensure you receive future subscribers-only news, please add this e-mail to your e-mail address book or safe senders list.<br />\n\n\n";
$welcome_body .= "Sincerely,<br />\n";
$welcome_body .= "[site:name]<br />\n";
$welcome_body .= "[site:url]<br /><br />\n\n";
$welcome_body .= "----<br />\n";
$welcome_body .= "You are receiving this email because on [newsletter:subscription_time] at [site:url] you subscribed to receive our e-newsletters.<br /><br />\n";
$welcome_body .= "You can unsubscribe via the link below:<br />\n";
$welcome_body .= "<a href=\"[newsletter:unsubscribe_url]\">Unsubscribe</a>\n";
$template = $controller
->create();
$template->basic = 1;
$template->subject = 'Newsletter welcome';
$template->field_newsletter_body[LANGUAGE_NONE][0] = array(
'value' => $welcome_body,
'format' => 'filtered_html',
);
$controller
->save($template);
$unsubscribe_body = "Dear [newsletter:subscriber_email],<br />\n\n";
$unsubscribe_body .= "This email is being sent to notify you that we have received a request to remove the following record from our mailing list:<br /><br />\n\n";
$unsubscribe_body .= "Email: [newsletter:subscriber_email]<br /><br />\n\n";
$unsubscribe_body .= "This record was removed from our database.<br />\n";
$unsubscribe_body .= "If you do receive further unwanted email from our system, please let us know and we'd be happy to address the issue immediately.<br /><br />\n\n";
$unsubscribe_body .= "Sincerely,<br />\n";
$unsubscribe_body .= "[site:name]<br />\n";
$unsubscribe_body .= "[site:url] <br />\n";
$template = $controller
->create();
$template->basic = 1;
$template->subject = 'Newsletter unsubscribe';
$template->field_newsletter_body[LANGUAGE_NONE][0] = array(
'value' => $unsubscribe_body,
'format' => 'filtered_html',
);
$controller
->save($template);
$body = "Hello [newsletter:subscriber_email],<br /><br />\n\n";
$body .= "Here is what's new on <a href=\"[site:url]\">[site:name]</a> over the past few days. Your comments and feedback are always welcome.<br />\n\n";
$body .= "<ol>\n";
$body .= " [repeat] \n";
$body .= "<li><a href=\"[node:url]\">[node:title]</a> -[node:created]<br /> [node:summary]<br /></li>\n";
$body .= " [/repeat] \n\n";
$body .= "</ol>Sincerely,<br /> <a href=\"[site:url]\">[site:name]</a><br /> <br /> <br />\n\n";
$body .= "--<br />You are receiving this email because on [newsletter:subscription_time] you subscribed to receive our newsletter list : [newsletter:list_name].<br /><br />\n\n";
$body .= "You can unsubscribe by clicking the link below:<br /> \n";
$body .= "<a href=\"[newsletter:unsubscribe_url]\">Unsubscribe</a><br />\n";
$template = $controller
->create();
$template->subject = 'Default';
$template->field_newsletter_body[LANGUAGE_NONE][0] = array(
'value' => $body,
'format' => 'filtered_html',
);
// Assign all terms to this template from a random vocabulary
$vocabulary = db_query_range("SELECT vid, machine_name FROM {taxonomy_vocabulary} WHERE machine_name <> 'newsletter_categories'", 0, 1)
->fetchObject();
if ($vocabulary) {
$terms = taxonomy_get_tree($vocabulary->vid);
$field = 'field_' . $vocabulary->machine_name;
foreach ($terms as $term) {
$template->{$field}[LANGUAGE_NONE][]['tid'] = $term->tid;
}
}
$controller
->save($template);
// Create Standard List
$controller = entity_get_controller('newsletter_list');
$list = $controller
->create();
$list->title = 'Standard list';
$list->field_newsletter_template[LANGUAGE_NONE][0]['target_id'] = 4;
$list->field_list_description[LANGUAGE_NONE][0]['value'] = 'An example newsletter list with Manual Send Rate.';
$list->send_rate = 'Manual';
$controller
->save($list);
}