@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3/**
4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorCalendarEventInvitee>
5 */
6final class PhabricatorCalendarEventInviteeQuery
7 extends PhabricatorCursorPagedPolicyAwareQuery {
8
9 private $ids;
10 private $eventPHIDs;
11 private $inviteePHIDs;
12 private $inviterPHIDs;
13 private $statuses;
14
15 public function withIDs(array $ids) {
16 $this->ids = $ids;
17 return $this;
18 }
19
20 public function withEventPHIDs(array $phids) {
21 $this->eventPHIDs = $phids;
22 return $this;
23 }
24
25 public function withInviteePHIDs(array $phids) {
26 $this->inviteePHIDs = $phids;
27 return $this;
28 }
29
30 public function withInviterPHIDs(array $phids) {
31 $this->inviterPHIDs = $phids;
32 return $this;
33 }
34
35 public function withStatuses(array $statuses) {
36 $this->statuses = $statuses;
37 return $this;
38 }
39
40 protected function loadPage() {
41 $table = new PhabricatorCalendarEventInvitee();
42 $conn_r = $table->establishConnection('r');
43
44 $data = queryfx_all(
45 $conn_r,
46 'SELECT * FROM %T %Q %Q %Q',
47 $table->getTableName(),
48 $this->buildWhereClause($conn_r),
49 $this->buildOrderClause($conn_r),
50 $this->buildLimitClause($conn_r));
51
52 return $table->loadAllFromArray($data);
53 }
54
55 protected function buildWhereClause(AphrontDatabaseConnection $conn) {
56 $where = array();
57
58 if ($this->ids !== null) {
59 $where[] = qsprintf(
60 $conn,
61 'id IN (%Ld)',
62 $this->ids);
63 }
64
65 if ($this->eventPHIDs !== null) {
66 $where[] = qsprintf(
67 $conn,
68 'eventPHID IN (%Ls)',
69 $this->eventPHIDs);
70 }
71
72 if ($this->inviteePHIDs !== null) {
73 $where[] = qsprintf(
74 $conn,
75 'inviteePHID IN (%Ls)',
76 $this->inviteePHIDs);
77 }
78
79 if ($this->inviterPHIDs !== null) {
80 $where[] = qsprintf(
81 $conn,
82 'inviterPHID IN (%Ls)',
83 $this->inviterPHIDs);
84 }
85
86 if ($this->statuses !== null) {
87 $where[] = qsprintf(
88 $conn,
89 'status = %d',
90 $this->statuses);
91 }
92
93 $where[] = $this->buildPagingClause($conn);
94
95 return $this->formatWhereClause($conn, $where);
96 }
97
98 public function getQueryApplicationClass() {
99 return PhabricatorCalendarApplication::class;
100 }
101
102}