Commit c2fe7bf8 authored by Alexandre Morin's avatar Alexandre Morin

Merge branch 'Support/2.4.X' into 'master'

Support/2.4.x master

See merge request !286
parents dcef8a19 738ba413
# CHANGELOG # CHANGELOG
## Version 2.4.4
### IHM
- `Fixed` Retrait de l’affichage des ressources si l'archive est en cours de suppression
### Métadonnées
- `Fixed` Ajout d'un bouton dans la modale de détail de l'archive permettant la conversion unitaire d'un document
- `Fixed` Rétablissement de l'affichage des fichiers convertis et des relations dans la modale de détails de l'archive
- `Changed` Différenciation entre le fichier d'origine et ses conversions dans l'arborescence du plan de classement
### Sécurité
- `Changed` Ajout du paramètre `lifetime` pour le jeton CSRF qui définit la durée de validité des jetons en secondes. Si omis, durée de 1 heure par défaut.
- `Fixed` Jeton CRSF consommé lorsqu'utilisé.
## Version 2.4.3 ## Version 2.4.3
### Métadonnées ### Métadonnées
......
...@@ -64,7 +64,7 @@ class csrf ...@@ -64,7 +64,7 @@ class csrf
return; return;
} }
$requestToken = $this->getRequestToken(); $requestToken = \laabs::getToken("Csrf", LAABS_IN_HEADER);
// Get account with LOCK // Get account with LOCK
$this->sdoFactory->beginTransaction(); $this->sdoFactory->beginTransaction();
...@@ -75,17 +75,19 @@ class csrf ...@@ -75,17 +75,19 @@ class csrf
return; return;
} }
$accountTokens = $account->authentication->csrf; $accountTokens = $account->authentication->csrf;
switch ($userCommand->method) { switch ($userCommand->method) {
case "create": case "create":
case "update": case "update":
case "delete": case "delete":
$requestTokenTime = $this->isValidToken($requestToken, $accountTokens); if (empty($requestToken)) {
throw new \core\Exception('Attempt to access without a valid token 1', 412);
}
$requestTokenTime = $this->checkToken($requestToken, $accountTokens);
$accountTokens = $this->shiftTokens($requestTokenTime, $accountTokens); $accountTokens = $this->shiftTokens($requestTokenTime, $accountTokens);
$accountTokens = $this->addToken($accountTokens); $accountTokens = $this->addToken($accountTokens);
break; break;
...@@ -130,21 +132,9 @@ class csrf ...@@ -130,21 +132,9 @@ class csrf
} }
/** /**
* Retrieves the request csrf token
*
* @return string
*/
private function getRequestToken()
{
$requestToken = \laabs::getToken("Csrf", LAABS_IN_HEADER);
return $requestToken;
}
/**
* Retrieves the account information with a LOCK on database * Retrieves the account information with a LOCK on database
* @param bool $lock Lock user * @param bool $lock Lock user
* *
* @return auth/userAccount * @return auth/userAccount
*/ */
private function getAccount($lock = false) private function getAccount($lock = false)
...@@ -171,10 +161,28 @@ class csrf ...@@ -171,10 +161,28 @@ class csrf
if (!is_object($account->authentication->csrf)) { if (!is_object($account->authentication->csrf)) {
$account->authentication->csrf = []; $account->authentication->csrf = [];
} else { return $account;
$account->authentication->csrf = get_object_vars($account->authentication->csrf); }
$account->authentication->csrf = get_object_vars($account->authentication->csrf);
$lifetime = '3600';
if (isset($this->config['lifetime'])) {
$lifetime = $this->config['lifetime'];
}
$duration = \laabs::newDuration('PT'.$lifetime.'S');
$now = \laabs::newTimestamp();
foreach ($account->authentication->csrf as $time => $token) {
$timestamp = \laabs::newTimestamp($time);
$expiration = $timestamp->add($duration);
if ($now->diff($expiration)->invert == 1) {
unset($account->authentication->csrf[$time]);
}
} }
return $account; return $account;
} }
...@@ -214,16 +222,8 @@ class csrf ...@@ -214,16 +222,8 @@ class csrf
return end($accountTokens); return end($accountTokens);
} }
private function isValidToken($requestToken, $accountTokens) private function checkToken($requestToken, $accountTokens)
{ {
if (empty($requestToken)) {
$e = new \core\Exception('Attempt to access without a valid token', 412);
throw $e;
return false;
}
$requestTokenTime = array_search($requestToken, $accountTokens); $requestTokenTime = array_search($requestToken, $accountTokens);
if (empty($requestTokenTime)) { if (empty($requestTokenTime)) {
...@@ -240,7 +240,7 @@ class csrf ...@@ -240,7 +240,7 @@ class csrf
private function shiftTokens($requestTokenTime, $accountTokens) private function shiftTokens($requestTokenTime, $accountTokens)
{ {
foreach ($accountTokens as $time => $token) { foreach ($accountTokens as $time => $token) {
if ($time < $requestTokenTime) { if ($time <= $requestTokenTime) {
unset($accountTokens[$time]); unset($accountTokens[$time]);
} }
} }
......
...@@ -168,7 +168,7 @@ class archive ...@@ -168,7 +168,7 @@ class archive
} else { } else {
$archive->hasRights = $archiveController->checkRights($archive); $archive->hasRights = $archiveController->checkRights($archive);
} }
} catch(\Exception $e) { } catch (\Exception $e) {
$archive->hasRights = false; $archive->hasRights = false;
} }
} }
...@@ -230,7 +230,7 @@ class archive ...@@ -230,7 +230,7 @@ class archive
{ {
$this->view->addContentFile("recordsManagement/archive/archiveInfo/archiveInfo.html"); $this->view->addContentFile("recordsManagement/archive/archiveInfo/archiveInfo.html");
// Managment metadata // Management metadata
$this->setManagementMetadatas($archive); $this->setManagementMetadatas($archive);
// Descriptive metadata // Descriptive metadata
...@@ -254,7 +254,7 @@ class archive ...@@ -254,7 +254,7 @@ class archive
$this->view->translate(); $this->view->translate();
$this->view->merge(); $this->view->merge();
return $this->view->saveHtml(); return $this->view->saveHtml();
} }
...@@ -289,7 +289,6 @@ class archive ...@@ -289,7 +289,6 @@ class archive
$this->view->translate(); $this->view->translate();
$this->view->merge(); $this->view->merge();
return $this->view->saveHtml(); return $this->view->saveHtml();
} }
...@@ -342,7 +341,7 @@ class archive ...@@ -342,7 +341,7 @@ class archive
$this->view->translate(); $this->view->translate();
$this->view->merge(); $this->view->merge();
return $this->view->saveHtml(); return $this->view->saveHtml();
} }
...@@ -656,7 +655,7 @@ class archive ...@@ -656,7 +655,7 @@ class archive
if ($result == false) { if ($result == false) {
$count = 0; $count = 0;
} else { } else {
$count = count($result); $count = 1;
} }
$this->json->message = '%1$s document(s) converted.'; $this->json->message = '%1$s document(s) converted.';
$this->json->message = $this->translator->getText($this->json->message); $this->json->message = $this->translator->getText($this->json->message);
...@@ -1227,22 +1226,22 @@ class archive ...@@ -1227,22 +1226,22 @@ class archive
protected function setDigitalResources($archive) protected function setDigitalResources($archive)
{ {
if ($archive->status == "disposed") { if ($archive->status == "disposed" || $archive->status == "restituted" || $archive->status == "transfered") {
$archive->digitalResources = null; $archive->digitalResources = null;
} elseif (isset($archive->digitalResources)) { } elseif (isset($archive->digitalResources)) {
foreach ($archive->digitalResources as $key => $digitalResource) { foreach ($archive->digitalResources as $key => $digitalResource) {
$archive->digitalResources[$key]->json = json_encode($digitalResource);
$digitalResource->isConvertible = \laabs::callService("digitalResource/digitalResource/updateIsconvertible", $digitalResource); $digitalResource->isConvertible = \laabs::callService("digitalResource/digitalResource/updateIsconvertible", $digitalResource);
if (!isset($digitalResource->relatedResource)) { if (!isset($digitalResource->relatedResource)) {
$digitalResource->relatedResource = []; $digitalResource->relatedResource = [];
continue; } else {
} foreach ($digitalResource->relatedResource as $relatedResource) {
$relatedResource->isConvertible = \laabs::callService("digitalResource/digitalResource/updateIsconvertible", $relatedResource);
foreach ($digitalResource->relatedResource as $relatedResource) { $relatedResource->relationshipType = $this->view->translator->getText($relatedResource->relationshipType, "relationship", "recordsManagement/messages");
$relatedResource->isConvertible = \laabs::callService("digitalResource/digitalResource/updateIsconvertible", $relatedResource); }
$relatedResource->relationshipType = $this->view->translator->getText($relatedResource->relationshipType, "relationship", "recordsManagement/messages");
} }
$archive->digitalResources[$key]->json = json_encode($digitalResource);
} }
} }
} }
......
...@@ -843,10 +843,6 @@ msgid "isTimestampOf" ...@@ -843,10 +843,6 @@ msgid "isTimestampOf"
msgstr "Jeton d'horodatage" msgstr "Jeton d'horodatage"
msgctxt "relationship" msgctxt "relationship"
msgid "isConversionOf"
msgstr "Document converti"
msgctxt "relationship"
msgid "Indexing modification" msgid "Indexing modification"
msgstr "Modification de l'index" msgstr "Modification de l'index"
......
<li class="document" data-archive-id="[?merge .archiveId ?]" data-res-id="[?merge .resId ?]" data-json="[?merge .json ?]"> <li class="document" data-archive-id="[?merge .archiveId ?]" data-res-id="[?merge .resId ?]" data-json="[?merge .json ?]">
<span class=""> <span class="">
<small class="documentName"><i class="fa fa-file">&nbsp;</i><?merge .fileName ?></small> <?merge .relationshipType.ifeq('isConversionOf') ?><i class="fa" data-closed-icon="none" data-opened-icon="none">&nbsp;</i>
<?merge .relatedResource.bool() ?><i class="fa" data-closed-icon="fa-caret-right" data-opened-icon="fa-caret-down">&nbsp;</i>
<small class="documentName">
<?merge .relationshipType.ifeq('isConversionOf') ?><i class="fa fa-files-o fa-fw">&nbsp;</i>
<?merge .relationshipType.bool().not() ?><i class="fa fa-file">&nbsp;</i>
<?merge .fileName ?>
</small>
</span> </span>
<ul> <ul>
<?merge .contents /recordsManagement/archive/archiveTree/archiveContentTemplate.html ?> <?merge .relatedResource /recordsManagement/archive/archiveTree/archiveContentTemplate.html ?>
</ul> </ul>
</li> </li>
\ No newline at end of file
...@@ -34,17 +34,25 @@ ...@@ -34,17 +34,25 @@
selected: null, selected: null,
select: function(e) { select: function(e) {
this.unselect(); this.unselect();
var li = e.closest('li') var li = e.closest('li');
if(e.hasClass('archiveName')) { if(e.hasClass('archiveName')) {
$("#archiveNameH3").text(e.text()); $("#archiveNameH3").text(e.text());
li.children('span').removeClass('node-default').addClass('node-warning'); li.children('span').removeClass('node-default').addClass('node-warning');
trigger("showDetails.archive", li.data('archive-id')); trigger("showDetails.archive", li.data('archive-id'));
this.selected = li; this.selected = li;
}
} else if (e.hasClass('documentName')) { else if (e.hasClass('documentName')) {
e.addClass('node-warning'); // Pour les fichiers convertis, on va récupérer les 'relatedResource' dans le data.json du parent
if (!li.data('json')){
var converted_data = li.parents("li").first().data('json');
$.each(converted_data.relatedResource, function( index, value ) {
if(value.resId == li.data('resId')) {
li.data('json', value);
}
});
}
e.addClass('node-warning').removeClass('node-default');
trigger("showDetails.digitalResource", li.data('json')); trigger("showDetails.digitalResource", li.data('json'));
this.selected = li; this.selected = li;
} }
......
...@@ -17,7 +17,7 @@ var BootstrapTree = { ...@@ -17,7 +17,7 @@ var BootstrapTree = {
.find('.fa:first') .find('.fa:first')
.each(function() { .each(function() {
$(this).addClass($(this).data('closed-icon')); $(this).addClass($(this).data('closed-icon'));
$(this).next().find("i").addClass("fa_folder"); $(this).next().find("i").addClass("fa-folder");
// $(this).next().find("i").addClass("fa-folder").removeClass("fa-folder-o"); // $(this).next().find("i").addClass("fa-folder").removeClass("fa-folder-o");
}); });
......
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