All comments/feedback/suggestions welcome
Alex


I am running Moodle cron for a windows server. Where do I look up the error messages?
Tieku
I'm having a similar problem. Here's a copy of an error message that shows up in the cron:
<!--StartFragment-->Processing cron function for online_users_map....<br />
<b>Fatal error</b>: Call to undefined function simplexml_load_string() in <b>/home/g8/public_html/g8moodle1/blocks/online_users_map/lib.php</b> on line <b>47</b><br />
BTW, the server is running PHP 5.2.3
Thanks,
Fernando
Thanks Alex,
The SimpleXML extention took care of the cron errors... but I still can't seem to get it working. I'm wondering... virtually all of the communities listing in our Moodle installation are small remote Aboriginal communities in Northern Canada. As far as I can tell, these communties seem to be listed in geonames.org but I noticed other communties often share the same name.
For example: "Poplar Hill" First Nation is listed here in 4 provinces: http://www.geonames.org/search.html?q=Poplar+Hill&country=CA
Since the profiles don't use any state/province field, how would this mod handle this location? Would it just use the first one on the list?
Fernando
Hello Fernando,
I tried to install the online users map and it seems that the file version.php is not in the package. Isn't it?
Would be glad if you could add version.php ...
Thanks
Juergen
But all the useres have country and city. It's a mandatory field. Bu I have a little problem: I choose the default country, but in registration don´t show that country I selected. I post that here: http://moodle.org/mod/forum/discuss.php?d=83198#p385560 But no solution for now. I don´t know if that is related with my problem with location not found... thanks :)
Finding location (porto,PT) for utilizador 1...location not found But he map is still without pins :(
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <geonames style="MEDIUM"> <totalResultsCount>1496</totalResultsCount> <geoname> <name>Porto</name> <lat>41.15</lat> <lng>-8.6166667</lng> <geonameId>2735943</geonameId> <countryCode>PT</countryCode> <countryName>Portugal</countryName> <fcl>P</fcl> <fcode>PPLA</fcode> </geoname> </geonames>HTH,
Hi Alex
I have checked my PHPinfo (version 5.2.5) and it says:
| Simplexml support | enabled |
|---|---|
| Revision | $Revision: 1.151.2.22.2.35 $ |
| Schema support | enabled |
I have also changed the lib.php file line 54 as you suggested.
I now get the following error in my chron:
Updating location for Admin User...
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<geonames style="MEDIUM">
<totalResultsCount>142</totalResultsCount>
<geoname>
<name>Sydney</name>
<lat>-33.8678499639382</lat>
<lng>151.207323074341</lng>
<geonameId>2147714</geonameId>
<countryCode>AU</countryCode>
<countryName>Australia</countryName>
<fcl>P</fcl>
<fcode>PPLA</fcode>
</geoname>
</geonames>
<br />
<b>Fatal error</b>: Call to undefined function: simplexml_load_string() in <b>/home/content/a/s/k/askjohn/html/ASKJOHNENGLISH/learn/blocks/online_users_map/lib.php</b> on line <b>53</b><br />
Needlesss to say, the online users map block still come up blank... what can i do?
Many thanks! I look forward to getting this working.
Thanks for the reply Alex! Much appreciated!
By 'popping this code at the beginning of the cron() function', do you mean the code in blocks\online_users_map\block_online_users_maps.php should be like this:
<?php
/**
* Online Users Map block - reworking of the standard Moodle online users
* block, but this displays the users on a Google map - using the location
* given in the Moodle profile.
* @author Alex Little
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package block_online_users_map
*/
include_once($CFG->dirroot.'/blocks/online_users_map/lib.php');
class block_online_users_map extends block_base {
function init() {
$this->title = get_string('blockname','block_online_users_map');
$this->version = 2008030600;
$this->cron = 3600;
}
function instance_allow_config() {
return false;
}
function has_config() {
return true;
}
function get_content() {
global $USER, $CFG, $COURSE;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass;
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance)) {
return $this->content;
}
//Calculate minutes
$minutes = floor(getTimeToShowUsers()/60);
$this->content->text = "<div class=\"info\">(".get_string("periodnminutes","block_online_users_map",$minutes).")</div>";
$this->content->text .= get_html_googlemap();
return $this->content;
}
function cron(){
if(!extension_loaded('simplexml')
// Nope, not loaded
else
// Already been loaded ;)
if(!extension_loaded('simplexml')
{
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
dl('php_simplexml.dll');
else
dl('simplexml.so');
}
// NOw that it should be loaded, we'll check again:
if(extension_loaded('simplexml'))
echo 'simpleXML was included properly!!';
else
echo 'simpleXML still wasn't included ';
}
update_users_locations();
return true;
}
function preferred_width(){
return 210;
}
}
?>
Many thanks for any help you may be able to give!
Hi Alex
I did as you suggested and the chron now reads:
<b>Parse error</b>: parse error, unexpected T_ELSE in <b>/home/content/a/s/k/askjohn/html/ASKJOHNENGLISH/learn/blocks/online_users_map/block_online_users_map.php</b> on line <b>60</b><br />
Also the content of my page has disappeared.
You can see the page here: http://askjohnenglish.com/learn/course/view.php?id=5
I know that if I change the file back the page will return, so that is not a problem.
Is all very strange...
Any ideas?
Thanks again
John
Thank you Alex.
I have done as you said. The chron now reads:
Processing cron function for online_users_map....<br />
<b>Warning</b>: dl(): Unable to load dynamic library './simplexml.so' - ./simplexml.so: cannot open shared object file: No such file or directory in <b>/home/content/a/s/k/askjohn/html/ASKJOHNENGLISH/learn/blocks/online_users_map/block_online_users_map.php</b> on line <b>61</b><br />
<br/>simpleXML still wasn't included
Updating location for Admin User...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The requested URL could not be retrieved</TITLE>
<STYLE type="text/css"><!--BODY{background-color:#ffffff;font-family:verdana,sans-serif}PRE{font-family:sans-serif}--></STYLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The requested URL could not be retrieved</H2>
<HR noshade size="1px">
<P>
While trying to retrieve the URL:
<A HREF="http://ws.geonames.org/search?">http://ws.geonames.org/search?</A>
<P>
The following error was encountered:
<UL>
<LI>
<STRONG>
Connection to 78.46.47.166 Failed
</STRONG>
</UL>
<P>
The system returned:
<PRE><I> (110) Connection timed out</I></PRE>
<P>
The remote host or network may be down. Please try the request again.
<P>Your cache administrator is <A HREF="mailto:webmaster">webmaster</A>.
<BR clear="all">
<HR noshade size="1px">
<ADDRESS>
Generated Mon, 19 May 2008 11:38:09 GMT by wc04.shr.phx3.gdg (squid/2.6.STABLE12)
</ADDRESS>
</BODY></HTML>
<br />
<b>Fatal error</b>: Call to undefined function: simplexml_load_string() in <b>/home/content/a/s/k/askjohn/html/ASKJOHNENGLISH/learn/blocks/online_users_map/lib.php</b> on line <b>52</b><br />
Any ideas?
Thank you Alex.
I checked with my host, who says:
'SimpleXML Library' is currently enabled. The SimpleXML library is readily accessible when using PHP5 on your hosting account. There is no need to specify a path, you can place any references to SimpleXML in your PHP5 code and it will be parsed accordingly.
I also tried the code Tommy Wonkium posted, but am still getting that error message in the cron...
Is all quite bizzare! I have every confidence that this block works... Not sure what I am doing wrong!
Hi alex
I downloaded the block again to make sure i hadn't botched the code up. When I installed it, I got this message in my notifications:
(mysql): SELECT * FROM mdl_config WHERE id = '-1'
(mysql): INSERT INTO mdl_config ( NAME, VALUE ) VALUES ( 'block_online_users_map_centre_user', '0' )
1062: Duplicate entry 'block_online_users_map_centre_user' for key 2
I then uploaded the full original new block (since you added the ability to center on the user) and still got the same error.
Thanks so much for all your help!
I now have found there are problems with my cron jobs (host problem perhaps? they are not being very helpful!) So will try and fix that, then do as you have suggested above.
Thank you! that fixed the block error message.
I also reinstalled the latest version of the block. This had the sample simplexml error in the cron, so I made changes to the lib.php file (only) as Tommy suggested.
The cron now reads:
Processing module function Online_Users_Map...done.
but the block still doesn't work... http://askjohnenglish.com/learn/course/view.php?id=5
(I have debugging set to 'developer' and no error messages are coming up...)
BTW the cron only read: Processing module function Online_Users_Map...done., the first time the cron ran after reinstalling the block. Thereafter it is not even mentioned in the cron. Is this normal?
Sorry for so many messages! I really appreciate all the help you have given!!
BTW the latest cron now reads:
Processing cron function for online_users_map....<div class="notifytiny" style="text-align:center">MySQL server has gone away<br /><br />UPDATE mdl_block SET lastcron = '1212095102' WHERE id = '47'<ul style="text-align:left"><li>line 1328 of lib/dmllib.php: call to debugging()</li><li>line 1254 of lib/dmllib.php: call to set_field_select()</li><li>line 149 of admin/cron.php: call to set_field()</li></ul></div>
Error: could not update timestamp for online_users_map
done.
Actually, I am having some trouble with my host, so have been focusing on that instead. I suspect that is the cause of my troubles...
Many thanks for all your time!
Alex,
Installed the block, database tables written without issue. Cron has run successfully, but when I enable the block on our site's homepage, the block itself is blank (other than "online users last 5 minutes" ) There is no map image or pins displayed....just whitespace.
Any suggestions?
Ken
Hey Alex,
The "blank block" can be seen at www.justicedegree.org (right hand column) - just turned it back on so that you can view . The API key is correct in settings, and like I mentioned earlier the cron appears to have run fine. Question (excuse the ignorance here) - could this somehow be related to how the student's location information (city,state) in their profile is formatted? We have a number of students with city,states that are listed as "Please Update" - as we encourage students to update this information on their own. Just a thought.
Thanks for the help.
Ken
Alex,
Think I found the issue (although don't know how to fix), Load page in firefox and get this error on the bottom of the page:
missing ) after argument list
map.setCenter(new GLatLng(39.5N,119.8W), 50);\n
Looks like I need to add a ) in the php code somewhere. This error doesn't show itself in IE
Ken
Alex,
ahh....yee old user error 
Thanks for the input...map is now working like a charm!
Ken
Alex,
New question (problem?).
It appears that we need users to input their location data in their profile in the following format: City,State. Messing around a bit, I updated mine profile as: City/State. The result did not work obviously (I am floating off the coast of Africa on the map
) .
I then went in and update my profile to the correct format and have re-run cron, but the location database appears not to be updating (not seeing it in cron). Could this be a function of the cron only running X percentage of all cron tasks each run (moodle default to save horsepower) or am i missing something?
As always, thanks for the help!
Ken
Alex,
Ignore above ^^^^^^^^^^^^^^^^^, as the cron ran again and things have been updated properly.
Ken
Alex - a great block, and very easy to install. I had only a couple of issues to deal with which I thought might be worth considereing as mods:
1 - GoogleMaps now include a Map Data copyright statement on the map which overflows to the left of the small map in this block. It is sort of corrected by adding 'overflow:hidden' to the DIV tag in lib.php (see my example here). I'm sure just cutting it off like this might upset GMs Terms of Use, but I don't see an alternative.
2 - I have a wider than standard right column in my theme, and so wanted to make the map slightly larger. Easy to do in lib.php, but perhaps the map dimension could either by a variable based on the column width (perhaps), or a config option? My prefernce would be the former.

