1
|
|
|
<?php |
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
3
|
|
|
/********************************************************************************* |
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
6
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
20
|
|
|
* details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25
|
|
|
* 02110-1301 USA. |
26
|
|
|
* |
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
29
|
|
|
* |
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
33
|
|
|
* |
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39
|
|
|
********************************************************************************/ |
40
|
|
|
|
41
|
|
|
//Bug 30094, If zlib is enabled, it can break the calls to header() due to output buffering. This will only work php5.2+ |
42
|
|
|
ini_set('zlib.output_compression', 'Off'); |
43
|
|
|
|
44
|
|
|
ob_start(); |
45
|
|
|
require_once('include/export_utils.php'); |
46
|
|
|
global $sugar_config; |
47
|
|
|
global $locale; |
48
|
|
|
global $current_user; |
49
|
|
|
global $app_list_strings; |
50
|
|
|
|
51
|
|
|
$the_module = clean_string($_REQUEST['module']); |
52
|
|
|
|
53
|
|
|
if($sugar_config['disable_export'] || (!empty($sugar_config['admin_export_only']) && !(is_admin($current_user) || (ACLController::moduleSupportsACL($the_module) && ACLAction::getUserAccessLevel($current_user->id,$the_module, 'access') == ACL_ALLOW_ENABLED && |
|
|
|
|
54
|
|
|
(ACLAction::getUserAccessLevel($current_user->id, $the_module, 'admin') == ACL_ALLOW_ADMIN || |
|
|
|
|
55
|
|
|
ACLAction::getUserAccessLevel($current_user->id, $the_module, 'admin') == ACL_ALLOW_ADMIN_DEV))))){ |
|
|
|
|
56
|
|
|
die($GLOBALS['app_strings']['ERR_EXPORT_DISABLED']); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
//check to see if this is a request for a sample or for a regular export |
60
|
|
|
if(!empty($_REQUEST['sample'])){ |
61
|
|
|
//call special method that will create dummy data for bean as well as insert standard help message. |
62
|
|
|
$content = exportSample(clean_string($_REQUEST['module'])); |
63
|
|
|
|
64
|
|
|
}else if(!empty($_REQUEST['uid'])){ |
65
|
|
|
$content = export(clean_string($_REQUEST['module']), $_REQUEST['uid'], isset($_REQUEST['members']) ? $_REQUEST['members'] : false); |
66
|
|
|
}else{ |
67
|
|
|
$content = export(clean_string($_REQUEST['module'])); |
68
|
|
|
} |
69
|
|
|
$filename = $_REQUEST['module']; |
70
|
|
|
//use label if one is defined |
71
|
|
|
if(!empty($app_list_strings['moduleList'][$_REQUEST['module']])){ |
72
|
|
|
$filename = $app_list_strings['moduleList'][$_REQUEST['module']]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
//strip away any blank spaces |
76
|
|
|
$filename = str_replace(' ','',$filename); |
77
|
|
|
|
78
|
|
|
$transContent = $GLOBALS['locale']->translateCharset($content, 'UTF-8', $GLOBALS['locale']->getExportCharset()); |
79
|
|
|
|
80
|
|
|
if($_REQUEST['members'] == true) |
81
|
|
|
$filename .= '_'.'members'; |
82
|
|
|
/////////////////////////////////////////////////////////////////////////////// |
83
|
|
|
//// BUILD THE EXPORT FILE |
84
|
|
|
ob_clean(); |
85
|
|
|
header("Pragma: cache"); |
86
|
|
|
header("Content-type: application/octet-stream; charset=".$GLOBALS['locale']->getExportCharset()); |
87
|
|
|
header("Content-Disposition: attachment; filename={$filename}.csv"); |
88
|
|
|
header("Content-transfer-encoding: binary"); |
89
|
|
|
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); |
90
|
|
|
header("Last-Modified: " . TimeDate::httpTime() ); |
91
|
|
|
header("Cache-Control: post-check=0, pre-check=0", false ); |
92
|
|
|
if (!empty($sugar_config['export_excel_compatible'])) { |
93
|
|
|
$transContent=chr(255) . chr(254) . mb_convert_encoding($transContent, 'UTF-16LE', 'UTF-8'); |
94
|
|
|
} |
95
|
|
|
header("Content-Length: ".mb_strlen($transContent, '8bit')); |
96
|
|
|
print $transContent; |
97
|
|
|
|
98
|
|
|
sugar_cleanup(true); |
99
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.