Code Duplication    Length = 36-36 lines in 2 locations

apps/sharebymail/lib/ShareByMailProvider.php 1 location

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

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 771-806 (lines=36) @@
768
	/**
769
	 * @inheritdoc
770
	 */
771
	public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
772
		/** @var IShare[] $shares */
773
		$shares = [];
774
775
		//Get shares directly with this user
776
		$qb = $this->dbConnection->getQueryBuilder();
777
		$qb->select('*')
778
			->from('share');
779
780
		// Order by id
781
		$qb->orderBy('id');
782
783
		// Set limit and offset
784
		if ($limit !== -1) {
785
			$qb->setMaxResults($limit);
786
		}
787
		$qb->setFirstResult($offset);
788
789
		$qb->where($qb->expr()->in('share_type', $qb->createNamedParameter($this->supportedShareType, IQueryBuilder::PARAM_INT_ARRAY)));
790
		$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
791
792
		// Filter by node if provided
793
		if ($node !== null) {
794
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
795
		}
796
797
		$cursor = $qb->execute();
798
799
		while($data = $cursor->fetch()) {
800
			$shares[] = $this->createShareObject($data);
801
		}
802
		$cursor->closeCursor();
803
804
805
		return $shares;
806
	}
807
808
	/**
809
	 * Get a share by token