Tips & Tricks

Mambo CMS Tips & Tricks: Part 1

Login with user photo

mambo

This trick will show a users photo, avatar, default user image and link to Community Builder Profile, in the login area, upon successful logon. This is for Mambo 4.5.1

This trick is in use at this site.

Step 1) You need to have mod_comprofilerlogin451.php installed. If you do not you can download it from internet or you can download the completed hack ready to install at the end of this article.

Step 2) Once installed, navigate to your mod directory and open up mod_comprofilerlogin451.php in your editor and select all then delete.

Step 3) Copy the code on the next page, and paste it in the file and then save and close the file. Your all done, enjoy

<?php
// $Id: mod_comprofilerlogin.php,v 1.1 2004/09/24 23:13:30 mambojoe Exp $
/**
* @package Mambo Open Source
* @Copyright (C) 2000 – 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.1 $
**/
/**
* Login modified by Jeffrey Randall(mrjeff)
* Date 21-02-2005
* Version 1.4
* Show user photo, avatar or default photo
* along with link to Community Builder
* Profile upon login.
* Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
**/
defined( ‘_VALID_MOS’ ) or
die( ‘Direct Access to this location is not allowed.’ );

$return = mosGetParam( $_SERVER, ‘REQUEST_URI’, null );
// converts & to & for xtml compliance
$return = str_replace( ‘&’, ‘&’, $return );

$registration_enabled = $mainframe->getCfg( ‘allowUserRegistration’ );
$pretext = $params->get( ‘pretext’ );
$posttext = $params->get( ‘posttext’ );
$login = $params->def( ‘login’, $return );
$logout = $params->def( ‘logout’, $return );
$message_login = $params->def( ‘login_message’, 0 );
$message_logout = $params->def( ‘logout_message’, 0 );
$name = $params->def( ‘name’, 1 );
$greeting = $params->def( ‘greeting’, 1 );

if ( $name ) {
$query = “SELECT name FROM #__users WHERE id = “. $my->id;
$database->setQuery( $query );
$name = $database->loadResult();
}
else
{
$name = $my->username;
}

