[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorPeopleLogQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $actorPHIDs; 7 private $userPHIDs; 8 private $relatedPHIDs; 9 private $sessionKeys; 10 private $actions; 11 private $remoteAddressPrefix; 12 13 public function withActorPHIDs(array $actor_phids) { 14 $this->actorPHIDs = $actor_phids; 15 return $this; 16 } 17 18 public function withUserPHIDs(array $user_phids) { 19 $this->userPHIDs = $user_phids; 20 return $this; 21 } 22 23 public function withRelatedPHIDs(array $related_phids) { 24 $this->relatedPHIDs = $related_phids; 25 return $this; 26 } 27 28 public function withSessionKeys(array $session_keys) { 29 $this->sessionKeys = $session_keys; 30 return $this; 31 } 32 33 public function withActions(array $actions) { 34 $this->actions = $actions; 35 return $this; 36 } 37 38 public function withRemoteAddressPrefix($remote_address_prefix) { 39 $this->remoteAddressPrefix = $remote_address_prefix; 40 return $this; 41 } 42 43 public function loadPage() { 44 $table = new PhabricatorUserLog(); 45 $conn_r = $table->establishConnection('r'); 46 47 $data = queryfx_all( 48 $conn_r, 49 'SELECT * FROM %T %Q %Q %Q', 50 $table->getTableName(), 51 $this->buildWhereClause($conn_r), 52 $this->buildOrderClause($conn_r), 53 $this->buildLimitClause($conn_r)); 54 55 return $table->loadAllFromArray($data); 56 } 57 58 private function buildWhereClause($conn_r) { 59 $where = array(); 60 61 if ($this->actorPHIDs !== null) { 62 $where[] = qsprintf( 63 $conn_r, 64 'actorPHID IN (%Ls)', 65 $this->actorPHIDs); 66 } 67 68 if ($this->userPHIDs !== null) { 69 $where[] = qsprintf( 70 $conn_r, 71 'userPHID IN (%Ls)', 72 $this->userPHIDs); 73 } 74 75 if ($this->relatedPHIDs !== null) { 76 $where[] = qsprintf( 77 $conn_r, 78 'actorPHID IN (%Ls) OR userPHID IN (%Ls)', 79 $this->relatedPHIDs, 80 $this->relatedPHIDs); 81 } 82 83 if ($this->sessionKeys !== null) { 84 $where[] = qsprintf( 85 $conn_r, 86 'session IN (%Ls)', 87 $this->sessionKeys); 88 } 89 90 if ($this->actions !== null) { 91 $where[] = qsprintf( 92 $conn_r, 93 'action IN (%Ls)', 94 $this->actions); 95 } 96 97 if ($this->remoteAddressPrefix !== null) { 98 $where[] = qsprintf( 99 $conn_r, 100 'remoteAddr LIKE %>', 101 $this->remoteAddressPrefix); 102 } 103 104 $where[] = $this->buildPagingClause($conn_r); 105 106 return $this->formatWhereClause($where); 107 } 108 109 public function getQueryApplicationClass() { 110 return 'PhabricatorPeopleApplication'; 111 } 112 113 }
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 |