Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
744c0084
Verified
Commit
744c0084
authored
5 years ago
by
Damien
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #11296 TIME 0:10 Refactoring test_right_doc
parent
d3d2f8fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/class/class_security.php
+3
-58
3 additions, 58 deletions
core/class/class_security.php
with
3 additions
and
58 deletions
core/class/class_security.php
+
3
−
58
View file @
744c0084
...
...
@@ -752,63 +752,8 @@ class security extends Database
*/
public
function
test_right_doc
(
$coll_id
,
$s_id
)
{
if
(
empty
(
$coll_id
)
||
empty
(
$s_id
))
{
return
false
;
}
$view
=
$this
->
retrieve_view_from_coll_id
(
$coll_id
);
if
(
empty
(
$view
))
{
$view
=
$this
->
retrieve_table_from_coll
(
$coll_id
);
}
$entitiesTab
=
$this
->
getEntitiesForCurrentUser
();
$where_clause
=
$this
->
get_where_clause_from_coll_id
(
$coll_id
);
$query
=
'select res_id from '
.
$view
.
' where res_id = ?'
;
if
(
!
empty
(
$entitiesTab
))
{
if
(
!
empty
(
$where_clause
))
{
$query
.
=
' and ('
.
$where_clause
.
' or folder_destination in (?)) '
;
}
$stmt
=
$this
->
query
(
$query
,
array
(
$s_id
,
$entitiesTab
));
}
else
{
if
(
!
empty
(
$where_clause
))
{
$query
.
=
' and ('
.
$where_clause
.
') '
;
}
$stmt
=
$this
->
query
(
$query
,
array
(
$s_id
));
}
if
(
$stmt
->
rowCount
()
<
1
)
{
//NOT IN THE DOC PERIMETER SO TEST IT IN THE BASKETS
$basketQuery
=
''
;
for
(
$ind_bask
=
0
;
$ind_bask
<
count
(
$_SESSION
[
'user'
][
'baskets'
]);
++
$ind_bask
)
{
if
(
$_SESSION
[
'user'
][
'baskets'
][
$ind_bask
][
'coll_id'
]
==
$coll_id
)
{
if
(
isset
(
$_SESSION
[
'user'
][
'baskets'
][
$ind_bask
][
'clause'
])
&&
trim
(
$_SESSION
[
'user'
][
'baskets'
][
$ind_bask
][
'clause'
])
!=
''
)
{
$basketQuery
.
=
' or ('
.
$_SESSION
[
'user'
][
'baskets'
][
$ind_bask
][
'clause'
]
.
')'
;
}
}
}
if
(
$basketQuery
!=
''
)
{
$basketQuery
=
preg_replace
(
'/^ or/'
,
''
,
$basketQuery
);
$query
=
'select res_id from '
.
$view
.
' where ('
.
$basketQuery
.
') and res_id = ?'
;
$stmt
=
$this
->
query
(
$query
,
array
(
$s_id
));
if
(
$stmt
->
rowCount
()
<
1
)
{
return
false
;
}
else
{
return
true
;
}
}
else
{
return
false
;
}
}
else
{
return
true
;
}
$user
=
\User\models\UserModel
::
getByLogin
([
'login'
=>
$_SESSION
[
'user'
][
'UserId'
],
'select'
=>
[
'id'
]]);
return
\Resource\controllers\ResController
::
hasRightByResId
([
'resId'
=>
[
$s_id
],
'userId'
=>
$user
[
'id'
]]);
}
}
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