[Vtigercrm-commits] [vtiger-commits] r10686 - /vtigercrm/branches/5.0.3/soap/customerportal.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Sat Apr 14 04:06:38 EDT 2007


Author: richie
Date: Sat Apr 14 02:06:33 2007
New Revision: 10686

Log:
* Modified the file download process ie., previously we stored the filecontents in the session so that when click on a file we simply display the content from session. This will save transaction time to server. But now we get the content from server when we click on file link. In this we can download large files which will not crash browser because of session storage, Fixed #3646

Modified:
    vtigercrm/branches/5.0.3/soap/customerportal.php

Modified: vtigercrm/branches/5.0.3/soap/customerportal.php
==============================================================================
--- vtigercrm/branches/5.0.3/soap/customerportal.php (original)
+++ vtigercrm/branches/5.0.3/soap/customerportal.php Sat Apr 14 02:06:33 2007
@@ -165,6 +165,17 @@
              )
 );
 
+//Added to return the file content
+$server->wsdl->addComplexType(
+        'get_filecontent_array',
+        'complexType',
+        'array',
+        '',
+        array(
+		'fileid'=>'xsd:string','type'=>'tns:xsd:string',
+             )
+);
+
 $server->wsdl->addComplexType(
         'add_ticket_attachment_array',
         'complexType',
@@ -274,6 +285,12 @@
 	'get_ticket_attachments',
 	array('id'=>'xsd:string','ticketid'=>'xsd:string'),
 	array('return'=>'tns:get_ticket_attachments_array'),
+	$NAMESPACE);
+
+$server->register(
+	'get_filecontent',
+	array('id'=>'xsd:string','fileid'=>'xsd:string','filename'=>'xsd:string'),
+	array('return'=>'tns:get_filecontent_array'),
 	$NAMESPACE);
 
 $server->register(
@@ -806,16 +823,43 @@
 		$filesize = filesize($filepath.$fileid."_".$filename);
 		$filetype = $adb->query_result($res,$i,'type');
 
-		$filecontents = base64_encode(file_get_contents($filepath.$fileid."_".$filename));//fread(fopen($filepath.$filename, "r"), $filesize));
+		//Now we will not pass the file content to CP, when the customer click on the link we will retrieve
+		//$filecontents = base64_encode(file_get_contents($filepath.$fileid."_".$filename));//fread(fopen($filepath.$filename, "r"), $filesize));
 
 		$output[$i]['fileid'] = $fileid;
 		$output[$i]['filename'] = $filename;
 		$output[$i]['filetype'] = $filetype;
 		$output[$i]['filesize'] = $filesize;
-		$output[$i]['filecontents'] = $filecontents;
+		//$output[$i]['filecontents'] = $filecontents;
 	}
 
 	return $output;
+}
+
+/**	function used to get the contents of a file
+ *	@param int $contactid - customer ie., contact id 
+ *	@param int $fileid - id of the file to which we want contents
+ *	@param string $filename - name of the file to which we want contents
+ *	return $filecontents array with single file contents like [fileid] => filecontent
+ */
+function get_filecontent($contactid, $fileid, $filename)
+{
+	global $adb;
+	$query = "select vtiger_attachments.path from vtiger_troubletickets 
+		inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid = vtiger_troubletickets.ticketid 
+		inner join vtiger_attachments on vtiger_attachments.attachmentsid = vtiger_seattachmentsrel.attachmentsid 
+		where 	vtiger_troubletickets.parent_id= $contactid and 
+			vtiger_attachments.attachmentsid= $fileid and 
+			vtiger_attachments.name='$filename'";
+	$res = $adb->query($query);
+
+	if($adb->num_rows($res)>0)
+	{
+		$filenamewithpath = $adb->query_result($res,0,'path').$fileid."_".$filename;
+		$filecontents[$fileid] = base64_encode(file_get_contents($filenamewithpath));
+		$adb->println("Going to return the content of the file ==> $filenamewithpath");
+	}
+	return $filecontents;
 }
 
 /**	function to add attachment for a ticket ie., the passed contents will be write in a file and the details will be stored in database





More information about the vtigercrm-commits mailing list