From 8a85ee7c1575945a0c649a255e28b951173465c9 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Fri, 6 Jan 2017 20:12:57 -0800 Subject: [PATCH] Add CustomPHID to PhabricatorProfileMenuEngineConfiguration Summary: Ref T5867, adds a customPHID field, nullable, and lets you query by it... i think? Not fully able to grok all the EditEngine stuff, but I think this is the right place for the query. Test Plan: Not wired to anything, but pulling up project menu, editing, all still works. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T5867 Differential Revision: https://secure.phabricator.com/D17149 --- .../20170106.menu.01.customphd.sql | 2 ++ .../PhabricatorProfileMenuEditEngine.php | 10 +++++++ .../engine/PhabricatorProfileMenuEngine.php | 26 ++++++++++++++++--- ...catorProfileMenuItemConfigurationQuery.php | 13 ++++++++++ ...habricatorProfileMenuItemConfiguration.php | 2 ++ 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 resources/sql/autopatches/20170106.menu.01.customphd.sql diff --git a/resources/sql/autopatches/20170106.menu.01.customphd.sql b/resources/sql/autopatches/20170106.menu.01.customphd.sql new file mode 100644 index 0000000000..2fb642ca8b --- /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 index f7b8f76ec7..70ba141967 100644 --- a/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php +++ b/src/applications/search/editor/PhabricatorProfileMenuEditEngine.php @@ -7,6 +7,7 @@ final class PhabricatorProfileMenuEditEngine private $menuEngine; private $profileObject; + private $customPHID; private $newMenuItemConfiguration; private $isBuiltin; @@ -32,6 +33,15 @@ final class PhabricatorProfileMenuEditEngine 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 index d930b31314..a3cc8e34d1 100644 --- a/src/applications/search/engine/PhabricatorProfileMenuEngine.php +++ b/src/applications/search/engine/PhabricatorProfileMenuEngine.php @@ -4,6 +4,7 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { private $viewer; private $profileObject; + private $customPHID; private $items; private $defaultItem; private $controller; @@ -27,6 +28,15 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { 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 @@ abstract class PhabricatorProfileMenuEngine extends Phobject { $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 index f8172638c3..f59e20460e 100644 --- a/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php +++ b/src/applications/search/query/PhabricatorProfileMenuItemConfigurationQuery.php @@ -6,6 +6,7 @@ final class PhabricatorProfileMenuItemConfigurationQuery private $ids; private $phids; private $profilePHIDs; + private $customPHIDs; public function withIDs(array $ids) { $this->ids = $ids; @@ -22,6 +23,11 @@ final class PhabricatorProfileMenuItemConfigurationQuery return $this; } + public function withCustomPHIDs(array $phids) { + $this->customPHIDs = $phids; + return $this; + } + public function newResultObject() { return new PhabricatorProfileMenuItemConfiguration(); } @@ -54,6 +60,13 @@ final class PhabricatorProfileMenuItemConfigurationQuery $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 index 3a9c0effc6..9509155e1b 100644 --- a/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php +++ b/src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php @@ -12,6 +12,7 @@ final class PhabricatorProfileMenuItemConfiguration protected $builtinKey; protected $menuItemOrder; protected $visibility; + protected $customPHID; protected $menuItemProperties = array(); private $profileObject = self::ATTACHABLE; @@ -52,6 +53,7 @@ final class PhabricatorProfileMenuItemConfiguration 'menuItemKey' => 'text64', 'builtinKey' => 'text64?', 'menuItemOrder' => 'uint32?', + 'customPHID' => 'phid?', 'visibility' => 'text32', ), self::CONFIG_KEY_SCHEMA => array(