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:
copyraw
<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>
  1.  <div class="portlet" id="p-personal"> 
  2.          <h5><?php $this->msg('personaltools') ?></h5> 
  3.          <div class="pBody"> 
  4.              <ul> 
  5.  <?php             foreach($this->data['personal_urls'] as $key => $item) { ?> 
  6.                  <li id="<?php echo Sanitizer::escapeId( "pt-$key) ?>"<?php 
  7.                      if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php 
  8.                  echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php 
  9.                  if(!empty($item['class'])) { ?> class="<?php 
  10.                  echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php 
  11.                  echo htmlspecialchars($item['text']) ?></a></li> 
  12.  <?php            } ?> 
  13.              </ul> 
  14.          </div> 
  15.      </div> 
To
copyraw
<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>
  1.  <div class="portlet" id="p-personal"> 
  2.          <h5><?php $this->msg('personaltools') ?></h5> 
  3.          <div class="pBody"> 
  4.              <ul> 
  5.  <?php            foreach($this->data['personal_urls'] as $key => $item) { ?> 
  6.                      if (($key!="login")&&($key!="logout")&&($key!="anonlogin")) { 
  7.                          <li id="<?php echo Sanitizer::escapeId( "pt-$key) ?>"<?php 
  8.                          if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php 
  9.                          echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php 
  10.                          if(!empty($item['class'])) { ?> class="<?php 
  11.                              echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php 
  12.                          echo htmlspecialchars($item['text']) ?></a></li> 
  13.  <?php                } 
  14.                  } 
  15.                  if($this->data['loggedin']==1) { 
  16.                      echo '<li id="pt-logout"><a href="/index.php?title=Special:Userlogout&returnto=Special:MainPage" title="Log Out">Log out</a></li>'
  17.                  } else { 
  18.                      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>'
  19.                  } ?> 
  20.              </ul> 
  21.          </div> 
  22.      </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.
Category: MediaWiki :: Article: 296

Add comment

Your rating:

Submit

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Accreditation

Badge - Zoho Creator Certified Developer Associate
Badge - Zoho Deluge Certified Developer
Badge - Certified Zoho CRM Developer

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF

Please publish modules in offcanvas position.