Mailinglist
 All Data Structures Files Functions Variables Pages
Functions
mailinglist.module File Reference

Interfaces with a mailinglist. More...

Go to the source code of this file.

Functions

 mailinglist_permission ()
 Implements hook_permission(). More...
 
 mailinglist_help ($path, $arg)
 Implements hook_help(). More...
 
 mailinglist_menu ()
 Implements hook_menu(). More...
 
 mailinglist_cron_queue_info ()
 Implements hook_cron_queue_info(). More...
 
 mailinglist_cron ()
 Implements hook_cron(). More...
 
 _mailinglist_file_path ()
 _mailinglist_file_path() gets the file path that we will use to place files in More...
 
 _mailinglist_base_filename ($path)
 _mailinglist_base_filename(). More...
 
 _mailinglist_mailbox_scan ()
 Process the configured mailing boxes. More...
 
 _mailinglist_maildir_scan ()
 _mailinglist_mailbox_scan() More...
 
 _mailinglist_mailbox_process ($list, $file, $offset)
 _mailinglist_mailbox_process(). More...
 
 mailinglist_message_callback ($msg)
 Message Queue Callback function. More...
 
 _mailinglist_encode_password ($pass)
 _mailinglist_encode_password More...
 
 _mailinglist_decode_password ($code)
 _mailinglist_decode_password More...
 
 mailinglist_array_merge_recursive_distinct (array &$array1, array &$array2)
 array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does. More...
 
 _mailinglist_datetime_schema ($desc)
 Return the schema for a 'datetime' field. More...
 
 _mailinglist_datetime_format ($ts)
 Convert a 'timestamp to a 'datetime'. More...
 
 _mailinglist_datetime_ts ($time)
 Convert a 'datetime' field into a timestamp. More...
 
 mailinglist_email_name ($email, $name, $count=0)
 Lookup Email <-> Name combination. More...
 
 mailinglist_init ()
 

CTOOLS Hooks


More...
 
 mailinglist_ctools_plugin_directory ($owner, $plugin_type)
 Implements hook_ctools_plugin_directory(). More...
 
 mailinglist_ctools_plugin_type ()
 Implements hook_ctools_plugin_type(). More...
 
 mailinglist_plugin_load_class ($module, $type, $plugin, $class_name='handler', $args=NULL)
 Wrapper to load any class type. More...
 
 mailinglist_get_plugins ($module, $type)
 Wrapper to load plugins. More...
 
 _mailinglist_build_options ($source, $key_name= 'name')
 Builds a Select control array from a menu form an array from a ctools_get_plugin. More...
 
 _mailinglist_object_factory ($schema, $data)
 Builds an type variable object from a database table entry. More...
 
 mailinglist_mailbox_load ($mbox)
 

CTools Export UI


More...
 
 mailinglist_mailbox_load_all ($show_disabled=TRUE)
 Load all mailinglists. More...
 
 _mailinglist_mailbox_test ($form, &$form_state)
 _mailinglist_mailbox_test More...
 
 _mailinglist_mailbox_test_output ($mailbox)
 _mailinglist_mailbox_test_output() More...
 
 mailinglist_list_load ($list)
 Load a list definition. More...
 
 mailinglist_list_load_all ($show_disabled=TRUE)
 Load all mailinglists. More...
 
 mailinglist_operation_load ($oper)
 @ name CTools Operation/******** operation More...
 
 mailinglist_operation_load_all ()
 mailinglist_operation_load_all() More...
 

Detailed Description

Interfaces with a mailinglist.

Todo:
Themeing Functions Message. MessageSummary. MessageSummaryList.
Todo:
Content Type Archived Message?
Todo:
Possible define a FieldType for Messages? as a way to link to Themeing.

Definition in file mailinglist.module.

Function Documentation

_mailinglist_base_filename (   $path)

_mailinglist_base_filename().

Converts an absolute file path to a relative path to our directory, primarily for logging.

Definition at line 239 of file mailinglist.module.

References _mailinglist_file_path().

Referenced by _mailinglist_mailbox_process(), _mailinglist_maildir_scan(), and MailinglistArchiveOperation\form().

239  {
240  $base = _mailinglist_file_path() . '/';
241  return str_replace($base, '', $path);
242 }
_mailinglist_file_path()
_mailinglist_file_path() gets the file path that we will use to place files in

Here is the call graph for this function:

Here is the caller graph for this function:

_mailinglist_build_options (   $source,
  $key_name = 'name' 
)

Builds a Select control array from a menu form an array from a ctools_get_plugin.

Parameters
$sourceArray - The array defining the options to select from. Key of array will be the value returned for the selected item, text taken from field selected by $key_name. A plugin list obtained from ctools_get_plugins is compatable with this function.
$key_nameString - The key used to access the field that give the Text to use for the option.
Returns
Array - a render array for the select control.

Definition at line 701 of file mailinglist.module.

Referenced by MailinglistListUI\edit_form(), and MailinglistRetrieveUI\edit_form().

701  {
702  $options = array();
703  foreach ($source as $key => $value) {
704  $options[$key] = is_object($value) ? $value->$key_name : $value[$key_name];
705  }
706  return $options;
707 }

Here is the caller graph for this function:

_mailinglist_datetime_format (   $ts)

Convert a 'timestamp to a 'datetime'.

Definition at line 561 of file mailinglist.module.

Referenced by mailinglist_archive_message_add(), mailinglist_members_scan(), mailinglist_members_seen(), mailinglist_members_subscribe(), mailinglist_members_unseen(), mailinglist_members_unsubscribe(), mailinglist_members_update(), and mailinglist_members_update_ind().

561  {
562  $value = gmdate('Y-m-d H:i:s', $ts);
563 // dpm($value . " ... " . date_iso8601($ts)); date_iso uses local timezone
564  return $value;
565 }

Here is the caller graph for this function:

_mailinglist_datetime_schema (   $desc)

Return the schema for a 'datetime' field.

Note that because drupal does not directly support a DateTime field standardly, we use these 3 functions to abstract out our decision.

Definition at line 548 of file mailinglist.module.

Referenced by _mailinglist_archives_list_schema(), _mailinglist_members_list_schema(), and mailinglist_archive_schema().

548  {
549  if (!is_array($desc)) {
550  $desc = array('description' => 'desc');
551  }
552 
553  $desc['type'] = 'char';
554  $desc['length'] = 19;
555  return $desc;
556 }

Here is the caller graph for this function:

_mailinglist_datetime_ts (   $time)

Convert a 'datetime' field into a timestamp.

Definition at line 570 of file mailinglist.module.

Referenced by MailinglistMembersOperation\form(), MailinglistArchiveOperation\form(), and mailinglist_archive_summary_list().

570  {
571  return strtotime($time . " UTC");
572 }

Here is the caller graph for this function:

_mailinglist_decode_password (   $code)

_mailinglist_decode_password

Simple decryption routine to make passwords harder to read in debug messages

Definition at line 481 of file mailinglist.module.

Referenced by MailinglistPop3Retrieve\connect(), MailinglistPhpImapRetrieve\edit_form(), MailinglistPop3Retrieve\edit_form(), Mailman21List\edit_form(), MailinglistMailboxRetrieve\edit_form(), and Mailman21List\getWebPage().

481  {
482  if (empty($code)) return $code;
483  $decode = base64_decode($code);
484  $seed = ord($decode[0]);
485  $pass = '';
486  for ($i=1; $i < strlen($decode); $i++) {
487  $ch = ord($decode[$i]);
488  $seed = $ch - $seed;
489  if ($seed < 0) $seed += 256;
490  $pass .= chr($seed);
491  $seed = $ch;
492  }
493  return $pass;
494 }

Here is the caller graph for this function:

_mailinglist_encode_password (   $pass)

_mailinglist_encode_password

Simple encryption routine to make passwords harder to read in debug messages

Definition at line 465 of file mailinglist.module.

Referenced by Mailman21List\edit_form_submit().

465  {
466  $seed = mt_rand(0, 255);
467  $str = chr($seed);
468  for ($i=0; $i < strlen($pass); $i++) {
469  $seed = ($seed + ord($pass[$i])) % 256;
470  $str .= chr($seed);
471  }
472  $encode = base64_encode($str);
473  return $encode;
474 }

Here is the caller graph for this function:

_mailinglist_file_path ( )

_mailinglist_file_path() gets the file path that we will use to place files in

Definition at line 222 of file mailinglist.module.

Referenced by _mailinglist_base_filename(), and _mailinglist_maildir_scan().

222  {
223  // Get path to store files for processing
224  $path = variable_get('file_private_path');
225  // If we don/t have a private path, get a public one, with defualts
226  if (empty($path)) {
227  $path = variable_get('file_public_path', conf_path() . '/files');
228  }
229  // Update to make absolute, and our sub directory
230  $path = DRUPAL_ROOT . '/' . $path . '/mailinglist';
231  $flag = file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
232  return $path;
233 }

Here is the caller graph for this function:

_mailinglist_mailbox_process (   $list,
  $file,
  $offset 
)

_mailinglist_mailbox_process().

Process the specified number of messages from a mailbox.

Parameters
$listThe list whose archives to add the messages to.
$filestring: The name of the file to process.
$offsetint: The number of messages to skip at the begining of the file.
Returns
the new value of $offset to continue processing, or FALSE if we finished the file.
Todo:
Unquote >From lines.
Todo:
we can add code to compare "From " line to message here and fix stuff.

Definition at line 352 of file mailinglist.module.

References _mailinglist_base_filename().

Referenced by _mailinglist_maildir_scan().

352  {
353  $time = time();
354  $queue = DrupalQueue::get('mailinglist_message');
355  $handle = fopen($file, 'r');
356  if (!$handle) {
357  // File not found
358  watchdog('Mailinglist', 'File not found @file',
359  array('@file' => _mailinglist_base_filename($file)),
360  WATCHDOG_NOTICE);
361  dpm($file, 'File Not found');
362  fclose($handle);
363  return FALSE;
364  }
365  fseek($handle, $offset);
366 
367  $fromline = fgets($handle);
368  $cnt = 0;
369  while( time() < $time+20 && $cnt < 1000) {
370  $cnt = $cnt + 1;
371  $msg = "";
372  while (1) {
373  // Remember where we were if we are now done.
374  $offset = ftell($handle);
375  $line = fgets($handle);
376  if ($line === FALSE || substr($line, 0, 5) == 'From ') {
377  $fromline = $line;
378  break; // message done
379  }
381  $msg .= $line;
382  }
383  if ($msg == "" && $fromline == FALSE) {
384  watchdog('Mailinglist', 'End of File @file',
385  array('@file' => _mailinglist_base_filename($file)),
386  WATCHDOG_NOTICE);
387  dpm('End of File: ' . $file);
388  unlink($file);
389  return FALSE;
390  }
391  $msg = new MailinglistMessage($msg);
392  $headers = $msg->headers();
393  if(!isset($headers['From']) || !isset($headers['Date']) || !isset($headers['Subject'])){
394 
395  watchdog('Mailinglist', 'Bad message @file @offset @from MSG: @msg' ,
396  array('@file' => _mailinglist_base_filename($file),
397  '@offset' => $offset,
398  '@from' => $fromline,
399  '@msg' => check_plain(print_r($msg, TRUE)),
400  ),
401  WATCHDOG_ERROR);
402  continue;
403  }
404  $from = $msg->header('From');
405  if (is_array($from)) {
406  $from = $from[0];
407  }
408  if (strpos($from, '@') == FALSE) {
409  // obfuscated from line from archives
410  $from = str_replace(' at ', '@', $from);
411  $msg->setHeader('From', $from);
412  }
414 
415  if ($list) {
416  // List Specific, give to that list, assume it is to be archived
417  $msg->setHeader('XX-List', $list->admin_name);
418  $msg->setHeader('XX-Archive', '1');
419  $msg->setHeader('XX-Status', 0);
420  }
421  $queue->createItem($msg);
422  }
423  fclose($handle);
424  return $offset;
425 }
Class defining the contents of an e-mail message.
_mailinglist_base_filename($path)
_mailinglist_base_filename().

Here is the call graph for this function:

Here is the caller graph for this function:

_mailinglist_mailbox_scan ( )

Process the configured mailing boxes.

Definition at line 247 of file mailinglist.module.

References _mailinglist_maildir_scan(), and mailinglist_mailbox_load_all().

Referenced by MailinglistArchiveOperation\form(), and mailinglist_cron().

247  {
249 
250  $boxes = mailinglist_mailbox_load_all(false);
251  foreach ($boxes as $index => $box) {
252 // dpm($box, $index);
253  }
254 }
mailinglist_mailbox_load_all($show_disabled=TRUE)
Load all mailinglists.
_mailinglist_maildir_scan()
_mailinglist_mailbox_scan()

Here is the call graph for this function:

Here is the caller graph for this function:

_mailinglist_mailbox_test (   $form,
$form_state 
)

_mailinglist_mailbox_test

Definition at line 797 of file mailinglist.module.

References _mailinglist_mailbox_test_output().

797  {
798  $mailbox = (object)$form_state['values'];
799  return _mailinglist_mailbox_test_output($mailbox);
800 }
_mailinglist_mailbox_test_output($mailbox)
_mailinglist_mailbox_test_output()

Here is the call graph for this function:

_mailinglist_mailbox_test_output (   $mailbox)

_mailinglist_mailbox_test_output()

Definition at line 805 of file mailinglist.module.

References mailinglist_plugin_load_class().

Referenced by _mailinglist_mailbox_test(), MailinglistListUI\test_page(), and MailinglistRetrieveUI\test_page().

805  {
806  $output = '<div id="mailinglist_test_results" class="form-wrapper">';
807  // Call the test function.
808  if (isset($mailbox->settings['object_type'])) {
809  $class = mailinglist_plugin_load_class('mailinglist', 'retrieve', $mailbox->settings['object_type'], 'handler');
810  if ($class) {
811  $ret = $class->test($mailbox);
812  foreach ($ret as $message) {
813  $output .= '<div class="messages ' . $message['severity'] . '">' . $message['message'] . '</div>';
814  }
815  }
816  }
817  $output .= "</div>";
818  return $output;
819 }
mailinglist_plugin_load_class($module, $type, $plugin, $class_name='handler', $args=NULL)
Wrapper to load any class type.

Here is the call graph for this function:

Here is the caller graph for this function:

_mailinglist_maildir_scan ( )

_mailinglist_mailbox_scan()

Scan our data directory for mailbox files, proecess the messages in them and them delete them. Mailboxes in sub directories are given specifically to the list by the same name, mailboxes in the base directory will be put through the list detection method.

Definition at line 265 of file mailinglist.module.

References _mailinglist_base_filename(), _mailinglist_file_path(), _mailinglist_mailbox_process(), mailinglist_list_load(), and mailinglist_list_load_all().

Referenced by _mailinglist_mailbox_scan().

265  {
266  $queue = DrupalQueue::get('mailinglist_message');
267  $path = _mailinglist_file_path();
268  // Get the mailbox we are currently processing
269  $file = variable_get('mailinglist_mailbox_current', FALSE);
270 
271  if ($file == FALSE) {
272  if($queue->numberOfItems() > 100) {
273  return; // If behind, don't start up a new file
274  }
275  $files = file_scan_directory($path, '/.*/');
276  ksort($files);
277  if (empty($files)) {
278  dpm('Nothing', 'mailinglist_maildir_scan');
279  return; // Nothing to do
280  }
281  $file = array_keys($files);
282  $file = $file[0];
283 
284  $handle = fopen($file, 'r');
285  fseek($handle, 0, SEEK_END);
286  $end = ftell($handle);
287 
288  $local = substr($file, strlen($path)+1);
289  $pos = strpos($local, '/');
290  if ($pos > 0) {
291  $listname = substr($local, 0, $pos);
292  }
293  else {
294  $listname = FALSE;
295  }
296  watchdog('Mailinglist', 'Starting @file (@msg) @list',
297  array('@msg' => $end,
298  '@file' => _mailinglist_base_filename($file),
299  '@list' => $listname),
300  WATCHDOG_NOTICE);
301  dpm($listname, 'list');
302  $offset = 0;
303  variable_set('mailinglist_mailbox_current', $file);
304  variable_set('mailinglist_mailbox_current_offset', $offset);
305  variable_set('mailinglist_mailbox_current_list', $listname);
306  variable_set('mailinglist_mailbox_current_max', $end);
307  }
308  else {
309  if($queue->numberOfItems() > 1000) {
310  return; // If far behind, don't queue up more from file
311  }
312  // Continuing with a file, get rest of details.
313  $offset = variable_get('mailinglist_mailbox_current_offset');
314  $listname = variable_get('mailinglist_mailbox_current_list');
315  $msgcnt = variable_get('mailinglist_mailbox_current_max');
316  }
317 
318  if ($listname) {
319  $list = mailinglist_list_load($listname);
320  }
321  else {
322  $list = FALSE;
323  }
324  if ($list == FALSE) {
325  $lists = mailinglist_list_load_all(FALSE);
326  }
327 
328  $offset = _mailinglist_mailbox_process($list, $file, $offset);
329 
330  if ($offset === FALSE) {
331  variable_set('mailinglist_mailbox_current', FALSE);
332  variable_set('mailinglist_mailbox_current_offset', 0);
333  }
334  else {
335  dpm($offset);
336  variable_set('mailinglist_mailbox_current_offset', $offset);
337  }
338 }
_mailinglist_file_path()
_mailinglist_file_path() gets the file path that we will use to place files in
mailinglist_list_load($list)
Load a list definition.
mailinglist_list_load_all($show_disabled=TRUE)
Load all mailinglists.
_mailinglist_base_filename($path)
_mailinglist_base_filename().
_mailinglist_mailbox_process($list, $file, $offset)
_mailinglist_mailbox_process().

Here is the call graph for this function:

Here is the caller graph for this function:

_mailinglist_object_factory (   $schema,
  $data 
)

Builds an type variable object from a database table entry.

Parameters
$schemaArray - The schema for the table being read
$dataObject(StdClass) - The data read from the table for this item
Returns
Object - loaded object of type specified by the data record

Note, the schema must have an field called 'type' which will be filled in with the type of object to be made. The plugin in its description needs to include the line 'object factory' => '_mailinglist_object_factory',

Called from the following code snippet in ctools_export_load_object if (isset($schema['export']['object factory']) && function_exists($schema['export']['object factory'])) { $object = $schema['export']['object factory']($schema, $data); } else { $object = _ctools_export_unpack_object($schema, $data, $export['object']); }

Where we will continue to the call to _ctools_export_unpack_object after determining the class that should be returned.

Definition at line 736 of file mailinglist.module.

Referenced by MailinglistExportUI\edit_form().

736  {
737  ctools_include('plugins');
738  $type = FALSE;
739  if (isset($data->object_type)) {
740  $object_type = $data->object_type;
741  $owner = $schema['export']['api']['owner'];
742  $api = $schema['export']['api']['api'];
743  $class_name = ctools_plugin_load_class($owner, $api, $object_type, 'handler');
744  if (!class_exists($class_name)) {
745  $class_name = FALSE;
746  $class_name = $schema['fields']['object_type']['default'];
747  }
748  }
749  $object = _ctools_export_unpack_object($schema, $data, $class_name);
750  return $object;
751 }

Here is the caller graph for this function:

mailinglist_array_merge_recursive_distinct ( array &  $array1,
array &  $array2 
)

array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does.

I.e., with array_merge_recursive, this happens (documented behavior):

array_merge_recursive(array('key' => 'org value'), array('key' => 'new value')); => array('key' => array('org value', 'new value'));

mailinglist_array_merge_recursive_distinct does not change the datatypes of the values in the arrays. Matching keys' values in the second array overwrite those in the first array, as is the case with array_merge, i.e.:

mailinglist_array_merge_recursive_distinct(array('key' => 'org value'), array('key' => 'new value')); => array('key' => array('new value'));

Parameters are passed by reference, though only for performance reasons. They're not altered by this function.

Parameters
$array1[array]
$array2[array]
Returns
array

Based on design:

Author
Daniel <daniel (at) danielsmedegaardbuus (dot) dk>
Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com>

Definition at line 523 of file mailinglist.module.

Referenced by MailinglistExportUI\edit_form().

523  {
524  $merged = $array1;
525 
526  foreach ( $array2 as $key => &$value ) {
527  if ( is_array ( $value ) && isset ( $merged [$key] ) && is_array ( $merged [$key] ) ) {
528  $merged [$key] = mailinglist_array_merge_recursive_distinct($merged [$key], $value);
529  }
530  else {
531  $merged [$key] = $value;
532  }
533  }
534 
535  return $merged;
536 }
mailinglist_array_merge_recursive_distinct(array &$array1, array &$array2)
array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays ...

