Mercurial > hg > egg-tcls
comparison tj.tcl @ 622:84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Feb 2021 15:27:10 +0200 |
parents | a1efc28ef5a4 |
children | e7c88d4e917c |
comparison
equal
deleted
inserted
replaced
621:a1efc28ef5a4 | 622:84a30765baa1 |
---|---|
202 tj_msg $upublic $unick $uchan "err_invalid_user" [list $uhand] | 202 tj_msg $upublic $unick $uchan "err_invalid_user" [list $uhand] |
203 return 1 | 203 return 1 |
204 } | 204 } |
205 | 205 |
206 set uhand [tj_correct_handle $uhand] | 206 set uhand [tj_correct_handle $uhand] |
207 set qadmin [matchattr $uhand n] | |
207 | 208 |
208 # Check and handle arguments | 209 # Check and handle arguments |
209 set rarglist [::textutil::split::splitx $uargs {\s+}] | 210 set rarglist [::textutil::split::splitx $uargs {\s+}] |
210 set rcmd [lindex $rarglist 0] | 211 set rcmd [lindex $rarglist 0] |
211 set rindex 1 | 212 set rindex 1 |
376 tj_msg $upublic $unick $uchan "help_add" | 377 tj_msg $upublic $unick $uchan "help_add" |
377 return 1 | 378 return 1 |
378 } | 379 } |
379 | 380 |
380 } elseif {[tj_cmd_match "list" $rcmd]} { | 381 } elseif {[tj_cmd_match "list" $rcmd]} { |
381 # !tj list | 382 # !tj list [name] |
382 # List reminders | 383 # List reminders |
384 if {[utl_arg_get $rarglist rindex uname 1]} { | |
385 set uname [tj_correct_handle $uname] | |
386 if {$uname != $uhand && !$qadmin} { | |
387 tj_msg $upublic $unick $uchan "access_denied" | |
388 return 1 | |
389 } | |
390 } else { | |
391 set uname $uhand | |
392 } | |
393 | |
383 set uclock [clock seconds] | 394 set uclock [clock seconds] |
384 | 395 |
385 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" | 396 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uname]'" |
386 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { | 397 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} { |
387 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] | 398 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg] |
388 tj_log "$uerrmsg on SQL:\n$usql" | 399 tj_log "$uerrmsg on SQL:\n$usql" |
389 return 1 | 400 return 1 |
390 } | 401 } |
391 | 402 |
392 set nitem 0 | 403 set nitem 0 |
393 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' ORDER BY ucreated" | 404 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated" |
394 tj_dbh eval $usql { | 405 tj_dbh eval $usql { |
395 incr nitem | 406 incr nitem |
396 set ustamp [utl_sql_datetime_to_stamp $utarget] | 407 set ustamp [utl_sql_datetime_to_stamp $utarget] |
397 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] | 408 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] |
398 } | 409 } |