1 # ===================================================================== 2 # blogger.getUsersBlogs: BloggerAPI method. 3 # 4 # Copyright (c) 2007,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 # List the groups in a specified Blog/Wiki the requesting user is a 23 # member of. With TW, groups are open to everybody in read-mode, and 24 # if any access restrictions ar in effect they apply to single pages, 25 # not to whole groups, therefore any users (even those that are not 26 # listed in 'auth+dat') are members of all the groups in the requested 27 # Blog/Wiki. 28 # 29 # Unlike all other TW methods, this program does not take a 'group' 30 # argument; that only makes sense in the BloggerAPI context, therefore 31 # it only works in RPC2 mode and that's why it does not have a native 32 # TW counterpart. 33 # ===================================================================== 34 35 # ===================================================================== 36 # Local variables and functions 37 # ===================================================================== 38 39 cgi.numeric = () 40 41 tmp1 = /dev/null 42 tns1 = () 43 44 # ===================================================================== 45 # Main program 46 # ===================================================================== 47 48 # Load call arguments. 49 csaGetArgs POST 50 51 tw_dstem = $CSA_ROOT/lib/default 52 53 # Account for the fact that templates are created by the client. 54 CSA_TPL_SAFEPATH = ($CSA_INSTALL/lib $tw_dstem $TMPDIR $CSA_TPL_ROOT 55 $CSA_DOCROOT/$CSA_LANG/$TNS_ATTACH_PUBDIR) 56 57 CSA_EXIT_SCRIPT = $CSA_ROOT/lib/exit-stuff.rc 58 59 # Although simply listing available blogs could be unrestricted, if 60 # a TW instance hosts many groups the operation could be a resource 61 # hog, also because it is called every time a user connects to the API. 62 # Because of that, and because of the fact that most parts of the API 63 # are restricted to editors (either global- or group-level ones), this 64 # method requires autentication, so that it will be possible to limit 65 # the listing as appropriate. 66 67 #~ $CSA_AUTH_USER () && csaExit.needauth 68 69 # Take into account all available groups, regardless of any language 70 # specified by the client, i.e. with x-csa-lang=... 71 72 csaMkTemp tmp1 73 74 # List all groups/blogs if global editor, otherwise list only 75 # own groups/blogs. 76 77 ~ ,$TNS_AUTH_GRP, *,editor,* && tns1=1 78 79 tablecat --path-elements 2 $CSA_ROOT/var/pages/*/group+dat | 80 awktable '-ve_='$tns1 -- 'BEGIN{ 81 print "\001k_group\t\001g_name\t\001_1\t\001g_uri\t\001g_descr\t\001k_node" 82 } 83 e_ || "," $g_editor "," ~ /,'$CSA_AUTH_USER',/ { 84 print $k_group,$g_name,$_1,$g_uri,$g_descr,$k_node 85 }' > $tmp1 86 87 csaStatus || csaExit.fault 0003 tablecat/awktable 88 89 csaMkTemp tpl.include.tw.rpc 90 91 ~ $TNS_API_PROP(1) n && cgi.numeric = on 92 93 csaExit.ok --table $tmp1 94 95 # End of program.