# HG changeset patch # User Matti Hamalainen # Date 1612963630 -7200 # Node ID 84a30765baa17bbbe6dd24b24b378e50394d8d3c # Parent a1efc28ef5a4ce9dc57ebe495c0372cad9e3a495 tj: Add ability for administrator users to 'list' other peoples TJs. diff -r a1efc28ef5a4 -r 84a30765baa1 tj.tcl --- a/tj.tcl Wed Feb 10 15:26:10 2021 +0200 +++ b/tj.tcl Wed Feb 10 15:27:10 2021 +0200 @@ -204,6 +204,7 @@ } set uhand [tj_correct_handle $uhand] + set qadmin [matchattr $uhand n] # Check and handle arguments set rarglist [::textutil::split::splitx $uargs {\s+}] @@ -378,11 +379,21 @@ } } elseif {[tj_cmd_match "list" $rcmd]} { - # !tj list + # !tj list [name] # List reminders + if {[utl_arg_get $rarglist rindex uname 1]} { + set uname [tj_correct_handle $uname] + if {$uname != $uhand && !$qadmin} { + tj_msg $upublic $unick $uchan "access_denied" + return 1 + } + } else { + set uname $uhand + } + set uclock [clock seconds] - set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" + set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uname]'" if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] tj_log "$uerrmsg on SQL:\n$usql" @@ -390,7 +401,7 @@ } set nitem 0 - set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" + set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated" tj_dbh eval $usql { incr nitem set ustamp [utl_sql_datetime_to_stamp $utarget]