A mail is what's stored at the IMAP/POP3 server. A message is information from an...
[squirrelmail.git] / plugins / mail_fetch / fetch.php
index b3b75491e74453587ffb1fd51aeaa659a1374b96..13f68d224e0429a9fa2e97e9caa6903acdedc58f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Fetch code.
  *
- * @copyright © 1999-2006 The SquirrelMail Project Team
+ * @copyright © 1999-2009 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
@@ -20,12 +20,17 @@ require('../../include/init.php');
 include_once(SM_PATH . 'functions/imap_general.php');
 include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
 
+// don't load this page if this plugin is not enabled
+//
+global $plugins;
+if (!in_array('mail_fetch', $plugins)) exit;
+
 /* globals */
 sqgetGlobalVar('delimiter',  $delimiter,  SQ_SESSION);
 /* end globals */
 
 /**
- * @param string $msg message
+ * @param string $msg mail
  */
 function Mail_Fetch_Status($msg) {
     echo html_tag( 'table',
@@ -119,7 +124,7 @@ function Mail_Fetch_Select_Server($mailfetch) {
 }
 
 $mailfetch = Mail_Fetch_Servers();
-displayPageHeader($color, 'None');
+displayPageHeader($color);
 
 echo '<br />';
 
@@ -132,8 +137,9 @@ echo html_tag( 'table',
 
 /* there are no servers defined yet... */
 if($mailfetch['server_number'] == 0) {
+//FIXME: do not echo directly to browser -- use templates only
     echo '<p>' . _("No POP3 servers configured yet.") . '</p>';
-    displayInternalLink('plugins/mail_fetch/options.php',
+    echo makeInternalLink('plugins/mail_fetch/options.php',
                         _("Click here to go to the options page.") );
     $oTemplate->display('footer.tpl');
     exit();
@@ -218,18 +224,18 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
     $i = 1;
 
     if ($Count>0) {
-        // If we leave messages on server, try using UIDL
+        // If we leave mails on server, try using UIDL
         if ($mailfetch_lmos == 'on') {
             Mail_Fetch_Status(_("Fetching UIDL..."));
             $msglist = $pop3->command_uidl();
             if (is_bool($msglist)) {
                 Mail_Fetch_Status(_("Server does not support UIDL.") . ' '.htmlspecialchars($pop3->error));
-                // User asked to leave messages on server, but we can't do that.
+                // User asked to leave mails on server, but we can't do that.
                 $pop3->command_quit();
                 continue;
                 // $mailfetch_lmos = 'off';
             } else {
-                // calculate number of new messages
+                // calculate number of new mails
                 for ($j = 1; $j <= sizeof($msglist); $j++) {
                     // do strict comparison ('1111.10' should not be equal to '1111.100')
                     if ($msglist[$j] === $mailfetch_uidl) {
@@ -239,17 +245,17 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
                 }
             }
         }
-        // fetch list of messages with LIST
+        // fetch list of mails with LIST
         // we can use else control, but we can also set $mailfetch_lmos 
         // to off if server does not support UIDL.
         if ($mailfetch_lmos != 'on') {
-            Mail_Fetch_Status(_("Fetching list of messages..."));
+            Mail_Fetch_Status(_("Fetching list of mails..."));
             $msglist = $pop3->command_list();
         }
     }
 
     if ($Count < $i) {
-        Mail_Fetch_Status(_("Login OK: No new messages"));
+        Mail_Fetch_Status(_("Login OK: No new mails"));
         $pop3->command_quit();
         continue;
     }
@@ -259,21 +265,21 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
         continue;
     } else {
         $newmsgcount = $Count - $i + 1;
-        Mail_Fetch_Status(sprintf(ngettext("Login OK: Inbox contains %s message",
-                                           "Login OK: Inbox contains %s messages",$newmsgcount), $newmsgcount));
+        Mail_Fetch_Status(sprintf(ngettext("Login OK: Inbox contains %s mail",
+                                           "Login OK: Inbox contains %s mails",$newmsgcount), $newmsgcount));
     }
 
     if ($mailfetch_lmos == 'on') {
         Mail_Fetch_Status(_("Leaving mail on server..."));
     } else {
-        Mail_Fetch_Status(_("Deleting messages from server..."));
+        Mail_Fetch_Status(_("Deleting mails from server..."));
     }
 
     for (; $i <= $Count; $i++) {
-        Mail_Fetch_Status(sprintf(_("Fetching message %s."), $i));
+        Mail_Fetch_Status(sprintf(_("Fetching mail %s."), $i));
 
         if (!ini_get('safe_mode'))
-            set_time_limit(20); // 20 seconds per message max
+            set_time_limit(20); // 20 seconds per mail max
 
         $Message = $pop3->command_retr($i);
 
@@ -291,7 +297,7 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
             $response=(implode('',$response));
             $message=(implode('',$message));
             if ($response != 'OK') {
-                Mail_Fetch_Status(_("Error Appending Message!")." ".htmlspecialchars($message) );
+                Mail_Fetch_Status(_("Error Appending Mail!")." ".htmlspecialchars($message) );
                 Mail_Fetch_Status(_("Closing POP"));
                 $pop3->command_quit();
                 Mail_Fetch_Status(_("Logging out from IMAP"));
@@ -303,19 +309,19 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
                 }
                 exit;
             } else {
-                Mail_Fetch_Status(_("Message appended to mailbox"));
+                Mail_Fetch_Status(_("Mail appended to mailbox"));
             }
 
             if ($mailfetch_lmos != 'on') {
                 if( $pop3->command_dele($i) ) {
-                    Mail_Fetch_Status(sprintf(_("Message %d deleted from remote server!"), $i));
+                    Mail_Fetch_Status(sprintf(_("Mail %d deleted from remote server!"), $i));
                 } else {
                     Mail_Fetch_Status(_("Delete failed:") . htmlspecialchars($pop3->error) );
                 }
             }
         } else {
             echo $Line;
-            Mail_Fetch_Status(_("Error Appending Message!"));
+            Mail_Fetch_Status(_("Error Appending Mail!"));
             Mail_Fetch_Status(_("Closing POP"));
             $pop3->command_quit();
             Mail_Fetch_Status(_("Logging out from IMAP"));
@@ -343,4 +349,3 @@ for ($i_loop=$i_start;$i_loop<$i_stop;$i_loop++) {
 }
 
 $oTemplate->display('footer.tpl');
-