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

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