/[drupal]/contributions/modules/mimemail/includes/mimemail.admin.inc
ViewVC logotype

Diff of /contributions/modules/mimemail/includes/mimemail.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1, Sun Feb 22 20:55:46 2009 UTC revision 1.1.2.2, Tue Apr 14 23:09:00 2009 UTC
# Line 0  Line 1 
1    <?php /* $Id: mimemail.admin.inc,v 1.1 2009/02/22 20:55:46 vauxia Exp $ */
2    
3    /**
4     * @file
5     * Admin settings pages for sending Mime-encoded emails.
6     */
7    
8    /**
9     * Administration settings.
10     *
11     * @return
12     *   The administration from.
13     */
14    function mimemail_admin_settings() {
15    
16      // override the smtp_library value if mimemail is chosen to handle all mail
17      // this will cause drupal_mail to call mimemail()
18      if (variable_get('mimemail_alter', 0)) {
19        if (!strpos(variable_get('smtp_library', ''), 'mimemail')) {
20          variable_set('smtp_library', drupal_get_filename('module', 'mimemail'));
21        }
22      }
23      else {
24        if (strpos(variable_get('smtp_library', ''), 'mimemail')) {
25          db_query("DELETE FROM {variable} WHERE name = 'smtp_library'");
26        }
27      }
28    
29      $engines = mimemail_get_engines();
30    
31      $form = array();
32      $form['site_mail'] = array(
33        '#type'          => 'textfield',
34        '#title'         => t('E-mail address'),
35        '#default_value' => variable_get('site_mail', ini_get('sendmail_from')),
36        '#size'          => 60,
37        '#maxlength'     => 128,
38        '#description'   => t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.')
39      );
40      $form['mimemail']['mimemail_alter'] = array(
41        '#type'          => 'checkbox',
42        '#title'         => t('Use mime mail for all messages'),
43        '#default_value' => variable_get('mimemail_alter', 0),
44        '#description'   => t('Use the mime mail module to deliver all site messages.  With this option, system emails will have styles and formatting'),
45      );
46    
47      $filter_format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
48      $form['mimemail']['mimemail_format'] =  filter_form($filter_format, NULL, array("mimemail_format"));
49    
50      $form['mimemail']['mimemail_textonly'] = array(
51        '#type'          => 'checkbox',
52        '#title'         => t('Plaintext email only'),
53        '#default_value' => variable_get('mimemail_textonly', 0),
54        '#description'   => t('This option disables the use of email messages with graphics and styles.  All messages will be converted to plain text.'),
55      );
56    
57      $form['mimemail']['incoming'] = array(
58        '#type'          => 'fieldset',
59        '#title'         => t('Advanced Settings'),
60        '#collapsible'   => TRUE,
61        '#collapsed'     => TRUE,
62      );
63      $form['mimemail']['incoming']['mimemail_incoming'] = array(
64        '#type'          => 'checkbox',
65        '#title'         => t('Process incoming messages posted to this site'),
66        '#default_value' => variable_get('mimemail_incoming', 0),
67        '#description'   => t('This is an advanced setting that should not be enabled unless you know what you are doing'),
68      );
69      $form['mimemail']['incoming']['mimemail_key'] = array(
70        '#type'          => 'textfield',
71        '#title'         => t('Message validation string'),
72        '#default_value' => variable_get('mimemail_key', md5(rand())),
73        '#required'      => TRUE,
74        '#description'   => t('This string will be used to validate incoming messages.  It can be anything, but must be used on both sides of the transfer'),
75      );
76    
77      // hide the settings if only 1 engine is available
78      if (count($engines) == 1) {
79        variable_set('mimemail_engine', key($engines));
80        $form['mimemail_engine'] = array(
81            '#type'          => 'hidden',
82            '#title'         => t('E-mail engine'),
83            '#default_value' => variable_get('mimemail_engine', 'mail'),
84            '#options'       => $engines,
85            '#description'   => t('Choose an e-mail engine for sending mails from your site.')
86        );
87      }
88      else {
89        $form['mimemail_engine'] = array(
90            '#type'          => 'select',
91            '#title'         => t('E-mail engine'),
92            '#default_value' => variable_get('mimemail_engine', 'mail'),
93            '#options'       => $engines,
94            '#description'   => t('Choose an e-mail engine for sending mails from your site.')
95        );
96      }
97    
98      if (variable_get('mimemail_engine', 0)) {
99        $settings = module_invoke(variable_get('mimemail_engine', 'mail'), 'mailengine', 'settings');
100        if ($settings) {
101            $form['mimemail_engine_settings'] = array(
102              '#type'        => 'fieldset',
103              '#title'       => t('Engine specific settings'),
104          );
105          foreach ($settings as $name => $value) {
106            $form['mimemail_engine_settings'][$name] = $value;
107          }
108        }
109      }
110      else {
111        drupal_set_message(t('Please choose a mail engine.'), 'error');
112      }
113    
114      return system_settings_form($form);
115    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2