Code Duplication    Length = 52-52 lines in 2 locations

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 703-754 (lines=52) @@
700
	/**
701
	 * @inheritdoc
702
	 */
703
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
704
		$qb = $this->dbConnection->getQueryBuilder();
705
		$qb->select('*')
706
			->from('share');
707
708
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
709
710
		/**
711
		 * Reshares for this user are shares where they are the owner.
712
		 */
713
		if ($reshares === false) {
714
			//Special case for old shares created via the web UI
715
			$or1 = $qb->expr()->andX(
716
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
717
				$qb->expr()->isNull('uid_initiator')
718
			);
719
720
			$qb->andWhere(
721
				$qb->expr()->orX(
722
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
723
					$or1
724
				)
725
			);
726
		} else {
727
			$qb->andWhere(
728
				$qb->expr()->orX(
729
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
730
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
731
				)
732
			);
733
		}
734
735
		if ($node !== null) {
736
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
737
		}
738
739
		if ($limit !== -1) {
740
			$qb->setMaxResults($limit);
741
		}
742
743
		$qb->setFirstResult($offset);
744
		$qb->orderBy('id');
745
746
		$cursor = $qb->execute();
747
		$shares = [];
748
		while($data = $cursor->fetch()) {
749
			$shares[] = $this->createShareObject($data);
750
		}
751
		$cursor->closeCursor();
752
753
		return $shares;
754
	}
755
756
	/**
757
	 * @inheritdoc

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

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