Here is the caller graph for this function:

mailinglist_cron ( )

Implements hook_cron().

Definition at line 156 of file mailinglist.module.

References _mailinglist_mailbox_scan(), and mailinglist_mailbox_load_all().

156  {
157 
158  $boxes = mailinglist_mailbox_load_all(false);
160  foreach ($boxes as $index => $box) {
161 // if (isset($list1->operations['members']) && $list1->operations['members']) {
162 // mailinglist_members_scan($list1);
163 // }
164  }
165 }
_mailinglist_mailbox_scan()
Process the configured mailing boxes.
mailinglist_mailbox_load_all($show_disabled=TRUE)
Load all mailinglists.

Here is the call graph for this function:

mailinglist_cron_queue_info ( )

Implements hook_cron_queue_info().

Definition at line 142 of file mailinglist.module.

142  {
143  $queue = array(
144  'mailinglist_message' => array(
145  'worker callback' => 'mailinglist_message_callback',
146  'time' => '20',
147  ),
148  );
149  return $queue;
150 }
mailinglist_ctools_plugin_directory (   $owner,
  $plugin_type 
)

Implements hook_ctools_plugin_directory().

divides the plugins by owner module

Todo:
Condition to only return directories that we might actually be using.

ctools/export_ui mailinglist/list mailinglist/operation mailinglist/retrieve

