@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
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 162 lines 4.0 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorProfileMenuItemConfiguration> 5 */ 6final class PhabricatorProfileMenuItemConfigurationQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $profilePHIDs; 12 private $customPHIDs; 13 private $includeGlobal; 14 private $affectedObjectPHIDs; 15 16 public function withIDs(array $ids) { 17 $this->ids = $ids; 18 return $this; 19 } 20 21 public function withPHIDs(array $phids) { 22 $this->phids = $phids; 23 return $this; 24 } 25 26 public function withProfilePHIDs(array $phids) { 27 $this->profilePHIDs = $phids; 28 return $this; 29 } 30 31 public function withCustomPHIDs(array $phids, $include_global = false) { 32 $this->customPHIDs = $phids; 33 $this->includeGlobal = $include_global; 34 return $this; 35 } 36 37 public function withAffectedObjectPHIDs(array $phids) { 38 $this->affectedObjectPHIDs = $phids; 39 return $this; 40 } 41 42 public function newResultObject() { 43 return new PhabricatorProfileMenuItemConfiguration(); 44 } 45 46 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 47 $where = parent::buildWhereClauseParts($conn); 48 49 if ($this->ids !== null) { 50 $where[] = qsprintf( 51 $conn, 52 'config.id IN (%Ld)', 53 $this->ids); 54 } 55 56 if ($this->phids !== null) { 57 $where[] = qsprintf( 58 $conn, 59 'config.phid IN (%Ls)', 60 $this->phids); 61 } 62 63 if ($this->profilePHIDs !== null) { 64 $where[] = qsprintf( 65 $conn, 66 'config.profilePHID IN (%Ls)', 67 $this->profilePHIDs); 68 } 69 70 if ($this->customPHIDs !== null) { 71 if ($this->customPHIDs && $this->includeGlobal) { 72 $where[] = qsprintf( 73 $conn, 74 'config.customPHID IN (%Ls) OR config.customPHID IS NULL', 75 $this->customPHIDs); 76 } else if ($this->customPHIDs) { 77 $where[] = qsprintf( 78 $conn, 79 'config.customPHID IN (%Ls)', 80 $this->customPHIDs); 81 } else { 82 $where[] = qsprintf( 83 $conn, 84 'config.customPHID IS NULL'); 85 } 86 } 87 88 if ($this->affectedObjectPHIDs !== null) { 89 $where[] = qsprintf( 90 $conn, 91 'affected.dst IN (%Ls)', 92 $this->affectedObjectPHIDs); 93 } 94 95 return $where; 96 } 97 98 protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) { 99 $joins = parent::buildJoinClauseParts($conn); 100 101 if ($this->affectedObjectPHIDs !== null) { 102 $joins[] = qsprintf( 103 $conn, 104 'JOIN %T affected ON affected.src = config.phid 105 AND affected.type = %d', 106 PhabricatorEdgeConfig::TABLE_NAME_EDGE, 107 PhabricatorProfileMenuItemAffectsObjectEdgeType::EDGECONST); 108 } 109 110 return $joins; 111 } 112 113 protected function willFilterPage(array $page) { 114 $items = PhabricatorProfileMenuItem::getAllMenuItems(); 115 foreach ($page as $key => $item) { 116 $item_type = idx($items, $item->getMenuItemKey()); 117 if (!$item_type) { 118 $this->didRejectResult($item); 119 unset($page[$key]); 120 continue; 121 } 122 $item_type = clone $item_type; 123 $item_type->setViewer($this->getViewer()); 124 $item->attachMenuItem($item_type); 125 } 126 127 if (!$page) { 128 return array(); 129 } 130 131 $profile_phids = mpull($page, 'getProfilePHID'); 132 133 $profiles = id(new PhabricatorObjectQuery()) 134 ->setViewer($this->getViewer()) 135 ->setParentQuery($this) 136 ->withPHIDs($profile_phids) 137 ->execute(); 138 $profiles = mpull($profiles, null, 'getPHID'); 139 140 foreach ($page as $key => $item) { 141 $profile = idx($profiles, $item->getProfilePHID()); 142 if (!$profile) { 143 $this->didRejectResult($item); 144 unset($page[$key]); 145 continue; 146 } 147 148 $item->attachProfileObject($profile); 149 } 150 151 return $page; 152 } 153 154 public function getQueryApplicationClass() { 155 return PhabricatorSearchApplication::class; 156 } 157 158 protected function getPrimaryTableAlias() { 159 return 'config'; 160 } 161 162}