46 'administer mailinglist' => array(
47 'title' => t(
'Administer Mailinglist mailboxes'),
50 foreach ($lists as $index => $list) {
51 $permissions[
'mailinglist ' . $index] = array(
52 'title' => t(
'Access ' . $list->admin_title),
54 foreach ($opers as $oindex => $oper) {
55 $permissions[
'mailinglist ' . $index .
' ' . $oindex] = array(
56 'title' => t($list->admin_title .
' ' . $oper->plugin[
'name']),
71 case 'admin/help#mailinglist':
72 $help = file_get_contents( dirname(__FILE__) .
"/INSTALL.txt");
73 return _filter_autop($help);
75 case 'admin/config/system/mailinglist/list/add':
76 return t(
'Add help here');
86 $base = variable_get(
'mailinglist_base',
'mailinglist');
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',
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',
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',
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',
126 'admin/config/system/mailinglist/config' => array(
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',
144 'mailinglist_message' => array(
145 'worker callback' =>
'mailinglist_message_callback',
160 foreach ($boxes as $index => $box) {
224 $path = variable_get(
'file_private_path');
227 $path = variable_get(
'file_public_path', conf_path() .
'/files');
230 $path = DRUPAL_ROOT .
'/' . $path .
'/mailinglist';
231 $flag = file_prepare_directory($path, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
241 return str_replace($base,
'', $path);
251 foreach ($boxes as $index => $box) {
266 $queue = DrupalQueue::get(
'mailinglist_message');
269 $file = variable_get(
'mailinglist_mailbox_current', FALSE);
271 if ($file == FALSE) {
272 if($queue->numberOfItems() > 100) {
275 $files = file_scan_directory($path,
'/.*/');
278 dpm(
'Nothing',
'mailinglist_maildir_scan');
281 $file = array_keys($files);
284 $handle = fopen($file,
'r');
285 fseek($handle, 0, SEEK_END);
286 $end = ftell($handle);
288 $local = substr($file, strlen($path)+1);
289 $pos = strpos($local,
'/');
291 $listname = substr($local, 0, $pos);
296 watchdog(
'Mailinglist',
'Starting @file (@msg) @list',
297 array(
'@msg' => $end,
299 '@list' => $listname),
301 dpm($listname,
'list');
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);
309 if($queue->numberOfItems() > 1000) {
313 $offset = variable_get(
'mailinglist_mailbox_current_offset');
314 $listname = variable_get(
'mailinglist_mailbox_current_list');
315 $msgcnt = variable_get(
'mailinglist_mailbox_current_max');
324 if ($list == FALSE) {
330 if ($offset === FALSE) {
331 variable_set(
'mailinglist_mailbox_current', FALSE);
332 variable_set(
'mailinglist_mailbox_current_offset', 0);
336 variable_set(
'mailinglist_mailbox_current_offset', $offset);
354 $queue = DrupalQueue::get(
'mailinglist_message');
355 $handle = fopen($file,
'r');
358 watchdog(
'Mailinglist',
'File not found @file',
361 dpm($file,
'File Not found');
365 fseek($handle, $offset);
367 $fromline = fgets($handle);
369 while( time() < $time+20 && $cnt < 1000) {
374 $offset = ftell($handle);
375 $line = fgets($handle);
376 if ($line === FALSE || substr($line, 0, 5) ==
'From ') {
383 if ($msg ==
"" && $fromline == FALSE) {
384 watchdog(
'Mailinglist',
'End of File @file',
387 dpm(
'End of File: ' . $file);
392 $headers = $msg->headers();
393 if(!isset($headers[
'From']) || !isset($headers[
'Date']) || !isset($headers[
'Subject'])){
395 watchdog(
'Mailinglist',
'Bad message @file @offset @from MSG: @msg' ,
397 '@offset' => $offset,
398 '@from' => $fromline,
399 '@msg' => check_plain(print_r($msg, TRUE)),
404 $from = $msg->header(
'From');
405 if (is_array($from)) {
408 if (strpos($from,
'@') == FALSE) {
410 $from = str_replace(
' at ',
'@', $from);
411 $msg->setHeader(
'From', $from);
417 $msg->setHeader(
'XX-List', $list->admin_name);
418 $msg->setHeader(
'XX-Archive',
'1');
419 $msg->setHeader(
'XX-Status', 0);
421 $queue->createItem($msg);
437 $listname = $msg->header(
'XX-List');
446 $list->processMessage($msg);
450 foreach ($lists as $list1) {
451 $flag = $list1->checkMessage($msg);
466 $seed = mt_rand(0, 255);
468 for ($i=0; $i < strlen($pass); $i++) {
469 $seed = ($seed + ord($pass[$i])) % 256;
472 $encode = base64_encode($str);
482 if (empty($code))
return $code;
483 $decode = base64_decode($code);
484 $seed = ord($decode[0]);
486 for ($i=1; $i < strlen($decode); $i++) {
487 $ch = ord($decode[$i]);
489 if ($seed < 0) $seed += 256;
526 foreach ( $array2 as $key => &$value ) {
527 if ( is_array ( $value ) && isset ( $merged [$key] ) && is_array ( $merged [$key] ) ) {
531 $merged [$key] = $value;
549 if (!is_array($desc)) {
550 $desc = array(
'description' =>
'desc');
553 $desc[
'type'] =
'char';
554 $desc[
'length'] = 19;
562 $value = gmdate(
'Y-m-d H:i:s', $ts);
571 return strtotime($time .
" UTC");
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();
584 $fields = array(
'email' => $email,
'name' => $name);
585 dpm($fields,
'New Combo');
586 return (
int) db_insert(
'mailinglist_names') -> fields($fields) -> execute();
590 return (
int) $result[
'name_key'];
604 if (strstr(request_uri(),
'system/ajax') && $_POST[
'form_id'] ==
'ctools_export_ui_edit_item_form') {
605 ctools_include(
'export');
621 return 'plugins/' . $owner .
'/' . $plugin_type;
630 'operation' => array(),
631 'retrieve' => array(),
653 ctools_include(
'plugins');
654 $class = ctools_plugin_load_class($module, $type,
$plugin, $class_name);
656 return new $class($args);
670 ctools_include(
'plugins');
671 $plugins = ctools_get_plugins($module, $type);
674 foreach ($plugins as $key => $info) {
675 if (!empty($info[
'hidden'])) {
678 if (!isset($info[
'weight'])) {
679 $info[
'weight'] = 10;
681 $weights[] = $info[
'weight'];
682 $result[$key] = $info;
684 array_multisort($weights, $result);
703 foreach ($source as $key => $value) {
704 $options[$key] = is_object($value) ? $value->$key_name : $value[$key_name];
737 ctools_include(
'plugins');
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)) {
746 $class_name = $schema[
'fields'][
'object_type'][
'default'];
749 $object = _ctools_export_unpack_object($schema, $data, $class_name);
770 ctools_include(
'export');
771 $retrieve = ctools_export_crud_load(
'mailinglist_retrieve', $mbox);
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]);
798 $mailbox = (object)$form_state[
'values'];
806 $output =
'<div id="mailinglist_test_results" class="form-wrapper">';
808 if (isset($mailbox->settings[
'object_type'])) {
811 $ret = $class->test($mailbox);
812 foreach ($ret as $message) {
813 $output .=
'<div class="messages ' . $message[
'severity'] .
'">' . $message[
'message'] .
'</div>';
833 ctools_include(
'export');
834 $obj = ctools_export_crud_load(
'mailinglist_list', $list);
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]);
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);
874 $class = ctools_plugin_get_class(
$plugin,
'handler');
875 if (class_exists($class)) {
893 foreach ($opers as $key =>
$plugin) {
_mailinglist_mailbox_scan()
Process the configured mailing boxes.
mailinglist_help($path, $arg)
Implements hook_help().
_mailinglist_encode_password($pass)
_mailinglist_encode_password
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 ...
mailinglist_ctools_plugin_type()
Implements hook_ctools_plugin_type().
Class defining the contents of an e-mail message.
mailinglist_cron_queue_info()
Implements hook_cron_queue_info().
_mailinglist_file_path()
_mailinglist_file_path() gets the file path that we will use to place files in
_mailinglist_mailbox_test_output($mailbox)
_mailinglist_mailbox_test_output()
mailinglist_mailbox_load_all($show_disabled=TRUE)
Load all mailinglists.
_mailinglist_build_options($source, $key_name= 'name')
Builds a Select control array from a menu form an array from a ctools_get_plugin. ...
mailinglist_list_load($list)
Load a list definition.
mailinglist_menu()
Implements hook_menu().
mailinglist_operation_load($oper)
@ name CTools Operation/******** operation
_mailinglist_datetime_schema($desc)
Return the schema for a 'datetime' field.
_mailinglist_decode_password($code)
_mailinglist_decode_password
mailinglist_get_plugins($module, $type)
Wrapper to load plugins.
_mailinglist_mailbox_test($form, &$form_state)
_mailinglist_mailbox_test
mailinglist_operation_load_all()
mailinglist_operation_load_all()
mailinglist_cron()
Implements hook_cron().
mailinglist_email_name($email, $name, $count=0)
Lookup Email <-> Name combination.
mailinglist_permission()
Implements hook_permission().
mailinglist_plugin_load_class($module, $type, $plugin, $class_name='handler', $args=NULL)
Wrapper to load any class type.
mailinglist_init()
CTOOLS Hooks
_mailinglist_object_factory($schema, $data)
Builds an type variable object from a database table entry.
mailinglist_message_callback($msg)
Message Queue Callback function.
_mailinglist_maildir_scan()
_mailinglist_mailbox_scan()
mailinglist_mailbox_load($mbox)
CTools Export UI
mailinglist_ctools_plugin_directory($owner, $plugin_type)
Implements hook_ctools_plugin_directory().
mailinglist_list_load_all($show_disabled=TRUE)
Load all mailinglists.
_mailinglist_datetime_format($ts)
Convert a 'timestamp to a 'datetime'.
_mailinglist_base_filename($path)
_mailinglist_base_filename().
_mailinglist_mailbox_process($list, $file, $offset)
_mailinglist_mailbox_process().
_mailinglist_datetime_ts($time)
Convert a 'datetime' field into a timestamp.