mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 01:28:47 +02:00
Export bug fixes:
- Properly handle on utf-8 CSV exports - Allow non administrators to run the export in interactive mode (since it is used by the "Export..." actions) SVN:trunk[3723]
This commit is contained in:
@@ -356,6 +356,10 @@ abstract class BulkExport
|
||||
{
|
||||
|
||||
}
|
||||
public function GetCharacterSet()
|
||||
{
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
public function GetStatistics()
|
||||
{
|
||||
|
||||
@@ -302,5 +302,9 @@ class CSVBulkExport extends TabularBulkExport
|
||||
{
|
||||
return 'csv';
|
||||
}
|
||||
public function GetCharacterSet()
|
||||
{
|
||||
return $this->aStatusInfo['charset'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2122,7 +2122,16 @@ EOF
|
||||
$aResult['token'] = $oExporter->SaveState();
|
||||
if (substr($oExporter->GetMimeType(), 0, 5) == 'text/')
|
||||
{
|
||||
$aResult['text_result'] = file_get_contents($oExporter->GetTmpFilePath());
|
||||
// Result must be encoded in UTF-8 to be passed as part of a JSON structure
|
||||
$sCharset = $oExporter->GetCharacterSet();
|
||||
if (strtoupper($sCharset) != 'UTF-8')
|
||||
{
|
||||
$aResult['text_result'] = iconv($sCharset, 'UTF-8', file_get_contents($oExporter->GetTmpFilePath()));
|
||||
}
|
||||
else
|
||||
{
|
||||
$aResult['text_result'] = file_get_contents($oExporter->GetTmpFilePath());
|
||||
}
|
||||
$aResult['mime_type'] = $oExporter->GetMimeType();
|
||||
}
|
||||
$aResult['message'] = Dict::Format('Core:BulkExport:ClickHereToDownload_FileName', $oExporter->GetDownloadFileName());
|
||||
@@ -2152,7 +2161,7 @@ EOF
|
||||
$sMimeType = $oExporter->GetMimeType();
|
||||
if (substr($sMimeType, 0, 5) == 'text/')
|
||||
{
|
||||
$sMimeType .= ';charset=utf-8';
|
||||
$sMimeType .= ';charset='.strtolower($oExporter->GetCharacterSet());
|
||||
}
|
||||
$oPage->SetContentType($sMimeType);
|
||||
$oPage->SetContentDisposition('attachment', $oExporter->GetDownloadFileName());
|
||||
|
||||
@@ -506,7 +506,12 @@ function DoExport(WebPage $oP, BulkExport $oExporter, $bInteractive = false)
|
||||
else
|
||||
{
|
||||
$exportResult .= $oExporter->GetFooter();
|
||||
$oP->SetContentType($oExporter->GetMimeType());
|
||||
$sMimeType = $oExporter->GetMimeType();
|
||||
if (substr($sMimeType, 0, 5) == 'text/')
|
||||
{
|
||||
$sMimeType .= ';charset='.strtolower($oExporter->GetCharacterSet());
|
||||
}
|
||||
$oP->SetContentType($sMimeType);
|
||||
$oP->SetContentDisposition('attachment', $oExporter->GetDownloadFileName());
|
||||
$oP->add($exportResult);
|
||||
$oExporter->Cleanup();
|
||||
@@ -661,8 +666,7 @@ try
|
||||
$bInteractive = utils::ReadParam('interactive', false);
|
||||
$sMode = utils::ReadParam('mode', '');
|
||||
|
||||
$bMustBeAdmin = $bInteractive;
|
||||
LoginWebPage::DoLogin($bMustBeAdmin); // Check user rights and prompt if needed
|
||||
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
ApplicationContext::SetUrlMakerClass('iTopStandardURLMaker');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user