Simple but effective Shoutbox for your Moodle block

Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Number of replies: 25
Picture of Plugin developers

It does what it is supposed to do: allow your moodle user to enter a text - asyncrhonous communication. Best setup in a blockas HTML code. Comes with a profanity censor. Not a resource hog and faster than the standard Moodle chat module.

http://moodurian.blogspot.com/2011/08/making-webs-best-shoutbox-even-better.html

Enjoy! Frankie Kam.

Average of ratings: -
In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Nicholas Walker -

I can attest that this chat block was easy enough to install (i.e., easier than peeling a durian) and works beautifully.  I'll let you know how my students take to it. Thanks Frankie!

In reply to Nicholas Walker

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi Nicholas.

You're most welcome!

Frankie Kam

P.S.,
I've also created a modified version of profanities.php file.
The download zip file contains TWO versions of the profanity list. 
In profanities.php, the entire word is asterisked off (I think that is better). 
In profanities.php_ori, all but the first letter is asterisked off.
You can download it from: http://i.minus.com/dD4RcCXqqqbfs.zip 

In reply to Nicholas Walker

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi Nicholas,

I assume that your localtime is in the same timezone as your Moodle server time. Therefore you did not experience any problem with timestamp. Therefore you need not change anything in the original shoutbox.php code if the staus quo remains for you. But if in future you do change to a moodle server that is in a different time zone, then you have to take heed to the solution below.

Yvonne of the Netherlands experienced a problem as she has a 6 hour difference between her local time and the moodle server she is using.

To solve her problem, I had to squash a hidden (until now) bug in the shoutbox.php original code as follows:

Go to shoutbox.php, line 193.

Modify the code as shown in red text below.

   Line 193: $date = substr($date,-18,8);
   Line 194: $date = str_replace (".0", ".", $date);
   Line 195: $date = str_replace (" 0", " ", $date);
   Line 196: $shout = $shout." (".$jd.", ".$date.", ".$time.")";

Basically, just two changes to the code and you are home.
(at line 193) Change 18 to 8
(at line 196) Insert the code ", ".$time. to that line $shout = $shout." (".$jd.", ".$date.")";

I've purposely set my config.php's
$timeoffset = 6;
and I've tested it on my Moodle site at
http://scm.moodleace.com/course/view.php?id=9
USername: student
Password: moodle

Works for me. Just thought you might want to know this.
Now the Shotbox (Whisperbox) is perfect.

Regards
Frankie Kam

In reply to Nicholas Walker

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi Nicholas,

I assume that your localtime is in the same timezone as your Moodle server time. Therefore you did not experience any problem with timestamp. Therefore you need not change anything in the original shoutbox.php code if the staus quo remains for you. But if in future you do change to a moodle server that is in a different time zone, then you have to take heed to the solution below.

Yvonne of the Netherlands experienced a problem as she has a 6 hour difference between her local time and the moodle server she is using.

To solve her problem, I had to squash a hidden (until now) bug in the shoutbox.php original code as follows:

Go to shoutbox.php, line 193.

Modify the code as shown in red text below.

   Line 193: $date = substr($date,-18,8);
   Line 194: $date = str_replace (".0", ".", $date);
   Line 195: $date = str_replace (" 0", " ", $date);
   Line 196: $shout = $shout." (".$jd.", ".$date.", ".$time.")";

Basically, just two changes to the code and you are home.
(at line 193) Change 18 to 8
(at line 196) Insert the code ", ".$time. to that line $shout = $shout." (".$jd.", ".$date.")";

I've purposely set my config.php's
$timeoffset = 6;
and I've tested it on my Moodle site at
http://scm.moodleace.com/course/view.php?id=9
USername: student
Password: moodle

Works for me. Just thought you might want to know this.
Now the Shotbox (Whisperbox) is perfect.

Regards
Frankie Kam

In reply to Nicholas Walker

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi Nicholas,

I assume that your localtime is in the same timezone as your Moodle server time. Therefore you did not experience any problem with timestamp. Therefore you need not change anything in the original shoutbox.php code if the staus quo remains for you. But if in future you do change to a moodle server that is in a different time zone, then you have to take heed to the solution below.

Yvonne of the Netherlands experienced a problem as she has a 6 hour difference between her local time and the moodle server she is using.

To solve her problem, I had to squash a hidden (until now) bug in the shoutbox.php original code as follows:

Go to shoutbox.php, line 193.

Modify the code as shown in red text below.

   Line 193: $date = substr($date,-18,8);
   Line 194: $date = str_replace (".0", ".", $date);
   Line 195: $date = str_replace (" 0", " ", $date);
   Line 196: $shout = $shout." (".$jd.", ".$date.", ".$time.")";

