Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Users Online Report


Go to End


5 Posts   3242 Views

Avatar
Tama

Community Member, 138 Posts

16 July 2010 at 9:03am

Morning

Has anyone developed a report which tells you which users are online (or maybe which users have been active in the past hour.)

We've got 50 contributors working on getting a website live and want to be able to warn them when we've doing code updates.

Cheers
Tama

Avatar
Willr

Forum Moderator, 5523 Posts

16 July 2010 at 3:50pm

Like the currently online feature in the forum module? :D

All members have a Last Visited field so something like $members = DataObject::get('Member', "\"LastVisited\" > NOW() - INTERVAL 15 MINUTE"); will get all the members who have visited in the last 15 minutes.

Avatar
Tama

Community Member, 138 Posts

19 July 2010 at 8:56am

Exactly like that - thanks Will :)

Avatar
Tama

Community Member, 138 Posts

22 July 2010 at 9:44am

Edited: 22/07/2010 9:45am

I'm struggling with this - the documentation for reports is really out of date: http://doc.silverstripe.org/site-reports - and I'm having trouble piecing the new parts together. This is far as I've got:

/mysite/_config.php
SS_Report::register("SS_Report", "UsersOnlineReport");


/mysite/code/CustomReports.php
<?php
class UsersOnlineReport extends SS_Report {
	function title() {
		return "Users Online";
	}
	
	function description() {
		return "Shows all Users active in the past 15 minutes";	
	}
	
	function records() {
		$members = DataObject::get('Member', "\"LastVisited\" > NOW() - INTERVAL 15 MINUTE"); 
		return $members;
	}
	
...

...and that's where I hit some major confusion - do we still use fieldsToShow() or do we use columns() ? And if so what syntax? I want to list the username, e-mail address, and when they were last active.

Cheers
Tama

Avatar
Willr

Forum Moderator, 5523 Posts

22 July 2010 at 10:49am

Best bet is to have a read of the API docs - http://api.silverstripe.org/2.4/cms/reports/SS_Report.html.

We are busily working on the docs as I speak. If you feel this area needs to be documented better then please make a documentation request on open.silverstripe.org (see http://open.silverstripe.org/report/12).

Thanks for baring with any confusion in the docs! We're in the process of doing a massive migration for it. API docs will be more up to date (although uglier)