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



2
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.



3
tsanyao
re: drawback
  • 2004/8/11 12:11

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


Recently i was told that raising the inter-dependence of components might not be a good idea. Furthermore, given harddisk measured in gigabytes, who cares about kilobytes ...



4
tsanyao
Sqmail bug: attachment
  • 2004/6/18 4:45

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


Hi,

i have encountered this error (in PHP debug mode) when trying to download attachment.

Quote:
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition message of the object you are trying to operate on was loaded _before_ the session was started in modules/sqmail/src/download.php on line 56


wonder if anyone has already found a fix?
Appreciate it.



5
tsanyao
[Case closed] Thank you
  • 2004/6/17 6:00

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


No, i don't think we'd need to update neither sqmail module nor system module. The reason being there is no changes to any template file.

QUICK FIX:
Create a symbolic link of xoops_version.php in modules/sqmail/src folder. The submenu items will appear after a refresh of browser.

BUG REPORT:
The real bug lies in include/common.php, line 233,

if (file_exists('./xoops_version.php')) {

The programmer has assumed current folder (ie modules/sqmail/src in this case) instead of a absolute reference to modules/sqmail folder. This line will determine if the $xoopsModule be created. $xoopsModule is required by function b_system_main_show in modules/system/blocks/system_blocks.php to determine if sublinks for a module would be created.



6
tsanyao
Creating sublinks in the main menu
  • 2004/6/16 11:54

  • tsanyao

  • Just popping in

  • Posts: 6

  • Since: 2004/6/16


Hi,

i am moving some of the Squirrel mail menu (ie Compose, Addresses, Folders, etc) over to the main menu of Xoops.

Thus far i have added the following in xoops_version.php:

$modversion['hasMain'] = 1;
$modversion['sub'][1]['name'] = _MI_SQMAIL_COMPOSE;
$modversion['sub'][1]['url'] = "src/compose.php";
$modversion['sub'][2]['name'] = _MI_SQMAIL_ADDRESSBOOK;
$modversion['sub'][2]['url'] = "src/addressbook.php";
$modversion['sub'][3]['name'] = _MI_SQMAIL_FOLDERS;
$modversion['sub'][3]['url'] = "src/folders.php";
$modversion['sub'][4]['name'] = _MI_SQMAIL_OPTIONS;
$modversion['sub'][4]['url'] = "src/options.php";
$modversion['sub'][5]['name'] = _MI_SQMAIL_Search;
$modversion['sub'][5]['url'] = "src/search.php";
$modversion['sub'][6]['name'] = _MI_SQMAIL_HELP;
$modversion['sub'][6]['url'] = "src/help.php";

However, i couldn't see the new sublinks at the main menu under Sqmail. i guess i have missed out a step or two.

Please advise. Appreciate it.




TopTop



Login

Who's Online

196 user(s) are online (131 user(s) are browsing Support Forums)


Members: 0


Guests: 196


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