[rt-devel] Listing logged-in users
Christian Loos
cloos at netcologne.de
Mon Dec 10 04:36:59 EST 2012
Why don't you just set the AutoLogoff value in RT_SiteConfig.pm and
setup a cronjob for sbin/rt-clean-sessions and then create an element
'active sessions' that loads the sessions.
Maybe this solution have a chance to go into RT core code as it isn't an
assumption or a lie ;-)
Chris
Am 06.12.2012 12:27, schrieb Michele Bergonzoni:
>> If I come up with something decent, I'll share it.
>
> Decent? Maybe, at least I don't see any obvious security hole. I don't
> know enough about RT to know if this will make a SQL query per row, or
> if it will take the names from some cache. Anyway that's what I have.
>
> Regards,
>
> Bergonz
>
> ================================================================
> <!--
> # A Box to show logged in users
> # Actually shows who displayed this box in the last 5 mins
> # To install:
> # - cd $RTHOME
> # - save this file as local/html/Elements/ListLogged
> # - copy the line with "Set($HomepageComponents ..." from
> etc/RT_Config.pm to etc/RT_SiteConfig.pm
> # - change it to include the word ListLogged
> # - mkdir var/logged_users
> # - chown <your web server user>.<your web server group> var/logged_users
> # - clean mason cache and restart apache
> -->
>
> <div class="ticket-overview">
> <&|/Widgets/TitleBox,
> title => loc("Who's seeing this page (last 5 min)"),
> bodyclass => ""
> &>
>
> <table border="0" cellspacing="0" cellpadding="1" width="100%"
> class="queue-summary">
> <%perl>
> require RT::User;
> my $base = $RT::BasePath . '/var/logged_users';
> my $file = $session{'CurrentUser'}->id();
>
> # Touch your file
> open(F, '> ' . $base . '/' . $file);
> close(F);
>
> my $u = RT::User->new($RT::SystemUser);
> my $now=time();
>
> if (not opendir(Q,$base)){
> die("Can't scan $base: $!\n");
> }
>
> my $tref = [];
> my $mtime;
> my $uname;
>
> while (defined($file=readdir(Q))){
> $mtime=(stat($base . '/' . $file))[9];
> if ($mtime >= ($now - 300)) {
> if($file =~ /^\d+$/){
> $u->Load(int($file));
> $uname = $u->Name();
> if ($uname){
> push(@$tref, [($uname)]);
> }
> }
> }
> }
> closedir(Q);
>
> my $i=0;
> for my $line (@{$tref}){
> </%perl>
> <tr class="<% $i%2 ? 'oddline' : 'evenline'%>">
> <td class="collection-as-table"><% $$line[0] %></td>
> </tr>
> <%perl>
> $i++;
> }
> </%perl>
> </table>
> </&>
> </div>
> ================================================================
>
>
More information about the rt-devel
mailing list