Code Duplication    Length = 52-52 lines in 2 locations

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 703-754 (lines=52) @@
700
	/**
701
	 * @inheritdoc
702
	 */
703
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
704
		$qb = $this->dbConnection->getQueryBuilder();
705
		$qb->select('*')
706
			->from('share');
707
708
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
709
710
		/**
711
		 * Reshares for this user are shares where they are the owner.
712
		 */
713
		if ($reshares === false) {
714
			//Special case for old shares created via the web UI
715
			$or1 = $qb->expr()->andX(
716
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
717
				$qb->expr()->isNull('uid_initiator')
718
			);
719
720
			$qb->andWhere(
721
				$qb->expr()->orX(
722
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
723
					$or1
724
				)
725
			);
726
		} else {
727
			$qb->andWhere(
728
				$qb->expr()->orX(
729
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
730
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
731
				)
732
			);
733
		}
734
735
		if ($node !== null) {
736
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
737
		}
738
739
		if ($limit !== -1) {
740
			$qb->setMaxResults($limit);
741
		}
742
743
		$qb->setFirstResult($offset);
744
		$qb->orderBy('id');
745
746
		$cursor = $qb->execute();
747
		$shares = [];
748
		while($data = $cursor->fetch()) {
749
			$shares[] = $this->createShareObject($data);
750
		}
751
		$cursor->closeCursor();
752
753
		return $shares;
754
	}
755
756
	/**
757
	 * @inheritdoc

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

@@ 638-689 (lines=52) @@
635
	/**
636
	 * @inheritdoc
637
	 */
638
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
639
		$qb = $this->dbConnection->getQueryBuilder();
640
		$qb->select('*')
641
			->from('share');
642
643
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE)));
644
645
		/**
646
		 * Reshares for this user are shares where they are the owner.
647
		 */
648
		if ($reshares === false) {
649
			//Special case for old shares created via the web UI
650
			$or1 = $qb->expr()->andX(
651
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
652
				$qb->expr()->isNull('uid_initiator')
653
			);
654
655
			$qb->andWhere(
656
				$qb->expr()->orX(
657
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
658
					$or1
659
				)
660
			);
661
		} else {
662
			$qb->andWhere(
663
				$qb->expr()->orX(
664
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
665
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
666
				)
667
			);
668
		}
669
670
		if ($node !== null) {
671
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
672
		}
673
674
		if ($limit !== -1) {
675
			$qb->setMaxResults($limit);
676
		}
677
678
		$qb->setFirstResult($offset);
679
		$qb->orderBy('id');
680
681
		$cursor = $qb->execute();
682
		$shares = [];
683
		while($data = $cursor->fetch()) {
684
			$shares[] = $this->createShareObject($data);
685
		}
686
		$cursor->closeCursor();
687
688
		return $shares;
689
	}
690
691
	/**
692
	 * @inheritdoc