Mailinglist
 All Data Structures Files Functions Variables Pages
Public Member Functions | Data Fields
MailinglistList Class Reference

Retrieve messages from a Mailhandler Mailbox. More...

Inheritance diagram for MailinglistList:
Inheritance graph
[legend]
Collaboration diagram for MailinglistList:
Collaboration graph
[legend]

Public Member Functions

 getWebPage ($url, $post="")
 getWebPage More...
 
MailinglistListInterface

 checkMessage (MailinglistMessageInterface $msg)
 Called on each message read from a mailbox to see if we want to process it. More...
 
 genericListMatch (MailinglistMessageInterface $msg)
 generic_list_match() More...
 
 processMessage (MailinglistMessageInterface $message)
 message_process() More...
 
 schema (&$schema, $type)
 schema() More...
 
 getMemberInfo ($email)
 getMemberInfo() More...
 
 getMemberPage ($page)
 getMemberPage() More...
 
ctools_export_ui

 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form(), cross linked via mailinglist_export_ui.class.php. More...
 
 edit_form_validate (&$form, &$form_state)
 edit_form_validate() More...
 
- Public Member Functions inherited from MailinglistExportable
 get_setting ($name, $def=NULL)
 get_settings() More...
 
 created ()
 created() More...
 
 edited ($old)
 edited() More...
 
 changedType (MailinglistPolymorpicExportableInterface $old)
 changedType() More...
 
 delete ()
 delete() More...
 
 baseName ()
 baseName() More...
 
 edit_form (&$form, &$form_state)
 Implements ctools_export_ui::edit_form() called via mailinglist_export_ui Build an edit form for our object. More...
 
 edit_form_validate (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_validate(). More...
 
 edit_form_submit (&$form, &$form_state)
 Implements ctools_export_ui::edit_form_submit(). More...
 
 log ($str, $level=self::LOG_NOTICE, $parms=array())
 log() More...
 
 log_screen ($str, $parms=array(), $level=self::LOG_NOTICE)
 log_screen() More...
 
 log_db ($str, $parms=array(), $level=self::LOG_ERROR)
 log_db(). More...
 
 log_file ($str, $parms=array(), $level=self::LOG_INFO)
 log_file(). More...
 
MailinglistPolymorphicExportableInterface
MailinglistListInterface

Data Fields

 $operations
 
 $parameters
 
- Data Fields inherited from MailinglistExportable
 $object_type
 The type of object we are. More...
 
 $settings
 Generic Array to hold misc settings so all can use same schema. More...
 
 $export_type
 Needed by CTools. More...
 
const LOG_OFF = 0
 
const LOG_SCREEN = 1
 
const LOG_DB = 2
 
const LOG_DB_SCREEN = 3
 
const LOG_FILE = 4
 
const LOG_FILE_SCREEN = 5
 
const LOG_DEBUG = WATCHDOG_DEBUG
 
const LOG_INFO = WATCHDOG_INFO
 
const LOG_NOTICE = WATCHDOG_NOTICE
 
const LOG_WARNING = WATCHDOG_WARNING
 
const LOG_ERROR = WATCHDOG_ERROR
 
const LOG_CRITICAL = WATCHDOG_CRITICAL
 
const LOG_ALERT = WATCHDOG_ALERT
 
const LOG_EMERGENCY = WATCHDOG_EMERGENCY
 
 $logging_screen = self::LOG_DEBUG
 
 $logging_db = self::LOG_INFO
 
 $logging_file = self::LOG_DEBUG
 

Detailed Description

Retrieve messages from a Mailhandler Mailbox.

Definition at line 18 of file MailinglistList.class.php.

Member Function Documentation

checkMessage ( MailinglistMessageInterface  $msg)

Called on each message read from a mailbox to see if we want to process it.

Parameters
$msgan Mailinglist_Message object with the email received
Returns
TRUE if we have processed the message, FALSE if we don't know what to do.

Implements MailinglistListInterface.

Definition at line 36 of file MailinglistList.class.php.

36  {
37  return FALSE;
38  }
edit_form ( $form,
$form_state 
)

Implements ctools_export_ui::edit_form(), cross linked via mailinglist_export_ui.class.php.

This hook is responsible for building the edit/create form for the object.

Todo:
Should this be conditioned on operation being available for the list or will the fact that this might depend on settings give us problems.

Definition at line 169 of file MailinglistList.class.php.

References MailinglistExportable\get_setting(), and mailinglist_operation_load_all().

169  {
170  parent::edit_form($form, $form_state);
171 
172  /* Administrative Title for the list extry (builds default list_name); */
173  $form['info']['admin_title']['#description'] = t('Suggested, but not required, to be the email address of the maiinglist.');
174 
175  $form['basic']['settings']['to_address'] = array(
176  '#type' => 'textfield',
177  '#title' => t('To Address'),
178  '#default_value' => $this->get_setting('to_address'),
179  '#required' => TRUE,
180  '#description' => t('The Email address to send messages to the list'),
181  '#weight' => 10,
182  );
183 
184  $form['basic']['settings']['from_address'] = array(
185  '#type' => 'textfield',
186  '#title' => t('From Address'),
187  '#default_value' => $this->get_setting('from_address'),
188  '#required' => TRUE,
189  '#description' => t('The default From address the site should use to send Email to the list'),
190  '#weight' => 20,
191  );
192 
193  if (!isset($form['basic']['settings']['detect_method'])) {
194  // No Detectect method defined, so add default.
195  $form['basic']['settings']['detect_method'] = array(
196  '#type' => 'select',
197  '#title' => t('Message Detection'),
198  '#options' => array('rfc' => 'RFC-2369', 'generic' => 'Generic'),
199  '#default_value' => $this->get_setting('detect_method'),
200  '#description' => t('The method to use to detect messages from list'),
201  '#required' => TRUE,
202  '#weight' => 40,
203  );
204  }
205 
206  // Remember the method used to build the form.
207  $form['basic']['settings']['detect_method_menu'] = array(
208  '#type' => 'hidden',
209  '#value' => isset($form['basic']['settings']['detect_method']['#default_value']) ? $form['basic']['settings']['detect_method']['#default_value'] : $form['basic']['settings']['detect_method']['#value']
210  );
211 
212  if ($form['basic']['settings']['detect_method_menu']['#value'] == 'generic') {
213  $form['basic']['settings']['generic_detect_header'] = array(
214  '#type' => 'textfield',
215  '#title' => t('Header'),
216  '#default_value' => $this->get_setting('generic_detect_header'),
217  '#required' => TRUE,
218  '#description' => t('The Header to check to see if message comes from the list'),
219  '#weight' => 50,
220  );
221  $form['basic']['settings']['generic_detect_regex'] = array(
222  '#type' => 'textfield',
223  '#title' => t('Regex'),
224  '#default_value' => $this->get_setting('generic_detect_regex'),
225  '#required' => TRUE,
226  '#description' => t('Regex to test Header with'),
227  '#weight' => 60,
228  );
229  }
230  elseif ($form['basic']['settings']['detect_method']['#default_value'] == 'rfc') {
231  $form['basic']['settings']['list_id'] = array(
232  '#type' => 'textfield',
233  '#title' => t('List ID'),
234  '#default_value' => $this->get_setting('list_id'),
235  '#required' => TRUE,
236  '#description' => t('The value if the List-ID header to check for'),
237  '#weight' => 50,
238  );
239  }
240 
241  $form['operations'] = array(
242  '#tree' => FALSE,
243  '#weight' => 50,
244  'operations' => array(
245  '#type' => 'fieldset',
246  '#title' => 'Enabled Operations',
247  '#tree' => TRUE,
248  '#collapsible' => TRUE,
249  '#collapsed' => FALSE,
250  ),
251  );
253  foreach ($opers as $key => $oper) {
256  $form['operations']['operations'][$key] = array(
257  '#type' => 'checkbox',
258  '#title' => check_plain($oper->plugin['name']),
259  '#default_value' => isset($this->operations[$key]) && !empty($this->operations[$key]),
260  );
261  }
262  }
get_setting($name, $def=NULL)
get_settings()
mailinglist_operation_load_all()
mailinglist_operation_load_all()

Here is the call graph for this function:

edit_form_validate ( $form,
$form_state 
)

edit_form_validate()

Implements ctools_export_ui::edit_form_validate().

Definition at line 269 of file MailinglistList.class.php.

269  {
270  parent::edit_form_validate($form, $form_state);
271 
272  if (!valid_email_address($form_state['input']['settings']['to_address'])) {
273  form_set_error('to_address', 'To email address is not valid');
274  }
275  if (!valid_email_address($form_state['input']['settings']['from_address'])) {
276  form_set_error('from_address', 'From email address is not valid');
277  }
278  if ($form_state['input']['settings']['detect_method'] != $form_state['input']['settings']['detect_method_menu']) {
279  form_set_error('detect_method', 'Type Changed, Check Settings!');
280  }
281  }
genericListMatch ( MailinglistMessageInterface  $msg)

generic_list_match()

Performs the generic list matching processes

Todo:
Check for RFC Method
Todo:

Definition at line 45 of file MailinglistList.class.php.

References MailinglistExportable\get_setting().

45  {
47  if (!isset($msg->headers[$this->get_setting('generic_detect_header')])) return FALSE;
48  $header = $msg->headers[$this->get_setting('generic_detect_header')];
49  dpm($header, 'generic_list_match');
50  return TRUE;
51  }
get_setting($name, $def=NULL)
get_settings()

Here is the call graph for this function:

getMemberInfo (   $email)

getMemberInfo()

Implements MailinglistListInterface.

Definition at line 73 of file MailinglistList.class.php.

73  {
74  return FALSE;
75  }
getMemberPage (   $page)

getMemberPage()

Implements MailinglistListInterface.

Definition at line 80 of file MailinglistList.class.php.

80  {
81  return array('next' => FALSE);
82  }
getWebPage (   $url,
  $post = "" 
)

getWebPage

Fetch web page via cURL, and return resultant page.

Parameters
$urlThe URL to fetch.
$postPost data for request (if any)
Returns
The results web page and headers as an array.
Todo:
Look at converting to drupal_http_request() instead of cURL.
Todo:
Move cookie to private diretory (if available).
Todo:
find someplace better as backup ( user home dir?)

Definition at line 99 of file MailinglistList.class.php.

99  {
100  $path = variable_get('file_private_path');
101  // If we don/t have a private path, get a public one, with defualts
102  if (empty($path)) {
104  $path = file_directory_temp();
105  } else {
106  // convert private path to abs.
107  $path = DRUPAL_ROOT . '/' . $path;
108  }
109 
110  $cookie = $path . "/mailinglist_cookie.inc";
111  $handle = curl_init($url);
112  curl_setopt($handle, CURLOPT_CRLF, TRUE);
113  curl_setopt($handle, CURLOPT_HEADER, TRUE); // Return header to program
114  curl_setopt($handle, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
115  curl_setopt($handle, CURLOPT_FOLLOWLOCATION, TRUE);
116  curl_setopt($handle, CURLOPT_COOKIEJAR, $cookie);
117  curl_setopt($handle, CURLOPT_COOKIEFILE, $cookie);
118  curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
119  if (!empty($post)) {
120  curl_setopt($handle, CURLOPT_POST, TRUE);
121  curl_setopt($handle, CURLOPT_POSTFIELDS, $post);
122  }
123  $page = curl_exec($handle);
124  $page = str_replace("\r\n", "\n", $page);
125  $headerbreak = strpos($page, "\n\n");
126  $headers = substr($page, 0, $headerbreak);
127  $body = substr($page, $headerbreak+2);
128 
129  // Fold continuation lines
130  $headers = str_replace(array("\n ", "\n\t"), " ", $headers);
131  $headers = explode("\n", $headers);
132  $head = array();
133  foreach ($headers as $header) {
134  $colon = strpos($header, ':');
135  if ($colon === FALSE) {
136  $head[] = $header;
137  }
138  else {
139  $sub = substr($header, 0, $colon);
140  $value = substr($header, $colon+1);
141  if (isset($head[$sub])) {
142  if (!is_array($head[$sub])) {
143  $head[$sub] = array($head[$sub]);
144  }
145  $head[$sub][] = trim($value);
146  }
147  else {
148  $head[$sub] = trim($value);
149  }
150  }
151  }
152  //@todo Process headers so body is in UTF-8
153  $page = array('header' => $head, 'body' => $body);
154  return $page;
155  }
processMessage ( MailinglistMessageInterface  $message)

message_process()

Processes the receipt of a message from the list. calls hook_mailinglist_message();

Implements MailinglistListInterface.

Definition at line 59 of file MailinglistList.class.php.

Referenced by MailinglistGenericList\checkMessage().

59  {
60  drupal_alter('mailinglist_message', $message, $this);
61  module_invoke_all('mailinglist_message', $message, $this);
62  }

Here is the caller graph for this function:

schema ( $schema,
  $type 
)

schema()

Implements MailinglistListInterface.

Definition at line 67 of file MailinglistList.class.php.

67  {
68  }

Field Documentation

$operations

Definition at line 19 of file MailinglistList.class.php.

$parameters

Definition at line 20 of file MailinglistList.class.php.


The documentation for this class was generated from the following file: