FEAT #11422 TIME 2 folder migration

parent bf4af72d
......@@ -667,12 +667,6 @@ if (!defined('_WORDING')) {
if (!defined('_COLLECTION')) {
define('_COLLECTION', 'Collection');
}
if (!defined('_VIEW_TREE_DOCTYPES')) {
define('_VIEW_TREE_DOCTYPES', 'File plan tree view');
}
if (!defined('_VIEW_TREE_DOCTYPES_DESC')) {
define('_VIEW_TREE_DOCTYPES_DESC', 'See file plan tree view (Folders types, folder, sub-folder, and document types)');
}
/************************* Administration ***********************************/
......@@ -1173,21 +1167,7 @@ if (!defined('_INFOS')) {
}
/************** Manage structure **************/
if (!defined('_ADMIN_ARCHI')) {
define('_ADMIN_ARCHI', 'File plan administration');
}
if (!defined('_MANAGE_STRUCTURE')) {
define('_MANAGE_STRUCTURE', 'Manage the sub-folders');
}
if (!defined('_MANAGE_STRUCTURE_DESC')) {
define('_MANAGE_STRUCTURE_DESC', 'Administer the folders.');
}
if (!defined('_MANAGE_SUBFOLDER')) {
define('_MANAGE_SUBFOLDER', 'Manage the sub-folders');
}
if (!defined('_MANAGE_SUBFOLDER_DESC')) {
define('_MANAGE_SUBFOLDER_DESC', 'Manage the sub-folders inside the folders.');
}
if (!defined('_ARCHITECTURE')) {
define('_ARCHITECTURE', 'File plan');
}
......@@ -3256,9 +3236,6 @@ if (!defined('_WHERE_CLAUSE_TARGET')) {
if (!defined('_WHERE_TARGET')) {
define('_WHERE_TARGET', 'Target');
}
if (!defined('_CLASS_SCHEME')) {
define('_CLASS_SCHEME', 'File plan');
}
if (!defined('_DOCS')) {
define('_DOCS', 'Documents');
}
......
......@@ -659,12 +659,6 @@ if (!defined('_WORDING')) {
if (!defined('_COLLECTION')) {
define('_COLLECTION', 'Collection');
}
if (!defined('_VIEW_TREE_DOCTYPES')) {
define('_VIEW_TREE_DOCTYPES', 'Arborescence du plan de classement');
}
if (!defined('_VIEW_TREE_DOCTYPES_DESC')) {
define('_VIEW_TREE_DOCTYPES_DESC', "Voir l'arborescence du plan de classement (types de dossiers, chemises, sous-chemises et types de document)");
}
/************************* Administration ***********************************/
......@@ -1174,21 +1168,6 @@ if (!defined('_INFOS')) {
}
/************** Admin de l'architecture (plan de classement) **************/
if (!defined('_ADMIN_ARCHI')) {
define('_ADMIN_ARCHI', 'Administration du plan de classement');
}
if (!defined('_MANAGE_STRUCTURE')) {
define('_MANAGE_STRUCTURE', 'Gérer les chemises');
}
if (!defined('_MANAGE_STRUCTURE_DESC')) {
define('_MANAGE_STRUCTURE_DESC', "Administrer les chemises. Celles-ci constituent l'élément le plus haut du plan de classement. Si le module Folder est connecté, vous pouvez associer un type de dossier à un plan de classement.");
}
if (!defined('_MANAGE_SUBFOLDER')) {
define('_MANAGE_SUBFOLDER', 'Gérer les sous-chemises');
}
if (!defined('_MANAGE_SUBFOLDER_DESC')) {
define('_MANAGE_SUBFOLDER_DESC', "Gérer les sous-chemises à l'intérieur des chemises.");
}
if (!defined('_ARCHITECTURE')) {
define('_ARCHITECTURE', 'Plan de classement');
}
......@@ -3282,9 +3261,6 @@ if (!defined('_WHERE_CLAUSE_TARGET')) {
if (!defined('_WHERE_TARGET')) {
define('_WHERE_TARGET', 'Cible');
}
if (!defined('_CLASS_SCHEME')) {
define('_CLASS_SCHEME', 'Plan de classement');
}
if (!defined('_DOCS')) {
define('_DOCS', 'Documents');
}
......
......@@ -218,8 +218,6 @@ if (!defined('_VIEW_HISTORY2')) { define('_VIEW_HISTORY2', 'Weergave van de gesc
if (!defined('_VIEW_HISTORY_BATCH2')) { define('_VIEW_HISTORY_BATCH2', 'Weergave van de geschiedenis van de batches');}
if (!defined('_WORDING')) { define('_WORDING', 'Omschrijving');}
if (!defined('_COLLECTION')) { define('_COLLECTION', 'Verzameling');}
if (!defined('_VIEW_TREE_DOCTYPES')) { define('_VIEW_TREE_DOCTYPES', 'Boomstructuur van het klasseringsplan');}
if (!defined('_VIEW_TREE_DOCTYPES_DESC')) { define('_VIEW_TREE_DOCTYPES_DESC', 'De boomstructuur van het klasseringsplan (type mappen, submappen en documenttypes) bekijken');}
if (!defined('_GROUPS_LIST')) { define('_GROUPS_LIST', 'Groepslijst');}
if (!defined('_ADMIN_GROUP')) { define('_ADMIN_GROUP', 'Beheergroep');}
if (!defined('_ADD_GROUP')) { define('_ADD_GROUP', 'Groep toevoegen');}
......@@ -376,11 +374,6 @@ if (!defined('_TOTAL_PROCESSED')) { define('_TOTAL_PROCESSED', 'Verwerkte docume
if (!defined('_TOTAL_ERRORS')) { define('_TOTAL_ERRORS', 'Documenten met fouten');}
if (!defined('_ONLY_ERRORS')) { define('_ONLY_ERRORS', 'Enkel met fouten');}
if (!defined('_INFOS')) { define('_INFOS', 'Informatie');}
if (!defined('_ADMIN_ARCHI')) { define('_ADMIN_ARCHI', 'Beheer van het klasseringsplan');}
if (!defined('_MANAGE_STRUCTURE')) { define('_MANAGE_STRUCTURE', 'Mappen beheren');}
if (!defined('_MANAGE_STRUCTURE_DESC')) { define('_MANAGE_STRUCTURE_DESC', 'Mappen beheren Deze zijn het hoogste element van het klasseringsplan. Indien de Directorymodule verbonden is, kunt u een dossiertype aan een klasseringsplan koppelen.');}
if (!defined('_MANAGE_SUBFOLDER')) { define('_MANAGE_SUBFOLDER', 'De submappen beheren');}
if (!defined('_MANAGE_SUBFOLDER_DESC')) { define('_MANAGE_SUBFOLDER_DESC', 'De submappen binnen de mappen beheren.');}
if (!defined('_ARCHITECTURE')) { define('_ARCHITECTURE', 'Klasseringsplan');}
if (!defined('_MORE_INFOS')) { define('_MORE_INFOS', 'Neem contact op met uw beheerder voor meer informatie');}
if (!defined('_ALREADY_EXISTS')) { define('_ALREADY_EXISTS', 'bestaat reeds');}
......@@ -1042,7 +1035,6 @@ if (!defined('_SSO_LOGIN')) { define('_SSO_LOGIN', 'Login via SSO');}
if (!defined('_LDAP')) { define('_LDAP', 'LDAP directory');}
if (!defined('_WHERE_CLAUSE_TARGET')) { define('_WHERE_CLAUSE_TARGET', 'Doel van de WHERE clause');}
if (!defined('_WHERE_TARGET')) { define('_WHERE_TARGET', 'Doel');}
if (!defined('_CLASS_SCHEME')) { define('_CLASS_SCHEME', 'Klasseringsplan');}
if (!defined('_DOCS')) { define('_DOCS', 'Documenten');}
if (!defined('_GO_MANAGE_USER')) { define('_GO_MANAGE_USER', 'Wijzigen');}
if (!defined('_GO_MANAGE_DOCSERVER')) { define('_GO_MANAGE_DOCSERVER', 'Wijzigen');}
......
#!/bin/sh
php ./migrateCustomFields.php
php ./migrateFileplans.php
php ./migrateFolders.php
php ./migrateFullText.php
php ./migrateIndexing.php
php ./migrateServicesEntities.php
......
<?php
require '../../vendor/autoload.php';
chdir('../..');
$customs = scandir('custom');
foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue;
}
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$migrated = 0;
$folders = \SrcCore\models\DatabaseModel::select([
'select' => ['folders_system_id', 'typist', 'destination', 'folder_name', 'parent_id'],
'table' => ['folder_tmp'],
'order_by' => ['parent_id asc']
]);
if (!empty($folders)) {
$superadmin = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => 'superadmin']);
if (empty($superadmin)) {
$firstMan = \User\models\UserModel::get(['select' => ['id'], 'orderBy' => ['id'], 'limit' => 1]);
$masterOwnerId = $firstMan[0]['id'];
} else {
$masterOwnerId = $superadmin['id'];
}
$masterFolderId = \Folder\models\FolderModel::create([
'label' => 'Reprise Dossier',
'public' => true,
'user_id' => $masterOwnerId,
'parent_id' => null,
'level' => 0
]);
$GLOBALS['entities'] = \Entity\models\EntityModel::get(['select' => ['id']]);
fillEntities($masterFolderId);
$aFolderIdMap = [];
foreach ($folders as $folder) {
$user = \User\models\UserModel::getByLogin(['select' => ['id'], 'login' => $folder['typist']]);
if (empty($folder['destination'])) {
// Public
if (empty($user)) {
$user['id'] = $masterOwnerId;
}
$folderId = \Folder\models\FolderModel::create([
'label' => $folder['folder_name'],
'public' => true,
'user_id' => $user['id'],
'parent_id' => empty($folder['parent_id']) ? $masterFolderId : $aFolderIdMap[$folder['parent_id']],
'level' => empty($folder['parent_id']) ? 1 : 2
]);
fillEntities($folderId);
} elseif (!empty($user)) {
// Private
$entity = \Entity\models\EntityModel::getByEntityId(['select' => ['id'], 'entityId' => $folder['destination']]);
if (empty($entity)) {
continue;
}
$folderId = \Folder\models\FolderModel::create([
'label' => $folder['folder_name'],
'public' => true,
'user_id' => $user['id'],
'parent_id' => $aFolderIdMap[$folder['parent_id']],
'level' => empty($folder['parent_id']) ? 0 : 1
]);
\Folder\models\EntityFolderModel::create([
'folder_id' => $folderId,
'entity_id' => $entity['id'],
'edition' => true,
]);
fillResources($folderId, $folder['folders_system_id']);
}
$aFolderIdMap[$folder['folders_system_id']] = $folderId;
++$migrated;
}
}
printf("Migration Dossier (CUSTOM {$custom}) : " . $migrated . " Dossier(s) trouvé(s) et migré(s).\n");
}
function fillEntities($folderId)
{
foreach ($GLOBALS['entities'] as $entity) {
\Folder\models\EntityFolderModel::create([
'folder_id' => $folderId,
'entity_id' => $entity['id'],
'edition' => true,
]);
}
}
function fillResources($folderId, $folderSystemId)
{
$resources = \SrcCore\models\DatabaseModel::select([
'select' => ['res_id'],
'table' => ['res_letterbox'],
'where' => ['folders_system_id = ?'],
'data' => [$folderSystemId]
]);
foreach ($resources as $resource) {
\Folder\models\ResourceFolderModel::create([
'folder_id' => $folderId,
'res_id' => $resource['res_id']
]);
}
}
......@@ -129,7 +129,7 @@ class FolderController
}
if (empty($data['parent_id'])) {
$data['parent_id'] = 0;
$data['parent_id'] = null;
$owner = $GLOBALS['id'];
$public = false;
$level = 0;
......@@ -184,7 +184,7 @@ class FolderController
if (!Validator::stringType()->notEmpty()->validate($data['label'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body label is empty or not a string']);
}
if (!empty($data['parent_id']) &&!Validator::intval()->validate($data['parent_id'])) {
if (!empty($data['parent_id']) && !Validator::intval()->validate($data['parent_id'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body parent_id is not a numeric']);
}
if ($data['parent_id'] == $aArgs['id']) {
......@@ -197,7 +197,7 @@ class FolderController
}
if (empty($data['parent_id'])) {
$data['parent_id'] = 0;
$data['parent_id'] = null;
$level = 0;
} else {
$folder = FolderController::getScopeFolders(['login' => $GLOBALS['userId'], 'folderId' => $data['parent_id']]);
......
......@@ -183,7 +183,7 @@ export class FolderTreeComponent implements OnInit {
flatToNestedObject(data: any) {
const nested = data.reduce((initial: any, value: any, index: any, original: any) => {
if (value.parent_id === 0) {
if (value.parent_id === null) {
if (initial.left.length) {
this.checkLeftOvers(initial.left, value);
}
......
......@@ -22,7 +22,7 @@ export class FolderUpdateComponent implements OnInit {
label: '',
public: true,
user_id: 0,
parent_id: 0,
parent_id: null,
level: 0,
sharing: {
entities: []
......@@ -66,7 +66,7 @@ export class FolderUpdateComponent implements OnInit {
element['state'] = {
opened: true
}
if (element.parent_id === 0) {
if (element.parent_id === null) {
element.parent_id = '#';
}
......
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