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.
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 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
Don't know how to go about mass importation of users into SQM. Sorry
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?
I'd be very interested in the details of how to do this if you have time to post the code here.
TIA,
Tim.
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;
}
}
?>
______________________________________________________
Very good idea! As you will let squirrelmail use ntlm authorization I'll be very happy to test it on my squirrelmail.
http://moodle.org/mod/forum/discuss.php?d=36036
Its working very well for us.
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!
Thanks
This question is unrelated to the SquirrelMail block itself; have you tried asking it of the SquirrelMail forums? http://www.squirrelmail.org/wiki/AdministratorSupport
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?