fix add user to group to work with grouped shares
This commit is contained in:
parent
bd268c35f5
commit
9f7b15582a
|
@ -45,6 +45,7 @@ class Hooks extends \OC\Share\Constants {
|
||||||
* @param array $arguments
|
* @param array $arguments
|
||||||
*/
|
*/
|
||||||
public static function post_addToGroup($arguments) {
|
public static function post_addToGroup($arguments) {
|
||||||
|
|
||||||
// Find the group shares and check if the user needs a unique target
|
// Find the group shares and check if the user needs a unique target
|
||||||
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
|
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?');
|
||||||
$result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid']));
|
$result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid']));
|
||||||
|
@ -52,18 +53,25 @@ class Hooks extends \OC\Share\Constants {
|
||||||
.' `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`,'
|
.' `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`,'
|
||||||
.' `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
|
.' `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)');
|
||||||
while ($item = $result->fetchRow()) {
|
while ($item = $result->fetchRow()) {
|
||||||
if ($item['item_type'] == 'file' || $item['item_type'] == 'file') {
|
|
||||||
$itemTarget = null;
|
$sourceExists = \OC\Share\Share::getItemSharedWithBySource($item['item_type'], $item['item_source'], self::FORMAT_NONE, null, true, $arguments['uid']);
|
||||||
|
|
||||||
|
if ($sourceExists) {
|
||||||
|
$fileTarget = $sourceExists['file_target'];
|
||||||
|
$itemTarget = $sourceExists['item_target'];
|
||||||
} else {
|
} else {
|
||||||
$itemTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER,
|
$itemTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'],
|
||||||
$arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']);
|
$item['owner'], null, $item['parent']);
|
||||||
}
|
|
||||||
if (isset($item['file_source'])) {
|
// do we also need a file target
|
||||||
$fileTarget = Helper::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER,
|
if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') {
|
||||||
$arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']);
|
$fileTarget = Helper::generateTarget('file', $row['file_target'], self::SHARE_TYPE_USER, $arguments['uid'],
|
||||||
} else {
|
$item['owner'], null, $item['parent']);
|
||||||
$fileTarget = null;
|
} else {
|
||||||
|
$fileTarget = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert an extra row for the group share if the item or file target is unique for this user
|
// Insert an extra row for the group share if the item or file target is unique for this user
|
||||||
if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) {
|
if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) {
|
||||||
$query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'],
|
$query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'],
|
||||||
|
|
Loading…
Reference in New Issue