diff --git a/resources/sql/autopatches/20170106.menu.01.customphd.sql b/resources/sql/autopatches/20170106.menu.01.customphd.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20170106.menu.01.customphd.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_search.search_profilepanelconfiguration + ADD customPHID VARBINARY(64); diff --git a/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php b/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php --- a/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php +++ b/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php @@ -7,6 +7,7 @@ private $menuEngine; private $profileObject; + private $customPHID; private $newMenuItemConfiguration; private $isBuiltin; @@ -32,6 +33,15 @@ return $this->profileObject; } + public function setCustomPHID($custom_phid) { + $this->customPHID = $custom_phid; + return $this; + } + + public function getCustomPHID() { + return $this->customPHID; + } + public function setNewMenuItemConfiguration( PhabricatorProfileMenuItemConfiguration $configuration) { $this->newMenuItemConfiguration = $configuration; diff --git a/src/applications/search/engine/PhabricatorProfileMenuEngine.php b/src/applications/search/engine/PhabricatorProfileMenuEngine.php --- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php +++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php @@ -4,6 +4,7 @@ private $viewer; private $profileObject; + private $customPHID; private $items; private $defaultItem; private $controller; @@ -27,6 +28,15 @@ return $this->profileObject; } + public function setCustomPHID($custom_phid) { + $this->customPHID = $custom_phid; + return $this; + } + + public function getCustomPHID() { + return $this->customPHID; + } + public function setController(PhabricatorController $controller) { $this->controller = $controller; return $this; @@ -244,10 +254,18 @@ $items = $this->loadBuiltinProfileItems(); - $stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) - ->setViewer($viewer) - ->withProfilePHIDs(array($object->getPHID())) - ->execute(); + if ($this->getCustomPHID()) { + $stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) + ->setViewer($viewer) + ->withProfilePHIDs(array($object->getPHID())) + ->withCustomPHIDs(array($this->getCustomPHID())) + ->execute(); + } else { + $stored_items = id(new PhabricatorProfileMenuItemConfigurationQuery()) + ->setViewer($viewer) + ->withProfilePHIDs(array($object->getPHID())) + ->execute(); + } foreach ($stored_items as $stored_item) { $impl = $stored_item->getMenuItem(); diff --git a/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php b/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php --- a/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php +++ b/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php @@ -6,6 +6,7 @@ private $ids; private $phids; private $profilePHIDs; + private $customPHIDs; public function withIDs(array $ids) { $this->ids = $ids; @@ -22,6 +23,11 @@ return $this; } + public function withCustomPHIDs(array $phids) { + $this->customPHIDs = $phids; + return $this; + } + public function newResultObject() { return new PhabricatorProfileMenuItemConfiguration(); } @@ -54,6 +60,13 @@ $this->profilePHIDs); } + if ($this->customPHIDs !== null) { + $where[] = qsprintf( + $conn, + 'customPHID IN (%Ls)', + $this->customPHIDs); + } + return $where; } diff --git a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php --- a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php +++ b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php @@ -12,6 +12,7 @@ protected $builtinKey; protected $menuItemOrder; protected $visibility; + protected $customPHID; protected $menuItemProperties = array(); private $profileObject = self::ATTACHABLE; @@ -52,6 +53,7 @@ 'menuItemKey' => 'text64', 'builtinKey' => 'text64?', 'menuItemOrder' => 'uint32?', + 'customPHID' => 'phid?', 'visibility' => 'text32', ), self::CONFIG_KEY_SCHEMA => array(