[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /*+*********************************************************************************** 3 * The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 *************************************************************************************/ 10 11 class Emails_DownloadFile_Action extends Vtiger_Action_Controller { 12 13 public function checkPermission(Vtiger_Request $request) { 14 $moduleName = $request->getModule(); 15 16 if(!Users_Privileges_Model::isPermitted($moduleName, 'DetailView', $request->get('record'))) { 17 throw new AppException(vtranslate('LBL_PERMISSION_DENIED', $moduleName)); 18 } 19 } 20 21 public function process(Vtiger_Request $request) { 22 $db = PearDatabase::getInstance(); 23 24 $attachmentId = $request->get('attachment_id'); 25 $query = "SELECT * FROM vtiger_attachments WHERE attachmentsid = ?" ; 26 $result = $db->pquery($query, array($attachmentId)); 27 28 if($db->num_rows($result) == 1) 29 { 30 $row = $db->fetchByAssoc($result, 0); 31 $fileType = $row["type"]; 32 $name = $row["name"]; 33 $filepath = $row["path"]; 34 $name = decode_html($name); 35 $saved_filename = $attachmentId."_".$name; 36 $disk_file_size = filesize($filepath.$saved_filename); 37 $filesize = $disk_file_size + ($disk_file_size % 1024); 38 $fileContent = fread(fopen($filepath.$saved_filename, "r"), $filesize); 39 40 header("Content-type: $fileType"); 41 header("Pragma: public"); 42 header("Cache-Control: private"); 43 header("Content-Disposition: attachment; filename=$name"); 44 header("Content-Description: PHP Generated Data"); 45 echo $fileContent; 46 } 47 } 48 } 49 50 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |