Extension talk:ShowRealUsernames/Archive 1
This page is an archive. Do not edit the contents of this page. Please direct any additional comments to the current talk page. |
Code doesn't seem to work for me. SRUquery throws an exception:
Detected bug in an extension! Hook SRUquery failed to return a value; should return true to continue hook processing or false to abort.
Backtrace:
- 0 C:\Wiki\htdocs\mediawiki\includes\specials\SpecialListusers.php(112): wfRunHooks('SpecialListuser...', Array)
- 1 C:\Wiki\htdocs\mediawiki\includes\Pager.php(239): UsersPager->getQueryInfo()
- 2 C:\Wiki\htdocs\mediawiki\includes\Pager.php(148): IndexPager->reallyDoQuery('', 51, true)
- 3 C:\Wiki\htdocs\mediawiki\includes\specials\SpecialListusers.php(157): IndexPager->doQuery()
- 4 C:\Wiki\htdocs\mediawiki\includes\specials\SpecialListusers.php(269): UsersPager->getBody()
- 5 [internal function]: wfSpecialListusers(NULL, Object(SpecialPage))
- 6 C:\Wiki\htdocs\mediawiki\includes\SpecialPage.php(771): call_user_func('wfSpecialListus...', NULL, Object(SpecialPage))
- 7 C:\Wiki\htdocs\mediawiki\includes\SpecialPage.php(559): SpecialPage->execute(NULL)
- 8 C:\Wiki\htdocs\mediawiki\includes\Wiki.php(229): SpecialPage::executePath(Object(Title))
- 9 C:\Wiki\htdocs\mediawiki\includes\Wiki.php(59): MediaWiki->initializeSpecialCases(Object(Title), Object(OutputPage), Object(WebRequest))
- 10 C:\Wiki\htdocs\mediawiki\index.php(116): MediaWiki->initialize(Object(Title), NULL, Object(OutputPage), Object(User), Object(WebRequest))
- 11 {main}
- In general, this type of error message is caused by a change in MediaWiki which took place at or before version 1.14a; the easiest fix is to go to the end of whatever routine it's complaining about in the extension (in this case, SRUquery()) and add: Very common to see this when using many old extensions on any of this year's MediaWiki versions, unfortunately. --Carlb 12:15, 10 September 2009 (UTC)
return true;
———
- NOTE: I had this problem with MW1.15.5, I found that PHP>5.3.0 also causes this problem, even if function does return a value. You need to edit code to remove ampersands, thus:
- function SRUquery( &$pager, &$query ) {
- becomes
- function SRUquery( $pager, $query ) {
- and
- function SRUrow( &$item, $row ) {
- becomes
- function SRUrow( $item, $row ) {
Something wrong and extension is not working
MediaWiki 1.14.0 PHP 5.2.9 (apache2handler) MySQL 5.1.33-community
Retrieved from "http://www.mediawiki.org/wiki/Extension:ShowRealUsernames" Warning: Cannot modify header information - headers already sent by (output started at C:\Programme\xampp\htdocs\FYwiki\extensions\ShowRealUsernames\ShowRealUsernames.php:95) in C:\Programme\xampp\htdocs\FYwiki\includes\WebResponse.php on line 16
Warning: Cannot modify header information - headers already sent by (output started at C:\Programme\xampp\htdocs\FYwiki\extensions\ShowRealUsernames\ShowRealUsernames.php:95) in C:\Programme\xampp\htdocs\FYwiki\includes\WebResponse.php on line 16
How can one fix this or how to find the reason? Thanks! --Jostar 09:14, 1 December 2009 (UTC)
Restricting who sees the Real Names
I only wanted 'crats to be able to see the Real Names, so I altered the SRUrow
function to add a check for the user having the showrealname right, as shown below:
function SRUrow( &$item, $row ) {
global $wgShowRealUsernamesInline, $wgUser;
$realName = htmlspecialchars( trim( $row->user_real_name ) );
if ( $realName == "" )
return true; # nothing to do
# Only show the real name if the user had the 'showrealname' right
if( $wgUser->isAllowed( 'showrealname' ) ) {
$m = array();
if(preg_match('/^(.*?<a\b[^>]*>)([^<]*)(<\/a\b[^>]*>)(.*)$/',$item,$m)) {
if ($wgShowRealUsernamesInline)
$item = $m[1] . wfMsg( 'sru-realname-inline', $realName ) . $m[3] . $m[4];
else
$item = $m[1] . $m[2] . $m[3] . wfMsg( 'sru-realname-append', $realName ) . $m[4];
}
return true;
}
else
return true;
}
Then I added the following to my LocalSettings.php
after the require_once call:
# Prevent people seeing Real Names in ShowRealUsernames:
$wgGroupPermissions['*']['showrealname'] = false;
# Allow 'crats to see Real Names in ShowRealUsernames:
$wgGroupPermissions['bureaucrat']['showrealname'] = true;
# Show real names if you are in the showrealname group
$wgGroupPermissions['showrealname']['showrealname'] = true;
I hope that this is useful (I know it works on MW 1.15.4) - I was tempted to change the documentation on the main Extension:ShowRealUsernames page, but I'll leave that to someone else! -- PhantomSteve/talk|contribs\ 16:45, 24 June 2010 (UTC)
- well looking, works fine, should be added to the extension code --Jostar 22:58, 24 June 2010 (UTC)
- This has been incoporated into version 1.2. - RV1971 (talk) 13:36, 17 April 2013 (UTC)
Internationalizartion issues: description and attempting to view ShowRealUsenames.i18n.php
The main file, ShowRealUsenames.php starts with a comment and then says:
if( !defined( 'MEDIAWIKI' ) ) {
echo "ShowRealUsernames: This is an extension to the MediaWiki package and cannot be run standalone.\n";
die( -1 );
I think something similar should be done in the internationalization file ShowRealUsernames.i18n.php. Also, the description shown in Special:Version could be internationalized by using a descriptionmsg instead. I have written a descriptionmsg in English and one in Spanish here:
<?php
/**
* Internationalization for ShowRealUsernames MediaWiki extension; MediaWiki version 1.13.3
*
* @file
* @ingroup Extensions
* @version 1.0
* @license public domain (given on http://www.mediawiki.org/wiki/Extension:ShowRealUsernames)
* @author Paul Lustgarten, modified by John Erling Blad
* @link http://www.mediawiki.org/wiki/Extension:ShowRealUsernames
*/
# Not a valid entry point, skip unless MEDIAWIKI is defined
if( !defined( 'MEDIAWIKI' ) ) {
echo "ShowRealUsernames: This is an extension to the MediaWiki package and cannot be run standalone.\n";
die( -1 );
}
$messages = array();
$messages['en'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' - $1',
'sru-description' => 'Extend the Special:Listusers page to show the real name of each user.',
);
$messages['es'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' — $1',
'sru-description' => 'Extiende la página Especial:ListaUsuarios para mostrar el nombre real de cada usuario.',
);
$messages['no'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' – $1',
);
$messages['nn'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' – $1',
);
and if the description is translated in the ShowRealUsernames.i18n.php page, in the ShowRealUsernames.php file, instead of:
'description' => 'Extend the Special:Listusers page to show the real name of each user.',
It could then be:
'descriptionmsg' => 'sru-description',
However, I have not tested the extension with these changes. Nlemslu Phlyshi 09:49, 8 July 2011 (UTC)
- Tested now and it seems to work correctly, however, the á may need to be written á if the text editor attempts to use a wrong encoding, I also suggest (and have tested) replacing "Special:ListUsers" with a wikilink, in Spanish that is "Especial:ListaUsuarios". It could be translated to other languages as well. I have attempted to add a translation to Danish of the messages and one to Bokmål Norwegian of the message, I am not completely sure about the accuracy of the latter one, but I cannot find any specific word in it that looks wrong, so I add it below anyway:
<?php
/**
* Internationalization for ShowRealUsernames MediaWiki extension; MediaWiki version 1.13.3
*
* @file
* @ingroup Extensions
* @version 1.0
* @license public domain (given on http://www.mediawiki.org/wiki/Extension:ShowRealUsernames)
* @author Paul Lustgarten, modified by John Erling Blad
* @link http://www.mediawiki.org/wiki/Extension:ShowRealUsernames
*/
# Not a valid entry point, skip unless MEDIAWIKI is defined
if( !defined( 'MEDIAWIKI' ) ) {
echo "ShowRealUsernames: This is an extension to the MediaWiki package and cannot be run standalone.\n";
die( -1 );
}
$messages = array();
$messages['da'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' – $1',
'sru-description' => 'Udvider [[Speciel:Brugerliste]] til at vise hver af brugernes virkelige navne.',
);
$messages['en'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' - $1',
'sru-description' => 'Extend the [[Special:Listusers]] page to show the real name of each user.',
);
$messages['es'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' — $1',
'sru-description' => 'Extiende la página [[Especial:ListaUsuarios]] para mostrar el nombre real de cada usuario.',
);
$messages['no'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' – $1',
'sru-description' => 'Utvider [[Spesial:Brukerliste]] til å vise hver av brukernes virkelige namna.',
);
$messages['nn'] = array(
'sru-realname-inline' => '$1',
'sru-realname-append' => ' – $1',
);
- I added it here. Cheers --[[kgh]] (talk) 01:39, 22 July 2012 (UTC)