Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
die_coolen_jungs
our_own_cloud_project
Commits
0ad16e84
Commit
0ad16e84
authored
12 years ago
by
Michael Gapczynski
Browse files
Options
Downloads
Patches
Plain Diff
Fix share collection query
parent
0a9d1ed3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/public/share.php
+34
-28
34 additions, 28 deletions
lib/public/share.php
with
34 additions
and
28 deletions
lib/public/share.php
+
34
−
28
View file @
0ad16e84
...
...
@@ -504,29 +504,33 @@ class Share {
}
}
if
(
isset
(
$item
))
{
if
(
$includeCollections
&&
$collectionTypes
=
self
::
getCollectionItemTypes
(
$itemType
))
{
$where
.
=
' AND ('
;
}
else
{
$where
.
=
' AND'
;
}
// If looking for own shared items, check item_source else check item_target
if
(
isset
(
$uidOwner
)
||
$itemShareWithBySource
)
{
// If item type is a file, file source needs to be checked in case the item was converted
if
(
$itemType
==
'file'
||
$itemType
==
'folder'
)
{
$where
.
=
'
AND
`file_source` = ?'
;
$where
.
=
' `file_source` = ?'
;
$column
=
'file_source'
;
}
else
{
$where
.
=
'
AND
`item_source` = ?'
;
$where
.
=
' `item_source` = ?'
;
$column
=
'item_source'
;
}
}
else
{
if
(
$itemType
==
'file'
||
$itemType
==
'folder'
)
{
$where
.
=
'
AND
`file_target` = ?'
;
$where
.
=
' `file_target` = ?'
;
}
else
{
$where
.
=
'
AND
`item_target` = ?'
;
$where
.
=
' `item_target` = ?'
;
}
}
$queryArgs
[]
=
$item
;
if
(
$includeCollections
&&
$collectionTypes
=
self
::
getCollectionItemTypes
(
$itemType
))
{
// TODO Bart - this doesn't work with only one argument
// $placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
// $where .= " OR item_type IN ('".$placeholders."')";
// $queryArgs = array_merge($queryArgs, $collectionTypes);
$placeholders
=
join
(
','
,
array_fill
(
0
,
count
(
$collectionTypes
),
'?'
));
$where
.
=
' OR item_type IN ('
.
$placeholders
.
'))'
;
$queryArgs
=
array_merge
(
$queryArgs
,
$collectionTypes
);
}
}
if
(
$limit
!=
-
1
&&
!
$includeCollections
)
{
...
...
@@ -629,28 +633,30 @@ class Share {
}
}
// Check if this is a collection of the requested item type
if
(
$includeCollections
&&
$row
[
'item_type'
]
!=
$itemType
&&
(
$collectionBackend
=
self
::
getBackend
(
$row
[
'item_type'
]))
&&
$collectionBackend
instanceof
Share_Backend_Collection
)
{
$row
[
'collection'
]
=
array
(
'item_type'
=>
$itemType
,
$column
=>
$row
[
$column
]);
// Fetch all of the children sources
$children
=
$collectionBackend
->
getChildren
(
$row
[
$column
]);
foreach
(
$children
as
$child
)
{
$childItem
=
$row
;
$childItem
[
'item_source'
]
=
$child
;
// $childItem['item_target'] = $child['target']; TODO
if
(
isset
(
$item
))
{
if
(
$childItem
[
$column
]
==
$item
)
{
// Return only the item instead of a 2-dimensional array
if
(
$limit
==
1
&&
$format
==
self
::
FORMAT_NONE
)
{
return
$childItem
;
}
else
{
// Unset the items array and break out of both loops
$items
=
array
();
$items
[]
=
$childItem
;
break
2
;
if
(
$includeCollections
&&
$row
[
'item_type'
]
!=
$itemType
)
{
if
((
$collectionBackend
=
self
::
getBackend
(
$row
[
'item_type'
]))
&&
$collectionBackend
instanceof
Share_Backend_Collection
)
{
$row
[
'collection'
]
=
array
(
'item_type'
=>
$itemType
,
$column
=>
$row
[
$column
]);
// Fetch all of the children sources
$children
=
$collectionBackend
->
getChildren
(
$row
[
$column
]);
foreach
(
$children
as
$child
)
{
$childItem
=
$row
;
$childItem
[
'item_source'
]
=
$child
;
// $childItem['item_target'] = $child['target']; TODO
if
(
isset
(
$item
))
{
if
(
$childItem
[
$column
]
==
$item
)
{
// Return only the item instead of a 2-dimensional array
if
(
$limit
==
1
&&
$format
==
self
::
FORMAT_NONE
)
{
return
$childItem
;
}
else
{
// Unset the items array and break out of both loops
$items
=
array
();
$items
[]
=
$childItem
;
break
2
;
}
}
}
else
{
$collectionItems
[]
=
$childItem
;
}
}
else
{
$collectionItems
[]
=
$childItem
;
}
}
// Remove collection item
...
...
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