Index: openacs-4/packages/xotcl-request-monitor/www/whos-online-today.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/whos-online-today.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/xotcl-request-monitor/www/whos-online-today.tcl 29 Jun 2018 17:27:19 -0000 1.9 +++ openacs-4/packages/xotcl-request-monitor/www/whos-online-today.tcl 3 Sep 2024 15:37:54 -0000 1.10 @@ -6,7 +6,7 @@ @cvs-id $Id$ } -query { {orderby:token,optional "date,desc"} - {all:optional 0} + {all:boolean,optional,notnull 0} } -properties { title:onevalue context:onevalue @@ -31,58 +31,57 @@ }] \ -columns [subst { AnchorField name -label "User" -orderby name - Field date -label "Last Activity" -html { align right } \ - -orderby date + HiddenField date + Field last -label "Last Activity" -html { align right } \ + -orderby date }] \ - -no_data "no registered online today" + -no_data "no registered online today" set users [list] lassign [throttle users users_per_day] ip auth -if {!$all} {set elements [concat $ip $auth]} {set elements $auth} +if {!$all} { + set elements [concat $ip $auth] +} { + set elements $auth +} set summary "We noticed in [expr {[llength $ip]+[llength $auth]}] users in total, containing [llength $auth] authenticated users" -set now_ansi [clock_to_ansi [clock seconds]] +set now_ansi [lc_clock_to_ansi [clock seconds]] +set xowiki_p [expr {[namespace which ::xowiki::utility] ne ""}] + foreach element $elements { lassign $element user_id timestamp - if {[string is integer $user_id]} { - set person [person::get_person_info -person_id $user_id] - set user_label "[dict get $person last_name], [dict get $person first_names]" - set user_url [acs_community_member_url -user_id $user_id] - } else { - # it was an IP address - set user_label $user_id - set user_url "" - } + set user_info [xo::request_monitor_user_info $user_id] - lappend users [list $user_label \ - $user_url \ - $timestamp \ - [util::age_pretty \ - -timestamp_ansi [clock_to_ansi $timestamp] \ - -sysdate_ansi $now_ansi \ - -mode_3_fmt "%d %b %Y, at %X"] \ - ] + set last_activity [expr {$xowiki_p ? + [::xowiki::utility pretty_age -timestamp $timestamp] : + [lc_clock_to_ansi $timestamp] + }] + lappend users [list [dict get $user_info label] \ + [dict get $user_info url] \ + $timestamp \ + $last_activity \ + ] } -switch -glob $orderby { - *,desc {set order -decreasing} - *,asc {set order -increasing} -} -switch -glob $orderby { - name,* {set index 0; set type -dictionary} - date,* {set index 2; set type -integer} -} -foreach e [lsort $type $order -index $index $users] { +foreach e $users { if {$admin} { - t1 add -name [lindex $e 0] \ - -name.href [lindex $e 1] \ - -date [lindex $e 3] \ - } + t1 add -name [lindex $e 0] \ + -name.href [lindex $e 1] \ + -date [lindex $e 2] \ + -last [lindex $e 3] \ + } } +lassign [split $orderby ,] att order +t1 orderby \ + -order [ad_decode $order desc decreasing asc increasing increasing] \ + -type [ad_decode $att date integer dictionary] \ + $att + set t1 [t1 asHTML] # Local variables: