Thursday, May 17, 2012

Change the login link in MediaWiki

As usual I have searched the WWW but I obviously don't how to use Google because I couldn't find an answer. My situation is this:
  • We have an internal wiki knowledge base using MediaWiki version 1.14.
  • Some articles are available for public, some are restricted to staff and different localgroups.
  • When users click on the 'Login' link, we want the system to automatically prompt them for their username/password. (Kerberos authenticated, as opposed to NTLM authenticated).
  • Note: This article is displaying how to change the link and not how to setup these authentication methods.


Open your skin file /skins/.php. Look for and change the following lines:
	<div class="portlet" id="p-personal">
		<h5><?php $this->msg('personaltools') ?></h5>
		<div class="pBody">
			<ul>
<?php 			foreach($this->data['personal_urls'] as $key => $item) { ?>
				<li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
					if ($item['active']) { ?> class="active"<?php } ?>><a href="/<?php
				echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
				if(!empty($item['class'])) { ?> class="<?php
				echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
				echo htmlspecialchars($item['text']) ?></a></li>
<?php			} ?>
			</ul>
		</div>
	</div>
To
	<div class="portlet" id="p-personal">
		<h5><?php $this->msg('personaltools') ?></h5>
		<div class="pBody">
			<ul>
<?php			foreach($this->data['personal_urls'] as $key => $item) { ?>
					if (($key!="login")&&($key!="logout")&&($key!="anonlogin")) {
						<li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
						if ($item['active']) { ?> class="active"<?php } ?>><a href="/<?php
						echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
						if(!empty($item['class'])) { ?> class="<?php
							echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
						echo htmlspecialchars($item['text']) ?></a></li>
<?php				}
				} 
				if($this->data['loggedin']==1) {
					echo '<li id="pt-logout"><a href="/index.php?title=Special:Userlogout&returnto=Special:MainPage" title="Log Out">Log out</a></li>';
				} else {
					echo '<li id="pt-login"><a href="/wiki/Special:UserLogin?returnto='.trim($_GET['title']).'" title="You are encouraged to log in; however, it is not mandatory [alt-o]" accesskey="o">Log in</a></li>';
				} ?>
			</ul>
		</div>
	</div>
What does this do?
  • Excludes displaying system login, anonymous login or logout links in personal toolbar
  • Add a list item linking to your own login page (in this example the default one as ours is Kerberos_Login) with login or logout link.

Add comment

Please note: all comments are reviewed before being published.


Security code
Refresh

Member Login

Joes Latest Members

A huge WELCOME goes to today's newest members:

  • infonat
Member Signups (Activated)
BeforeCurrentTrend
Day21=
Week105ê
Month11224ê
Year2,265612ê

Member Stats
56 guests are currently online.
1,178 members are still deciding.
There are 5,935 members in total.

Latest Comments

Paypal Donations

Want to support my work? Any donation is a blessing :c)