New SquirrelMail Block

New SquirrelMail Block

by Julian Ridden -
Number of replies: 14
Here at my college our students access their webmail using an app called squirrelmail.

Because we use LDAP, their logon details for moodle and SQM are exactly the same and allowed for me to create this block to allow for easy access.

For security freasons we ask students to type in in their passowrd again rather than passing this info automatically. This decision was made as many students often forget to log out. And the last thing we wanted was for access to other students mailboxes due to this.

Setup is easy. Just extract the zip to your moodle root and then go to admin to install the block. Once installed, go to Admin->Blocks-> SquirrelMail Block settings and enter the URL to your SQM installation. Then your done.

I have set this up to use lang packs, but only speaking english have attatched only the en lang data.

Hope some of you find this useful.
Average of ratings: -
In reply to Julian Ridden

Re: New SquirrelMail Block

by Darren Smith -
This is superb smile

I couldn't get the settings link to appear in the blocks config page but as our squirrelmail is on the same sever as moodle is was pretty simple to just alter the path in the php file.

A small minority of our students have different usernames for email so I am going to try and work out how to show a username form which is prefilled with their moodle username. If anyone has any clues it could save me a few hours!

Thanks again for this

Darren.

EDIT: That was pretty easy! See attached for those who are interested
In reply to Darren Smith

Re: New SquirrelMail Block

by Julian Ridden -
Simple to do and allready done smile

In the file is a username field that is hidden and has the moodle username propogated in it.

Just change it from a hidden to a text filed and your done.

Julian
In reply to Darren Smith

Re: New SquirrelMail Block

by Richard Ackland -
Our squirrelmail server is also on the same one as moodle. Have you found an easy way to upload user accounts. At present I have to add all squirrel mail users manually!
In reply to Richard Ackland

Re: New SquirrelMail Block

by Julian Ridden -
at our school we use an LDAP server for both moodle and SQM. This means both have autogenerated users that have the same username and password.

Don't know how to go about mass importation of users into SQM. Sorry sad
In reply to Julian Ridden

Re: New SquirrelMail Block

by Richard Ackland -

Our problem is uploading the users into C-panel - it doesn't seem to have a mass upload utility using a csv file, or anything...

Can SQm be used without creating mail accounts with cpanel?

In reply to Julian Ridden

Re: New SquirrelMail Block

by Colin G -
I actually now have managed to hack moodle to provide login details to squirrelmail. If you use the same authentication type for both moodle & squirrel (like imap or ldap) the hack is very easy to do by modifying 4 lines in login.php. Now when people login to our moodle they see a popup window showing their new email. If anyone is interested in the single login hack for moodle/squirrel let me know. Next week I plan on creating an ntlm authorisation script so users no longer have to login on our intranet since they have already authenticated on the windows login.
In reply to Colin G

Re: New SquirrelMail Block

by Tim Allen -
If anyone is interested in the single login hack for moodle/squirrel let me know.

I'd be very interested in the details of how to do this if you have time to post the code here.  smile

TIA,
Tim.
In reply to Tim Allen

Re: New SquirrelMail Block

by Colin G -
This is a quick and dirty hack for squirrelmail single login. Warning this may not be totally secure but it works !

First add the lines to login/index.php just below update_login_count();
__________________________________________________________
$smpass = $frm->password;
$smuser = $frm->username;
$_SESSION["smpass"] = $smpass;
$_SESSION["smuser"] = $smuser;
__________________________________________________________

This stores the login details in smuser & smpass.

Then to make squirrelmail popup window open at login add this to the very end of /index.php, you may need to make your site a trusted site for popups to work :

__________________________________________________________
<script type="text/javascript">

var popurls=new Array()
popurls[0]="https://yoursite.com/squirrelmail/src/redirect.php?login_username=<?php echo $_SESSION["smuser"]; ?>&secretkey=<?php echo $_SESSION["smpass"]; ?>"
function openpopup(popurl){
var winpops=window.open(popurl,"","width=800,height=600,toolbar,location,status,scrollbars,menubar,resizable")
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

popfrequency="1 minutes"

function resetcookie(){
var expireDate = new Date()
expireDate.setMinutes(expireDate.getMinutes()-10)
document.cookie = "jkpopunder=;path=/;expires=" + expireDate.toGMTString()
}

function loadornot(){
if (get_cookie('jkpopunder')==''){
openpopup(popurls[Math.floor(Math.random()*(popurls.length))])
var expireDate = new Date()
expireDate.setMinutes(expireDate.getMinutes()+parseInt(popfrequency))
document.cookie = "jkpopunder="+parseInt(popfrequency)+";path=/;expires=" + expireDate.toGMTString()
}
}

if (get_cookie('jkpopunder')!=parseInt(popfrequency))
resetcookie()
loadornot()

</script>'
_______________________________________________________

and replace the block squirrelmail for single sign on with something like this:

________________________________________________________
<?php

class block_squirrelmail extends block_base {

function init() {
$this->title = get_string('blockname','block_squirrelmail');
$this->content_type = BLOCK_TYPE_TEXT;
$this->version = 2005111300;
}


function applicable_formats() {
return array('site' => true);
}

function get_content () {
global $USER, $CFG;
$wwwroot = '';
$serverpath = $CFG->block_squirrelmail_serverpath;
$password = get_string('password', 'block_squirrelmail');
$mustlogin = get_string('mustlogin', 'block_squirrelmail');
$go = get_string('go', 'block_squirrelmail');
$signup = '';

if ($this->content !== NULL) {
return $this->content;
}

$this->content->text = '';


if (empty($USER->loggedin)) {
$this->content->text .= "$mustlogin.\n";
} else {
$this->content->text = '
<center><img src="https://yoursite.com/email.png" alt="My Email" title="My Email">
<form action="'.$serverpath.'/squirrelmail/src/redirect.php" target=_new method="post">
<input type="hidden" name="login_username" value="'.$_SESSION["smuser"].'" size="16"/>
<input type="hidden" name="secretkey" value="'.$_SESSION["smpass"].'" size="16" />
<input type="submit" value="My Email" />
</form>';
}
$this->content->footer = '';
return $this->content;
}
}

?>
______________________________________________________
In reply to Colin G

Re: New SquirrelMail Block

by Leonardo Bianchi Quota -

Very good idea! As you will let squirrelmail use ntlm authorization I'll be very happy to test it on my squirrelmail.

In reply to Leonardo Bianchi Quota

Re: New SquirrelMail Block

by Colin G -
I have started a new discussion for the ntlm automatic moodle login here:

http://moodle.org/mod/forum/discuss.php?d=36036


Its working very well for us.
In reply to Colin G

Re: New SquirrelMail Block

by Leonardo Bianchi Quota -

Hi, Thank You very much for Your reply. Last week "Google-ing" for a solution for squirrelmail using ntlm I reached your moodle-system and I hoped for some help. Today I saw Your replay in my email account and that's was good! now my problem is: how to implement it? I thought that this protocol was tied to MS Active Directory but  I don't know the way to implement it. How could be used Your code? Then I would like to use it for squirrelmail only if possible....

Thanks!

In reply to Leonardo Bianchi Quota

Re: New SquirrelMail Block

by Stephen Plume -
Is it possible to have profanity checking on squirrelmail so some words can be blocked and is it possible to have administrators with the ability to enter mail boxes and monitor emails?

Thanks
In reply to Julian Ridden

Re: New SquirrelMail Block

by William McGrath -
After unpacking the zipfile into moodle/blocks on the server, the Blocks admin panel fails to reveal any configuration items for the SquirrelMail block. If you try to add the block to a page in Blocks editing mode, it fails to appear in the list of blocks you can add.

Just in case, I've checked to see if it's a permissions issue on my server, all the scripts are 644 and are readable by the webserver like the rest of my moodle installation.

Have I simply forgotten to do something, or is there a problem with the code in the block?