summaryrefslogtreecommitdiffstats
path: root/lib/private/Share/Helper.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-11-29 22:50:30 +0100
committerMorris Jobke <hey@morrisjobke.de>2020-11-30 09:51:18 +0100
commit83a75c670bb52efbee498418398f03ab12301840 (patch)
treeb537da42d73ca84c430922cc6b12c47aa838ad08 /lib/private/Share/Helper.php
parent9409968451be5e25e271ea282863cea7818bed98 (diff)
downloadnextcloud-server-83a75c670bb52efbee498418398f03ab12301840.tar.gz
nextcloud-server-83a75c670bb52efbee498418398f03ab12301840.zip
Replace static call to Share::unshare with ShareManager->deleteShare in tests
And then cleanup all the code that is dead then... Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Share/Helper.php')
-rw-r--r--lib/private/Share/Helper.php104
1 files changed, 0 insertions, 104 deletions
diff --git a/lib/private/Share/Helper.php b/lib/private/Share/Helper.php
index 06f9baa4f57..191e410d990 100644
--- a/lib/private/Share/Helper.php
+++ b/lib/private/Share/Helper.php
@@ -30,95 +30,9 @@
namespace OC\Share;
-use OC\HintException;
-use OCP\DB\QueryBuilder\IQueryBuilder;
-
class Helper extends \OC\Share\Constants {
/**
- * Delete all reshares and group share children of an item
- * @param int $parent Id of item to delete
- * @param bool $excludeParent If true, exclude the parent from the delete (optional)
- * @param string $uidOwner The user that the parent was shared with (optional)
- * @param int $newParent new parent for the childrens
- * @param bool $excludeGroupChildren exclude group children elements
- */
- public static function delete($parent, $excludeParent = false, $uidOwner = null, $newParent = null, $excludeGroupChildren = false) {
- $ids = [$parent];
- $deletedItems = [];
- $changeParent = [];
- $parents = [$parent];
- while (!empty($parents)) {
- $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $query->select(
- 'id', 'share_with', 'item_type', 'share_type',
- 'item_target', 'file_target', 'parent'
- )
- ->from('share')
- ->where($query->expr()->in('parent', $query->createNamedParameter(
- $parents, IQueryBuilder::PARAM_INT_ARRAY
- )));
-
- if (count($ids) === 1 && isset($uidOwner)) {
- // Check the owner on the first search of reshares, useful for
- // finding and deleting the reshares by a single user of a group share
- $query->andWhere($query->expr()->eq('uid_owner', $uidOwner));
- }
-
- if ($excludeGroupChildren) {
- $query->andWhere($query->expr()->eq('share_type', self::$shareTypeGroupUserUnique));
- }
-
- $result = $query->execute();
- // Reset parents array, only go through loop again if items are found
- $parents = [];
- while ($item = $result->fetch()) {
- $tmpItem = [
- 'id' => $item['id'],
- 'shareWith' => $item['share_with'],
- 'itemTarget' => $item['item_target'],
- 'itemType' => $item['item_type'],
- 'shareType' => (int)$item['share_type'],
- ];
- if (isset($item['file_target'])) {
- $tmpItem['fileTarget'] = $item['file_target'];
- }
- // if we have a new parent for the child we remember the child
- // to update the parent, if not we add it to the list of items
- // which should be deleted
- if ($newParent !== null) {
- $changeParent[] = $item['id'];
- } else {
- $deletedItems[] = $tmpItem;
- $ids[] = $item['id'];
- $parents[] = $item['id'];
- }
- }
- $result->closeCursor();
- }
- if ($excludeParent) {
- unset($ids[0]);
- }
-
- if (!empty($changeParent)) {
- $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $query->update('share')
- ->set('parent', $query->createNamedParameter($newParent, IQueryBuilder::PARAM_INT))
- ->where($query->expr()->in('id', $query->createNamedParameter($changeParent, IQueryBuilder::PARAM_INT_ARRAY)));
- $query->execute();
- }
-
- if (!empty($ids)) {
- $query = \OC::$server->getDatabaseConnection()->getQueryBuilder();
- $query->delete('share')
- ->where($query->expr()->in('id', $query->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)));
- $query->execute();
- }
-
- return $deletedItems;
- }
-
- /**
* get default expire settings defined by the admin
* @return array contains 'defaultExpireDateSet', 'enforceExpireDate', 'expireAfterDays'
*/
@@ -204,24 +118,6 @@ class Helper extends \OC\Share\Constants {
}
/**
- * split user and remote from federated cloud id
- *
- * @param string $id
- * @return string[]
- * @throws HintException
- */
- public static function splitUserRemote($id) {
- try {
- $cloudId = \OC::$server->getCloudIdManager()->resolveCloudId($id);
- return [$cloudId->getUser(), $cloudId->getRemote()];
- } catch (\InvalidArgumentException $e) {
- $l = \OC::$server->getL10N('core');
- $hint = $l->t('Invalid Federated Cloud ID');
- throw new HintException('Invalid Federated Cloud ID', $hint, 0, $e);
- }
- }
-
- /**
* check if two federated cloud IDs refer to the same user
*
* @param string $user1