Commit 82bb7959 authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

Merge branch 'fix/ArchiveRestitution' into 'release/2.4'

Fix/archive restitution

See merge request maarch/thirdPartyArchiving!67
parents 3c6a3953 0164085f
......@@ -77,4 +77,28 @@ class archive extends \bundle\recordsManagement\Controller\archive
return $res;
}
/**
* Check if the new status of an archive is possible depending on current status
* @param string $archiveId Identifier of the archives to check
* @param string $status New status to check
*
* @return boolean if the new status is possible on this archive (depends on the current status of the archive)
*/
public function checkStatus($archiveId, $status)
{
$statusList = [];
$statusList['restituable'] = array('preserved', 'restituted', 'disposed');
if (!isset($statusList[$status])) {
return false;
}
$archive = $this->sdoFactory->read('recordsManagement/archiveStatus', $archiveId);
if (!in_array($archive->status, $statusList[$status])) {
return false;
}
return true;
}
}
......@@ -71,17 +71,23 @@ class archiveModification
} else {
$success = count($result['success']);
$echec = count($result['error']);
$this->json->message='';
$this->json->message = '%1$s archive(s) flagged for restitution.';
$this->json->message = $this->translator->getText($this->json->message);
$this->json->message = sprintf($this->json->message, $success);
if ($success > 0) {
$this->json->message = '%1$s archive(s) flagged for restitution.';
$this->json->message = $this->translator->getText($this->json->message);
$this->json->message = sprintf($this->json->message, $success);
}
if ($echec > 0) {
$message = '%1$s archive(s) can not be flagged.';
if ($success > 0) {
$this->json->message .= '<br>';
}
$message = '%1$s archive(s) can not be flagged because an action is already in progress on this(these) archive(s) (or on one of its/their objects).';
$message = $this->translator->getText($message);
$message = sprintf($message, $echec);
$this->json->message .= ' '.$message;
$this->json->message .= $message;
}
}
......
Markdown is supported
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