Code Duplication    Length = 36-36 lines in 2 locations

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

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

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 600-635 (lines=36) @@
597
	/**
598
	 * @inheritdoc
599
	 */
600
	public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
601
		/** @var IShare[] $shares */
602
		$shares = [];
603
604
		//Get shares directly with this user
605
		$qb = $this->dbConnection->getQueryBuilder();
606
		$qb->select('*')
607
			->from('share');
608
609
		// Order by id
610
		$qb->orderBy('id');
611
612
		// Set limit and offset
613
		if ($limit !== -1) {
614
			$qb->setMaxResults($limit);
615
		}
616
		$qb->setFirstResult($offset);
617
618
		$qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
619
		$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
620
621
		// Filter by node if provided
622
		if ($node !== null) {
623
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
624
		}
625
626
		$cursor = $qb->execute();
627
628
		while($data = $cursor->fetch()) {
629
			$shares[] = $this->createShareObject($data);
630
		}
631
		$cursor->closeCursor();
632
633
634
		return $shares;
635
	}
636
637
	/**
638
	 * Get a share by token