Code Duplication    Length = 36-36 lines in 2 locations

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

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

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 580-615 (lines=36) @@
577
	/**
578
	 * @inheritdoc
579
	 */
580
	public function getSharedWith($userId, $shareType, $node, $limit, $offset) {
581
		/** @var IShare[] $shares */
582
		$shares = [];
583
584
		//Get shares directly with this user
585
		$qb = $this->dbConnection->getQueryBuilder();
586
		$qb->select('*')
587
			->from('share');
588
589
		// Order by id
590
		$qb->orderBy('id');
591
592
		// Set limit and offset
593
		if ($limit !== -1) {
594
			$qb->setMaxResults($limit);
595
		}
596
		$qb->setFirstResult($offset);
597
598
		$qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
599
		$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
600
601
		// Filter by node if provided
602
		if ($node !== null) {
603
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
604
		}
605
606
		$cursor = $qb->execute();
607
608
		while($data = $cursor->fetch()) {
609
			$shares[] = $this->createShareObject($data);
610
		}
611
		$cursor->closeCursor();
612
613
614
		return $shares;
615
	}
616
617
	/**
618
	 * Get a share by token