diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 73708a72f5..fb3cc622e4 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1640,9 +1640,11 @@ phutil_register_library_map(array( 'PhabricatorStandardCustomFieldDate' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php', 'PhabricatorStandardCustomFieldInt' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php', 'PhabricatorStandardCustomFieldInterface' => 'infrastructure/customfield/interface/PhabricatorStandardCustomFieldInterface.php', + 'PhabricatorStandardCustomFieldPHIDs' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php', 'PhabricatorStandardCustomFieldRemarkup' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldRemarkup.php', 'PhabricatorStandardCustomFieldSelect' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php', 'PhabricatorStandardCustomFieldText' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldText.php', + 'PhabricatorStandardCustomFieldUsers' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php', 'PhabricatorStandardPageView' => 'view/page/PhabricatorStandardPageView.php', 'PhabricatorStatusController' => 'applications/system/PhabricatorStatusController.php', 'PhabricatorStorageFixtureScopeGuard' => 'infrastructure/testing/fixture/PhabricatorStorageFixtureScopeGuard.php', @@ -3792,9 +3794,11 @@ phutil_register_library_map(array( 'PhabricatorStandardCustomFieldBool' => 'PhabricatorStandardCustomField', 'PhabricatorStandardCustomFieldDate' => 'PhabricatorStandardCustomField', 'PhabricatorStandardCustomFieldInt' => 'PhabricatorStandardCustomField', + 'PhabricatorStandardCustomFieldPHIDs' => 'PhabricatorStandardCustomField', 'PhabricatorStandardCustomFieldRemarkup' => 'PhabricatorStandardCustomField', 'PhabricatorStandardCustomFieldSelect' => 'PhabricatorStandardCustomField', 'PhabricatorStandardCustomFieldText' => 'PhabricatorStandardCustomField', + 'PhabricatorStandardCustomFieldUsers' => 'PhabricatorStandardCustomFieldPHIDs', 'PhabricatorStandardPageView' => 'PhabricatorBarePageView', 'PhabricatorStatusController' => 'PhabricatorController', 'PhabricatorStorageManagementDatabasesWorkflow' => 'PhabricatorStorageManagementWorkflow', diff --git a/src/applications/people/query/PhabricatorPeopleQuery.php b/src/applications/people/query/PhabricatorPeopleQuery.php index 3bdfdb1a4c..1f0c12bfc0 100644 --- a/src/applications/people/query/PhabricatorPeopleQuery.php +++ b/src/applications/people/query/PhabricatorPeopleQuery.php @@ -105,8 +105,8 @@ final class PhabricatorPeopleQuery $table->getTableName(), $this->buildJoinsClause($conn_r), $this->buildWhereClause($conn_r), - $this->buildOrderClause($conn_r), $this->buildApplicationSearchGroupClause($conn_r), + $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); if ($this->needPrimaryEmail) { diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 74496d9cf7..70cc7536ec 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -504,7 +504,7 @@ abstract class PhabricatorApplicationSearchEngine { $handles = array(); if ($all_phids) { $handles = id(new PhabricatorHandleQuery()) - ->setViewer($this->getViewer()) + ->setViewer($this->requireViewer()) ->withPHIDs($all_phids) ->execute(); } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php new file mode 100644 index 0000000000..755f4fcdc1 --- /dev/null +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -0,0 +1,89 @@ +getFieldValue(); + if (is_array($value)) { + foreach ($value as $phid) { + $indexes[] = $this->newStringIndex($phid); + } + } + + return $indexes; + } + + public function readValueFromRequest(AphrontRequest $request) { + $value = $request->getArr($this->getFieldKey()); + $this->setFieldValue($value); + } + + public function getValueForStorage() { + $value = $this->getFieldValue(); + if (!$value) { + return null; + } + + return json_encode(array_values($value)); + } + + public function setValueFromStorage($value) { + $result = array(); + if ($value) { + $value = json_decode($value, true); + if (is_array($value)) { + $result = array_values($value); + } + } + $this->setFieldValue($value); + } + + public function readApplicationSearchValueFromRequest( + PhabricatorApplicationSearchEngine $engine, + AphrontRequest $request) { + return $request->getArr($this->getFieldKey()); + } + + public function applyApplicationSearchConstraintToQuery( + PhabricatorApplicationSearchEngine $engine, + PhabricatorCursorPagedPolicyAwareQuery $query, + $value) { + if ($value) { + $query->withApplicationSearchContainsConstraint( + $this->newStringIndex(null), + $value); + } + } + + public function getRequiredHandlePHIDsForApplicationSearch($value) { + if ($value) { + return $value; + } + return array(); + } + + public function renderPropertyViewValue() { + $value = $this->getFieldValue(); + if (!$value) { + return null; + } + + // TODO: Surface and batch this. + + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->getViewer()) + ->withPHIDs($value) + ->execute(); + + $handles = mpull($handles, 'renderLink'); + $handles = phutil_implode_html(', ', $handles); + return $handles; + } + +} diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php new file mode 100644 index 0000000000..135db3b1d3 --- /dev/null +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php @@ -0,0 +1,52 @@ +getFieldValue(); + if ($value) { + + // TODO: Surface and batch. + + $handles = id(new PhabricatorHandleQuery()) + ->setViewer($this->getViewer()) + ->withPHIDs($value) + ->execute(); + } + + $control = id(new AphrontFormTokenizerControl()) + ->setLabel($this->getFieldName()) + ->setName($this->getFieldKey()) + ->setDatasource('/typeahead/common/accounts/') + ->setValue($handles); + + $limit = $this->getFieldConfigValue('limit'); + if ($limit) { + $control->setLimit($limit); + } + + return $control; + } + + public function appendToApplicationSearchForm( + PhabricatorApplicationSearchEngine $engine, + AphrontFormView $form, + $value, + array $handles) { + + $control = id(new AphrontFormTokenizerControl()) + ->setLabel($this->getFieldName()) + ->setName($this->getFieldKey()) + ->setDatasource('/typeahead/common/accounts/') + ->setValue($handles); + + $form->appendChild($control); + } + +}