Allow specifying the item source in unshareFromSelf().
This commit is contained in:
parent
acafb4a426
commit
ecdd04374a
2 changed files with 9 additions and 8 deletions
|
@ -718,23 +718,24 @@ class Share extends \OC\Share\Constants {
|
|||
/**
|
||||
* Unshare an item shared with the current user
|
||||
* @param string $itemType
|
||||
* @param string $itemTarget
|
||||
* @param string $itemOrigin Item target or source
|
||||
* @param boolean $originIsSource true if $itemOrigin is the source, false if $itemOrigin is the target (optional)
|
||||
* @return boolean true on success or false on failure
|
||||
*
|
||||
* Unsharing from self is not allowed for items inside collections
|
||||
*/
|
||||
public static function unshareFromSelf($itemType, $itemTarget) {
|
||||
|
||||
public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) {
|
||||
$originType = ($originIsSource) ? 'source' : 'target';
|
||||
$uid = \OCP\User::getUser();
|
||||
|
||||
if ($itemType === 'file' || $itemType === 'folder') {
|
||||
$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_target` = ?';
|
||||
$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `file_' . $originType . '` = ?';
|
||||
} else {
|
||||
$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_target` = ?';
|
||||
$statement = 'SELECT * FROM `*PREFIX*share` WHERE `item_type` = ? and `item_' . $originType . '` = ?';
|
||||
}
|
||||
|
||||
$query = \OCP\DB::prepare($statement);
|
||||
$result = $query->execute(array($itemType, $itemTarget));
|
||||
$result = $query->execute(array($itemType, $itemOrigin));
|
||||
|
||||
$shares = $result->fetchAll();
|
||||
|
||||
|
|
|
@ -265,8 +265,8 @@ class Share extends \OC\Share\Constants {
|
|||
*
|
||||
* Unsharing from self is not allowed for items inside collections
|
||||
*/
|
||||
public static function unshareFromSelf($itemType, $itemTarget) {
|
||||
return \OC\Share\Share::unshareFromSelf($itemType, $itemTarget);
|
||||
public static function unshareFromSelf($itemType, $itemOrigin, $originIsSource = false) {
|
||||
return \OC\Share\Share::unshareFromSelf($itemType, $itemOrigin, $originIsSource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue