Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15402868
D20927.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
D20927.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
@@ -11690,6 +11690,7 @@
'PhabricatorUserEmail' => array(
'PhabricatorUserDAO',
'PhabricatorDestructibleInterface',
+ 'PhabricatorPolicyInterface',
),
'PhabricatorUserEmailTestCase' => 'PhabricatorTestCase',
'PhabricatorUserEmpowerTransaction' => 'PhabricatorUserTransactionType',
diff --git a/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php b/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php
--- a/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php
+++ b/src/applications/people/phid/PhabricatorPeopleUserEmailPHIDType.php
@@ -29,6 +29,12 @@
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
+
+ foreach ($handles as $phid => $handle) {
+ $email = $objects[$phid];
+ $handle->setName($email->getAddress());
+ }
+
return null;
}
diff --git a/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php b/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php
--- a/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php
+++ b/src/applications/people/query/PhabricatorPeopleUserEmailQuery.php
@@ -48,6 +48,32 @@
return $where;
}
+ protected function willLoadPage(array $page) {
+
+ $user_phids = mpull($page, 'getUserPHID');
+
+ $users = id(new PhabricatorPeopleQuery())
+ ->setViewer($this->getViewer())
+ ->setParentQuery($this)
+ ->withPHIDs($user_phids)
+ ->execute();
+ $users = mpull($users, null, 'getPHID');
+
+ foreach ($page as $key => $address) {
+ $user = idx($users, $address->getUserPHID());
+
+ if (!$user) {
+ unset($page[$key]);
+ $this->didRejectResult($address);
+ continue;
+ }
+
+ $address->attachUser($user);
+ }
+
+ return $page;
+ }
+
public function getQueryApplicationClass() {
return 'PhabricatorPeopleApplication';
}
diff --git a/src/applications/people/storage/PhabricatorUserEmail.php b/src/applications/people/storage/PhabricatorUserEmail.php
--- a/src/applications/people/storage/PhabricatorUserEmail.php
+++ b/src/applications/people/storage/PhabricatorUserEmail.php
@@ -6,7 +6,9 @@
*/
final class PhabricatorUserEmail
extends PhabricatorUserDAO
- implements PhabricatorDestructibleInterface {
+ implements
+ PhabricatorDestructibleInterface,
+ PhabricatorPolicyInterface {
protected $userPHID;
protected $address;
@@ -14,6 +16,8 @@
protected $isPrimary;
protected $verificationCode;
+ private $user = self::ATTACHABLE;
+
const MAX_ADDRESS_LENGTH = 128;
protected function getConfiguration() {
@@ -52,6 +56,15 @@
return parent::save();
}
+ public function attachUser(PhabricatorUser $user) {
+ $this->user = $user;
+ return $this;
+ }
+
+ public function getUser() {
+ return $this->assertAttached($this->user);
+ }
+
/* -( Domain Restrictions )------------------------------------------------ */
@@ -287,4 +300,28 @@
$this->delete();
}
+
+/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
+ public function getCapabilities() {
+ return array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ );
+ }
+
+ public function getPolicy($capability) {
+ $user = $this->getUser();
+
+ if ($this->getIsSystemAgent() || $this->getIsMailingList()) {
+ return PhabricatorPolicies::POLICY_ADMIN;
+ }
+
+ return $user->getPHID();
+ }
+
+ public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
+ return false;
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 19, 12:46 AM (3 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7582196
Default Alt Text
D20927.diff (3 KB)
Attached To
Mode
D20927: Implement "PolicyInterface" on "UserEmail" so "EmailQuery" can load them properly
Attached
Detach File
Event Timeline
Log In to Comment