User talk:Callum Wilson

From mediawiki.org
Latest comment: 16 years ago by Callum Wilson

Hello, I have a question which folows the note you added in the LDAP Authntication discussion board: How do I change the "special:Recentchanges" list, to include the user_real_name? --David, 05:25, 3 February 2008 (UTC)

Hi David, I only have used real names in the page histories so far but have it on my list of todos. Here is our own (internal) wiki link on how to do the page histories.

--Callum Wilson 10:44, 4 February 2008 (UTC)Reply

Using Real Names in Page History[edit]

One of the problems with the early version of the wiki was that the page history pages just showed the username of the editor - since the XXXCOMPANYXX usernames are numbersd, this made it difficult to determine who actually did the revision.

e.g. the old way:

  • (cur) (last) 08:32, 1 November 2007 T1325300 (Talk | contribs | block) (17,713 bytes) (→Extra Steps) [rollback]

the new look:

  • (cur) (last) 08:32, 1 November 2007 (Wilson Callum) T1325300 (Talk | contribs | block) (17,713 bytes) (→Extra Steps) [rollback]

Add a function to Revision.php
The Revision.php is stored in the wiki/includes folder. Add this function:

/**
 * Fetch the real name of the revisioner. CW XXXCOMPANYXXX
 * @return string
 */
 function getUserRealName() {
   if( $this->isDeleted( self::DELETED_USER ) ) {
      return "";
   } else {
      return User::whoIsReal($this->mUser);
   }
 }

Adding the Real Name to the History Page
Now edit the PageHistory.php and navigate to the historyLine function. The standard code will build up the $user string to include a link rather like this T1325300. Just change the $user string to look like:

  $user = ' (' . $rev->getUserRealName() . ') ';
  $user .= $this->mSkin->userLink( $rev->getUser(), $rev->getUserText() )
                                . $this->mSkin->userToolLinks( $rev->getUser(), $rev->getUserText() );
Thank you very much, it is very useful also. --David, 16:55, 4 February 2008 (UTC)

Making the UserList more helpful[edit]

Because XXXCOMPANYXXX usernames are numbers, the standard mediawiki Special:Listusers page normally just displays the user account names. This modification adds in the long name of the user in italics. e.g.

  • T1325300: Wilson Callum ‎(Bureaucrat, Sysop)

instead of:

Making the change:

  • open the file SpecialListuser.php
$ cd includes/
$ vi SpecialListuser.php
  • then change these bits of code
  • firstly, in GetQueryInfo(), add user_real_name to the fields paramater
'fields' => array('user_real_name','user_name',
                        'MAX(user_id) AS user_id',
                        'COUNT(ug_group) AS numgroups',
                        'MAX(ug_group) AS singlegroup'),
                        'options' => array('GROUP BY' => 'user_name'),
                        'conds' => $conds
  • then in formatRow() add in the realname display:
        function formatRow( $row ) {
                $userPage = Title::makeTitle( NS_USER, $row->user_name );

                $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) );
                $realname = ': <i>' .  $row->user_real_name . '</i>';

                if( $row->numgroups > 1 || ( $this->requestedGroup && $row->numgroups == 1 ) ) {
                        $list = array();
                        foreach( self::getGroups( $row->user_id ) as $group )
                                $list[] = self::buildGroupLink( $group );
                        $groups = implode( ', ', $list );
                } elseif( $row->numgroups == 1 ) {
                        $groups = self::buildGroupLink( $row->singlegroup );
                } else {
                        $groups = '';
                }

                return '<li>' . wfSpecialList( $name . $realname, $groups ) . '</li>';
        }