-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathviews_send.admin.inc
109 lines (98 loc) · 4.95 KB
/
views_send.admin.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @file
* Views Send administration page.
*
* @ingroup views_send
*/
/**
* Callback for admin/settings/views_send menu item.
*/
function views_send_settings() {
$form = array();
if (VIEWS_SEND_MIMEMAIL) {
$form['views_send_attachment_valid_extensions'] = array(
'#type' => 'textfield',
'#title' => t('Valid file extensions for attachments'),
'#default_value' => config_get('views_send.settings','views_send_attachment_valid_extensions'),
'#description' => t('A space separated list of allowed file extensions for attachments. Leave the list empty if you want to use the default list from file_save_upload().'),
);
}
$throttle = backdrop_map_assoc(array(1, 10, 20, 30, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000));
$throttle[0] = t('Unlimited');
$form['views_send_throttle'] = array(
'#type' => 'select',
'#title' => t('Cron throttle'),
'#options' => $throttle,
'#default_value' => config_get('views_send.settings','views_send_throttle'),
'#description' => t('Sets the numbers of messages sent per cron run. Failure to send will also be counted. Cron execution must not exceed the PHP maximum execution time of %max seconds. You find the time spend to send emails in the !recent_logs.', array('%max' => ini_get('max_execution_time'), '!recent_logs' => l(t('Recent log entries'), 'admin/reports/dblog'))),
);
$form['views_send_spool_expire'] = array(
'#type' => 'select',
'#title' => t('Mail spool expiration'),
'#options' => array(0 => t('Immediate'), 1 => t('1 day'), 7 => t('1 week'), 14 => t('2 weeks')),
'#default_value' => config_get('views_send.settings','views_send_spool_expire'),
'#description' => t('Emails are spooled. How long must messages be retained in the spool after successfull sending.'),
);
$form['views_send_debug'] = array(
'#type' => 'checkbox',
'#title' => t('Log emails'),
'#default_value' => config_get('views_send.settings','views_send_debug'),
'#description' => t('When checked all outgoing messages are logged in the system log. A logged email does not guarantee that it is sent or will be delivered. It only indicates that a message is sent to the PHP mail() function. No status information is available of delivery by the PHP mail() function.'),
);
$form['views_send_additional_options'] = array(
'#type' => 'checkbox',
'#title' => t('Show additional email options'),
'#default_value' => config_get('views_send.settings','views_send_additional_options'),
'#description' => t('When checked the user will be able to use the additional email options.'),
);
$form['views_send_from_name'] = array(
'#type' => 'textfield',
'#title' => t('Send from name'),
'#default_value' => config_get('views_send.settings','views_send_from_name'),
'#description' => t('The name to be shown as the sender of the email.'),
);
$form['views_send_from_mail'] = array(
'#type' => 'textfield',
'#title' => t('Send from email address'),
'#default_value' => config_get('views_send.settings','views_send_from_mail'),
'#description' => t('The email address to be shown as the sender of the email.'),
);
// Add default mail system
$mailsystem_options = array();
$mailsystem_options['DefaultMailSystem'] = 'Default for System';
if (VIEWS_SEND_MIMEMAIL) {
$mailsystem_options['MimeMailSystem'] = 'Mime Mail';
}
$form['views_send_default_mailsystem'] = array(
'#type' => 'select',
'#options' => $mailsystem_options,
'#title' => t('Default mail system'),
'#default_value' => config_get('views_send.settings','views_send_default_mailsystem'),
'#description' => t('The default mail system to be used for Views Send messages.'),
);
// Add a submit button
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}
/**
* Submit handler for module_settings_form().
*/
function views_send_settings_submit($form, &$form_state){
$config = config('views_send.settings');
$config->set('views_send_attachment_valid_extensions', $form_state['values']['views_send_attachment_valid_extensions']);
$config->set('views_send_throttle', $form_state['values']['views_send_throttle']);
$config->set('views_send_spool_expire', $form_state['values']['views_send_spool_expire']);
$config->set('views_send_debug', $form_state['values']['views_send_debug']);
$config->set('views_send_additional_options', $form_state['values']['views_send_additional_options']);
$config->set('views_send_from_name', $form_state['values']['views_send_from_name']);
$config->set('views_send_from_mail', $form_state['values']['views_send_from_mail']);
$config->set('views_send_default_mailsystem', $form_state['values']['views_send_default_mailsystem']);
$config->save();
config_set('system.mail','views_send', $form_state['values']['views_send_default_mailsystem']);
backdrop_set_message(t('The configuration options have been saved.'));
}