Definition at line 620 of file mailinglist.module.

620  {
621  return 'plugins/' . $owner . '/' . $plugin_type;
622 }
mailinglist_ctools_plugin_type ( )

Implements hook_ctools_plugin_type().

Definition at line 627 of file mailinglist.module.

627  {
628  return array(
629  'list' => array(), // List Personality Modules
630  'operation' => array(), // Extension Modules
631  'retrieve' => array(), // Data Retrieval Modules
632  );
633 }
mailinglist_email_name (   $email,
  $name,
  $count = 0 
)

Lookup Email <-> Name combination.

Definition at line 576 of file mailinglist.module.

Referenced by _mailinglist_members_lookup(), mailinglist_archive_message_add(), and mailinglist_members_process_memberpage().

576  {
577  $email = strtolower($email);
578  $sql = 'SELECT name_key from {mailinglist_names}
579  WHERE email = :email AND name = :name';
580  $result = db_query($sql, array(':email' => $email, ':name' => $name));
581  $result = $result -> fetchAssoc();
582  if (!$result) {
583  // New Combo
584  $fields = array('email' => $email, 'name' => $name);
585  dpm($fields, 'New Combo');
586  return (int) db_insert('mailinglist_names') -> fields($fields) -> execute();
587  }
588  else {
589  // Existing Combo
590  return (int) $result['name_key'];
591  }
592 }

Here is the caller graph for this function:

mailinglist_get_plugins (   $module,
  $type 
)

Wrapper to load plugins.

Parameters
$moduleString - name of module owning the plugin type.
$typeString - type of plugins to retrieve.
Returns
Array - an array of plugin descriptors, sorted by weight.

Definition at line 669 of file mailinglist.module.

Referenced by MailinglistListUI\edit_form(), MailinglistRetrieveUI\edit_form(), and mailinglist_operation_load_all().

669  {
670  ctools_include('plugins');
671  $plugins = ctools_get_plugins($module, $type);
672  $result = array();
673  $weights = array();
674  foreach ($plugins as $key => $info) {
675  if (!empty($info['hidden'])) {
676  continue;
677  }
678  if (!isset($info['weight'])) {
679  $info['weight'] = 10;
680  }
681  $weights[] = $info['weight'];
682  $result[$key] = $info;
683  }
684  array_multisort($weights, $result);
685  return $result;
686 }

Here is the caller graph for this function:

mailinglist_help (   $path,
  $arg 
)

Implements hook_help().

Help text added to pages specified (in "Help" region)

Todo:
expand to meet help text standards: http://drupal.org/node/632280

Definition at line 68 of file mailinglist.module.

68  {
70  switch ($path) {
71  case 'admin/help#mailinglist':
72  $help = file_get_contents( dirname(__FILE__) . "/INSTALL.txt");
73  return _filter_autop($help);
74  break;
75  case 'admin/config/system/mailinglist/list/add':
76  return t('Add help here');
77  }
78 }
mailinglist_init ( )


CTOOLS Hooks


Implements hook_init().

Definition at line 603 of file mailinglist.module.

603  {
604  if (strstr(request_uri(), 'system/ajax') && $_POST['form_id'] == 'ctools_export_ui_edit_item_form') {
605  ctools_include('export');
606  }
607 }
mailinglist_list_load (   $list)

Load a list definition.

Implements hook_load().

Parameters
$listThis mailbox's name value.
Returns
A list object.

Definition at line 832 of file mailinglist.module.

Referenced by _mailinglist_maildir_scan(), mailinglist_members_callback(), and mailinglist_message_callback().

832  {
833  ctools_include('export');
834  $obj = ctools_export_crud_load('mailinglist_list', $list);
835  return $obj;
836 }

Here is the caller graph for this function:

mailinglist_list_load_all (   $show_disabled = TRUE)

Load all mailinglists.

Implements hook_load_all().

