liquid_feedback_frontend
annotate bin/liquid-admin.lua @ 118:93f4e465b50d
add initiator support in delegation
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
| author | Daniel Poelzleithner <poelzi@poelzi.org> |
|---|---|
| date | Mon Sep 20 20:32:04 2010 +0200 (2010-09-20) |
| parents | eeb167cf9dc4 |
| children |
| rev | line source |
|---|---|
| poelzi@107 | 1 #!/usr/bin/env lua |
| poelzi@107 | 2 |
| poelzi@107 | 3 OptionParser = require("utils.optparse") |
| poelzi@107 | 4 |
| poelzi@107 | 5 COMMANDS = {{"setpwd <username> <password>", "Set a user command"}, |
| poelzi@107 | 6 {"listuser", "List usernames"}, |
| poelzi@107 | 7 } |
| poelzi@107 | 8 |
| poelzi@107 | 9 t={usage="<some usage message>", version="<version string>", commands=COMMANDS} |
| poelzi@107 | 10 op=OptionParser(t) |
| poelzi@107 | 11 --op.add_option({"-t", action="safe_true", dest="test", help="<help message for this option>"}) |
| poelzi@107 | 12 op.add_option({"-c", action="store", dest="config", help="config name to use", default="default"}) |
| poelzi@107 | 13 op.add_option({"-w", action="store", dest="webmcp", help="path to webmcp", default="../webmcp"}) |
| poelzi@107 | 14 |
| poelzi@107 | 15 options,args = op.parse_args() |
| poelzi@107 | 16 |
| poelzi@107 | 17 if #args == 0 then |
| poelzi@107 | 18 print("Error: command is required\n") |
| poelzi@107 | 19 op.print_help() |
| poelzi@107 | 20 return |
| poelzi@107 | 21 end |
| poelzi@107 | 22 |
| poelzi@107 | 23 -- dirty dirty dirty, dirty dirty, dirty dirty dow monkey patch env |
| poelzi@107 | 24 if not os.setenv then |
| poelzi@107 | 25 |
| poelzi@107 | 26 local env, getenv = { }, os.getenv |
| poelzi@107 | 27 |
| poelzi@107 | 28 function os.setenv(k,v) |
| poelzi@107 | 29 env[k] = v |
| poelzi@107 | 30 end |
| poelzi@107 | 31 |
| poelzi@107 | 32 function os.getenv(k) |
| poelzi@107 | 33 return env[k] or getenv(k) |
| poelzi@107 | 34 end |
| poelzi@107 | 35 |
| poelzi@107 | 36 end |
| poelzi@107 | 37 |
| poelzi@107 | 38 -- detect current path FIXME: platform portable |
| poelzi@107 | 39 local PWD = io.popen("pwd"):read() |
| poelzi@107 | 40 os.setenv("WEBMCP_APP_BASEPATH", PWD) |
| poelzi@107 | 41 os.setenv("WEBMCP_CONFIG_NAME", options.config) |
| poelzi@107 | 42 os.setenv("WEBMCP_INTERACTIVE", "yes") |
| poelzi@107 | 43 |
| poelzi@107 | 44 -- load webmcp framework |
| poelzi@107 | 45 WEBMCP_PATH = options.webmcp .. "/framework/" |
| poelzi@107 | 46 dofile(options.webmcp .. "/framework/cgi-bin/webmcp.lua") |
| poelzi@107 | 47 |
| poelzi@107 | 48 function error(why) |
| poelzi@107 | 49 print(why) |
| poelzi@107 | 50 os.exit(2) |
| poelzi@107 | 51 end |
| poelzi@107 | 52 |
| poelzi@107 | 53 if args[1] == "setpwd" then |
| poelzi@107 | 54 if #args < 2 then |
| poelzi@107 | 55 error("login is required") |
| poelzi@107 | 56 end |
| poelzi@107 | 57 require("model.member") |
| poelzi@107 | 58 user = Member:by_login(args[2]) |
| poelzi@107 | 59 if not user then |
| poelzi@107 | 60 error("User "..args[2].." not found") |
| poelzi@107 | 61 end |
| poelzi@107 | 62 print("Enter password:") |
| poelzi@107 | 63 password = io.read() |
| poelzi@107 | 64 if password then |
| poelzi@107 | 65 user:set_password(password) |
| poelzi@107 | 66 user:save() |
| poelzi@107 | 67 end |
| poelzi@107 | 68 end |
| poelzi@107 | 69 |
| poelzi@107 | 70 if args[1] == "listusers" then |
| poelzi@107 | 71 require("model.member") |
| poelzi@107 | 72 sel = Member:new_selector() |
| poelzi@107 | 73 users = sel:exec() |
| poelzi@107 | 74 --sel:optional_object_mode() |
| poelzi@107 | 75 print("Login Active") |
| poelzi@107 | 76 for i,v in pairs(users) do |
| poelzi@107 | 77 if v.login then |
| poelzi@107 | 78 print(v.login .. string.rep(" ", 25-#v.login), v.active) |
| poelzi@107 | 79 end |
| poelzi@107 | 80 end |
| poelzi@107 | 81 end |
| poelzi@107 | 82 |
| poelzi@107 | 83 |
| poelzi@107 | 84 |
| poelzi@107 | 85 |
| poelzi@107 | 86 |