| @@ 636-687 (lines=52) @@ | ||
| 633 | /** |
|
| 634 | * @inheritdoc |
|
| 635 | */ |
|
| 636 | public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { |
|
| 637 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 638 | $qb->select('*') |
|
| 639 | ->from('share'); |
|
| 640 | ||
| 641 | $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE))); |
|
| 642 | ||
| 643 | /** |
|
| 644 | * Reshares for this user are shares where they are the owner. |
|
| 645 | */ |
|
| 646 | if ($reshares === false) { |
|
| 647 | //Special case for old shares created via the web UI |
|
| 648 | $or1 = $qb->expr()->andX( |
|
| 649 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 650 | $qb->expr()->isNull('uid_initiator') |
|
| 651 | ); |
|
| 652 | ||
| 653 | $qb->andWhere( |
|
| 654 | $qb->expr()->orX( |
|
| 655 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), |
|
| 656 | $or1 |
|
| 657 | ) |
|
| 658 | ); |
|
| 659 | } else { |
|
| 660 | $qb->andWhere( |
|
| 661 | $qb->expr()->orX( |
|
| 662 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 663 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) |
|
| 664 | ) |
|
| 665 | ); |
|
| 666 | } |
|
| 667 | ||
| 668 | if ($node !== null) { |
|
| 669 | $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); |
|
| 670 | } |
|
| 671 | ||
| 672 | if ($limit !== -1) { |
|
| 673 | $qb->setMaxResults($limit); |
|
| 674 | } |
|
| 675 | ||
| 676 | $qb->setFirstResult($offset); |
|
| 677 | $qb->orderBy('id'); |
|
| 678 | ||
| 679 | $cursor = $qb->execute(); |
|
| 680 | $shares = []; |
|
| 681 | while($data = $cursor->fetch()) { |
|
| 682 | $shares[] = $this->createShareObject($data); |
|
| 683 | } |
|
| 684 | $cursor->closeCursor(); |
|
| 685 | ||
| 686 | return $shares; |
|
| 687 | } |
|
| 688 | ||
| 689 | /** |
|
| 690 | * @inheritdoc |
|
| @@ 691-742 (lines=52) @@ | ||
| 688 | /** |
|
| 689 | * @inheritdoc |
|
| 690 | */ |
|
| 691 | public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { |
|
| 692 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 693 | $qb->select('*') |
|
| 694 | ->from('share'); |
|
| 695 | ||
| 696 | $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); |
|
| 697 | ||
| 698 | /** |
|
| 699 | * Reshares for this user are shares where they are the owner. |
|
| 700 | */ |
|
| 701 | if ($reshares === false) { |
|
| 702 | //Special case for old shares created via the web UI |
|
| 703 | $or1 = $qb->expr()->andX( |
|
| 704 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 705 | $qb->expr()->isNull('uid_initiator') |
|
| 706 | ); |
|
| 707 | ||
| 708 | $qb->andWhere( |
|
| 709 | $qb->expr()->orX( |
|
| 710 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), |
|
| 711 | $or1 |
|
| 712 | ) |
|
| 713 | ); |
|
| 714 | } else { |
|
| 715 | $qb->andWhere( |
|
| 716 | $qb->expr()->orX( |
|
| 717 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 718 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) |
|
| 719 | ) |
|
| 720 | ); |
|
| 721 | } |
|
| 722 | ||
| 723 | if ($node !== null) { |
|
| 724 | $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); |
|
| 725 | } |
|
| 726 | ||
| 727 | if ($limit !== -1) { |
|
| 728 | $qb->setMaxResults($limit); |
|
| 729 | } |
|
| 730 | ||
| 731 | $qb->setFirstResult($offset); |
|
| 732 | $qb->orderBy('id'); |
|
| 733 | ||
| 734 | $cursor = $qb->execute(); |
|
| 735 | $shares = []; |
|
| 736 | while($data = $cursor->fetch()) { |
|
| 737 | $shares[] = $this->createShareObject($data); |
|
| 738 | } |
|
| 739 | $cursor->closeCursor(); |
|
| 740 | ||
| 741 | return $shares; |
|
| 742 | } |
|
| 743 | ||
| 744 | /** |
|
| 745 | * @inheritdoc |
|