Parameters
$show_disabledIf TRUE, will return disabled mailinglists.
Returns
An array of list definition objects.

Definition at line 848 of file mailinglist.module.

Referenced by _mailinglist_maildir_scan(), _mailinglist_pagecallback(), mailinglist_archive_cron(), mailinglist_archive_schema(), mailinglist_members_cron(), mailinglist_members_modules_enabled(), mailinglist_members_permission(), mailinglist_members_schema(), mailinglist_message_callback(), mailinglist_permission(), and MailinglistRetrieveUI\process_page().

848  {
849  ctools_include('export');
850  $lists = ctools_export_crud_load_all('mailinglist_list');
851  foreach ($lists as $list => $listdef) {
852  if (isset($listdef->disabled) && $listdef->disabled && !$show_disabled) {
853  unset($lists[$list]);
854  }
855  }
856  return $lists;
857 }

Here is the caller graph for this function:

mailinglist_mailbox_load (   $mbox)


CTools Export UI


Load a mailbox definition.

Parameters
$mboxThis mailbox's name value.
Returns
A list object.

Definition at line 769 of file mailinglist.module.

769  {
770  ctools_include('export');
771  $retrieve = ctools_export_crud_load('mailinglist_retrieve', $mbox);
772  return $retrieve;
773 }
mailinglist_mailbox_load_all (   $show_disabled = TRUE)

Load all mailinglists.

Parameters
$show_disabledIf TRUE, will return disabled mailinglists.
Returns
An array of list definition objects.

Definition at line 783 of file mailinglist.module.

Referenced by _mailinglist_mailbox_scan(), and mailinglist_cron().

783  {
784  ctools_include('export');
785  $mboxes = ctools_export_crud_load_all('mailinglist_retrieve');
786  foreach ($mboxes as $email => $mbox) {
787  if (isset($listdef->disabled) && $mbox->disabled && !$show_disabled) {
788  unset($mboxes[$email]);
789  }
790  }
791  return $mboxes;
792 }

Here is the caller graph for this function:

mailinglist_menu ( )

Implements hook_menu().

Define urls we will respond to

Definition at line 85 of file mailinglist.module.

