Rush has submitted this change and it was merged.

Change subject: add LDAP username / link to profile to profile
......................................................................


add LDAP username / link to profile to profile

Some people (like me) have different names on wikitech
than on Phab or other systems (including IRC).

Change-Id: I0c2c4a6234a756c268a18e154855a35f119263bb
---
A LDAPUserpageCustomField.php
1 file changed, 44 insertions(+), 0 deletions(-)

Approvals:
  Rush: Verified; Looks good to me, approved



diff --git a/LDAPUserpageCustomField.php b/LDAPUserpageCustomField.php
new file mode 100644
index 0000000..41af321
--- /dev/null
+++ b/LDAPUserpageCustomField.php
@@ -0,0 +1,44 @@
+<?php
+
+final class LDAPUserpageCustomField extends PhabricatorUserCustomField {
+
+  public function shouldUseStorage() {
+    return false;
+  }
+
+  public function getFieldKey() {
+    return 'ldap:externalaccount';
+  }
+
+  public function shouldAppearInPropertyView() {
+    return true;
+  }
+
+  public function renderPropertyViewLabel() {
+    return pht('LDAP User');
+  }
+
+  public function renderPropertyViewValue(array $handles) {
+    $user = $this->getObject();
+
+    $account = id(new PhabricatorExternalAccount())->loadOneWhere(
+      'userPHID = %s AND accountType = %s',
+      $user->getPHID(),
+      'ldap');
+
+    if (! $account || !strlen($account->getusername())) {
+      return pht('Unknown');
+    }
+    $url = 'https://wikitech.wikimedia.org/wiki/User:';
+    $name = $account->getusername();
+    $uri = urldecode($url . $name);
+
+    return phutil_tag(
+      'a',
+      array(
+        'href' => $uri
+      ),
+      $name);
+  }
+
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/181609
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0c2c4a6234a756c268a18e154855a35f119263bb
Gerrit-PatchSet: 2
Gerrit-Project: phabricator/extensions
Gerrit-Branch: master
Gerrit-Owner: Rush <[email protected]>
Gerrit-Reviewer: Rush <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to