As mentioned earlier in this thread, the Joomla/RoundCube component is not really an integration of Joomla with RoundCube. The approach I have taken is to use the wrapper functionality of Joomla to integrae RoundCube. Then. in the wrapper.php routine, I append the userID to the RC url. When RoundCube starts, I grab the userID and use it to log the user into the associated IMAP server. This requires keeping an encrypted password that can be decrypted for use in logging into the IMAP server. I use the RoundCube encrypt and decrypt functions for this. This approach requires a new attribute (column) be added to the Joomla user table as described in the following code. Also, you must add the users email account to IMAP using your isp's interface, such as CPanel.
#
# Support integration with Joomla
#
# You will need to integrate RC into Joomla using the wrapper content functionality.
# The following mods will add an attribute (column) to the Joomla User table to hold the RC password.
# This is required since Joomla encrypts using a one-way encryption and RC needs to have a decrypted
# password to pass to the IMAP login if we are doing automatic logins using the Joomla userID. The first
# time a user logs in to their IMAP account, the password is encrypted and stored in the Joomla user table.
# On subsequent logins, the encrypted IMAP password is read from the Joomla User table, decrypted and
# used to login to the IMAP server. If the userid/password pair do not match in the IMAP server, a RC login
# page will be shown.
#
# -------------------------------------------------------------------------------------------------------------
#
# In file index.php
# Insert after Line 92
$josuid = $_GET['uid']; //Set in Joomla wrapper.php
# Insert after Line 150
if(isset($_POST['_pass'])){
$pass = get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-8859-1');
if($pass != ''){
$lfaencrypt = encrypt_passwd($pass);
$query = "UPDATE jos_users SET rcpassword = " . $DB->Quote($lfaencrypt) . " WHERE id = " . (int) $_SESSION['JOSUID'];
$DB->query($query);
}
}
# Replace lines that read: $OUTPUT->task = 'login';
# $OUTPUT->send('login'); (about Line 233,234 old - 239,240 new)
# with:
$result = $DB->query("SELECT username,rcpassword FROM jos_users WHERE id=?",$josuid);
$userid = '';
$dpassword = '';
if($DB->num_rows()==1){
$row = $DB->fetch_array( $result );
$username = $row[0];
$epassword = $row[1];
$dpassword = decrypt_passwd($epassword);
}
//If $DB->num_rows() != 1 then normal login screen will be displayed.
$_SESSION['JOSUID'] = $josuid;
$host = rcmail_autoselect_host();
// check if client supports cookies
if (empty($_COOKIE))
{
$OUTPUT->show_message("cookiesdisabled", 'warning');
}
else if (rcmail_login($username, $dpassword, $host))
{
// create new session ID
unset($_SESSION['temp']);
sess_regenerate_id();
// send auth cookie if necessary
rcmail_authenticate_session();
// send redirect
header("Location: $COMM_PATH");
# -------------------------------------------------------------------------------------------------------------
#
# In file joomla/components/com_wrapper/wrapper.php
# Insert after Line 17
session_start();
# Replace line that reads: global $database, $Itemid, $mainframe (about line 25)
# with
global $database, $Itemid, $mainframe, $my;
# Insert after line that reads: $url = $params->def( 'url', '' ); the following (about line 49)
if(strstr($url, 'roundcube'))
$url .= '?uid=' . $my->id;
# -------------------------------------------------------------------------------------------------------------
#
# Database Additions for Joomla integration. Run in the joomla database. Change jos_users to whatever your joomla users table is called
#
# Run in PhpMyAdmin:
#
ALTER TABLE `jos_users` ADD `rcpassword` VARCHAR(100);
David