/[drupal]/contributions/modules/mail_archive/mail_archive.module
ViewVC logotype

Diff of /contributions/modules/mail_archive/mail_archive.module

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

revision 1.14 by jeremy, Mon Jan 31 04:43:24 2005 UTC revision 1.15 by jeremy, Sat Feb 5 19:01:12 2005 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id:  // $Id: initialize $
3    
4  /*  /*
5  ** mail_archive.module:  ** mail_archive.module:
# Line 635  function mail_archive_menu($may_cache) { Line 635  function mail_archive_menu($may_cache) {
635  function mail_archive_cron() {  function mail_archive_cron() {
636    $last_check = variable_get('mail_archive_checked_mail', '');    $last_check = variable_get('mail_archive_checked_mail', '');
637    
638    // download and index new messages    // download and index new messages no more than once every five minutes
639    if ((time() - $last_check) >= variable_get('mail_archive_download_time', 300)) {    if ((time() - $last_check) >= variable_get('mail_archive_download_time', 300)) {
640      $result = db_query('SELECT s.*, n.title FROM {mail_archive_subscriptions} s INNER JOIN {node} n ON s.nid = n.nid WHERE subscription_status = 1');      $result = db_query('SELECT s.*, n.title FROM {mail_archive_subscriptions} s INNER JOIN {node} n ON s.nid = n.nid WHERE subscription_status = 1');
641      while ($subscription = db_fetch_object($result)) {      while ($subscription = db_fetch_object($result)) {
642        mail_archive_fetch_mail($subscription);        mail_archive_fetch_mail($subscription);
643          /* give the mail system time to catch up (downloading a large number of
644          ** subscriptions at one time without pause can result in the last few
645          ** failing.)
646          */
647          sleep (1);
648      }      }
649      variable_set('mail_archive_checked_mail', time());      variable_set('mail_archive_checked_mail', time());
650    }    }
# Line 650  function mail_archive_node_name() { Line 655  function mail_archive_node_name() {
655  }  }
656    
657  function mail_archive_insert($node) {  function mail_archive_insert($node) {
658      watchdog('mail_archive', t('Mail archive subscription "%title" created.', array('%title' => $node->title)));
659    db_query('INSERT INTO {mail_archive_subscriptions} (nid, created, server, port, folder, username, password, connection, delete_read, subscription_status) VALUES(%d, %d, "%s", %d, "%s", "%s", "%s", %d, %d, %d)', $node->nid, $node->created, $node->server, $node->port, $node->folder, $node->username, $node->password, $node->connection, $node->delete_read, $node->subscription_status);    db_query('INSERT INTO {mail_archive_subscriptions} (nid, created, server, port, folder, username, password, connection, delete_read, subscription_status) VALUES(%d, %d, "%s", %d, "%s", "%s", "%s", %d, %d, %d)', $node->nid, $node->created, $node->server, $node->port, $node->folder, $node->username, $node->password, $node->connection, $node->delete_read, $node->subscription_status);
660  }  }
661    
# Line 658  function mail_archive_update($node) { Line 664  function mail_archive_update($node) {
664  }  }
665    
666  function mail_archive_delete($node) {  function mail_archive_delete($node) {
667      watchdog('mail_archive', t('Mail archive subscription "%title" deleted.', array('%title' => $node->title)));
668    // TODO: figure out what to do with mail archive (delete everything?)    // TODO: figure out what to do with mail archive (delete everything?)
669    db_query('DELETE FROM {mail_archive_subscriptions} WHERE nid = %d', $node->nid);    db_query('DELETE FROM {mail_archive_subscriptions} WHERE nid = %d', $node->nid);
670    // currently we leave everything related to a subscription orphaned    // currently we leave everything related to a subscription orphaned
# Line 1282  function mail_archive_message_delete($li Line 1289  function mail_archive_message_delete($li
1289      // update subscription message count      // update subscription message count
1290      db_query('UPDATE {mail_archive_subscriptions} SET messages = messages - 1 WHERE lid = %d', $lid);      db_query('UPDATE {mail_archive_subscriptions} SET messages = messages - 1 WHERE lid = %d', $lid);
1291    
1292        watchdog('mail_archive', t('Message "%subject" delete from mail archive "%title".', array('%subject' => $message->subject_short, '%title' => mail_archive_get_subscription_name($lid))));
1293    
1294      // go back to list overview      // go back to list overview
1295      drupal_goto("mailarchive/$lid/overview/thread");      drupal_goto("mailarchive/$lid/overview/thread");
1296    }    }
# Line 1429  function mail_archive_fetch_mail($subscr Line 1438  function mail_archive_fetch_mail($subscr
1438    }    }
1439    $mailbox = @imap_open($connect, $username, $password);    $mailbox = @imap_open($connect, $username, $password);
1440    if ($mailbox === FALSE) {    if ($mailbox === FALSE) {
1441        watchdog('mail_archive', t('Connection to mail server "%server" with username "%username"failed', array('%server' => $connect, '%username' => $username)));
1442      drupal_set_message (t('Connection to mail server "%server" failed.<br />', array('%server' => $connect)), 'error');      drupal_set_message (t('Connection to mail server "%server" failed.<br />', array('%server' => $connect)), 'error');
1443      if ($alerts = imap_alerts()) {      if ($alerts = imap_alerts()) {
1444        foreach ($alerts as $alert) {        foreach ($alerts as $alert) {
# Line 1475  function mail_archive_fetch_mail($subscr Line 1485  function mail_archive_fetch_mail($subscr
1485    
1486    if ($messages_downloaded) {    if ($messages_downloaded) {
1487      db_query('UPDATE {mail_archive_subscriptions} SET messages = messages + %d, last = %d WHERE lid = %d', $messages_downloaded, time(), $subscription->lid);      db_query('UPDATE {mail_archive_subscriptions} SET messages = messages + %d, last = %d WHERE lid = %d', $messages_downloaded, time(), $subscription->lid);
1488      drupal_set_message(t('Succesfully fetched %number messages.', array('%number' => $messages_downloaded)));      drupal_set_message(t('Successfully fetched %number messages for "%subscription".', array('%number' => $messages_downloaded, '%subscription' => $subscription->title)));
1489    }    }
1490    else {    else {
1491      drupal_set_message('No messages were downloaded.');      drupal_set_message('No messages were downloaded.');

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.3