| @@ 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 |
|
| @@ 472-523 (lines=52) @@ | ||
| 469 | /** |
|
| 470 | * @inheritdoc |
|
| 471 | */ |
|
| 472 | public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { |
|
| 473 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 474 | $qb->select('*') |
|
| 475 | ->from('share'); |
|
| 476 | ||
| 477 | $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))); |
|
| 478 | ||
| 479 | /** |
|
| 480 | * Reshares for this user are shares where they are the owner. |
|
| 481 | */ |
|
| 482 | if ($reshares === false) { |
|
| 483 | //Special case for old shares created via the web UI |
|
| 484 | $or1 = $qb->expr()->andX( |
|
| 485 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 486 | $qb->expr()->isNull('uid_initiator') |
|
| 487 | ); |
|
| 488 | ||
| 489 | $qb->andWhere( |
|
| 490 | $qb->expr()->orX( |
|
| 491 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)), |
|
| 492 | $or1 |
|
| 493 | ) |
|
| 494 | ); |
|
| 495 | } else { |
|
| 496 | $qb->andWhere( |
|
| 497 | $qb->expr()->orX( |
|
| 498 | $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), |
|
| 499 | $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) |
|
| 500 | ) |
|
| 501 | ); |
|
| 502 | } |
|
| 503 | ||
| 504 | if ($node !== null) { |
|
| 505 | $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); |
|
| 506 | } |
|
| 507 | ||
| 508 | if ($limit !== -1) { |
|
| 509 | $qb->setMaxResults($limit); |
|
| 510 | } |
|
| 511 | ||
| 512 | $qb->setFirstResult($offset); |
|
| 513 | $qb->orderBy('id'); |
|
| 514 | ||
| 515 | $cursor = $qb->execute(); |
|
| 516 | $shares = []; |
|
| 517 | while($data = $cursor->fetch()) { |
|
| 518 | $shares[] = $this->createShareObject($data); |
|
| 519 | } |
|
| 520 | $cursor->closeCursor(); |
|
| 521 | ||
| 522 | return $shares; |
|
| 523 | } |
|
| 524 | ||
| 525 | /** |
|
| 526 | * @inheritdoc |
|