if ( $my->id ) {
?>
<br/>
<form action=”<?php
echo sefRelToAbs( ‘index.php?option=logout’ ); ?>” method=”post” name=”login” >
<?php

$avatar_path = $mosConfig_live_site.”/images/comprofiler/”;
$user_photo_path = $mosConfig_live_site.”/images/comprofiler/tn”;

$attributes = “\”hspace=\”4\” align=\”left\” border=\”0\” alt=\”$name\””;

$query = “SELECT avatar FROM #__comprofiler WHERE id = “. $my->id;
$database->setQuery( $query );
$pic = $database->loadResult();

if(preg_match(‘/(gallery)/’,$pic)){
echo “<a href=\”index.php?option=
com_comprofiler&task=userProfile&user=”.$my->id.”\”>\n”;
echo “<img src=\”$avatar_path$pic$attributes/></a>\n”;}

elseif(preg_match(‘/(jpg)/’,$pic)){
echo “<a href=\”index.php?option=
com_comprofiler&task=userProfile&user=”.$my->id.”\”>\n”;
echo “<img src=\”$user_photo_path$pic$attributes/></a>\n”;}

elseif(preg_match(‘/(png)/’,$pic)){
echo “<a href=\”index.php?option=
com_comprofiler&task=userProfile&user=”.$my->id.”\”>\n”;
echo “<img src=\”$user_photo_path$pic$attributes/></a>\n”;}

else //user has no photo or avatar, show default image
{
echo “<a href=\”index.php?option=
com_comprofiler&task=userProfile&user=”.$my->id.”\”>\n”;
echo “<img src=\”components/com_comprofiler/images/english/tnnophoto.jpg
$attributes/></a>\n”;}

?>
<div align=”center”>

<?php
if ( $greeting ) {
echo _HI.”
“;
echo $name;
}
?>

<input type=”submit” name=”Submit” class=”button” value=”
<?php echo _BUTTON_LOGOUT; ?>” />
</div>

<input type=”hidden” name=”op2″ value=”logout” />
<input type=”hidden” name=”lang” value=”<?php echo $mosConfig_lang; ?>” />
<input type=”hidden” name=”return” value=”<?php echo sefRelToAbs( $logout ); ?>” />
<input type=”hidden” name=”message” value=”<?php echo $message_logout; ?>” />
</form>
<?php
} else {
?>
<form action=”<?php
echo sefRelToAbs(“index.php?option=com_comprofiler&task=
login”); ?>” method=”post” name=”login” >
<?php
echo $pretext;
?>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ align=”center”>
<tr>
<td>
<?php echo _USERNAME; ?>

<input name=”username” type=”text” class=”inputbox” alt=”username” size=”10″ />

<?php echo _PASSWORD; ?>

<input type=”password” name=”passwd” class=”inputbox” size=”10″ alt=”password” />

<input type=”checkbox” name=”remember” class=”inputbox” value=”yes” alt=”Remember Me” />
<?php echo _REMEMBER_ME; ?>

<input type=”submit” name=”Submit” class=”button” value=”
<?php echo _BUTTON_LOGIN; ?>” />
</td>
</tr>
<tr>
<td>
<a href=”<?php
echo sefRelToAbs(“index.php?option=com_comprofiler&task=lostPassword”); ?>”>
<?php echo _LOST_PASSWORD; ?>
</a>
</td>
</tr>
</table>
<?php
echo $posttext;
?>
<input type=”hidden” name=”op2″ value=”login” />
<input type=”hidden” name=”lang” value=”<?php echo $mosConfig_lang; ?>” />
<input type=”hidden” name=”return” value=”<?php echo sefRelToAbs( $login ); ?>” />
<input type=”hidden” name=”message” value=”<?php echo $message_login; ?>” />
</form>

<?php
if ( $registration_enabled ) {
?>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″ align=”center”>
<tr>
<td>
<?php echo _NO_ACCOUNT; ?>
<a href=”<?php
echo sefRelToAbs(“index.php?option=com_comprofiler&task=registers”); ?>”>
<?php echo _CREATE_ACCOUNT;?>
</a>
</td>
</tr>
</table>
<?php
}
}
?>

Link to a User Home Pages in their profile

UHP is a component that allows registered users to create their own home page, upload images and customize what is shown there. The Image gallery displays thumbnails etc.

To show a link to a User Home Pages in their profile. Follow the steps below.

Step 1) Open up comprofiler.html.php located in the directory “/components/comprofiler/” and find the following lines of code.

<tr>
<td class=sectiontableentry<?php echo $i; ?> width=35% style=”font-weight:bold;”>
<?php echo _UE_HITS; ?></td>
<td class=sectiontableentry<?php echo $i; ?> ><?php echo $user->hits; ?>
</td>
</tr>

Step 2) Paste the following code above the code in step 1.

<tr><td class=sectiontableentry
<?php echo $i; ?> width=35% style=”font-weight:bold;”>
<?php echo _UE_UHP; ?></td>
<td class=sectiontableentry<?php echo $i; ?> >
<a href=”
<?php echo sefRelToAbs(“index.php?option=com_uhp&task=mypage=
show&action=user&id=”.$user->id); ?>”>
<?php echo _UE_UHP_LINK; ?></a>
</td></tr>
<?php $i= ($i==1) ? 2 : 1; ?>

Step 3) In your language file located in the directory “administration/components/comprofiler/language/” add the following lines of code. You can change the words “HP Albúm” and “ver minha Home Page e meu Albúm de Fotos” to what you like.

DEFINE(‘_UE_UHP’,’HP Albúm’);
DEFINE(‘_UE_UHP_LINK’,’ver minha Home Page e meu Albúm de Fotos ‘);

 

Leave a Reply

Your email address will not be published. Required fields are marked *