$params->get('logout') in smf_login bridge not there

Started by mojito, January 19, 2006, 05:38:53 AM

Previous topic - Next topic

mojito

My last post got lost somewhere?  >:(

I have been working on modifying the smf joomla mod for the login as I wanted a flat version.
In my version though the following $params->get('logout') isnt available and I have had to hard code it to a vlaue of 2 to get the logout to work, otherwise th elogout works but doesnt redirect properly.

here is the logout link code
global $my;
if($my->username){
echo $my->username." is logged in ";
//logout link-doesnt work-takes me to wrong place, params wrong..
//echo "params->get('logout')  = " .$params->get('logout');
if ($params->get('logout')=="2")
$_SESSION['return'] = sefReltoAbs(basename($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING']);

echo '
<a href="', sefReltoAbs($scripturl . 'action=logout&amp;returnurl=2'.$params->get('logout').'&amp;sesc='. $context['session_id']), '">', $smf_logout_button ? '<img src="' . (!empty($smf_logout_button_image) && $smf_logout_button_image!="" ? $smf_logout_button_image : $settings['images_url'] . '/' . $context['user']['language'] . '/logout.gif').'" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108], '</a>';


}
else{
//echo "Welcome Guest ";



thanks for any insight.

m
SMF 1.1 RC2 bridge 1.4

Orstio

The $params object is defined in the modules database table, in the filed named "params".

If $params->get('logout') returns nothing (or an error), you probably did not edit the parameters of your mod_smf_login module.

mojito

I see the code up to that point in my script and your mod_smf_login.php is identical. I have not published the module mod_smf_login however so there might be some code after that point which is significant and editing that params object. I will see if I can get some more clues, otherwise I will leave the value hard coded as 2? hope this doesnt affect security.

thanks for help..
SMF 1.1 RC2 bridge 1.4

Orstio

There is nothing wrong with the code in the module.

Go to your Mambo/Joomla admin panel.  Go to the Modules Menu.  Click on Site Modules.

Find the mod_smf_login in the list.  It might not be on the first page.  Click on it.

Edit the parameters to your liking.  Click Save at the top of the page.  Even if you change nothing, click Save at the top of the page.


mojito

Hi orstio

There is nothing wrong with the module, i just want a more "light" version, only showing login if not logged in and logout if logged in and username. That is all.

I just used the first part of the module code. Your module works fine, and this is where I cant understand why mine doesnt.
just for ref here's the code based on your module
if (!defined('SMF'))
{
global $mosConfig_absolute_path, $smf_path, $maintenance, $sourcedir, $context, $user, $mosConfig_live_site, $mosConfig_db, $mosConfig_dbprefix;

require($mosConfig_absolute_path . '/administrator/components/com_smf/config.smf.php');
require_once($smf_path . '/Settings.php');
}

global $context, $txt, $scripturl, $boardurl, $settings, $mosConfig_dbprefix, $bridge_reg, $db_prefix, $db_name, $smf_date, $mosConfig_db, $mosConfig_sef;

mysql_select_db($mosConfig_db);

$result = mysql_query("
SELECT id
FROM {$mosConfig_dbprefix}menu
WHERE link = 'index.php?option=com_smf'");

if ($result !== false)
list($menu_item['id']) = mysql_fetch_row($result);
else
$menu_item['id'] = 1;

$myurl = basename($_SERVER['PHP_SELF']) . '?option=com_smf&amp;Itemid=' . $menu_item['id'] . '&amp;';

$scripturl = $myurl;

$smf_align = $params->get('smf_align');
$smf_personal_welcome = $params->get('smf_personal_welcome');
$smf_notification = $params->get('smf_notification');
$smf_unread = $params->get('smf_unread');
$smf_new_answers = $params->get('smf_new_answers');
$smf_new_pms = $params->get('smf_new_pms');
$smf_loggedin_time = $params->get('smf_loggedin_time');
$smf_notify_logged_in = $params->get('smf_notify_logged_in');
$smf_logout_button = $params->get('smf_logout_button');
$smf_logout_button_image = $params->get('smf_logout_button_image');

mysql_select_db($db_name);


//echo ".........................".$params->get('logout');

global $my;
if($my->username){
echo $my->username." is logged in ";
//logout link-doesnt work-takes me to wrong place, params wrong..
//echo "params->get('logout')  = " .$params->get('logout');
if ($params->get('logout')=="2")
$_SESSION['return'] = sefReltoAbs(basename($_SERVER['PHP_SELF']).'?'.$_SERVER['QUERY_STRING']);

echo '
<a href="', sefReltoAbs($scripturl . 'action=logout&amp;returnurl=2'.$params->get('logout').'&amp;sesc='. $context['session_id']), '">', $smf_logout_button ? '<img src="' . (!empty($smf_logout_button_image) && $smf_logout_button_image!="" ? $smf_logout_button_image : $settings['images_url'] . '/' . $context['user']['language'] . '/logout.gif').'" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108], '</a>';


}
else{
//login link
$txt['welcome_guest'] = str_replace($boardurl.'/index.php?', $scripturl , $txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'?',$scripturl,$txt['welcome_guest']);
if ($bridge_reg==true)
{
//echo "bridge reg is true ".$bridge_reg." ";
$txt['welcome_guest'] = str_replace($scripturl.'action=register', sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf_registration&amp;task=register'), $txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'action=activate', sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf_registration&amp;task=lostCode'), $txt['welcome_guest']);
}
else {
$txt['welcome_guest'] = str_replace($scripturl.'action=register', sefReltoAbs($scripturl.'action=register'),$txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'action=activate', sefReltoAbs($scripturl.'action=activate'),$txt['welcome_guest']);
}

echo ' ', $txt['welcome_guest'];
}

//echo "here".empty($context['user']['is_logged']);

/**/

// If the user is logged in, display stuff like their name, new messages, etc.
//if ($context['user']['is_logged']){
//echo ".....................................".$context['user']['is_logged'];

/* */



// Otherwise they're a guest - so politely ask them to register or login.
/* else
{
$txt['welcome_guest'] = str_replace($boardurl.'/index.php?', $scripturl , $txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'?',$scripturl,$txt['welcome_guest']);
if ($bridge_reg==true)
{
echo "bridge reg is true";
/*
$txt['welcome_guest'] = str_replace($scripturl.'action=register', sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf_registration&amp;task=register'), $txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'action=activate', sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?option=com_smf_registration&amp;task=lostCode'), $txt['welcome_guest']);
} else {
$txt['welcome_guest'] = str_replace($scripturl.'action=register', sefReltoAbs($scripturl.'action=register'),$txt['welcome_guest']);
$txt['welcome_guest'] = str_replace($scripturl.'action=activate', sefReltoAbs($scripturl.'action=activate'),$txt['welcome_guest']);
*/
/*
}
$txt[34] = str_replace('&?','&', $txt[34]);
if (!isset($login))
{$login = '';}
if (!isset($message_login))
{$message_login = '';}
}*/
/* echo '
', $txt['welcome_guest'], '<br />
', $context['current_time'], '<br />

<script language="JavaScript" type="text/javascript" src="', $settings['default_theme_url'], '/sha1.js"></script>

<form action="', sefReltoAbs($scripturl . 'action=login2'), '" method="post" style="margin: 3px 1ex 1px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
',$txt[35],': <input type="text" name="user" size="10" />
',$txt[36],': <input type="password" name="passwrd" size="10" />
<select name="cookielength">
<option value="60">', $txt['smf53'], '</option>
<option value="1440">', $txt['smf47'], '</option>
<option value="10080">', $txt['smf48'], '</option>
<option value="302400">', $txt['smf49'], '</option>
<option value="-1" selected="selected">', $txt['smf50'], '</option>
</select>
<input type="submit" value="', $txt[34], '" /><br />
<span class="middletext">', $txt['smf52'], '</span>
<input type="hidden" name="hash_passwrd" value="" />
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="option" value="com_smf" />
<input type="hidden" name="Itemid" value="', $menu_item['id'], '" />
<input type="hidden" name="action" value="login2" />
<input type="hidden" name="returnurl" value="', $params->get('login'), '" />
<input type="hidden" name="lang" value="', $mosConfig_lang, '" />
<input type="hidden" name="return" value="', sefReltoAbs(basename($_SERVER['PHP_SELF']), '?', $_SERVER['QUERY_STRING']), '" />
<input type="hidden" name="message" value="', $message_login, '" />

</form><br />
<a href="', ($bridge_reg==true ? sefReltoAbs(basename($_SERVER['PHP_SELF']). '?option=com_smf_registration&amp;task=lostPassword') : sefReltoAbs($scripturl . 'action=reminder')) , '">Forgot your password?</a>';
}
if ($params->get('login') == '2' && $_REQUEST['action'] != 'login' && $_REQUEST['option'] != 'com_smf_registration')
$_SESSION['return'] = $mosConfig_sef=='1' ? sefReltoAbs(basename($_SERVER['PHP_SELF']) . '?' . $_SERVER['QUERY_STRING']) : $mosConfig_live_site . '/' . basename($_SERVER['PHP_SELF']) . '?' . $_SERVER['QUERY_STRING'];

/* echo '
</td>
</tr></table>
</div>';
*/


most of the extraneous stuff is commented out. But something broke to do with $params->get('logout') not being available when logged in. Now what happens when the user clicks login is that they use the SMF forum login panel, Im thinking this shouldnt change this though???

cheers
SMF 1.1 RC2 bridge 1.4

Kindred

mojito...  I'm not sure what you are using, but my mod_smf_login (straight from install, no modifications) only asks people to login, register or forgot password only if they are not currently logged in...  and if they are logged in, it shows logout...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

mojito

Im really only after the following text displaying for both cases ! in a single neat little line..

welcome guest [Login] or [register]

or

welcome mojito [Logout]


on clicking the login the user is taken to the smf login wrapped with joomla (is this a problem -(using smf login)?-as from here after log in it redirects to the forum root and I cant see joomla anymore) This redirecting to the forum root is the problem as if there was no joomla just a forum install. Have I missed some code? or is the bridge login supposed to replace the forum login totally? if this is the case there are a few cases where the forum login comes up i.e bugs...and problems..how is the bridge supposed to handle the login and redirects..

thanks I realise you 2 are pretty much it for the bridge support..
SMF 1.1 RC2 bridge 1.4

Orstio

It has nothing to do with the code in the login module.  The code is correct.

Follow the instructions in my last post, and there will be a value in $params->get('logout').

Until you follow those instructions, there will be no value there.

mojito

I did follow those instructions,and it changes nothing  but I dont want to use your module. SO what gives.? I unpublish it again...

I am interested in my own module developed from your module (copied!), yours is ok for most but for me it is too bulky. So please allow me to use just my own (yours without login form). I still dont understand why $params->get('logout') doesnt exist.

I'm not the best in php, but logicaly where are things going wrong.

Can ANYONE answer me this; IF I use the smf bridge...can I use the regular forum login? I dont want the smf_bridge login as it is too bulky.

thank you all
SMF 1.1 RC2 bridge 1.4

Orstio

QuoteI am interested in my own module developed from your module (copied!), yours is ok for most but for me it is too bulky. So please allow me to use just my own (yours without login form). I still dont understand why $params->get('logout') doesnt exist.

The params are first defined in the file mod_smf_login.xml.  Did you also copy that file?

QuoteCan ANYONE answer me this; IF I use the smf bridge...can I use the regular forum login? I dont want the smf_bridge login as it is too bulky.

Yes, but from the forum component only, not from the stand alone forum.

mojito

No I didnt, I used a standard xml file and changed the values, I thought the xml file was purely to give form and reduce errors for the module install. Wow I missed a big core feature here.

We could do with a theory of developing a module in the joomla site. Thanks for your help orsitio, thats probably done it.

mojito
SMF 1.1 RC2 bridge 1.4

Advertisement: