| @@ 629-680 (lines=52) @@ | ||
| 626 | /** |
|
| 627 | * @inheritdoc |
|
| 628 | */ |
|
| 629 | public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { |
|
| 630 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 631 | $qb->select('*') |
|
| 632 | ->from('share'); |
|
| 633 | ||
| 634 | $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_REMOTE))); |
|
| 635 | ||
| 636 | /** |
|
| 637 | * Reshares for this user are shares where they are the owner. |
|
| 638 | */ |
|
| 639 | if ($reshares === false) { |
|
| 640 | //Special case for old shares created via the web UI |
|
| 641 | $or1 = $qb->expr()->andX( |
|
| 642 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 643 | $qb->expr()->isNull('uid_initiator') |
|
| 644 | ); |
|
| 645 | ||
| 646 | $qb->andWhere( |
|
| 647 | $qb->expr()->orX( |
|
| 648 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), |
|
| 649 | $or1 |
|
| 650 | ) |
|
| 651 | ); |
|
| 652 | } else { |
|
| 653 | $qb->andWhere( |
|
| 654 | $qb->expr()->orX( |
|
| 655 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 656 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) |
|
| 657 | ) |
|
| 658 | ); |
|
| 659 | } |
|
| 660 | ||
| 661 | if ($node !== null) { |
|
| 662 | $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); |
|
| 663 | } |
|
| 664 | ||
| 665 | if ($limit !== -1) { |
|
| 666 | $qb->setMaxResults($limit); |
|
| 667 | } |
|
| 668 | ||
| 669 | $qb->setFirstResult($offset); |
|
| 670 | $qb->orderBy('id'); |
|
| 671 | ||
| 672 | $cursor = $qb->execute(); |
|
| 673 | $shares = []; |
|
| 674 | while($data = $cursor->fetch()) { |
|
| 675 | $shares[] = $this->createShareObject($data); |
|
| 676 | } |
|
| 677 | $cursor->closeCursor(); |
|
| 678 | ||
| 679 | return $shares; |
|
| 680 | } |
|
| 681 | ||
| 682 | /** |
|
| 683 | * @inheritdoc |
|
| @@ 492-543 (lines=52) @@ | ||
| 489 | /** |
|
| 490 | * @inheritdoc |
|
| 491 | */ |
|
| 492 | public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { |
|
| 493 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 494 | $qb->select('*') |
|
| 495 | ->from('share'); |
|
| 496 | ||
| 497 | $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); |
|
| 498 | ||
| 499 | /** |
|
| 500 | * Reshares for this user are shares where they are the owner. |
|
| 501 | */ |
|
| 502 | if ($reshares === false) { |
|
| 503 | //Special case for old shares created via the web UI |
|
| 504 | $or1 = $qb->expr()->andX( |
|
| 505 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 506 | $qb->expr()->isNull('uid_initiator') |
|
| 507 | ); |
|
| 508 | ||
| 509 | $qb->andWhere( |
|
| 510 | $qb->expr()->orX( |
|
| 511 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), |
|
| 512 | $or1 |
|
| 513 | ) |
|
| 514 | ); |
|
| 515 | } else { |
|
| 516 | $qb->andWhere( |
|
| 517 | $qb->expr()->orX( |
|
| 518 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 519 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) |
|
| 520 | ) |
|
| 521 | ); |
|
| 522 | } |
|
| 523 | ||
| 524 | if ($node !== null) { |
|
| 525 | $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); |
|
| 526 | } |
|
| 527 | ||
| 528 | if ($limit !== -1) { |
|
| 529 | $qb->setMaxResults($limit); |
|
| 530 | } |
|
| 531 | ||
| 532 | $qb->setFirstResult($offset); |
|
| 533 | $qb->orderBy('id'); |
|
| 534 | ||
| 535 | $cursor = $qb->execute(); |
|
| 536 | $shares = []; |
|
| 537 | while($data = $cursor->fetch()) { |
|
| 538 | $shares[] = $this->createShareObject($data); |
|
| 539 | } |
|
| 540 | $cursor->closeCursor(); |
|
| 541 | ||
| 542 | return $shares; |
|
| 543 | } |
|
| 544 | ||
| 545 | /** |
|
| 546 | * @inheritdoc |
|