Unverified Commit 01cc9777 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : Add limit to search and update conf

parent cc2bd949
Pipeline #8702 failed with stage
......@@ -5,7 +5,7 @@
@include menu.ini
; Default max result in search screens
maxResults = 200
maxResults = 500
; Public archive mode
publicArchives = false
......
......@@ -29,30 +29,31 @@ trait archiveAccessTrait
{
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $processingStatus
* @param bool $checkAccess
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $processingStatus
* @param bool $checkAccess
* @param integer $maxResults
*
* @return recordsManagement/archive[] Array of recordsManagement/archive object
*/
......@@ -80,7 +81,8 @@ trait archiveAccessTrait
$originatingEndDate = null,
$archiverArchiveId = null,
$processingStatus = null,
$checkAccess = true
$checkAccess = true,
$maxResults = null
) {
$accountController = \laabs::newController('auth/userAccount');
$accountController->isAuthorized('user');
......@@ -133,8 +135,9 @@ trait archiveAccessTrait
$searchClasses['recordsManagement/description'] = $this->useDescriptionController('recordsManagement/description');
}
}
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess));
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess, $maxResults));
}
return $archives;
......
......@@ -120,20 +120,21 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
return json_decode($descriptionObject->description);
} catch (\Exception $e) {
}
}
/**
* Search the description objects
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $archiveArgs The search args on archive std properties
* @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $archiveArgs The search args on archive std properties
* @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data
* @param integer $maxResults Max results to display
*
* @return array The result of the research
*/
public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true)
public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true, $maxResults = null)
{
$queryParams = [];
$queryParts = ['(description!=null and text!=null)'];
......@@ -203,7 +204,7 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
$queryString = \laabs\implode(' and ', $queryParts);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, $maxResults);
foreach ($archiveUnits as $archiveUnit) {
if (!empty($archiveUnit->description)) {
......
......@@ -138,15 +138,14 @@ class log implements archiveDescriptionInterface
*
* @return object Array of description objects
*/
public function search($description = null, $text = null, array $args = [])
public function search($description = null, $text = null, array $args = [], $checkAccess = null, $maxResults = null)
{
$archiveController = \laabs::newController('recordsManagement/archive');
$archives = [];
$sortBy = ">fromDate";
$numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults'];
$logs = $this->sdoFactory->find("recordsManagement/log", $description, [], $sortBy, 0, $numberOfResult);
$logs = $this->sdoFactory->find("recordsManagement/log", $description, [], $sortBy, 0, $maxResults);
foreach ($logs as $log) {
try {
$archive = $archiveController->read($log->archiveId);
......@@ -283,7 +282,7 @@ class log implements archiveDescriptionInterface
/**
* Get the last usable journal
* @param string $type The type of journal
* @param string $ownerOrgRegNumber The journal owner organization registration number
* @param string $ownerOrgRegNumber The journal owner organization registration number
*
* @return recordsManagement/log The journal object
*/
......
......@@ -32,28 +32,29 @@ interface archivesInterface
*/
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param integer $maxResults
*
* @action recordsManagement/archive/search
*
......@@ -80,7 +81,8 @@ interface archivesInterface
$depositEndDate = null,
$originatingStartDate = null,
$originatingEndDate = null,
$archiverArchiveId = null
$archiverArchiveId = null,
$maxResults = null
);
/**
......
......@@ -94,6 +94,9 @@ class archive
$deleteDescription = (bool) \laabs::configuration("recordsManagement")['deleteDescription'];
}
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$this->view->setSource("maxResults", $maxResults);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource("emptyRole", $emptyRole);
$this->view->setSource("profiles", $profiles);
......@@ -198,6 +201,13 @@ class archive
}
}
$hasReachMaxResults = false;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])
&& count($archives) >= \laabs::configuration('presentation.maarchRM')['maxResults']) {
$hasReachMaxResults = true;
}
$dataTable = $this->view->getElementsByClass("dataTable")->item(0)->plugin['dataTable'];
$dataTable->setPaginationType("full_numbers");
......@@ -210,6 +220,8 @@ class archive
$this->readPrivilegesOnArchives();
$this->view->setSource('hasReachMaxResults', $hasReachMaxResults);
$this->view->setSource('maxResults', \laabs::configuration('presentation.maarchRM')['maxResults']);
$this->view->setSource("accessRules", $accessRules);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource('archive', $archives);
......@@ -424,7 +436,7 @@ class archive
$thesaurusList->function = "T2";
$conf = \laabs::Configuration()['recordsManagement'];
if (isset($conf['refDirectory']) || is_dir($conf['refDirectory'])) {
$refDirectory = $conf['refDirectory'];
foreach ($thesaurusNames as $thesaurusName) {
......
......@@ -762,7 +762,7 @@ msgid "%1$s destruction(s) can not be canceled."
msgstr "%1$s destruction(s) ne sont pas annulée(s)."
msgid "%1$s resource(s) can\'t be deleted."
msgstr "la ressource %1$s ne peut pas être supprimée."
msgstr "la ressource %1$s ne peut pas être supprimée."
msgid "%1$s resource(s) deleted."
msgstr "%1$s ressource(s) supprimée(s)"
......@@ -1099,4 +1099,10 @@ msgid "Click to modify '%1$s'"
msgstr "Cliquer pour modifier '%1$s'"
msgid "* At least one field must be filled in."
msgstr "* Au moins un champ doit être renseigné."
\ No newline at end of file
msgstr "* Au moins un champ doit être renseigné."
msgid "Your query returns too much results, only first"
msgstr "Votre recherche a retourné trop de résultats, seulement les"
msgid "results are displayed"
msgstr "premiers sont affichés"
......@@ -4,6 +4,8 @@
<div class="panel-heading clearfix">
<div class="pull-left">
<h4><?merge archive.count() ?> result(s)</h4>
<?merge hasReachMaxResults ?>
<h4><span>Your query returns too much results, only first</span>&nbsp;<?merge maxResults ?>&nbsp;<span>results are displayed</span></h4>
</div>
<div class="dropdown pull-right">
<button class="btn btn-warning dropdown-toggle" type="button" id="archiveList_actions" data-toggle="dropdown" aria-expanded="true" title="Actions" disabled="disabled">
......@@ -33,10 +35,10 @@
<tr id="[?merge .archiveId ?]" name="[?merge .archiveName ?]" class="[?merge .disposable.bool().then('danger') ?]" data-iscommunicable="[?merge .isCommunicable ?]">
<td>
<?merge .hasRights.bool() ?>
<input type="checkbox"
data-archive-status="[?merge .status ?]"
data-final-disposition='[?merge .finalDisposition ?]'
data-disposable="[?merge .disposable ?]"
<input type="checkbox"
data-archive-status="[?merge .status ?]"
data-final-disposition='[?merge .finalDisposition ?]'
data-disposable="[?merge .disposable ?]"
data-noretention="[?merge .noRetention ?]"
value="[?merge .archiveId ?]"/>
</td>
......
......@@ -18,18 +18,19 @@
<div class="container-fluid" lang="en" data-translate-catalog="recordsManagement/messages">
<?merge emptyRole ?>
<h3><i class="fa fa-times"></i> You have to choose a working organization unit to proceed this action.</h3>
<?merge emptyRole.not() ?>
<?merge emptyRole.not() ?>
<div class="panel-group" id="accordionSearch">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordionSearch" href="#collapseOne" style="cursor:pointer;">
<h4 class="panel-title" style="float:left;">
Search form
Search form
</h4>
<i class="fa fa-caret-down" style="float:right;"></i>
<div style="clear:both;"></div>
</div>
<div id="collapseOne" class="well panel-collapse collapse in" style="margin-bottom: 0px">
<form class="form-horizontal" id="archive_searchForm">
<input type="hidden" name="maxResults" id="maxResults" value="[?merge maxResults ?]"/>
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-3 control-label">Archive identifier</label>
......@@ -274,7 +275,7 @@
function searchFormSerialize() {
var parameters = new Object();
$('#archive_searchForm').find('input[type="text"], input[type="number"], select').each(function(){
$('#archive_searchForm').find('input[type="text"], input[type="hidden"], input[type="number"], select').each(function(){
if(!$(this).hasClass('orgHide')) {
parameters[$(this).attr('name')] = $(this).val();
......
......@@ -57,16 +57,17 @@ interface retrieveInterface
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $description
* @param string $text
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $description
* @param string $text
* @param integer $maxResults
*
* @return recordsManagement/archive/search
* @uses recordsManagement/archives/read
......@@ -81,7 +82,8 @@ interface retrieveInterface
$finalDisposition = null,
$originatorOrgRegNumber = null,
$description = null,
$text = null
$text = null,
$maxResults = null
);
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment