xoops forums

tsanyao

Just popping in
Posted on: 2004/8/12 8:46
tsanyao
tsanyao (Show more)
Just popping in
Posts: 6
Since: 2004/6/16
#1

How-to: Single Sign-on for SquirrelMail & Xoops

i thought somebody would be interested in this simple hack.

Version: Squirrel Mail 1.4.1 for Xoops, XOOPS 2.0.7

Summary: This hack adds a checkbox at XOOPS user login page. When checked, checklogin redirect successful logon to sqmail for a login attempt. No kernel hack involved.

Files involved (5):
language/english/user.php
modules/system/templates/system_userform.html
user.php
include/checklogin.php
modules/sqmail/src/redirect.php

Step One: Add a dictionary entry in language/english/user.php
[color=00CC00]define('_US_LOGINMAIL','Login My Mail too');[/color]


Step Two: Modify user.php to add the dictionary word
$xoopsTpl->assign('lang_youremail'_US_YOUREMAIL);
        
$xoopsTpl->assign('lang_sendpassword'_US_SENDPASSWORD);    
        [
color=00CC00]$xoopsTpl->assign('lang_loginmail'_US_LOGINMAIL);[/color]
        include 
'footer.php';
    } elseif ( 
$xoopsUser ) {


Step Three: Add a checkbox in system_userform.html (note: you can recompile system module now to see the change)
[color=00CC00]<small><input type="checkbox" name="sync_sqmail" value="1" /><{$lang_loginmail}></small><br>[/color]
<
input type="hidden" name="op" value="login" />
<
input type="hidden" name="xoops_redirect" value="<{$redirect_page}>" />
<
input type="submit" value="<{$lang_login}>" />


Step Four: Tweak checklogin.php a bit
$notification_handler->doLoginMaintenance($user->getVar('uid'));

    [
color=00CC00]if (isset($sync_sqmail)) 
    {
        
$HTTP_SESSION_VARS['login_username'] = $uname;
        
$HTTP_SESSION_VARS['secretkey'] = $pass;
        
$HTTP_SESSION_VARS['login_quietly'] = 1;
        
$HTTP_SESSION_VARS['login_redirect'] = $url;
        
$HTTP_SESSION_VARS['login_redirect_text'] = 
            
sprintf(_US_LOGGINGU$user->getVar('uname'));
        
redirect_header(
            
XOOPS_URL."/modules/sqmail/src/redirect.php"
            
0
            
sprintf(_US_LOGGINGU$user->getVar('uname')));

    }[/
color]
    
redirect_header($url1sprintf(_US_LOGGINGU$user->getVar('uname')));

} else {

    
redirect_header(XOOPS_URL.'/user.php',1,_US_INCORRECTLOGIN);
}
exit();


Step Five(optional): In case you wished a silent login for Squirrel mail, add the following in redirect.php.
Part a:
sqGetGlobalVar('secretkey'$secretkey);
[
color=00CC00]sqGetGlobalVar('login_quietly'$login_quietly);
sqGetGlobalVar('login_redirect'$login_redirect);
sqGetGlobalVar('login_redirect_text'$login_redirect_text);[/color]

sqGetGlobalVar('js_autodetect_results'$js_autodetect_results);

Part b:
/* Write session data and send them off to the appropriate page. */
session_write_close();
[
color=00CC00]if ($login_quietly)
{
    
sqsession_unregister('login_username');
    
sqsession_unregister('secretkey');
    
sqsession_unregister('login_quietly');
    
sqsession_unregister('login_redirect');
    
sqsession_unregister('login_redirect_text');
    
redirect_header($login_redirect1$login_redirect_text);
}
else[/
colorheader("Location: $redirect_url");


Well done.
i hope this is helpful. Please give me your comments.

Bassman

Friend of XOOPS
Posted on: 2004/8/12 9:33
Bassman
Bassman (Show more)
Friend of XOOPS
Posts: 1272
Since: 2003/5/23
#2

Re: sqmail & xoops single sign-on hack

Awesome, people will be very happy about this hack :) I'll try it tomorrow.

theprof

Quite a regular
Posted on: 2004/8/12 10:44
theprof
theprof (Show more)
Quite a regular
Posts: 225
Since: 2004/7/14
#3

Re: sqmail & xoops single sign-on hack

GREAT! even though I cannot use it. Tried 3 times to install SQ mail to no haps.


prof!

tsanyao

Just popping in
Posted on: 2004/8/13 2:52
tsanyao
tsanyao (Show more)
Just popping in
Posts: 6
Since: 2004/6/16
#4

Re: sqmail & xoops single sign-on hack

In sqmail, there is a do_hook function to launch functions from different plugins. i wonder XOOPS has a similar interface for its modules. Anyone?

For example, step four can be improved to use a generic do_hook function rather than assumed the existence of sqmail module:

Step Four: Tweak checklogin.php a bit
$notification_handler->doLoginMaintenance($user->getVar('uid'));

        [
color=00CC66]do_hook("before redirect");[/color]
    
redirect_header($url1sprintf(_US_LOGGINGU$user->getVar('uname')));

} else {

    
redirect_header(XOOPS_URL.'/user.php',1,_US_INCORRECTLOGIN);
}
exit();

ricky123

Just popping in
Posted on: 2004/8/25 20:57
ricky123
ricky123 (Show more)
Just popping in
Posts: 28
Since: 2004/8/25
#5

Re: sqmail & xoops single sign-on hack

i installed the sqmail but it doesnt appear , the page is blank ,this happened with myed2k links modules too .
rest all the other modules that i installed worked fine

flaystus

Just popping in
Posted on: 2004/9/13 7:47
flaystus
flaystus (Show more)
Just popping in
Posts: 14
Since: 2004/9/12
#6

Re: sqmail & xoops single sign-on hack

EAsy to follow guide. I did the steps exactly but the option doesn't appear at the front page login. Just the full page one.

I edited the file and got the check box on the login block, but not really knowing PHP I can't for the life of me figure out howto:

1) get the test to appear in the login block, now its just a labeless check box.

2) make the box checked by default, there is a way right?