Code Duplication    Length = 52-52 lines in 2 locations

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 663-714 (lines=52) @@
660
	/**
661
	 * @inheritdoc
662
	 */
663
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
664
		$qb = $this->dbConnection->getQueryBuilder();
665
		$qb->select('*')
666
			->from('share');
667
668
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
669
670
		/**
671
		 * Reshares for this user are shares where they are the owner.
672
		 */
673
		if ($reshares === false) {
674
			//Special case for old shares created via the web UI
675
			$or1 = $qb->expr()->andX(
676
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
677
				$qb->expr()->isNull('uid_initiator')
678
			);
679
680
			$qb->andWhere(
681
				$qb->expr()->orX(
682
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
683
					$or1
684
				)
685
			);
686
		} else {
687
			$qb->andWhere(
688
				$qb->expr()->orX(
689
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
690
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
691
				)
692
			);
693
		}
694
695
		if ($node !== null) {
696
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
697
		}
698
699
		if ($limit !== -1) {
700
			$qb->setMaxResults($limit);
701
		}
702
703
		$qb->setFirstResult($offset);
704
		$qb->orderBy('id');
705
706
		$cursor = $qb->execute();
707
		$shares = [];
708
		while($data = $cursor->fetch()) {
709
			$shares[] = $this->createShareObject($data);
710
		}
711
		$cursor->closeCursor();
712
713
		return $shares;
714
	}
715
716
	/**
717
	 * @inheritdoc

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 636-687 (lines=52) @@
633
	/**
634
	 * @inheritdoc
635
	 */
636
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
637
		$qb = $this->dbConnection->getQueryBuilder();
638
		$qb->select('*')
639
			->from('share');
640
641
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)));
642
643
		/**
644
		 * Reshares for this user are shares where they are the owner.
645
		 */
646
		if ($reshares === false) {
647
			//Special case for old shares created via the web UI
648
			$or1 = $qb->expr()->andX(
649
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
650
				$qb->expr()->isNull('uid_initiator')
651
			);
652
653
			$qb->andWhere(
654
				$qb->expr()->orX(
655
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
656
					$or1
657
				)
658
			);
659
		} else {
660
			$qb->andWhere(
661
				$qb->expr()->orX(
662
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
663
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
664
				)
665
			);
666
		}
667
668
		if ($node !== null) {
669
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
670
		}
671
672
		if ($limit !== -1) {
673
			$qb->setMaxResults($limit);
674
		}
675
676
		$qb->setFirstResult($offset);
677
		$qb->orderBy('id');
678
679
		$cursor = $qb->execute();
680
		$shares = [];
681
		while($data = $cursor->fetch()) {
682
			$shares[] = $this->createShareObject($data);
683
		}
684
		$cursor->closeCursor();
685
686
		return $shares;
687
	}
688
689
	/**
690
	 * @inheritdoc