I'm running Mediawiki (now 1.20.x) with PageCreator 0.3, LdapAuthentication + RealNames extension in a big ICT Company. All users log in into wiki with their own & unique company ID .The real name of each one is located on realname field of LDAP server and the real name can be show with RealNames extension, because It was developed mainly for Enterprise/Corporate users of MediaWiki where realnames are much more important, and often make much more sense than algorithmically chosen usernames.
For example: login as ABC12345 and the real name is John Doe, the realname display after log in is: John Doe [ABC12345]
Now, I've write a small (and with really bad code...) patch to obtain a new variable {{CREATORREALNAME}} who return the real name of user:
--- GetPageCreator.php_orig 2013-03-28 12:41:30.000000000 +0100 +++ GetPageCreator.php 2013-03-28 15:01:42.000000000 +0100 @@ -11,9 +11,9 @@ */ define( 'PPP_PAGECREATOR', 'PAGECREATOR' ); define( 'PPP_CREATIONTIMESTAMP', 'CREATIONTIMESTAMP' ); - - - +define( 'PPP_PAGEREVISIONUSER', 'PAGEREVISIONUSER' ); +define( 'PPP_CREATORREALNAME', 'CREATORREALNAME' ); + /** * Step 2: define some words to use in wiki markup */ @@ -24,8 +24,8 @@ // magic ID 'mycustomvar1' (0 means case-insensitive) $magicWords[PPP_PAGECREATOR] = array( 0, PPP_PAGECREATOR); $magicWords[PPP_CREATIONTIMESTAMP] = array( 0, PPP_CREATIONTIMESTAMP); - - // must do this or you will silence every LanguageGetMagic hook after this! + $magicWords[PPP_CREATORREALNAME] = array( 0, PPP_CREATORREALNAME); + // must do this or you will silence every LanguageGetMagic hook after this! return true; } @@ -71,12 +71,9 @@ } } - - - - if ( PPP_CREATIONTIMESTAMP == $magicWordId ) { + if ( PPP_PAGECREATOR == $magicWordId ) { global $wgUser; - $revuser = $wgUser->getName(); + $revuser = $wgUser->getRealName(); $ret = $revuser; @@ -96,11 +93,11 @@ $revTable = $dbr->tableName( 'revision' ); $pageId = $myArticle->getId(); - $q0 = "select rev_timestamp from ".$revTable." where rev_page=".$pageId." order by rev_timestamp asc limit 1"; + $q0 = "select rev_user_text from ".$revTable." where rev_page=".$pageId." order by rev_timestamp asc limit 1"; if(($res0 = mysql_query($q0)) && ($row0 = mysql_fetch_object($res0))) { - $ret=$row0->rev_timestamp; -//$ret='coucou'; + $ret=$row0->rev_user_text; +// $ret= $magicWordId ; } else { @@ -109,10 +106,17 @@ $articleId=$myTitle->getArticleID(); // $ret="pageId:".$pageId."-arcticleId:".$articleId."-getText:".$myTitle->getText()."-getFullText:".$myTitle->getFullText(); } + } + +// get the real name of user and return it + if ( PPP_CREATORREALNAME == $magicWordId ) { + global $wgUser; + $revuser = $wgUser->getRealName(); + $ret = $revuser; } - - - + + + // We must return true for two separate reasons: // 1. To permit further callbacks to run for this hook. @@ -152,7 +156,7 @@ // variable IDs. We oblige by adding ours: $customVariableIds[] = PPP_PAGECREATOR; $customVariableIds[] = PPP_CREATIONTIMESTAMP; - + $customVariableIds[] = PPP_CREATORREALNAME; // must do this or you will silence every MagicWordwgVariableIds hook // registered after this! return true;
Usage example: {{PAGECREATOR}} == {{CREATORREALNAME}} return ABC12345 == John Doe
It' simple but it's useful!