1
tsanyao
How-to: Single Sign-on for SquirrelMail & Xoops
  • 2004/8/12 8:46

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


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.

2
Bassman
Re: sqmail & xoops single sign-on hack
  • 2004/8/12 9:33

  • Bassman

  • Friend of XOOPS

  • Posts: 1272

  • Since: 2003/5/23


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

3
theprof
Re: sqmail & xoops single sign-on hack
  • 2004/8/12 10:44

  • theprof

  • Quite a regular

  • Posts: 225

  • Since: 2004/7/14


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


prof!

4
tsanyao
Re: sqmail & xoops single sign-on hack
  • 2004/8/13 2:52

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


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();

5
ricky123
Re: sqmail & xoops single sign-on hack
  • 2004/8/25 20:57

  • ricky123

  • Just popping in

  • Posts: 28

  • Since: 2004/8/25


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

6
flaystus
Re: sqmail & xoops single sign-on hack
  • 2004/9/13 7:47

  • flaystus

  • Just popping in

  • Posts: 14

  • Since: 2004/9/12


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?

Login

Who's Online

156 user(s) are online (108 user(s) are browsing Support Forums)


Members: 0


Guests: 156


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits