[Vtigercrm-commits] [vtiger-commits] r6298 - in /vtigercrm/trunk/modules/Webmails: Save.php Webmail.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon May 22 21:00:24 EDT 2006
Author: mmbrich
Date: Mon May 22 19:00:22 2006
New Revision: 6298
Log:
added filesizes to webmail object, added file attachments on qualify
Modified:
vtigercrm/trunk/modules/Webmails/Save.php
vtigercrm/trunk/modules/Webmails/Webmail.php
Modified: vtigercrm/trunk/modules/Webmails/Save.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Save.php (original)
+++ vtigercrm/trunk/modules/Webmails/Save.php Mon May 22 19:00:22 2006
@@ -5,6 +5,7 @@
require_once('include/logging.php');
require_once('include/database/PearDatabase.php');
require_once('include/utils/UserInfoUtil.php');
+require_once('include/utils/CommonUtils.php');
global $current_user;
@@ -84,6 +85,35 @@
$contact_focus->column_fields['email'] = $email->from;
$contact_focus->save("Contacts");
$focus->column_fields['parent_id']=$contact_focus->id.'@'.$fieldid.'|';
+
+ // add attachments to contact
+
+ $attachments=$email->downloadAttachments();
+ $upload_filepath = decideFilePath();
+ for($i=0,$num_files=count($attachments);$i<$num_files;$i++) {
+ $current_id = $adb->getUniqueID("crmentity");
+ $date_var = date('YmdHis');
+
+ $filename = $attachments[$i]["filename"];
+ $filetype= substr($filename,strstr($filename,"."),strlen($filename));
+ $filesize = $attachments[$i]["filesize"];
+
+ $query = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime) values('";
+ $query .= $current_id."','".$current_user->id."','".$current_user->id."','Contacts Attachment','Uploaded from webmail during qualification','".$date_var."')";
+ $result = $adb->query($query);
+
+ $sql = "insert into attachments values(";
+ $sql .= $current_id.",'".$filename."','Uploaded ".$filename." from webmail','".$filetype."','".$upload_filepath."')";
+ $result = $adb->query($sql);
+
+ $sql1 = "insert into seattachmentsrel values('";
+ $sql1 .= $contact_focus->id."','".$current_id."')";
+ $result = $adb->query($sql1);
+
+ $fp = fopen($upload_filepath.'/'.$filename, "w") or die("Can't open file");
+ fputs($fp, base64_decode($attachments[$i]["filedata"]));
+ fclose($fp);
+ }
}
$_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
$focus->save("Emails");
Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Mon May 22 19:00:22 2006
@@ -223,7 +223,7 @@
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
- $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
+ $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
}
if ($parts[$i]->parts) {
$stack[] = array("p" => $parts, "i" => $i);
More information about the vtigercrm-commits
mailing list