Code Duplication    Length = 36-36 lines in 2 locations

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 744-779 (lines=36) @@
741
	/**
742
	 * @inheritdoc
743
	 */
744
	public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
745
		/** @var IShare[] $shares */
746
		$shares = [];
747
748
		//Get shares directly with this user
749
		$qb = $this->dbConnection->getQueryBuilder();
750
		$qb->select('*')
751
			->from('share');
752
753
		// Order by id
754
		$qb->orderBy('id');
755
756
		// Set limit and offset
757
		if ($limit !== -1) {
758
			$qb->setMaxResults($limit);
759
		}
760
		$qb->setFirstResult($offset);
761
762
		$qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)));
763
		$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
764
765
		// Filter by node if provided
766
		if ($node !== null) {
767
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
768
		}
769
770
		$cursor = $qb->execute();
771
772
		while($data = $cursor->fetch()) {
773
			$shares[] = $this->createShareObject($data);
774
		}
775
		$cursor->closeCursor();
776
777
778
		return $shares;
779
	}
780
781
	/**
782
	 * Get a share by token

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 799-834 (lines=36) @@
796
	/**
797
	 * @inheritdoc
798
	 */
799
	public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
800
		/** @var IShare[] $shares */
801
		$shares = [];
802
803
		//Get shares directly with this user
804
		$qb = $this->dbConnection->getQueryBuilder();
805
		$qb->select('*')
806
			->from('share');
807
808
		// Order by id
809
		$qb->orderBy('id');
810
811
		// Set limit and offset
812
		if ($limit !== -1) {
813
			$qb->setMaxResults($limit);
814
		}
815
		$qb->setFirstResult($offset);
816
817
		$qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
818
		$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
819
820
		// Filter by node if provided
821
		if ($node !== null) {
822
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
823
		}
824
825
		$cursor = $qb->execute();
826
827
		while($data = $cursor->fetch()) {
828
			$shares[] = $this->createShareObject($data);
829
		}
830
		$cursor->closeCursor();
831
832
833
		return $shares;
834
	}
835
836
	/**
837
	 * Get a share by token