Basically, just two changes to the code and you are home.
(at line 193) Change 18 to 8
(at line 196) Insert the code ", ".$time. to that line $shout = $shout." (".$jd.", ".$date.")";

I've purposely set my config.php's
$timeoffset = 6;
and I've tested it on my Moodle site at
http://scm.moodleace.com/course/view.php?id=9
USername: student
Password: moodle

Works for me. Just thought you might want to know this.
Now the Shotbox (Whisperbox) is perfect.

Regards
Frankie Kam

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Nicholas Walker -

Hi Frankie,

Like you, my students are in the same timezone. I have taken note of your Shoutbox code changes, but I will not have a chance to make these particular changes immediately as I just have too much to attend to right now. Thank you nonetheless. When I do, I'll let you know what happens.

Thanks,

Nick

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Yvonne van Lingen -

Hi Frankie

I've just installed the shoutbox in Moodle 2.1. It's really working great! I've customized it to my own design etc. The only thing I can't get right is the time offset. I changed the '0' to '6' as I'm in The Netherlands, but the time doesn't change for new posts. Any suggestions?

Thanks!

Kind regards

Yvonne van Lingen

In reply to Yvonne van Lingen

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi Yvonne!

>I changed the '0' to '6' as I'm in The Netherlands,...
>
I'm trying to understand what you are saying.

Time difference between USA and Netherlands is: +6:0 hrs Netherlands is 6:0 hours ahead of USA That means when it is 9:00 am in Washington DC USA, it is 3:00 pm in Amsterdam Netherlands.

Did you change the following code

                $date = str_replace (".0", ".", $date);
                $date = str_replace (" 0", " ", $date);
to:
                $date = str_replace (".6", ".", $date);
                $date = str_replace (" 6", " ", $date);
? thoughtful

If that is what you did, I don't understand why you would do it. The code just replaces the datestamp from, for example, " 09.08.11" to "9.8.11". This makes the datestamp shorter and easier to read. Also the date in this modified form will not take up too much horizontal space in the shoutbox.
Any comments?

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Yvonne van Lingen -

Hello Frankie

Thanks for your quick reply!

What I did was changing the parameter in config.php. I changed the '0' into a '6'.

$timeoffset = 6; //The different between your time and the time on your sever, in hours.  Basically get this by taking your local time and subtracting server time, so if your local time is 3:30 PM and the server time (that ShoutPro gives when this is set to 0) is 2:30 PM, this should be set to 1 to add 1 hour to the server time.  This will only affect shouts posted AFTER the offset is saved, since previous shouts have their date and time saved in shouts.php.  Default is 0.

Thanks!

Yvonne

In reply to Yvonne van Lingen

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Yvonne,

I managed to solve this problem after 5 hours(!)

Go to shoutbox.php, line 193.
Modify the code as shown in red text below.

   Line 193: $date = substr($date,-18,8);
   Line 194: $date = str_replace (".0", ".", $date);
   Line 195: $date = str_replace (" 0", " ", $date);
   Line 196: $shout = $shout." (".$jd.", ".$date.", ".$time.")";

Basically, just two changes to the code and you are home.
(at line 193) Change 18 to 8
(at line 196) Insert the code ", ".$time. to that line $shout = $shout." (".$jd.", ".$date.")";

I've purposely set my config.php's
$timeoffset = 6;
and I've tested it on my Moodle site at
http://scm.moodleace.com/course/view.php?id=9
USername: student
Password: moodle

Works for me! Thanks for highlighting the problem with the $timeoffset. It seems that there was a bug with the original shoutpro code. Now the bug's squashed! Let me know if that solves it for you.

Regards
Frankie Kam

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Yvonne van Lingen -

Hello Frankie

Thanks for all your efforts!

I made the changes in shoutbox.php as described above, and ... it works!

Thanks a lot!

Yvonne

In reply to Yvonne van Lingen

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Hi Yvonne and Nicholas,

I understand from your posts that you have got Frankie's brainchild working. I haven't managed and would like your help.

I have Moodle 2.0.2. In the html block, instead of the shoutbox, I get the homepage of the site. I guess their is a path problem.

I chmod-ed as per the ShoutPro 1.5.2 readme.txt, altho' it's unclear which folder to 777 when they mention the "shoutbox folder". In Frankie's package, would that be the shout folder or the whisperbox folder? I've tried both, to no effect.