85  {
86  $base = variable_get('mailinglist_base', 'mailinglist');
87  $items = array(
88  // User Pages
89  $base => array(
90  'title' => 'Mailing Lists',
91  'description' => 'Entry page for Mailinglist Module',
92  'type' => MENU_CALLBACK,
93  'page callback' => '_mailinglist_pagecallback',
94  'page arguments' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
95  'access arguments' => array('access content'),
96  'file' => 'mailinglist.pagecallback.inc',
97  ),
98  $base . '/%mailinglist_list' => array(
99  'title' => 'MailingList Page',
100  'description' => 'Entry page for Mailinglist Module',
101  'type' => MENU_CALLBACK,
102  'page callback' => '_mailinglist_list_pagecallback',
103  'page arguments' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
104  'access arguments' => array('access content'),
105  'file' => 'mailinglist.pagecallback.inc',
106  ),
107  $base . '/%mailinglist_list/%mailinglist_operation' => array(
108  'title' => 'Mailing Lists Operation',
109  'description' => 'Manage Mailing Operation Page',
110  'type' => MENU_NORMAL_ITEM,
111  'page callback' => 'drupal_get_form',
112  'page arguments' => array('mailinglist_operation_form', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
113  'access arguments' => array('access content'),
114  'file' => 'mailinglist.pagecallback.inc',
115  ),
116  // Admin Pages
117  'admin/config/system/mailinglist' => array(
118  'title' => 'Mailing Lists Configuration',
119  'description' => 'Manage Mailing List Interface',
120  'type' => MENU_NORMAL_ITEM,
121  'page callback' => 'drupal_get_form',
122  'page arguments' => array('_mailinglist_config_form'),
123  'access arguments' => array('administer mailinglist'),
124  'file' => 'mailinglist.admin.inc',
125  ),
126  'admin/config/system/mailinglist/config' => array(
127  'title' => 'Config',
128  'type' => MENU_DEFAULT_LOCAL_TASK,
129  'page callback' => 'drupal_get_form',
130  'page arguments' => array('_mailinglist_config_form'),
131  'access arguments' => array('administer mailinglist'),
132  'file' => 'mailinglist.admin.inc',
133  ),
134  );
135  return $items;
136 }
mailinglist_message_callback (   $msg)

Message Queue Callback function.

Called by Queue processing

Definition at line 436 of file mailinglist.module.

References mailinglist_list_load(), and mailinglist_list_load_all().

436  {
437  $listname = $msg->header('XX-List');
438 
439  if ($listname) {
440  $list = mailinglist_list_load($listname);
441  }
442  else {
443  $list = FALSE;
444  }
445  if($list) {
446  $list->processMessage($msg);
447  } else {
448  // No valid list specified, check all the lists.
449  $lists = mailinglist_list_load_all(FALSE);
450  foreach ($lists as $list1) {
451  $flag = $list1->checkMessage($msg);
452  }
453  }
454 }
mailinglist_list_load($list)
Load a list definition.
mailinglist_list_load_all($show_disabled=TRUE)
Load all mailinglists.

Here is the call graph for this function:

mailinglist_operation_load (   $oper)

@ name CTools Operation/******** operation

mailinglist_operation_load()

Implements hook_load().

Definition at line 869 of file mailinglist.module.

References $plugin.

Referenced by _mailinglist_list_pagecallback(), and mailinglist_operation_load_all().

869  {
870  ctools_include('plugins');
871  require_once(drupal_get_path('module', 'mailinglist') . '/plugins/mailinglist/operation/MailinglistOperation.class.php');
872  $plugin = ctools_get_plugins('mailinglist', 'operation', $oper);
873  $plugin['key'] = $oper;
874  $class = ctools_plugin_get_class($plugin, 'handler');
875  if (class_exists($class)) {
876  $obj = new $class;
877  $obj->plugin = $plugin;
878  }
879  else {
880  $obj = NULL;
881  }
882  return $obj;
883 }
$plugin
Definition: archive.inc:7

Here is the caller graph for this function:

mailinglist_operation_load_all ( )

mailinglist_operation_load_all()

Implements hook_load_all*().

Definition at line 890 of file mailinglist.module.

References $plugin, mailinglist_get_plugins(), and mailinglist_operation_load().

Referenced by MailinglistList\edit_form(), and mailinglist_permission().

890  {
891  $opers = mailinglist_get_plugins('mailinglist', 'operation');
892  $ret = array();
893  foreach ($opers as $key => $plugin) {
894  $ret[$key] = mailinglist_operation_load($key);
895  }
896  return $ret;
897 }
$plugin
Definition: archive.inc:7
mailinglist_operation_load($oper)
@ name CTools Operation/******** operation
mailinglist_get_plugins($module, $type)
Wrapper to load plugins.

Here is the call graph for this function:

Here is the caller graph for this function:

mailinglist_permission ( )

Implements hook_permission().

Definition at line 41 of file mailinglist.module.

References mailinglist_list_load_all(), and mailinglist_operation_load_all().

41  {
42  $lists = mailinglist_list_load_all(false);
44 
45  $permissions = array(
46  'administer mailinglist' => array(
47  'title' => t('Administer Mailinglist mailboxes'),
48  ),
49  );
50  foreach ($lists as $index => $list) {
51  $permissions['mailinglist ' . $index] = array(
52  'title' => t('Access ' . $list->admin_title),
53  );
54  foreach ($opers as $oindex => $oper) {
55  $permissions['mailinglist ' . $index . ' ' . $oindex] = array(
56  'title' => t($list->admin_title . ' ' . $oper->plugin['name']),
57  );
58  }
59  }
60  return $permissions;
61 }
mailinglist_operation_load_all()
mailinglist_operation_load_all()
mailinglist_list_load_all($show_disabled=TRUE)
Load all mailinglists.

Here is the call graph for this function:

mailinglist_plugin_load_class (   $module,
  $type,
  $plugin,
  $class_name = 'handler',
  $args = NULL 
)

Wrapper to load any class type.

Parameters
$moduleString - The module that owns the plugin type.
$typeString - The type of plugin.
$pluginString - The id of the specific plugin to load.
$class_nameString - The identifier of the class. For example, 'handler'.
$argsParameter passed to the constructor of the plugin
Returns
An instance of the plugin, created with the supplied arguments.

Definition at line 652 of file mailinglist.module.

References $plugin.

Referenced by _mailinglist_mailbox_test_output().

652  {
653  ctools_include('plugins');
654  $class = ctools_plugin_load_class($module, $type, $plugin, $class_name);
655  if ($class) {
656  return new $class($args);
657  }
658 }
$plugin
Definition: archive.inc:7

Here is the caller graph for this function: