Skip to content

Commit

Permalink
Code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmels committed Nov 8, 2019
1 parent 54c68cb commit dda6778
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 59 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Requirements

* For large mailing lists, cron is required.
* HTML-format newsletters and/or newsletters with file attachments require the mime mail or HMTL mail module.
* When sending newsletters on regular cron (cron.php), it is important that the base url (settings.php, variable $base_url) is set correctly or links inside the newsletter will not work.
* When sending newsletters on regular cron (cron.php), it is important that the base url (settings.php, variable $base_url) is set correctly or links inside the newsletter will not work.
* Additionally when using Drush to start cron, it is important to use the argument --uri=http://www.example.com


Expand All @@ -25,7 +25,7 @@ Configuration

* To administer various Simplenews settings go to Configuration > Web services > Newsletter > Settings (`/admin/config/services/simplenews/settings`).

* Add or edit newsletter categories on Configuration > Web services > Newsletter (`/admin/config/services/simplenews`).
* Add or edit newsletter categories on Configuration > Web services > Newsletter (`/admin/config/services/simplenews`).

* By default Simplenews creates a new `Simplenews newsletter` content type, however you can enable any other content type to use as a newsletter on Structure > ccontent type > Configure > Publishing settings > Use as simplenews newsletter.

Expand All @@ -45,7 +45,7 @@ Cron is required to send large mailing lists. If you have a medium or large size

To use cron:
* Check the 'Use cron to send newsletters' checkbox.
* Set the 'Cron throttle' to the number of newsletters send per cron run. Too high values may lead to mail server overload or you may hit hosting restrictions.
* Set the 'Cron throttle' to the number of newsletters send per cron run. Too high values may lead to mail server overload or you may hit hosting restrictions.

Don't use cron:
* Uncheck the 'Use cron to send newsletters' checkbox.
Expand Down Expand Up @@ -92,10 +92,10 @@ Related modules
Allows fine grained control over cron tasks.
https://backdropcms.org/project/elysia_cron
* Mailsystem
Extends drupal core mailystem wirh Administrative UI and Developers API.
Extends Backdrop core mailystem wirh Administrative UI and Developers API.
https://backdropcms.org/project/mailsystem
* Maillog
Captures outgoing mails, helps users debugging simplenews.
Captures outgoing mails, helps users debugging Simplenews.
https://backdropcms.org/project/maillog


Expand Down
7 changes: 2 additions & 5 deletions config/simplenews.settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"_config_name": "simplenews.settings",
"simplenews_from_address": "",
"simplenews_from_name": "",
"simplenews_format": "plain",
"simplenews_priority": "0",
"simplenews_priority": 0,
"simplenews_send": 0,
"simplenews_use_cron": true,
"simplenews_source_cache": "SimplenewsSourceCacheBuild",
Expand All @@ -23,6 +21,5 @@
"simplenews_block_quantity": 5,
"simplenews_block_rss": true,
"simplenews_machine_name": "newsletter",
"simplenews_content_type_simplenews": true,
"simplenews_block_m_multiple": "Select the newsletter(s) to which you want to subscribe or unsubscribe.",
"simplenews_content_type_simplenews": true
}
23 changes: 12 additions & 11 deletions includes/simplenews.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ function simplenews_admin_category_form($form, &$form_state, $edit = array()) {
if (!is_array($edit)) {
$edit = (array) $edit;
}

$edit += array(
'tid' => 0,
'name' => '',
Expand All @@ -439,8 +440,8 @@ function simplenews_admin_category_form($form, &$form_state, $edit = array()) {
'priority' => $config->get('simplenews_priority'),
'receipt' => $config->get('simplenews_receipt'),
'from_name' => $config->get('simplenews_from_name'),
'from_email_address' => $config->get('simplenews_from_address'),
'email_subject' => '[[simplenews-category:name]] [node:title]',
'from_address' => $config->get('simplenews_from_address'),
'hyperlinks' => 1,
);

Expand Down Expand Up @@ -566,6 +567,16 @@ function simplenews_admin_category_form($form, &$form_state, $edit = array()) {
'#default_value' => $edit['from_name'],
);

// Email from address
$form['simplenews_sender_information']['from_address'] = array(
'#type' => 'textfield',
'#title' => t('From email address'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => $edit['from_email_address'],
);

// Email subject
$form['simplenews_subject'] = array(
'#type' => 'fieldset',
Expand Down Expand Up @@ -594,16 +605,6 @@ function simplenews_admin_category_form($form, &$form_state, $edit = array()) {
'#default_value' => $edit['email_subject'],
);

// Email from address
$form['simplenews_sender_information']['from_address'] = array(
'#type' => 'textfield',
'#title' => t('From email address'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => $edit['from_address'],
);

// Type of hyperlinks
$form['simplenews_hyperlinks'] = array(
'#type' => 'fieldset',
Expand Down
15 changes: 5 additions & 10 deletions includes/simplenews.subscription.inc
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ function simplenews_block_form($form, &$form_state, $tid) {
*/

/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
* form_validate
*/
function simplenews_block_form_validate($form, &$form_state) {
if (!valid_email_address($form_state['values']['mail'])) {
Expand All @@ -188,8 +187,7 @@ function simplenews_block_form_validate($form, &$form_state) {
*/

/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
* form_submit
*/
function simplenews_block_form_submit($form, &$form_state) {
$tid = $form['#tid'];
Expand Down Expand Up @@ -625,8 +623,7 @@ function simplenews_confirm_add_form($form, &$form_state, $mail, $newsletter) {
}

/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
* form_submit
*/
function simplenews_confirm_add_form_submit($form, &$form_state) {
$config = config('simplenews.settings');
Expand Down Expand Up @@ -666,8 +663,7 @@ function simplenews_confirm_multi_form($form, &$form_state, $subscriber) {
}

/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
* form_submit
*/
function simplenews_confirm_multi_form_submit($form, &$form_state) {
$subscriber = $form_state['values']['subscriber'];
Expand Down Expand Up @@ -733,8 +729,7 @@ function simplenews_confirm_removal_form($form, &$form_state, $mail, $newsletter
}

/**
* @todo Please document this function.
* @see http://drupal.org/node/1354
* form_submit
*/
function simplenews_confirm_removal_form_submit($form, &$form_state) {
$config = config('simplenews.settings');
Expand Down
31 changes: 3 additions & 28 deletions simplenews.install
Original file line number Diff line number Diff line change
Expand Up @@ -353,39 +353,18 @@ function simplenews_install() {
config_set('simplenews.settings', 'simplenews_test_address', $email);
}
elseif (!empty($email = ini_get('sendmail_from'))) {
// This is not alway reliable as https://www.php.net/manual/en/mail.configuration.php
// shows the default for `sendmail_from` is NULL.
// This is not always reliable as https://www.php.net/manual/en/mail.configuration.php
// shows the default for `sendmail_from` is NULL.
config_set('simplenews.settings', 'simplenews_from_address', $email);
config_set('simplenews.settings', 'simplenews_test_address', $email);
}
else {
// As the last resort, there is no chance $user->init returns empty.
$user = user_load('1');
config_set('simplenews.settings', 'simplenews_from_address', $user->init);

config_set('simplenews.settings', 'simplenews_test_address', $user->init);
}

config_set('simplenews.settings', 'simplenews_from_name', config_get('system.core', 'site_name'));
config_set('simplenews.settings', 'simplenews_format', "plain");
config_set('simplenews.settings', 'simplenews_priority', SIMPLENEWS_PRIORITY_NONE);
config_set('simplenews.settings', 'simplenews_send', 0);
config_set('simplenews.settings', 'simplenews_use_cron', TRUE);
config_set('simplenews.settings', 'simplenews_source_cache', "SimplenewsSourceCacheBuild");
config_set('simplenews.settings', 'simplenews_throttle', "20");
config_set('simplenews.settings', 'simplenews_debug', FALSE);
config_set('simplenews.settings', 'simplenews_sync_account', TRUE);
config_set('simplenews.settings', 'simplenews_use_combined', "multiple");
config_set('simplenews.settings', 'simplenews_spool_progress_expiration', "3600");
config_set('simplenews.settings', 'simplenews_source', "SimplenewsSourceNode");
config_set('simplenews.settings', 'simplenews_private_key', FALSE);
config_set('simplenews.settings', 'simplenews_category_field', 'field_simplenews_term');
config_set('simplenews.settings', 'simplenews_block_message_multiple', st('Select the newsletter(s) to which you want to subscribe or unsubscribe.'));
config_set('simplenews.settings', 'simplenews_block_message', "Stay informed on our latest news!");
config_set('simplenews.settings', 'simplenews_block_interface', 1);
config_set('simplenews.settings', 'simplenews_block_link', TRUE);
config_set('simplenews.settings', 'simplenews_block_previous', FALSE);
config_set('simplenews.settings', 'simplenews_block_quantity', 5);
config_set('simplenews.settings', 'simplenews_block_rss', TRUE);

_simplenews_init_simplenews_vocabulary();
_simplenews_init_simplenews_category();
Expand All @@ -397,10 +376,6 @@ function simplenews_install() {
* Implements hook_uninstall().
*/
function simplenews_uninstall() {
// Remove Simplenews database tables.
if (taxonomy_vocabulary_load('newsletter')) {
taxonomy_vocabulary_delete('newsletter');
}
// Remove Simplenews configuration file.
config('simplenews.settings')->delete();
}
Expand Down

0 comments on commit dda6778

Please sign in to comment.