I edited the local (whisperbox) config.php to personalise it, but did not change the time offset yet (I'm in NL, like Yvonne).

In the shoutbox.php file, I first left the string unchanged because the Moodle config.php is indeed two layers up.

require_once('../../config.php');

Then I edited the string to give the exact path, but it made no difference.

Any ideas?

 

David

In reply to David Dunn

Re: Simple but effective Shoutbox for your Moodle block

by Yvonne van Lingen -

Hi David

I had the same problem as you're having now, the homepage instead of the shoutbox appearing in the block.

I changed the attributes as described in the instructions. It's indeed a path problem. I used the complete path of my moodle installation in the config.php: "http://www.domain.nl/moodledirectory" and in the html block I used this full path again "http://www.domain.nl/moodledirectory/shout/dca-it/shoutbox.php/".

Hope this helps!

Regards

Yvonne

In reply to Yvonne van Lingen

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Great to chat to you "live", Yvonne.

Problem solved by changed permissions of files from 666 to 777 (see the ShoutPro readme.txt to see which two files).

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

I've made some more changes to the file shoutbox.php to allow the display of the user's avatar for each post made by the user.

Warning! This has only been tested with Moodle 1.9. I sincerely doubt that it will work under Moodle 2.x since I think that the folder structure of M2 is different from M1.9. For your convenience, I've attached the new file shoutbox.php to this post (look to the top right of this post!).

Installation Instructions (for Moodle 1.9.x)
1. Please backup your existing shoutbox.php. You can rename it to shoutbox.php_ori) before attempting this hack.

2. Download the latest shoutbox.php

3. Upload (ftp) the latest shoutbox.php to the same folder as the original shoutbox.php

4. Test it out! It should work for Moodle 1.9.x sites. Not yet ready for Moodle 2.x sites. I'm just guessing - intelligently. If you are running on Moodle 2.x, and if you are brave enough, you can also give it a try - PROVIDED you PROMISE to backup your original shoutpro.php first.

Frankie Kam

 

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Hi Frankie,

Back to bother you again big grin

When I click on the Help link, I get a pop-up of the shoutbox, not the help file with smilies.

I don't see where it could be going wrong in the various php files.

Truth be told, I like the pop-up shoutbox, but would also like the help pop-up.

In reply to David Dunn

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

David

Seems to be something interfering with the Javascript code found inside shoutbox.php.

Try clearing your Browser's cache (i.e., in FireFox, choose Tools | Clear Recent History). Then try again.

Frankie Kam

In reply to David Dunn

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

Hi David

Test your browser on my Moodle site:

http://scm.moodleace.com/shout/whisperbox/shoutbox.php

Test the Help link.

 

I get this on my Firefox:

No need to login. The chat widget should display.
I guess the 777 privileges allows anyone, anywhere to run the shoutbox.php file eh?

Haha! I'm not logged into Moodle, but by going to http://scm.moodleace.com/shout/whisperbox/shoutbox.php, I can post a message. My username is null in this case. This seems to be a security problem posed by the 777 privilege. Just realised this. Is it bad? Don't know. Anyway, let's solve one problem at a time, eh?

Frankie

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Yeah, works great on your place, but still not on mine (different 'puter, fresh cache).

Too late for more thinks.

Have a great weekend!

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Re. your screenshots, Frankie, I get exactly the same when I run shoutbox directly in Firefox. The problem then is that it does not function correctly when placed in the Moodle theme (Aardvark post-it). The colours default to the theme (minimalist white) and the Help link javascript opens the shoutbox chat window instead of the help pop-up.

Any idea what I need to change?

Site: Learning with Lingua Lucida

In reply to David Dunn

Re: Simple but effective Shoutbox for your Moodle block

by David Dunn -

Re. the problem of unlogged users posting messages, I have the same experience.

Another thing, I wanted to install the TinyMCE Configuration Tool but it wouldn't install because the upgrade plugin screen got blocked on the Shoutbox plugin, saying that it was out of date (or something). So I shut off the shoutbox folder by adding a ~ symbol in the name. It disappeared from the list of plugins and I could upgrade to include the Tiny MCE config tool.

And yet ... the shoutbox window works just as before on the front page!

Curiouser and curiouser ...

In reply to David Dunn

Re: Simple but effective Shoutbox for your Moodle block

by Frankie Kam -
Picture of Plugin developers

David

I'm not sure I can help you here with the theme-related problem. Out of my league there.

Who is the author of the Aardvark post-it, Mary Evans? You can forward an email to her. She's the best person to help you solve this since I am pretty sure it is some CSS problem.  You should email her a copy of the styles.css file so that she can help you diagnose the problem. Also send her some screenshots so she will know exactly what is happening.

Frankie

In reply to Frankie Kam

Re: Simple but effective Shoutbox for your Moodle block

by amit gupta -

Hey Frankie,

I was trying to use shoutbox for my moodle 2.5, but its not installing. Can you suggest me some way to get it going for my moodle site.

Any help would be appreciated.

 

Regards,

Amit