Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
maarchRM
Commits
1f2a3e61
Commit
1f2a3e61
authored
Nov 08, 2021
by
Arnaud Pauget
Browse files
feat() : add presenter on changing originator to custom message and preparing for multi changing
parent
a60bf6bf
Pipeline
#14353
failed with stages
in 1 minute and 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bundle/recordsManagement/Controller/archiveModificationTrait.php
View file @
1f2a3e61
...
...
@@ -979,30 +979,48 @@ trait archiveModificationTrait
/**
* Update originator service of an array of archives
*
* @param
string
$archiveIds
List
of archive identifiers
* @param
array
$archiveIds
Array
of archive identifiers
* @param string $orgId Organization identified destined to be new originator of archive
*
*/
public
function
updateOriginator
(
$archiveIds
,
$orgId
)
{
$archive
=
$this
->
sdoFactory
->
read
(
'recordsManagement/archive'
,
$archiveIds
);
$currentOwnerOrgId
=
$archive
->
originatorOwnerOrgId
;
$newOriginatorOrg
=
$this
->
sdoFactory
->
read
(
'organization/organization'
,
$orgId
);
if
(
!
is_array
(
$archiveIds
))
{
$archiveIds
=
[
$archiveIds
];
}
$result
=
[];
$result
[
"success"
]
=
[];
$result
[
"error"
]
=
[];
$newOriginatorOrg
=
$this
->
sdoFactory
->
read
(
'organization/organization'
,
$orgId
);
if
(
$newOriginatorOrg
->
enabled
==
false
)
{
throw
new
\
bundle\recordsManagement\Exception\organizationException
(
"This organization is disabled."
);
}
if
(
$currentOwnerOrgId
==
$newOriginatorOrg
->
ownerOrgId
)
{
foreach
(
$archiveIds
as
$archiveId
)
{
$archive
=
$this
->
sdoFactory
->
read
(
'recordsManagement/archive'
,
$archiveId
);
$currentOwnerOrgId
=
$archive
->
originatorOwnerOrgId
;
if
(
$currentOwnerOrgId
!=
$newOriginatorOrg
->
ownerOrgId
)
{
$result
[
"error"
][]
=
$archiveId
;
continue
;
// throw new \bundle\recordsManagement\Exception\organizationException(
// "The new originator organization of the archive must have the same owner organization as the current one."
// );
}
$archive
->
originatorOrgRegNumber
=
$newOriginatorOrg
->
registrationNumber
;
$archive
->
lastModificationDate
=
\
laabs
::
newTimestamp
();
$this
->
sdoFactory
->
update
(
$archive
,
'recordsManagement/archive'
);
}
else
{
throw
new
\
bundle\recordsManagement\Exception\organizationException
(
"The new originator organization of the archive must have the same owner organization as the current one."
);
$result
[
"success"
][]
=
$archiveId
;
}
return
$result
;
}
}
src/presentation/maarchRM/Presenter/recordsManagement/archive.php
View file @
1f2a3e61
...
...
@@ -1461,4 +1461,30 @@ class archive
return
$file
;
}
/**
* Serializer JSON for changing originator method
* @param array $result
*
* @return object JSON object with a status and message parameters
*/
public
function
setOriginator
(
$result
)
{
$success
=
count
(
$result
[
'success'
]);
$echec
=
count
(
$result
[
'error'
]);
$this
->
json
->
message
=
'%1$s archive(s) modified.'
;
$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 modified.'
;
$message
=
$this
->
translator
->
getText
(
$message
);
$message
=
sprintf
(
$message
,
$echec
);
$this
->
json
->
message
.
=
' '
.
$message
;
}
return
$this
->
json
->
save
();
}
}
src/presentation/maarchRM/UserStory/archiveManagement/adminOriginatorInterface.php
View file @
1f2a3e61
...
...
@@ -31,6 +31,7 @@ interface adminOriginatorInterface
/**
* @uses recordsManagement/archives/updateOriginator
* @return recordsManagement/archive/setOriginator
*/
public
function
updateRecordsmanagementArchiveOriginator
(
$archiveIds
,
$orgId
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment