Mailinglist
 All Data Structures Files Functions Variables Pages
MailinglistMailboxRetrieve.class.php
Go to the documentation of this file.
1 <?php
11 
21  function edit_form(&$form, &$form_state) {
22  parent::edit_form($form, $form_state);
23  global $cookie_domain;
24 
25  /* Parameters that we need:
26  Base:
27  Hostname:
28  Port:
29  Timeout:
30  UseSocket
31  Username:
32  Password:
33 
34  Extra:
35  APOPDetect:
36  Delete when done:
37  Logging: No, Yes, Yes-ShowPasswords
38  */
39 
40  $ajax_settings = array(
41  'callback' => '_mailinglist_mailbox_test',
42  'wrapper' => 'mailinglist_test_results',
43  'event' => 'change',
44  'progress' => array(
45  'type' => 'throbber',
46  'message' => t('Please wait - testing connection settings...'),
47  ),
48  );
49  $form['connection']['settings']['domain'] = array(
50  '#type' => 'textfield',
51  '#title' => t('Domain'),
52  '#default_value' => $this->get_setting('domain'),
53  '#required' => TRUE,
54  '#description' => t('The domain of the server used to collect mail.'),
55  '#ajax' => $ajax_settings,
56  );
57  $form['connection']['settings']['port'] = array(
58  '#type' => 'textfield',
59  '#title' => t('Port'),
60  '#size' => 5,
61  '#maxlength' => 5,
62  '#default_value' => $this->get_setting('port'),
63  '#description' => t('The mailbox port number (usually 110 for POP3).'),
64  '#element_validate' => array('element_validate_integer_positive'),
65  '#required' => TRUE,
66  '#ajax' => $ajax_settings,
67  );
68  $form['connection']['settings']['name'] = array(
69  '#type' => 'textfield',
70  '#title' => t('Username'),
71  '#default_value' => $this->get_setting('name'),
72  '#required' => TRUE,
73  '#description' => t('This username is used while logging into this mailbox during mail retrieval.'),
74  '#ajax' => $ajax_settings,
75  );
76  $form['connection']['settings']['pass'] = array(
77  '#type' => 'textfield',
78  '#title' => t('Password'),
79  '#default_value' => _mailinglist_decode_password($this->get_setting('pass')),
80  '#description' => t('The mailbox password corresponding to the username above. Consider using a non-vital password, since this field is stored with minimal encryption in the database and displayed here.'),
81  '#ajax' => $ajax_settings,
82  );
83 
84  $form['connection']['settings']['results'] = array(
85  '#type' => 'container',
86  '#attributes' => array(
87  'id' => 'mailinglist_test_results',
88  ),
89  );
90 
91  $form['connection']['settings']['timeout'] = array(
92  '#type' => 'textfield',
93  '#title' => t('Timeout'),
94  '#size' => 5,
95  '#maxlength' => 5,
96  '#default_value' => $this->get_setting('timeout', 10),
97  '#description' => t('Timeout (in Sec) to connect to server'),
98  '#element_validate' => array('element_validate_number'),
99  '#required' => TRUE,
100  '#ajax' => $ajax_settings,
101  );
102 
103  $form['extra']['settings']['apop'] = array(
104  '#type' => 'checkbox',
105  '#title' => t('Detect APOP?'),
106  '#default_value' => $this->get_setting('apop', FALSE),
107  '#description' => t('Check to enable APOP protocal detection'),
108  );
109 
110  $form['extra']['settings']['delete_after_read'] = array(
111  '#type' => 'checkbox',
112  '#title' => t('Delete messages after they are processed?'),
113  '#default_value' => $this->get_setting('delete_after_read', TRUE),
114  '#description' => t('Uncheck this box to leave read messages in the mailbox. They will not be processed again unless they become marked as unread. You normallys should check this box.'),
115  );
116 
117  $form['extra']['settings']['ipv6'] = array(
118  '#type' => 'checkbox',
119  '#title' => t('IPv6'),
120  '#default_value' => $this->get_setting('ipv6', FALSE),
121  '#description' => t('Use IPv6'),
122  );
123 
124  }
125 
130  function edit_form_validate(&$form, &$form_state) {
131  parent::edit_form_validate($form, $form_state);
132  if ($form_state['values']['settings']['port'] < 1 || 65535 < $form_state['values']['settings']['port']) {
133  form_set_error('port', t('Port must be between 1 and 65535'));
134  }
135 
136  if ($form_state['values']['settings']['port'] != 110) {
137  drupal_set_message(t('Non-standard Pop3 Port: @port', array('@port' => (int)$form_state['values']['settings']['port'])), 'warning');
138  }
139 
140  // If POP3 mailbox is chosen, messages should be deleted after processing.
141  // Do not set an actual error because this is helpful for testing purposes.
142  if ( $form_state['values']['settings']['delete_after_read'] == 0) {
143  drupal_set_message(t('Unless you check off "Delete messages after they are processed" when using a POP3 mailbox, old emails will be re-imported each time the mailbox is processed.'), 'warning');
144  }
145  }
146 
151  function edit_form_submit(&$form, &$form_state) {
152  parent::edit_form_submit($form, $form_state);
153  }
155 
156 
170  public function get_message_list($max=0) {
171  $res = array();
172  return $res;
173  }
174 
178  public function get_message($id) {
179  $msg = "";
180  return new MailinglistMessage($msg);
181  }
182 
186  public function purge_message($id) {
187  }
188 
192  public function close() {
193  }
195 
200  public function __destruct() {
201  }
202 }
get_message_list($max=0)
Overrides/Implements Mailinglist:Retrieve::get_message_list Connect to mailbox and run message retrie...
Class defining the contents of an e-mail message.
edit_form_validate(&$form, &$form_state)
Implements ctools_export_ui::edit_form_validate().
edit_form_submit(&$form, &$form_state)
Implements ctools_export_ui::edit_form_submit().
get_setting($name, $def=NULL)
get_settings()
purge_message($id)
Overrides/Implements MailinglistRetrieve::purge_message();.
close()
Overrides/Implements MailinglistRetrieve::close().
Retrieve messages from a local mailbox file.
get_message($id)
Overrides/Implements MailinglistRetrieve::get_message().
_mailinglist_decode_password($code)
_mailinglist_decode_password
edit_form(&$form, &$form_state)
Implements ctools_export_ui::edit_form().
Retrieve messages from a Mailinglist Mailbox.