Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchParapheur
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchParapheur
Commits
608b6115
Commit
608b6115
authored
2 years ago
by
Quentin Ribac
Browse files
Options
Downloads
Patches
Plain Diff
FEAT 20779 TIME 2:15 unifying and cleaning search & access conditions
parent
b1156044
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/document/controllers/DocumentController.php
+30
-41
30 additions, 41 deletions
src/app/document/controllers/DocumentController.php
src/app/search/controllers/SearchController.php
+16
-8
16 additions, 8 deletions
src/app/search/controllers/SearchController.php
with
46 additions
and
49 deletions
src/app/document/controllers/DocumentController.php
+
30
−
41
View file @
608b6115
...
...
@@ -1033,58 +1033,47 @@ class DocumentController
ValidatorModel
::
intVal
(
$args
,
[
'id'
,
'userId'
]);
ValidatorModel
::
boolType
(
$args
,
[
'readOnly'
]);
$readOnly
=
$args
[
'readOnly'
]
??
false
;
$args
[
'id'
]
=
(
int
)
$args
[
'id'
];
$args
[
'readOnly'
]
=
$args
[
'readOnly'
]
??
false
;
$args
[
'id'
]
=
(
int
)
$args
[
'id'
];
$args
[
'userId'
]
=
(
int
)
$args
[
'userId'
];
$document
=
DocumentModel
::
getById
([
'select'
=>
[
'typist'
],
'id'
=>
$args
[
'id'
]]);
if
(
$document
[
'typist'
]
==
$GLOBALS
[
'id'
])
{
if
(
!
empty
(
$document
[
'typist'
])
&&
$document
[
'typist'
]
==
$GLOBALS
[
'id'
])
{
return
true
;
}
if
(
!
$readOnly
)
{
$
workflow
=
WorkflowModel
::
getCurrentStep
([
'select'
=>
[
'user_id'
],
'documentId'
=>
$args
[
'id'
]]);
if
(
empty
(
$
workflow
))
{
if
(
!
$
args
[
'
readOnly
'
]
)
{
$
currentStep
=
WorkflowModel
::
getCurrentStep
([
'select'
=>
[
'user_id'
],
'documentId'
=>
$args
[
'id'
]]);
if
(
empty
(
$
currentStep
))
{
return
false
;
}
if
(
$workflow
[
'user_id'
]
!=
$args
[
'userId'
])
{
$user
=
UserModel
::
getById
([
'id'
=>
$workflow
[
'user_id'
],
'select'
=>
[
'substitute'
]]);
if
(
$user
[
'substitute'
]
!=
$args
[
'userId'
])
{
return
false
;
}
}
}
else
{
$circuitUsers
=
WorkflowModel
::
get
([
'select'
=>
[
'user_id'
,
'(process_date is not null) as processed'
],
'where'
=>
[
'main_document_id = ?'
],
'data'
=>
[
$args
[
'id'
]],
'orderBy'
=>
[
'"order" asc'
]
]);
$previousAndOneUsers
=
[];
foreach
(
$circuitUsers
as
$user
)
{
if
(
$user
[
'processed'
])
{
$previousAndOneUsers
[]
=
$user
[
'user_id'
];
continue
;
}
$previousAndOneUsers
[]
=
$user
[
'user_id'
];
break
;
}
$circuitUsers
=
$previousAndOneUsers
;
unset
(
$previousAndOneUsers
);
if
(
!
empty
(
$circuitUsers
))
{
$circuitSubstitutes
=
array_column
(
UserModel
::
get
([
'select'
=>
[
'substitute'
],
'where'
=>
[
'substitute is not null'
,
'id in (?)'
],
'data'
=>
[
$circuitUsers
],
]),
'substitute'
);
$circuitUsers
=
array_merge
(
$circuitUsers
,
$circuitSubstitutes
);
}
if
(
!
in_array
(
$args
[
'userId'
],
$circuitUsers
))
{
return
false
;
if
(
$currentStep
[
'user_id'
]
==
$args
[
'userId'
])
{
return
true
;
}
else
{
$user
=
UserModel
::
getById
([
'id'
=>
$currentStep
[
'user_id'
],
'select'
=>
[
'substitute'
]]);
return
$currentStep
[
'user_id'
]
==
$user
[
'substitute'
];
}
}
return
true
;
$canReadOnly
=
WorkflowModel
::
get
([
'select'
=>
[
1
],
'where'
=>
[
'main_document_id = ?'
,
'(process_date IS NOT NULL AND user_id = ?)
OR (
process_date IS NULL
AND user_id IN (
SELECT (SELECT ?::int) UNION (SELECT id FROM users WHERE substitute = ?)
)
AND "order" = (
SELECT min(ws2."order") FROM workflows ws2 WHERE ws2.main_document_id = main_document_id
)
)'
],
'data'
=>
[
$args
[
'id'
],
$args
[
'userId'
],
$args
[
'userId'
],
$args
[
'userId'
]]
]);
return
!
empty
(
$canReadOnly
);
}
public
static
function
getEncodedDocumentFromEncodedZip
(
array
$args
)
...
...
This diff is collapsed.
Click to expand it.
src/app/search/controllers/SearchController.php
+
16
−
8
View file @
608b6115
...
...
@@ -37,14 +37,22 @@ class SearchController
$data
=
[];
$hasFullRights
=
PrivilegeController
::
hasPrivilege
([
'userId'
=>
$GLOBALS
[
'id'
],
'privilege'
=>
'manage_documents'
]);
if
(
!
$hasFullRights
)
{
$substitutedUsers
=
UserModel
::
get
([
'select'
=>
[
'id'
],
'where'
=>
[
'substitute = ?'
],
'data'
=>
[
$GLOBALS
[
'id'
]]]);
$users
=
[
$GLOBALS
[
'id'
]];
foreach
(
$substitutedUsers
as
$value
)
{
$users
[]
=
$value
[
'id'
];
}
$where
=
[
"(id IN (SELECT main_document_id FROM workflows WHERE user_id IN (?)) OR typist = ?)"
];
$data
=
[
$users
,
$GLOBALS
[
'id'
]];
$where
=
[
'id IN (
SELECT DISTINCT ws1.main_document_id
FROM workflows ws1
WHERE typist = ?
OR (ws1.process_date IS NOT NULL AND ws1.user_id = ?)
OR (
ws1.process_date IS NULL
AND ws1.user_id IN (
SELECT (SELECT ?::int) UNION (SELECT id FROM users WHERE substitute = ?)
)
AND ws1."order" = (
SELECT min(ws2."order") FROM workflows ws2 WHERE ws2.main_document_id = ws1.main_document_id
)
)
)'
];
$data
=
[
$GLOBALS
[
'id'
],
$GLOBALS
[
'id'
],
$GLOBALS
[
'id'
],
$GLOBALS
[
'id'
]];
}
$whereWorkflow
=
[];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment