Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14347902
D11546.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11546.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1953,6 +1953,7 @@
'PhabricatorMetaMTAActorQuery' => 'applications/metamta/query/PhabricatorMetaMTAActorQuery.php',
'PhabricatorMetaMTAApplication' => 'applications/metamta/application/PhabricatorMetaMTAApplication.php',
'PhabricatorMetaMTAApplicationEmail' => 'applications/metamta/storage/PhabricatorMetaMTAApplicationEmail.php',
+ 'PhabricatorMetaMTAApplicationEmailDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'applications/phid/PhabricatorMetaMTAApplicationEmailPHIDType.php',
'PhabricatorMetaMTAApplicationEmailQuery' => 'applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php',
'PhabricatorMetaMTAAttachment' => 'applications/metamta/storage/PhabricatorMetaMTAAttachment.php',
@@ -5184,6 +5185,7 @@
'PhabricatorMetaMTADAO',
'PhabricatorPolicyInterface',
),
+ 'PhabricatorMetaMTAApplicationEmailDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorMetaMTAApplicationEmailPHIDType' => 'PhabricatorPHIDType',
'PhabricatorMetaMTAApplicationEmailQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorMetaMTAConfigOptions' => 'PhabricatorApplicationConfigOptions',
diff --git a/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php b/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
--- a/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
+++ b/src/applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php
@@ -6,6 +6,7 @@
private $ids;
private $phids;
private $addresses;
+ private $addressPrefix;
private $applicationPHIDs;
public function withIDs(array $ids) {
@@ -23,6 +24,11 @@
return $this;
}
+ public function withAddressPrefix($prefix) {
+ $this->addressPrefix = $prefix;
+ return $this;
+ }
+
public function withApplicationPHIDs(array $phids) {
$this->applicationPHIDs = $phids;
return $this;
@@ -75,6 +81,13 @@
$this->addresses);
}
+ if ($this->addressPrefix !== null) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'appemail.address LIKE %>',
+ $this->addressPrefix);
+ }
+
if ($this->applicationPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
diff --git a/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php b/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php
@@ -0,0 +1,43 @@
+<?php
+
+final class PhabricatorMetaMTAApplicationEmailDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type an application email address...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorMetaMTAApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $emails = id(new PhabricatorMetaMTAApplicationEmailQuery())
+ ->setViewer($viewer)
+ ->withAddressPrefix($raw_query)
+ ->setLimit($this->getLimit())
+ ->execute();
+
+ if ($emails) {
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($emails, 'getPHID'))
+ ->execute();
+ } else {
+ $handles = array();
+ }
+
+ $results = array();
+ foreach ($handles as $handle) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getName())
+ ->setPHID($handle->getPHID());
+ }
+
+ return $results;
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 3:54 AM (20 h, 40 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6908810
Default Alt Text
D11546.diff (3 KB)
Attached To
Mode
D11546: Application Emails - add datasource so we can have a typeahead
Attached
Detach File
Event Timeline
Log In to Comment