diff --git a/pages/audit.php b/pages/audit.php
index e737b1c18..1c9336ef7 100644
--- a/pages/audit.php
+++ b/pages/audit.php
@@ -158,6 +158,30 @@ try
switch($operation)
{
+ case 'csv':
+ // Big result sets cause long OQL that cannot be passed (serialized) as a GET parameter
+ // Therefore we don't use the standard "search_oql" operation of UI.php to display the CSV
+ $iCategory = utils::ReadParam('category', '');
+ $iRuleIndex = utils::ReadParam('rule', 0);
+
+ $oAuditCategory = MetaModel::GetObject('AuditCategory', $iCategory);
+ $oDefinitionFilter = DBObjectSearch::FromOQL($oAuditCategory->Get('definition_set'));
+ FilterByContext($oDefinitionFilter, $oAppContext);
+ $oDefinitionSet = new CMDBObjectSet($oDefinitionFilter);
+ $oFilter = GetRuleResultFilter($iRuleIndex, $oDefinitionFilter, $oAppContext);
+ $oErrorObjectSet = new CMDBObjectSet($oFilter);
+ $oAuditRule = MetaModel::GetObject('AuditRule', $iRuleIndex);
+ $oP->add('
');
+ $oP->p('[Back to audit results]');
+ $sBlockId = 'audit_errors';
+ $oP->p("\n");
+ $oBlock = DisplayBlock::FromObjectSet($oErrorObjectSet, 'csv');
+ $oBlock->Display($oP, 1);
+ $oP->p("
\n");
+ // Adjust the size of the Textarea containing the CSV to fit almost all the remaining space
+ $oP->add_ready_script(" $('#1>textarea').height(400);"); // adjust the size of the block
+ break;
+
case 'errors':
$iCategory = utils::ReadParam('category', '');
$iRuleIndex = utils::ReadParam('rule', 0);
@@ -175,7 +199,9 @@ try
$oP->p("\n");
$oBlock = DisplayBlock::FromObjectSet($oErrorObjectSet, 'list');
$oBlock->Display($oP, 1);
- $oP->p("
\n");
+ $oP->p("\n");
+ $sExportUrl = utils::GetAbsoluteUrlAppRoot()."pages/audit.php?operation=csv&category=".$oAuditCategory->GetKey()."&rule=".$oAuditRule->GetKey();
+ $oP->add_ready_script("$('a[href*=\"pages/UI.php?operation=search\"]').attr('href', '".$sExportUrl."')");
break;
case 'audit':
@@ -232,7 +258,7 @@ try
{
$aObjectsWithErrors[$aErrorRow['id']] = true;
}
- $aRow['nb_errors'] = ($iErrorsCount == 0) ? '0' : "GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">$iErrorsCount";
+ $aRow['nb_errors'] = ($iErrorsCount == 0) ? '0' : "GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">$iErrorsCount GetKey()."&rule=".$oAuditRule->GetKey()."&".$oAppContext->GetForLink()."\">(CSV)";
$aRow['percent_ok'] = sprintf('%.2f', 100.0 * (($iCount - $iErrorsCount) / $iCount));
$aRow['class'] = GetReportColor($iCount, $iErrorsCount);
}