diff --git a/application/utils.inc.php b/application/utils.inc.php index 3447e67f2..b2597efc6 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -153,8 +153,11 @@ class utils { $iDefault = 0; } - $iCurrent = self::ReadParam('with-archive', $iDefault, true); + // Read and record the value for switching the archive mode + $iCurrent = self::ReadParam('with-archive', $iDefault); $_SESSION['archive_mode'] = $iCurrent; + // Read and use the value for the current page (web services) + $iCurrent = self::ReadParam('with_archive', $iCurrent, true); self::$bPageMode = ($iCurrent == 1); } diff --git a/webservices/export-v2.php b/webservices/export-v2.php index 4dffddef9..4e1c4967c 100644 --- a/webservices/export-v2.php +++ b/webservices/export-v2.php @@ -1,5 +1,5 @@ p(" * expression: an OQL expression (e.g. SELECT Contact WHERE name LIKE 'm%')"); $oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook"); + if (Utils::IsModeCLI()) + { + $oP->p(" * with_archive: (optional, defaults to 0) if set to 1 then the result set will include archived objects"); + } + else + { + $oP->p(" * with_archive: (optional, defaults to the current mode) if set to 1 then the result set will include archived objects"); + } $oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'"); $aSupportedFormats = BulkExport::FindSupportedFormats(); $oP->p(" * format: (optional, default is html) the desired output format. Can be one of '".implode("', '", array_keys($aSupportedFormats))."'"); @@ -430,13 +438,19 @@ EOF * @param string $sExpression The OQL query to export or null * @param string $sQueryId The entry in the query phrasebook if $sExpression is null * @param string $sFormat The code of export format: csv, pdf, html, xlsx + * @param boolean $bWithArchive * @throws MissingQueryArgument * @return Ambigous */ function CheckParameters($sExpression, $sQueryId, $sFormat) { - $oExporter = null; - + $oExporter = null; + + if (utils::IsArchiveMode() && !UserRights::CanBrowseArchive()) + { + ReportErrorAndExit("The user account is not authorized to access the archives"); + } + if (($sExpression === null) && ($sQueryId === null)) { ReportErrorAndUsage("Missing parameter. The parameter 'expression' or 'query' must be specified."); @@ -485,7 +499,7 @@ function CheckParameters($sExpression, $sQueryId, $sFormat) } } $oSearch->SetInternalParams($aArgs); - + $sFormat = utils::ReadParam('format', 'html', true /* Allow CLI */, 'raw_data'); $oExporter = BulkExport::FindExporter($sFormat, $oSearch); if ($oExporter == null) @@ -588,7 +602,11 @@ if (utils::IsModeCLI()) $sExpression = utils::ReadParam('expression', null, true /* Allow CLI */, 'raw_data'); $sQueryId = utils::ReadParam('query', null, true /* Allow CLI */, 'raw_data'); $bLocalize = (utils::ReadParam('no_localize', 0) != 1); - + if (utils::IsArchiveMode() && !UserRights::CanBrowseArchive()) + { + ReportErrorAndExit("The user account is not authorized to access the archives"); + } + if (($sExpression == null) && ($sQueryId == null)) { ReportErrorAndUsage("Missing parameter. At least one of '--expression' or '--query' must be specified."); diff --git a/webservices/export.php b/webservices/export.php index 3c6a721b7..996038623 100644 --- a/webservices/export.php +++ b/webservices/export.php @@ -1,5 +1,5 @@ p("The user account is not authorized to access the archives"); + $oP->output(); + exit -1; +} + $bLocalize = (utils::ReadParam('no_localize', 0) != 1); $sFileName = utils::ReadParam('filename', '', true, 'string'); @@ -336,6 +344,14 @@ if (!$oP) $oP->p("Parameters:"); $oP->p(" * expression: an OQL expression (URL encoded if needed)"); $oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook"); + if (Utils::IsModeCLI()) + { + $oP->p(" * with_archive: (optional, defaults to 0) if set to 1 then the result set will include archived objects"); + } + else + { + $oP->p(" * with_archive: (optional, defaults to the current mode) if set to 1 then the result set will include archived objects"); + } $oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'"); $oP->p(" * format: (optional, default is html) the desired output format. Can be one of 'html', 'spreadsheet', 'csv', 'xlsx' or 'xml'"); $oP->p(" * fields: (optional, no effect on XML format) list of fields (attribute codes, or alias.attcode) separated by a coma");