Page MenuHomePhabricator

Making an extension that can affect Flow
Closed, InvalidPublic

Description

I'm working on an extension to be used on my wiki which would give classes showing their user groups to the user links that have the mw-userlink class. The reason I want to do this is because I want to format the links for certain user groups differently in CSS.

Here is the php code that I'm using for MediaWiki core:

$wgHooks['HtmlPageLinkRendererBegin'][] = 'handle_link';

function handle_link( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) {
  if(strpos($customAttribs['class'], 'mw-userlink') !== false){
    $username = explode(':',$target)[1];
    if(strpos($username,'/') !== false){
      $username = explode('/',$username)[1];
    }
    $customAttribs['class'] = $customAttribs['class'] . ' mw-userlink-user-' . $username . get_user_group_classes($username,'mw-userlink-group-');
    
  }
  return true;
}
   
function get_user_group_classes($username,$groupprefix,$commonclass){
  $ret = '';
  if($commonclass){
    $ret = $ret . ' ' . $commonclass;
  }
  $user = User::newFromName( $username );
  if(!$user){
    $ret = $ret . ' ERROR-with-user-' . $username;
    return $ret;
  }
  $groups = $user->getGroups();
  foreach($groups as $key => $group){
    $ret = $ret . ' ' . $groupprefix . $group;
  }
  return $ret;
}

The only problem I have is I don't know what code I need to use in order to affect the user links that have the mw-userlink class on the Flow boards without directly modifiying the files of the Flow extension or other extensions. What should I do?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Tribly updated the task description. (Show Details)
Aklapper closed this task as Invalid.EditedJun 7 2017, 3:05 PM

Hi @Tribly. This does not sound like something is wrong in the code base (a so-called "software bug"), but instead like a support request (questions how to do something, etc.).
As Wikimedia Phabricator/Maniphest is for bug reports and enhancement requests, please ask on the MediaWiki Support Desk or ask on a dedicated project/extension talk page like https://www.mediawiki.org/wiki/Extension_talk:Flow or by contacting the Collaboration team which maintains the Flow software. When asking there, please include version information for the MediaWiki software (and for any other projects/extensions that your problem is related to). Thanks for your understanding!
Closing this task as invalid as it is out of scope for Phabricator (it could however be in scope if the task was a enhancement request to Flow code to allow it "affect user links which have the mw-userlink class on the Flow boards").

Oh sorry. I did not knew that. I'll try to make a contact on those other channels you suggested.