[Vtigercrm-commits] [vtiger-commits] r6297 - in /vtigercrm/trunk/modules/Webmails: CallRelatedList.php DetailView.php EditView.php ListView.php Save.php Webmail.php body.php dlAttachments.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon May 22 20:16:10 EDT 2006


Author: mmbrich
Date: Mon May 22 18:16:09 2006
New Revision: 6297

Log:
imap_open fixes (to populate SSL and TLS variables if NULL), completed attachment download from the detail view, other misc fixes

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/Save.php
    vtigercrm/trunk/modules/Webmails/Webmail.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 Mon May 22 18:16:09 2006
@@ -31,8 +31,11 @@
 
 if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
 global $mbox;
-$mbox = @imap_open("\{$imapServerAddress/$mail_protocol/$ssltype/$sslmeth}$mailbox", $login_username, $secretkey) or die("Connection to server failed");
-
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
+
 $email = new Webmail($mbox, $mailid);
 $from = $email->from;
 $subject=$email->subject;

Modified: vtigercrm/trunk/modules/Webmails/DetailView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/DetailView.php (original)
+++ vtigercrm/trunk/modules/Webmails/DetailView.php Mon May 22 18:16:09 2006
@@ -27,8 +27,10 @@
 
 if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
 global $mbox;
-//$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed");
-$mbox = @imap_open('{'.$imapServerAddress.'/'.$mail_protocol.'}'.$mailbox, $login_username, $secretkey) or die("Connection to server failed with: ".imap_last_error())
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
 
 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 Mon May 22 18:16:09 2006
@@ -77,8 +77,10 @@
 $ssltype=$temprow["ssltype"];
 $sslmeth=$temprow["sslmeth"];
 
-//$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed");
-$mbox = @imap_open('{'.$imapServerAddress.'/'.$mail_protocol.'}'.$mailbox, $login_username, $secretkey) or die("Connection to server failed with: ".imap_last_error());
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
 $webmail = new Webmail($mbox,$mailid);
 $webmail->loadMail();
 $focus->column_fields['description'] = strip_tags($webmail->body);

Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Mon May 22 18:16:09 2006
@@ -20,7 +20,12 @@
 	$("reply_button_all").innerHTML = '<input type="button" name="reply" value=" Reply to All " class="classWebBtn" onclick="window.location = \'index.php?module=Webmails&action=EditView&mailid='+mid+'&reply=all&return_action=index&return_module=Webmails\';" />';
 	$("reply_button").innerHTML = '<input type="button" name="reply" value=" Reply to Sender " class="classWebBtn" onclick="window.location = \'index.php?module=Webmails&action=EditView&mailid='+mid+'&reply=single&return_action=index&return_module=Webmails\';" />';
 	$("qualify_button").innerHTML = '<input type="button" name="Qualify2" value=" Qualify " onclick="showRelationships('+mid+');" class="classWebBtn" />';
-
+	$("download_attach_button").innerHTML = '<input type="button" name="download" value=" Download Attachments " class="classWebBtn" onclick="displayAttachments('+mid+');" />';
+
+}
+function displayAttachments(mid) {
+	var url = "index.php?module=Webmails&action=dlAttachments&mailid="+mid;
+	window.open(url,"Download Attachments",'menubar=no,toolbar=no,location=no,status=no,resizable=no,width=450,height=450');
 }
 function showRelationships(mid) {
 	// just add to vtiger for now
@@ -158,9 +163,11 @@
 
 
 global $mbox;
-//$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed");
-
-$mbox = @imap_open('{'.$imapServerAddress.'/'.$mail_protocol.'}'.$mailbox, $login_username, $secretkey) or die("Connection to server failed with: ".imap_last_error());
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
+
 
 function SureRemoveDir($dir) {
    if(!$dh = @opendir($dir)) return;

Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Mon May 22 18:16:09 2006
@@ -40,8 +40,10 @@
 if($_REQUEST["mailbox"] && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
 
 global $mbox;
-//$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed");
-$mbox = @imap_open('{'.$imapServerAddress.'/'.$mail_protocol.'}'.$mailbox, $login_username, $secretkey) or die("Connection to server failed with: ".imap_last_error());
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
 
 $email = new Webmail($mbox, $_REQUEST["mailid"]);
 

Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Mon May 22 18:16:09 2006
@@ -190,20 +190,20 @@
 	return $inline;
 }
 function dl_attachments($mailid,$mbox) {
-        $struct = imap_fetchstructure($mbox, $mailid);
-        $parts = $struct->parts;
-
-        $content = array();
-        $i = 0;
-        if (!$parts)
-		return;
-        else {
-
-        $stack = array();
-        $attachment = array();
-
-        $endwhile = false;
-
+        $struct = imap_fetchstructure($mbox, $mailid);
+        $parts = $struct->parts;
+
+        $content = array();
+        $i = 0;
+        if (!$parts)
+		return;
+        else {
+
+        $stack = array();
+        $attachment = array();
+
+        $endwhile = false;
+
         while (!$endwhile) {
            if (!$parts[$i]) {
              if (count($stack) > 0) {

Modified: vtigercrm/trunk/modules/Webmails/body.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/body.php (original)
+++ vtigercrm/trunk/modules/Webmails/body.php Mon May 22 18:16:09 2006
@@ -21,8 +21,10 @@
 if(isset($_REQUEST["mailbox"]) && $_REQUEST["mailbox"] != "") {$mailbox=$_REQUEST["mailbox"];} else {$mailbox="INBOX";}
 
 global $mbox;
-//$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed");
-$mbox = @imap_open('{'.$imapServerAddress.'/'.$mail_protocol.'}'.$mailbox, $login_username, $secretkey) or die("Connection to server failed with: ".imap_last_error());
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
 $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 Mon May 22 18:16:09 2006
@@ -14,27 +14,46 @@
 $mail_protocol=$temprow["mail_protocol"];
 $ssltype=$temprow["ssltype"];
 $sslmeth=$temprow["sslmeth"];
-
-$mbox = @imap_open("\{$imapServerAddress/$mail_protocol/$ssltype/$sslmeth}$mailbox", $login_username, $secretkey) or die("Connection to server failed");
-
-$mailid=$_REQUEST["mailid"];
-$num=$_REQUEST["num"];
-$email = new Webmail($mbox,$mailid);
-$attachments=$email->downloadAttachments();
+
+if($ssltype == "") {$ssltype = "notls";}
+if($sslmeth == "") {$sslmeth = "novalidate-cert";}
+$mbox = @imap_open("{".$imapServerAddress."/".$mail_protocol."/".$ssltype."/".$sslmeth."}".$mailbox, $login_username, $secretkey) or die("Connection to server failed ".imap_last_error());
+
+
+$mailid=$_REQUEST["mailid"];
+$num=$_REQUEST["num"];
+
+$email = new Webmail($mbox,$mailid);
+$attachments=$email->downloadAttachments();
+
+if($num == "" || !isset($num) && count($attachments) >0 ) {
+	echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
+	for($i=0;$i<count($attachments);$i++) {
+		echo "<tr><td align='center'>".count($attachments).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."'>".$attachments[$i]["filename"]."</td></tr>";
+	}
+	echo "</table><br><br>";
+
+} elseif (count(attachments) == 0) {
+	echo "<center><strong>No attachments for this email</strong></center><br><br>";
+} else {
+
 global $root_directory;
-$save_path=$root_directory.'/modules/Webmails/tmp';
-$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
-if(!is_dir($user_dir))
-	mkdir($user_dir);
-
+$save_path=$root_directory.'/modules/Webmails/tmp';
+$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
+if(!is_dir($user_dir))
+	mkdir($user_dir);
+
 $fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
 fputs($fp, base64_decode($attachments[$num]["filedata"]));
-fclose($fp);
-imap_close($mbox);
-
-$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
-?>
-<center><h2>File Download</h2></center>
-<META HTTP-EQUIV="Refresh"
-CONTENT="0; URL=<?php echo $filename;?>"
-]"
+fclose($fp);
+imap_close($mbox);
+
+$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
+?>
+<center><h2>File Download</h2></center>
+<META HTTP-EQUIV="Refresh"
+CONTENT="0; URL=<?php echo $filename;?>"
+]"
+<?
+}
+?>





More information about the vtigercrm-commits mailing list