[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorCalendarEventQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 private $rangeBegin; 9 private $rangeEnd; 10 private $invitedPHIDs; 11 private $creatorPHIDs; 12 13 public function withIDs(array $ids) { 14 $this->ids = $ids; 15 return $this; 16 } 17 18 public function withPHIDs(array $phids) { 19 $this->phids = $phids; 20 return $this; 21 } 22 23 public function withDateRange($begin, $end) { 24 $this->rangeBegin = $begin; 25 $this->rangeEnd = $end; 26 return $this; 27 } 28 29 public function withInvitedPHIDs(array $phids) { 30 $this->invitedPHIDs = $phids; 31 return $this; 32 } 33 34 public function withCreatorPHIDs(array $phids) { 35 $this->creatorPHIDs = $phids; 36 return $this; 37 } 38 39 protected function loadPage() { 40 $table = new PhabricatorCalendarEvent(); 41 $conn_r = $table->establishConnection('r'); 42 43 $data = queryfx_all( 44 $conn_r, 45 'SELECT * FROM %T %Q %Q %Q', 46 $table->getTableName(), 47 $this->buildWhereClause($conn_r), 48 $this->buildOrderClause($conn_r), 49 $this->buildLimitClause($conn_r)); 50 51 return $table->loadAllFromArray($data); 52 } 53 54 protected function buildWhereClause($conn_r) { 55 $where = array(); 56 57 if ($this->ids) { 58 $where[] = qsprintf( 59 $conn_r, 60 'id IN (%Ld)', 61 $this->ids); 62 } 63 64 if ($this->phids) { 65 $where[] = qsprintf( 66 $conn_r, 67 'phid IN (%Ls)', 68 $this->phids); 69 } 70 71 if ($this->rangeBegin) { 72 $where[] = qsprintf( 73 $conn_r, 74 'dateTo >= %d', 75 $this->rangeBegin); 76 } 77 78 if ($this->rangeEnd) { 79 $where[] = qsprintf( 80 $conn_r, 81 'dateFrom <= %d', 82 $this->rangeEnd); 83 } 84 85 // TODO: Currently, the creator is always the only invitee, but you can 86 // query them separately since this won't always be true. 87 88 if ($this->invitedPHIDs) { 89 $where[] = qsprintf( 90 $conn_r, 91 'userPHID IN (%Ls)', 92 $this->invitedPHIDs); 93 } 94 95 if ($this->creatorPHIDs) { 96 $where[] = qsprintf( 97 $conn_r, 98 'userPHID IN (%Ls)', 99 $this->creatorPHIDs); 100 } 101 102 $where[] = $this->buildPagingClause($conn_r); 103 104 return $this->formatWhereClause($where); 105 } 106 107 public function getQueryApplicationClass() { 108 return 'PhabricatorCalendarApplication'; 109 } 110 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |