[Vtigercrm-commits] [vtiger-commits] r6484 - in /vtigercrm/trunk/modules/Webmails: CallRelatedList.php DetailView.php EditView.php ListView.php MailParse.php Save.php WebmailsAjax.php body.php dlAttachments.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Fri May 26 12:54:57 EDT 2006
Author: mmbrich
Date: Fri May 26 10:54:56 2006
New Revision: 6484
Log:
new imap_open command in mailparse to make maint easier, this new imap_open command should fix some of the problems that users were seeing with invalid mailboxes.
Modified:
vtigercrm/trunk/modules/Webmails/CallRelatedList.php
vtigercrm/trunk/modules/Webmails/DetailView.php
vtigercrm/trunk/modules/Webmails/EditView.php
vtigercrm/trunk/modules/Webmails/ListView.php
vtigercrm/trunk/modules/Webmails/MailParse.php
vtigercrm/trunk/modules/Webmails/Save.php
vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
vtigercrm/trunk/modules/Webmails/body.php
vtigercrm/trunk/modules/Webmails/dlAttachments.php
Modified: vtigercrm/trunk/modules/Webmails/CallRelatedList.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/CallRelatedList.php (original)
+++ vtigercrm/trunk/modules/Webmails/CallRelatedList.php Fri May 26 10:54:56 2006
@@ -15,42 +15,30 @@
global $mod_strings;
if($_REQUEST["record"]) {$mailid=$_REQUEST["record"];} else {$mailid=$_REQUEST["mailid"];}
-
-$mailInfo = getMailServerInfo($current_user);
-$temprow = $adb->fetch_array($mailInfo);
-
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
-$imapServerAddress=$temprow["mail_servername"];
-$start_message=$_REQUEST["start_message"];
-$box_refresh=$temprow["box_refresh"];
-$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
-
-if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-global $mbox;
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+$mailInfo = getMailServerInfo($current_user);
+$temprow = $adb->fetch_array($mailInfo);
+$imapServerAddress=$temprow["mail_servername"];
+$start_message=$_REQUEST["start_message"];
+$box_refresh=$temprow["box_refresh"];
+$mails_per_page=$temprow["mails_per_page"];
+$mail_protocol=$temprow["mail_protocol"];
+
+if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
+
+$mbox=getImapMbox($mailbox,$temprow);
+
+$email = new Webmail($mbox, $mailid);
+$from = $email->from;
+$subject=$email->subject;
+$date=$email->date;
+$to=$email->to;
+$cc_list=$email->cc_list;
+$reply_to=$email->replyTo;
-$email = new Webmail($mbox, $mailid);
-$from = $email->from;
-$subject=$email->subject;
-$date=$email->date;
-$to=$email->to;
-$cc_list=$email->cc_list;
-$reply_to=$email->replyTo;
-
-
-$block["Leads"]= "";
-global $adb;
+$block["Leads"]= "";
+global $adb;
if($email->relationship != 0 && $email->relationship["type"] == "Leads") {
$q = "SELECT leaddetails.firstname, leaddetails.lastname, leaddetails.email, leaddetails.company, crmentity.smownerid from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid WHERE leaddetails.leadid='".$email->relationship["id"]."'";
$rs = $adb->query($q);
Modified: vtigercrm/trunk/modules/Webmails/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/DetailView.php (original)
+++ vtigercrm/trunk/modules/Webmails/DetailView.php Fri May 26 10:54:56 2006
@@ -13,29 +13,17 @@
global $app_strings;
global $mod_strings;
if($_REQUEST["record"]) {$mailid=$_REQUEST["record"];} else {$mailid=$_REQUEST["mailid"];}
+
$mailInfo = getMailServerInfo($current_user);
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$start_message=$_REQUEST["start_message"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-global $mbox;
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
-
+$mbox = getImapMbox($mailbox,$temprow);
echo ' after in DetailView ';
$email = new Webmail($mbox, $mailid);
Modified: vtigercrm/trunk/modules/Webmails/EditView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/EditView.php (original)
+++ vtigercrm/trunk/modules/Webmails/EditView.php Fri May 26 10:54:56 2006
@@ -64,27 +64,17 @@
define('SM_PATH','modules/Webmails/');
require_once(SM_PATH . 'Webmail.php');
require_once('include/utils/UserInfoUtil.php');
+require_once("modules/Webmails/MailParse.php");
+
$mailInfo = getMailServerInfo($current_user);
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$start_message=$_REQUEST["start_message"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
-
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
+
+$mbox = getImapMbox($mailbox,$temprow);
$webmail = new Webmail($mbox,$mailid);
$webmail->loadMail();
Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Fri May 26 10:54:56 2006
@@ -127,16 +127,13 @@
}
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
$account_name=$temprow["account_name"];
$show_hidden=$_REQUEST["show_hidden"];
+
+$mbox = getImapMbox($mailbox,$temprow);
?>
<script language="Javascript" type="text/javascript" src="modules/Webmails/js/ajax_connection.js"></script>
@@ -250,26 +247,6 @@
//<<<<<customview>>>>>
-global $mbox;
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-
-if(!$mbox)
-{
- if($mail_protocol == 'pop3')
- {
- $connectString = "{".$imapServerAddress."/".$mail_protocol.":110/notls}".$mailbox;
- }
- else
- {
- $connectString = "{".$imapServerAddress.":143/".$mail_protocol."/notls}".$mailbox;
- }
- //$mbox = imap_open($connectString, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
- $mbox = imap_open($connectString, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
-}
-
if($_POST["command"] == "check_mbox" && $_POST["ajax"] == "true") {
$check = imap_mailboxmsginfo($mbox);
if($check->Unread > 0)
@@ -446,8 +423,8 @@
}
$list = imap_getmailboxes($mbox, "{".$imapServerAddress."}", "*");
-echo ' deliberately putting this print here ';
-print_r($list);
+//echo ' deliberately putting this print here ';
+//print_r($list);
sort($list);
if (is_array($list)) {
$boxes = '<select name="mailbox" id="mailbox_select">';
@@ -465,23 +442,13 @@
$box = imap_mailboxmsginfo($mbox);
$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" /> <a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a> <b>('.$box->Unread.' of '.$box->Nmsgs.')</b></li>';
} else {
- if($ssltype == "") {$ssltype = "notls";}
- if($sslmeth == "") {$sslmeth = "novalidate-cert";}
- echo ' the tmbox check fails here because of .bash_logout being passed as the mailbox >>>>>>> ' .$tmpval;
- // $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
- $tmbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$tmpval, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
- //echo ' 1211111111111111 ';
- echo ' tmbox is ' .$tmbox;
- if(!$tmbox)
- {
- $tmbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
- $connectString = "{".$imapServerAddress.":143/".$imapProtocol."/notls}".$mailbox;
- $tmbox = imap_open($connectString, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
- $box = imap_mailboxmsginfo($tmbox);
+ $tmpbox = getImapMbox($tmpval,$temprow);
+ $box = imap_mailboxmsginfo($tmpbox);
+
$boxes .= '<option value="'.$tmpval.'">'.$tmpval;
$folders .= '<li><img src="'.$image_path.'/'.$img.'" align="absmiddle" /> <a href="javascript:changeMbox(\''.$tmpval.'\');" class="webMnu">'.$tmpval.'</a> <b>('.$box->Unread.' of '.$box->Nmsgs.')</b></li>';
- }
- imap_close($tmbox);
+
+ imap_close($tmpbox);
}
}
$boxes .= '</select>';
Modified: vtigercrm/trunk/modules/Webmails/MailParse.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/MailParse.php (original)
+++ vtigercrm/trunk/modules/Webmails/MailParse.php Fri May 26 10:54:56 2006
@@ -5,7 +5,43 @@
$mailOverviews = @imap_fetch_overview($mbox, "1:$numEmails", 0);
$out = array("headers"=>$mailHeaders,"overview"=>$mailOverviews,"count"=>$numEmails);
return $out;
-}
+}
+function getImapMbox($mailbox,$temprow) {
+ global $mbox;
+
+ $login_username= $temprow["mail_username"];
+ $secretkey=$temprow["mail_password"];
+ $imapServerAddress=$temprow["mail_servername"];
+ $box_refresh=$temprow["box_refresh"];
+ $mails_per_page=$temprow["mails_per_page"];
+ $mail_protocol=$temprow["mail_protocol"];
+ $ssltype=$temprow["ssltype"];
+ $sslmeth=$temprow["sslmeth"];
+ $account_name=$temprow["account_name"];
+ $show_hidden=$_REQUEST["show_hidden"];
+
+
+ // first we will try a regular old IMAP connection:
+ if($ssltype == "") {$ssltype = "notls";}
+ if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+ $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
+
+ if(!$mbox)
+ {
+ if($mail_protocol == 'pop3')
+ {
+ $connectString = "{".$imapServerAddress."/".$mail_protocol.":110/notls}".$mailbox;
+ }
+ else
+ {
+ $connectString = "{".$imapServerAddress.":143/".$mail_protocol."/".$ssltype."}".$mailbox;
+ }
+ $mbox = imap_open($connectString, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+ }
+
+ return $mbox;
+}
+
function getInlineAttachments($mailid,$mbox) {
$struct = imap_fetchstructure($mbox, $mailid);
$parts = $struct->parts;
Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Fri May 26 10:54:56 2006
@@ -6,8 +6,9 @@
require_once('include/database/PearDatabase.php');
require_once('include/utils/UserInfoUtil.php');
require_once('include/utils/CommonUtils.php');
+require_once("modules/Webmails/MailParse.php");
+
global $current_user;
-
$local_log =& LoggerManager::getLogger('index');
$focus = new Email();
@@ -28,28 +29,14 @@
}
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
-$account_name=$temprow["account_name"];
if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-global $mbox;
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
-
+$mbox = getImapMbox($mailbox,$temprow);
$email = new Webmail($mbox, $_REQUEST["mailid"]);
Modified: vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/trunk/modules/Webmails/WebmailsAjax.php Fri May 26 10:54:56 2006
@@ -18,6 +18,8 @@
require_once('include/logging.php');
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
+require_once("modules/Webmails/MailParse.php");
+
global $adb,$mbox,$current_user;
@@ -30,33 +32,15 @@
}
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
-$account_name=$temprow["account_name"];
$show_hidden=$_REQUEST["show_hidden"];
+$mbox = getImapMbox($mailbox,$temprow);
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-// bug in windows PHP having to do with SSL not being linked correctly
-// causes this open command to fail.
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$_REQUEST["mailbox"], $login_username, $secretkey);
-
-
-$check = imap_check($mbox);
-
-//if($check->Recent > 0) {
$search = imap_search($mbox, "NEW ALL");
if($search === false) {echo "";flush();exit();}
-
-//echo $search[0];flush();exit();
$data = imap_fetch_overview($mbox,implode(',',$search));
$num=sizeof($data);
Modified: vtigercrm/trunk/modules/Webmails/body.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/body.php (original)
+++ vtigercrm/trunk/modules/Webmails/body.php Fri May 26 10:54:56 2006
@@ -3,32 +3,20 @@
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once('modules/Webmails/Webmail.php');
+require_once("modules/Webmails/MailParse.php");
if(!isset($_SESSION["authenticated_user_id"]) || $_SESSION["authenticated_user_id"] != $current_user->id) {echo "ajax failed";flush();exit();}
$mailInfo = getMailServerInfo($current_user);
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
$mailid=$_REQUEST["mailid"];
if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
-global $mbox;
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
+$mbox = getImapMbox($mailbox,$temprow);
$email = new Webmail($mbox,$mailid);
$email->loadMail();
Modified: vtigercrm/trunk/modules/Webmails/dlAttachments.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/dlAttachments.php (original)
+++ vtigercrm/trunk/modules/Webmails/dlAttachments.php Fri May 26 10:54:56 2006
@@ -3,27 +3,15 @@
require_once('include/utils/UserInfoUtil.php');
require_once('include/utils/utils.php');
require_once('modules/Webmails/Webmail.php');
-
+require_once("modules/Webmails/MailParse.php");
+
$mailInfo = getMailServerInfo($current_user);
$temprow = $adb->fetch_array($mailInfo);
-$login_username= $temprow["mail_username"];
-$secretkey=$temprow["mail_password"];
$imapServerAddress=$temprow["mail_servername"];
$box_refresh=$temprow["box_refresh"];
$mails_per_page=$temprow["mails_per_page"];
-$mail_protocol=$temprow["mail_protocol"];
-$ssltype=$temprow["ssltype"];
-$sslmeth=$temprow["sslmeth"];
-if($ssltype == "") {$ssltype = "notls";}
-if($sslmeth == "") {$sslmeth = "novalidate-cert";}
-if(!preg_match("/windows/i",php_uname()))
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey);
-
-if(!$mbox)
- $mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
-
-
+$mbox = getImapMbox($mailbox,$temprow);
$mailid=$_REQUEST["mailid"];
$num=$_REQUEST["num"];
More information about the vtigercrm-commits
mailing list