Chad has submitted this change and it was merged.
Change subject: CustomField extension that adds a "MediaWiki Userpage" link on
phabricator user profile pages when a phabricator account is linked to
mediawiki oauth.
......................................................................
CustomField extension that adds a "MediaWiki Userpage"
link on phabricator user profile pages when a phabricator
account is linked to mediawiki oauth.
Change-Id: I52462555c824eca3a9efc6aea52431702e7133dc
---
A MediaWikiUserpageCustomField.php
1 file changed, 50 insertions(+), 0 deletions(-)
Approvals:
Chad: Verified; Looks good to me, approved
Objections:
Mattflaschen: There's a problem with this change, please improve
diff --git a/MediaWikiUserpageCustomField.php b/MediaWikiUserpageCustomField.php
new file mode 100644
index 0000000..3e6cc4a
--- /dev/null
+++ b/MediaWikiUserpageCustomField.php
@@ -0,0 +1,50 @@
+<?php
+
+final class MediaWikiUserpageCustomField extends PhabricatorUserCustomField {
+
+ public function shouldUseStorage() {
+ return false;
+ }
+
+ public function getFieldKey() {
+ return 'mediawiki:externalaccount';
+ }
+
+ public function shouldAppearInPropertyView() {
+ return true;
+ }
+
+ public function renderPropertyViewLabel() {
+ return pht('MediaWiki Userpage');
+ }
+
+ public function renderPropertyViewValue(array $handles) {
+ $user = $this->getObject();
+
+ $account = id(new PhabricatorExternalAccount())->loadOneWhere(
+ 'userPHID = %s AND accountType = %s',
+ $user->getPHID(),
+ 'mediawiki');
+
+ if (! $account || !strlen($account->getAccountURI())) {
+ return pht('Unknown');
+ }
+
+ $uri = $account->getAccountURI();
+
+ // Split on the User: part of the userpage uri
+ $name = explode('User:',$uri);
+ // grab the part after User:
+ $name = array_pop($name);
+ // decode for display:
+ $name = urldecode($name);
+
+ return phutil_tag(
+ 'a',
+ array(
+ 'href' => $uri
+ ),
+ $name);
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/144711
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I52462555c824eca3a9efc6aea52431702e7133dc
Gerrit-PatchSet: 4
Gerrit-Project: phabricator/extensions
Gerrit-Branch: master
Gerrit-Owner: 20after4 <[email protected]>
Gerrit-Reviewer: 20after4 <[email protected]>
Gerrit-Reviewer: Aklapper <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Greg Grossmeier <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Rush <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits