Code Duplication    Length = 52-52 lines in 2 locations

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

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

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