[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 * The contents of this file are subject to the SugarCRM Public License Version 1.1.2 4 * ("License"); You may not use this file except in compliance with the 5 * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL 6 * Software distributed under the License is distributed on an "AS IS" basis, 7 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 8 * the specific language governing rights and limitations under the License. 9 * The Original Code is: SugarCRM Open Source 10 * The Initial Developer of the Original Code is SugarCRM, Inc. 11 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.; 12 * All Rights Reserved. 13 * Contributor(s): ______________________________________. 14 ********************************************************************************/ 15 16 if (substr(phpversion(), 0, 1) == "5") { 17 ini_set("zend.ze1_compatibility_mode", "1"); 18 } 19 20 require_once ('config.php'); 21 require_once ('include/logging.php'); 22 require_once ('include/database/PearDatabase.php'); 23 require_once ('modules/Accounts/Accounts.php'); 24 require_once ('modules/Contacts/Contacts.php'); 25 require_once ('modules/Leads/Leads.php'); 26 require_once ('modules/Contacts/Contacts.php'); 27 require_once ('modules/Emails/Emails.php'); 28 require_once ('modules/Calendar/Activity.php'); 29 require_once ('modules/Notes/Notes.php'); 30 require_once ('modules/Potentials/Potentials.php'); 31 require_once ('modules/Users/Users.php'); 32 require_once ('modules/Products/Products.php'); 33 require_once ('include/utils/UserInfoUtil.php'); 34 35 global $allow_exports; 36 37 session_start(); 38 39 $current_user = new Users(); 40 41 if(isset($_SESSION['authenticated_user_id'])) 42 { 43 $result = $current_user->retrieve_entity_info($_SESSION['authenticated_user_id'],"users"); 44 if($result == null) 45 { 46 session_destroy(); 47 header("Location: index.php?action=Login&module=Users"); 48 } 49 50 } 51 52 //Security Check 53 if(isPermitted($_REQUEST['module'],"Export") == "no") 54 { 55 $allow_exports="none"; 56 } 57 58 if ($allow_exports=='none' || ( $allow_exports=='admin' && ! is_admin($current_user) ) ) 59 { 60 61 ?> 62 <script language=javascript> 63 alert("you are not permitted to export!"); 64 window.location="index.php?module=<?php echo $_REQUEST['module'] ?>&action=index"; 65 </script> 66 <?php 67 } 68 69 /**Function convert line breaks to space in description during export 70 * Pram $str - text 71 * retrun type string 72 */ 73 function br2nl_vt($str) 74 { 75 global $log; 76 $log->debug("Entering br2nl_vt(".$str.") method ..."); 77 $str = preg_replace("/(\r\n)/", " ", $str); 78 $log->debug("Exiting br2nl_vt method ..."); 79 return $str; 80 } 81 82 /**This function exports all the data for a given module 83 * Param $type - module name 84 * Return type text 85 */ 86 function export_all($type) 87 { 88 global $log; 89 $log->debug("Entering export_all(".$type.") method ..."); 90 global $adb; 91 92 $focus = 0; 93 $content = ''; 94 95 if ($type != "") 96 { 97 $focus = new $type; 98 } 99 100 $log = LoggerManager::getLogger('export_'.$type); 101 $db = new PearDatabase(); 102 103 if ( isset($_REQUEST['all']) ) 104 { 105 $where = ''; 106 } 107 else 108 { 109 $where = $_SESSION['export_where']; 110 } 111 112 $order_by = ""; 113 114 $query = $focus->create_export_query($order_by,$where); 115 116 117 $result = $adb->query($query,true,"Error exporting $type: "."<BR>$query"); 118 119 $fields_array = $adb->getFieldsArray($result); 120 121 $header = implode("\",\"",array_values($fields_array)); 122 $header = "\"" .$header; 123 $header .= "\"\r\n"; 124 $content .= $header; 125 126 $column_list = implode(",",array_values($fields_array)); 127 128 while($val = $adb->fetchByAssoc($result, -1, false)) 129 { 130 $new_arr = array(); 131 132 foreach ($val as $key => $value) 133 { 134 if($key=="description") 135 { 136 $value=br2nl_vt($value); 137 } 138 array_push($new_arr, preg_replace("/\"/","\"\"",$value)); 139 } 140 $line = implode("\",\"",$new_arr); 141 $line = "\"" .$line; 142 $line .= "\"\r\n"; 143 $content .= $line; 144 } 145 $log->debug("Exiting export_all method ..."); 146 return $content; 147 148 } 149 150 $content = export_all($_REQUEST['module']); 151 152 header("Content-Disposition: attachment; filename={$_REQUEST['module']}.csv"); 153 header("Content-Type: text/csv; charset=UTF-8"); 154 header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 155 header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); 156 header( "Cache-Control: post-check=0, pre-check=0", false ); 157 header("Content-Length: ".strlen($content)); 158 print $content; 159 160 exit; 161 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |