How to resolve “I am unable to logout from my Joomla website” problem

A new solicitor firm based in the UK signed up for website maintenance with our company. The website had been developed in Joomla and running for the past 1 year. The first issue they reported was that their members were not able to log out from the website even if they clicked on the logout button. They were concerned (and rightly so) that their member’s account could be used to perform any negative activity on the website.

The form code for the logout button was as follows

<form action="index.php" method="post" name="login" id="form-login">
<?php if ($params->get('greeting')) : ?>
<div>
<?php if ($params->get('name')) : {
echo JText::sprintf( 'HINAME', $user->get('name') );
} else : {
echo JText::sprintf( 'HINAME', $user->get('username') );
} endif; ?>
</div>
<?php endif; ?>
<div align="center">
<input type="submit" name="Submit" class="button" value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" />
</div>

<input type="hidden" name="option" value="com_user" />
<input type="hidden" name="task" value="logout" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
</form>

After initial assessment I found that the logout code was doing a POST instead of sending the parameters in querystring. Due to this Joomla did not know whether the visitor was trying to logout or not.

I opened the modules/mod_login/tmpl/default.php and changed the form action from POST to GET.

I also added the following hidden field

<input type="hidden" name="view" value="login" />

So the final form code comes out to be as follows

<form action="index.php" method="get" name="login" id="form-login">
<?php if ($params->get('greeting')) : ?>
<div>
<?php if ($params->get('name')) : {
echo JText::sprintf( 'HINAME', $user->get('name') );
} else : {
echo JText::sprintf( 'HINAME', $user->get('username') );
} endif; ?>
</div>
<?php endif; ?>
<div align="center">
<input type="submit" name="Submit" class="button" value="<?php echo JText::_( 'BUTTON_LOGOUT'); ?>" />
</div>

<input type="hidden" name="option" value="com_user" />
<input type="hidden" name="view" value="login" />
<input type="hidden" name="task" value="logout" />
<input type="hidden" name="return" value="<?php echo $return; ?>" />
</form>

I saved the file and the logout started to work fine after that.

Hope the above helped. Comments?

How to resolve the empty confirmCode issue in Joomla

I was working on a client website based on Joomla. When any member registered on the website an email was sent to the member’s email address to verify his account. The email was coming up fine but the confirmCode variable in the query string was empty. Client wanted me to resolve it so I set to work on it.

The email text was generated from the administrator/components/com_comprofiler/comprofiler.class.php file. The function generating the email text is _replaceVariables. There is one function by that name in the file so you can just do Ctrl-F and do a search for it. For some reason, there was a check in the file as follows

if ( $row->cbactivation ) {
         $confirmCode = $row->cbactivation;
}
else {
         $confirmCode = '';
}

No guessing here. The code was always going to the else condition as the $row->cbactivation was empty. After going through the code, I found that the encryption code was being generated but not saved in the cbactivation column in the jos_comprofiler table. Due to this the confirmCode was always empty.

The best solution I came up with was generate the code, save it in the database and send it to the member from the same function i.e. _replaceVariables. I copied over the encryption code and altered the code in the else block to the following:

//$confirmCode = '';
$row->cbactivation = "reg" . md5( cbMakeRandomString() ) . sprintf( "%08x", ((int) hexdec(substr( md5 ( $mainframe->getCfg( 'secret' ) . $mainframe->getCfg( 'db' ) ), 0, 7))) ^ ( (int) $row->id ) ); 
$_CB_database->setQuery( "UPDATE #__comprofiler SET cbactivation='".$row->cbactivation."' WHERE user_id='".$row->id."' " );
$_CB_database->query();
$confirmCode = $row->cbactivation;	

The code above generates the encryption code and saves it into the database which is what I wanted. I registered a member on the website and voila I got the email with the confirmCode coming up. I clicked on the URL and my account was also confirmed.

I also got some help from the following solution at JoomlaPolis.

Hope the above helped.

Customize menus in Joomla 1.5

Joomla 1.5 has come a long way since Joomla 1.2. Earlier if you had to customize a module you had two choices:

1. Edit code in the actual module file.
2. Write custom code to implement the functionality.

Choosing either of the two steps would involve more time and in the end it also invited the chance of more bugs into the working of the system. However, with the advent of Joomla 1.5 you don’t need to go through all that hassle.

You have to navigate to the module folder in which you have to make the customization and make the changes in the files present in the tmpl folder. This has considerably improved customizing functionality according to requirements. Now, the developer does not need to have to do anything in the actual code file of the module rather he just has to use the methods exposed to him in the tmpl folder and customize them.

Try Joomla 1.5 today and you will definitely see the difference.