Correctly select file cache values also when checking group shares

This commit is contained in:
Joas Schilling 2015-04-29 14:12:12 +02:00
parent 09d479e79d
commit 3c37cbdfe7
1 changed files with 7 additions and 7 deletions

View File

@ -333,15 +333,15 @@ class Share extends Constants {
$shares = array();
$fileDependent = false;
$where = 'WHERE';
$fileDependentWhere = '';
if ($itemType === 'file' || $itemType === 'folder') {
$fileDependent = true;
$column = 'file_source';
$where = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` ';
$where .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` ';
$where .= ' WHERE';
$fileDependentWhere = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` ';
$fileDependentWhere .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` ';
} else {
$column = 'item_source';
$where = 'WHERE';
}
$select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent);
@ -364,7 +364,7 @@ class Share extends Constants {
$arguments[] = $owner;
}
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $where);
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $fileDependentWhere . $where);
$result = \OC_DB::executeAudited($query, $arguments);
@ -380,7 +380,7 @@ class Share extends Constants {
$groups = \OC_Group::getUserGroups($user);
if (!empty($groups)) {
$where = 'WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
$where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)';
$arguments = array($itemSource, $itemType, $groups);
$types = array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY);
@ -394,7 +394,7 @@ class Share extends Constants {
// class isn't static anymore...
$conn = \OC_DB::getConnection();
$result = $conn->executeQuery(
'SELECT * FROM `*PREFIX*share` ' . $where,
'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where,
$arguments,
$types
);