[Vtigercrm-commits] [vtiger-commits] r6300 - /vtigercrm/trunk/modules/Webmails/Save.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Mon May 22 21:23:02 EDT 2006


Author: mmbrich
Date: Mon May 22 19:23:01 2006
New Revision: 6300

Log:
add attachments to already related contacts

Modified:
    vtigercrm/trunk/modules/Webmails/Save.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:23:01 2006
@@ -76,6 +76,9 @@
 if($email->relationship != 0)
 {
 	$focus->column_fields['parent_id']=$email->relationship["id"].'@'.$fieldid.'|';
+
+	if($email->relationship["type"] == "Contacts")
+		add_attachment_to_contact($email->relationship["id"],$email);
 }else
 {
 	//if relationship is not available create a contact and relate the email to the contact
@@ -86,7 +89,12 @@
 	$contact_focus->save("Contacts");
 	$focus->column_fields['parent_id']=$contact_focus->id.'@'.$fieldid.'|';
 
+	add_attachment_to_contact($contact_focus->id,$email);
+}
+
+function add_attachment_to_contact($cid,$email) {
 	// add attachments to contact
+	global $adb,$current_user;
 	
 	$attachments=$email->downloadAttachments();
 	$upload_filepath = decideFilePath();
@@ -104,10 +112,11 @@
 
                 $sql = "insert into attachments values(";
                 $sql .= $current_id.",'".$filename."','Uploaded ".$filename." from webmail','".$filetype."','".$upload_filepath."')";
+		echo $query;
                 $result = $adb->query($sql);
 
                 $sql1 = "insert into seattachmentsrel values('";
-                $sql1 .= $contact_focus->id."','".$current_id."')";
+                $sql1 .= $cid."','".$current_id."')";
                 $result = $adb->query($sql1);
 
 		$fp = fopen($upload_filepath.'/'.$filename, "w") or die("Can't open file");
@@ -115,6 +124,7 @@
 		fclose($fp);
 	}
 }
+
 $_REQUEST['parent_id'] = $focus->column_fields['parent_id'];
 $focus->save("Emails");
 





More information about the vtigercrm-commits mailing list