Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Users Online Report

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

Page: 1
Go to End
Author Topic: 2377 Views
  • Tama
    Avatar
    Community Member
    119 Posts

    Users Online Report Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Users Online Report Link to this post

    Like the currently online feature in the forum module?

    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.

  • Tama
    Avatar
    Community Member
    119 Posts

    Re: Users Online Report Link to this post

    Exactly like that - thanks Will

  • Tama
    Avatar
    Community Member
    119 Posts

    Re: Users Online Report Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Users Online Report Link to this post

    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)

    2377 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.