1 # ===================================================================== 2 # listUsers: list user accounts, possibly matching a keyword. 3 # 4 # Copyright (c) 2009 Carlo Strozzi 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; version 2 dated June, 1991. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 # 19 # ===================================================================== 20 21 # ===================================================================== 22 # Local variables and functions 23 # ===================================================================== 24 25 cgi.group = () 26 cgi.group.literal = () 27 cgi.grep.user = . # match all by default. 28 29 tmp1 = /dev/null 30 31 # ===================================================================== 32 # Main program 33 # ===================================================================== 34 35 # Load call arguments. 36 csaGetArgs GET 37 38 #~ $REMOTE_ADDR 192.168.1.2 && csaExit.env 39 40 . $CSA_ROOT/lib/group-stuff.rc 41 42 # Check group required metadata. 43 ~ $'cgi.grep.user' () && csaExit.fault 0041 cgi.grep.user 44 45 # Only *authenticated* global editors are allowed to list user accounts. 46 # This must be checked *before* a user is granted group-level editor 47 # privileges! 48 49 if (!csaTrue $CSA_AUTH_OK || !~ ,$TNS_AUTH_GRP, *,editor,*) { 50 csaExit.needauth 51 } 52 53 # Group-level editor privileges can be granted only *after* the above test! 54 . $CSA_ROOT/lib/group-editor.rc 55 56 if (csaIsFullPath --exists --quiet $CSA_TPL_ROOT/tw-list-users.txt) { 57 # custom page-attachments template. 58 tpl.include.html.body = $CSA_TPL_ROOT/tw-list-users.txt 59 } else { 60 # default page-attachments template. 61 tpl.include.html.body = $tw_dstem/tw-list-users.txt 62 } 63 64 . $CSA_ROOT/lib/tpl-stuff.rc 65 66 csaMkTemp tpl.include.tw.page 67 68 # I cannot check the pipeline status here, as grep(1) my return 69 # non-zero if no matches are found. 70 71 filtertable --input $TNS_USER_TABLE -- grep -ie $'cgi.grep.user' | 72 getcolumn k_user u_^(name sname email gui) | sorttable > $tmp1 73 74 user_tmp = $tmp1 75 76 # This view does not correspond to an actual page on disk, 77 # so we need to toggle unapplicable sections in templates. 78 79 tpl.if.tw.ispage = '(::DEL:)' 80 tpl.fi.tw.ispage = '(:DEL::)' 81 tpl.if.tw.printable = '(::DEL:)' 82 tpl.fi.tw.printable = '(:DEL::)' 83 tpl.if.tw.isview = () 84 tpl.fi.tw.isview = () 85 86 csaExit.ok --table $user_tmp $tpl_file 87 88 # End of program.