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

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