Code Duplication    Length = 52-52 lines in 2 locations

apps/federatedfilesharing/lib/FederatedShareProvider.php 1 location

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

apps/sharebymail/lib/ShareByMailProvider.php 1 location

@@ 514-565 (lines=52) @@
511
	/**
512
	 * @inheritdoc
513
	 */
514
	public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) {
515
		$qb = $this->dbConnection->getQueryBuilder();
516
		$qb->select('*')
517
			->from('share');
518
519
		$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
520
521
		/**
522
		 * Reshares for this user are shares where they are the owner.
523
		 */
524
		if ($reshares === false) {
525
			//Special case for old shares created via the web UI
526
			$or1 = $qb->expr()->andX(
527
				$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
528
				$qb->expr()->isNull('uid_initiator')
529
			);
530
531
			$qb->andWhere(
532
				$qb->expr()->orX(
533
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)),
534
					$or1
535
				)
536
			);
537
		} else {
538
			$qb->andWhere(
539
				$qb->expr()->orX(
540
					$qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)),
541
					$qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))
542
				)
543
			);
544
		}
545
546
		if ($node !== null) {
547
			$qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId())));
548
		}
549
550
		if ($limit !== -1) {
551
			$qb->setMaxResults($limit);
552
		}
553
554
		$qb->setFirstResult($offset);
555
		$qb->orderBy('id');
556
557
		$cursor = $qb->execute();
558
		$shares = [];
559
		while($data = $cursor->fetch()) {
560
			$shares[] = $this->createShareObject($data);
561
		}
562
		$cursor->closeCursor();
563
564
		return $shares;
565
	}
566
567
	/**
568
	 * @inheritdoc