host ws.geonames.org: 111: Connection refuse have you seen this before. Shall I see if it works with a new API? Thanks.
Hi there,
this looks great but i'm having some basic probs uploading it. after downloading latest version, do i just upload load entire contents to my blocks directory (via cpanel)?
Thanks
ben
thanks alex,
maybe im just being dumb here, when i selct all downloaded files and folders and zip them and then upload zip via cpanel to blocks folder, only the files and not the directories are there. can you only zip files and then the directories and their contents are uploaded individually?
OK Alex,
i finally managed to upload all files/folders. then confirmed set up of tables via notifications and added the API in block settings and then tried to add the block. i get a blank block. This is very frustarting. as you can see the online user block works just fine - do they need to be linked up maybe?
any ideas
thanks
ben
brilliant alex, i love ya - it works! problem was with the integers. (still no calendar tho.
Thanks
ben
Alex - re calendar
at top of manage blocks page it says this:
Block calendar_month is not compatible with the current version of Moodle and needs to be updated by a programmer....strange
havent got access to browser javascript console as am at school...
thx
ben
Processing cron function for online_users_map.... SimpleXML extension is loaded There are no locations to update.done. Finished blocks Has anyone else seen this?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Bad Gateway!</title> <link rev="made" href="mailto:%5bno%20address%20given%5d" /> <style type="text/css"><!--/*--><![CDATA[/*><!--*/ body { color: #000000; background-color: #FFFFFF; } a:link { color: #0000CC; } p, address {margin-left: 3em;} span {font-size: smaller;} /*]]>*/--></style> </head> <body> <h1>Bad Gateway!</h1> <p> The proxy server received an invalid response from an upstream server. </p> <p> If you think this is a server error, please contact the <a href="mailto:%5bno%20address%20given%5d">webmaster</a>. </p> <h2>Error 502</h2> <address> <a href="/">ws.geonames.org</a><br /> <span>Mon Dec 14 10:47:10 2009<br /> Apache/2.2.10 (Linux/SUSE)</span> </address> </body> </html>I'm using Siteground to host Moodle in. Anybody else got this problem?