Software /
code /
prosody
Annotate
plugins/mod_admin_adhoc.lua @ 3860:8abadb7c03b6
prosody: Added a comment, to match prosodyctl.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 12 Dec 2010 17:15:57 +0500 |
parent | 3540:bc139431830b |
child | 3777:5ecbcef42ffb |
rev | line source |
---|---|
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
1 -- Copyright (C) 2009-2010 Florian Zeitz |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
2 -- |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
3 -- This file is MIT/X11 licensed. Please see the |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
4 -- COPYING file in the source package for more information. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
5 -- |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
6 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
7 local _G = _G; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
8 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
9 local prosody = _G.prosody; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
10 local hosts = prosody.hosts; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
11 local t_concat = table.concat; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
12 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
13 require "util.iterators"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
14 local usermanager_user_exists = require "core.usermanager".user_exists; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
15 local usermanager_create_user = require "core.usermanager".create_user; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
16 local usermanager_get_password = require "core.usermanager".get_password; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
17 local usermanager_set_password = require "core.usermanager".set_password; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
18 local is_admin = require "core.usermanager".is_admin; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
19 local rm_load_roster = require "core.rostermanager".load_roster; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
20 local st, jid, uuid = require "util.stanza", require "util.jid", require "util.uuid"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
21 local timer_add_task = require "util.timer".add_task; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
22 local dataforms_new = require "util.dataforms".new; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
23 local array = require "util.array"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
24 local modulemanager = require "modulemanager"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
25 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
26 local adhoc_new = module:require "adhoc".new; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
27 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
28 function add_user_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
29 local add_user_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
30 title = "Adding a User"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
31 instructions = "Fill out this form to add a user."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
32 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
33 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
34 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for the account to be added" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
35 { name = "password", type = "text-private", label = "The password for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
36 { name = "password-verify", type = "text-private", label = "Retype password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
37 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
38 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
39 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
40 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
41 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
42 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
43 local fields = add_user_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
44 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
45 return { status = "completed", error = { message = "You need to specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
46 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
47 local username, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
48 if data.to ~= host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
49 return { status = "completed", error = { message = "Trying to add a user on " .. host .. " but command was sent to " .. data.to}}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
50 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
51 if (fields["password"] == fields["password-verify"]) and username and host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
52 if usermanager_user_exists(username, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
53 return { status = "completed", error = { message = "Account already exists" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
54 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
55 if usermanager_create_user(username, fields.password, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
56 module:log("info", "Created new account " .. username.."@"..host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
57 return { status = "completed", info = "Account successfully created" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
58 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
59 return { status = "completed", error = { message = "Failed to write data to disk" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
60 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
61 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
62 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
63 module:log("debug", (fields.accountjid or "<nil>") .. " " .. (fields.password or "<nil>") .. " " |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
64 .. (fields["password-verify"] or "<nil>")); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
65 return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
66 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
67 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
68 return { status = "executing", form = add_user_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
69 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
70 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
71 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
72 function change_user_password_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
73 local change_user_password_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
74 title = "Changing a User Password"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
75 instructions = "Fill out this form to change a user's password."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
76 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
77 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
78 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
79 { name = "password", type = "text-private", required = true, label = "The password for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
80 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
81 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
82 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
83 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
84 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
85 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
86 local fields = change_user_password_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
87 if not fields.accountjid or fields.accountjid == "" or not fields.password then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
88 return { status = "completed", error = { message = "Please specify username and password" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
89 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
90 local username, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
91 if data.to ~= host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
92 return { status = "completed", error = { message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. data.to}}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
93 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
94 if usermanager_user_exists(username, host) and usermanager_set_password(username, fields.password, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
95 return { status = "completed", info = "Password successfully changed" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
96 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
97 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
98 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
99 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
100 return { status = "executing", form = change_user_password_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
101 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
102 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
103 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
104 function delete_user_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
105 local delete_user_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
106 title = "Deleting a User"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
107 instructions = "Fill out this form to delete a user."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
108 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
109 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
110 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) to delete" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
111 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
112 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
113 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
114 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
115 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
116 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
117 local fields = delete_user_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
118 local failed = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
119 local succeeded = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
120 for _, aJID in ipairs(fields.accountjids) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
121 local username, host, resource = jid.split(aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
122 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
123 module:log("debug", "User " .. aJID .. " has been deleted"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
124 succeeded[#succeeded+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
125 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
126 module:log("debug", "Tried to delete non-existant user "..aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
127 failed[#failed+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
128 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
129 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
130 return {status = "completed", info = (#succeeded ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
131 "The following accounts were successfully deleted:\n"..t_concat(succeeded, "\n").."\n" or "").. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
132 (#failed ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
133 "The following accounts could not be deleted:\n"..t_concat(failed, "\n") or "") }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
134 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
135 return { status = "executing", form = delete_user_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
136 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
137 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
138 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
139 function disconnect_user(match_jid) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
140 local node, hostname, givenResource = jid.split(match_jid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
141 local host = hosts[hostname]; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
142 local sessions = host.sessions[node] and host.sessions[node].sessions; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
143 for resource, session in pairs(sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
144 if not givenResource or (resource == givenResource) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
145 module:log("debug", "Disconnecting "..node.."@"..hostname.."/"..resource); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
146 session:close(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
147 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
148 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
149 return true; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
150 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
151 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
152 function end_user_session_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
153 local end_user_session_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
154 title = "Ending a User Session"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
155 instructions = "Fill out this form to end a user's session."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
156 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
157 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
158 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to end sessions" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
159 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
160 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
161 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
162 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
163 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
164 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
165 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
166 local fields = end_user_session_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
167 local failed = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
168 local succeeded = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
169 for _, aJID in ipairs(fields.accountjids) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
170 local username, host, resource = jid.split(aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
171 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
172 succeeded[#succeeded+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
173 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
174 failed[#failed+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
175 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
176 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
177 return {status = "completed", info = (#succeeded ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
178 "The following accounts were successfully disconnected:\n"..t_concat(succeeded, "\n").."\n" or "").. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
179 (#failed ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
180 "The following accounts could not be disconnected:\n"..t_concat(failed, "\n") or "") }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
181 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
182 return { status = "executing", form = end_user_session_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
183 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
184 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
185 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
186 local end_user_session_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
187 title = "Ending a User Session"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
188 instructions = "Fill out this form to end a user's session."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
189 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
190 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
191 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to end sessions" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
192 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
193 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
194 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
195 function get_user_password_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
196 local get_user_password_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
197 title = "Getting User's Password"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
198 instructions = "Fill out this form to get a user's password."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
199 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
200 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
201 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
202 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
203 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
204 local get_user_password_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
205 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
206 { name = "accountjid", type = "jid-single", label = "JID" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
207 { name = "password", type = "text-single", label = "Password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
208 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
209 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
210 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
211 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
212 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
213 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
214 local fields = get_user_password_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
215 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
216 return { status = "completed", error = { message = "Please specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
217 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
218 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
219 local accountjid = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
220 local password = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
221 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
222 return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
223 elseif usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
224 accountjid = fields.accountjid; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
225 password = usermanager_get_password(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
226 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
227 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
228 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
229 return { status = "completed", result = { layout = get_user_password_result_layout, values = {accountjid = accountjid, password = password} } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
230 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
231 return { status = "executing", form = get_user_password_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
232 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
233 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
234 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
235 function get_user_roster_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
236 local get_user_roster_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
237 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
238 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the roster" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
239 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
240 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
241 local get_user_roster_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
242 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
243 { name = "accountjid", type = "jid-single", label = "This is the roster for" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
244 { name = "roster", type = "text-multi", label = "Roster XML" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
245 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
246 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
247 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
248 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
249 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
250 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
251 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
252 local fields = get_user_roster_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
253 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
254 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
255 return { status = "completed", error = { message = "Please specify a JID" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
256 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
257 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
258 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
259 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
260 return { status = "completed", error = { message = "Tried to get roster for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
261 elseif not usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
262 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
263 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
264 local roster = rm_load_roster(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
265 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
266 local query = st.stanza("query", { xmlns = "jabber:iq:roster" }); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
267 for jid in pairs(roster) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
268 if jid ~= "pending" and jid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
269 query:tag("item", { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
270 jid = jid, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
271 subscription = roster[jid].subscription, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
272 ask = roster[jid].ask, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
273 name = roster[jid].name, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
274 }); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
275 for group in pairs(roster[jid].groups) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
276 query:tag("group"):text(group):up(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
277 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
278 query:up(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
279 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
280 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
281 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
282 local query_text = query:__tostring(); -- TODO: Use upcoming pretty_print() function |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
283 query_text = query_text:gsub("><", ">\n<"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
284 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
285 local result = get_user_roster_result_layout:form({ accountjid = user.."@"..host, roster = query_text }, "result"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
286 result:add_child(query); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
287 return { status = "completed", other = result }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
288 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
289 return { status = "executing", form = get_user_roster_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
290 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
291 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
292 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
293 function get_user_stats_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
294 local get_user_stats_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
295 title = "Get User Statistics"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
296 instructions = "Fill out this form to gather user statistics."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
297 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
298 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
299 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for statistics" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
300 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
301 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
302 local get_user_stats_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
303 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
304 { name = "ipaddresses", type = "text-multi", label = "IP Addresses" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
305 { name = "rostersize", type = "text-single", label = "Roster size" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
306 { name = "onlineresources", type = "text-multi", label = "Online Resources" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
307 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
308 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
309 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
310 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
311 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
312 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
313 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
314 local fields = get_user_stats_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
315 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
316 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
317 return { status = "completed", error = { message = "Please specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
318 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
319 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
320 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
321 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
322 return { status = "completed", error = { message = "Tried to get stats for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
323 elseif not usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
324 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
325 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
326 local roster = rm_load_roster(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
327 local rostersize = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
328 local IPs = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
329 local resources = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
330 for jid in pairs(roster) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
331 if jid ~= "pending" and jid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
332 rostersize = rostersize + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
333 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
334 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
335 for resource, session in pairs((hosts[host].sessions[user] and hosts[host].sessions[user].sessions) or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
336 resources = resources .. "\n" .. resource; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
337 IPs = IPs .. "\n" .. session.ip; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
338 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
339 return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = tostring(rostersize), |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
340 onlineresources = resources}} }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
341 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
342 return { status = "executing", form = get_user_stats_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
343 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
344 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
345 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
346 function get_online_users_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
347 local get_online_users_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
348 title = "Getting List of Online Users"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
349 instructions = "How many users should be returned at most?"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
350 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
351 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
352 { name = "max_items", type = "list-single", label = "Maximum number of users", |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
353 value = { "25", "50", "75", "100", "150", "200", "all" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
354 { name = "details", type = "boolean", label = "Show details" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
355 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
356 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
357 local get_online_users_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
358 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
359 { name = "onlineuserjids", type = "text-multi", label = "The list of all online users" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
360 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
361 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
362 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
363 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
364 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
365 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
366 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
367 local fields = get_online_users_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
368 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
369 local max_items = nil |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
370 if fields.max_items ~= "all" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
371 max_items = tonumber(fields.max_items); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
372 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
373 local count = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
374 local users = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
375 for username, user in pairs(hosts[data.to].sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
376 if (max_items ~= nil) and (count >= max_items) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
377 break; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
378 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
379 users[#users+1] = username.."@"..data.to; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
380 count = count + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
381 if fields.details then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
382 for resource, session in pairs(user.sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
383 local status, priority = "unavailable", tostring(session.priority or "-"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
384 if session.presence then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
385 status = session.presence:child_with_name("show"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
386 if status then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
387 status = status:get_text() or "[invalid!]"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
388 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
389 status = "available"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
390 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
391 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
392 users[#users+1] = " - "..resource..": "..status.."("..priority..")"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
393 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
394 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
395 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
396 return { status = "completed", result = {layout = get_online_users_result_layout, values = {onlineuserjids=t_concat(users, "\n")}} }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
397 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
398 return { status = "executing", form = get_online_users_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
399 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
400 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
401 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
402 function list_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
403 local result = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
404 title = "List of loaded modules"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
405 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
406 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#list" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
407 { name = "modules", type = "text-multi", label = "The following modules are loaded:" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
408 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
409 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
410 local modules = array.collect(keys(hosts[data.to].modules)):sort():concat("\n"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
411 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
412 return { status = "completed", result = { layout = result; values = { modules = modules } } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
413 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
414 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
415 function load_module_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
416 local layout = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
417 title = "Load module"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
418 instructions = "Specify the module to be loaded"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
419 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
420 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#load" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
421 { name = "module", type = "text-single", required = true, label = "Module to be loaded:"}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
422 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
423 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
424 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
425 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
426 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
427 local fields = layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
428 if (not fields.module) or (fields.module == "") then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
429 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
430 message = "Please specify a module." |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
431 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
432 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
433 if modulemanager.is_loaded(data.to, fields.module) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
434 return { status = "completed", info = "Module already loaded" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
435 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
436 local ok, err = modulemanager.load(data.to, fields.module); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
437 if ok then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
438 return { status = "completed", info = 'Module "'..fields.module..'" successfully loaded on host "'..data.to..'".' }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
439 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
440 return { status = "completed", error = { message = 'Failed to load module "'..fields.module..'" on host "'..data.to.. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
441 '". Error was: "'..tostring(err or "<unspecified>")..'"' } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
442 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
443 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
444 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
445 return { status = "executing", form = layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
446 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
447 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
448 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
449 -- TODO: Allow reloading multiple modules (depends on list-multi) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
450 function reload_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
451 local layout = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
452 title = "Reload module"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
453 instructions = "Select the module to be reloaded"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
454 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
455 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#reload" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
456 { name = "module", type = "list-single", required = true, label = "Module to be reloaded:"}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
457 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
458 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
459 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
460 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
461 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
462 local fields = layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
463 if (not fields.module) or (fields.module == "") then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
464 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
465 message = "Please specify a module. (This means your client misbehaved, as this field is required)" |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
466 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
467 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
468 local ok, err = modulemanager.reload(data.to, fields.module); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
469 if ok then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
470 return { status = "completed", info = 'Module "'..fields.module..'" successfully reloaded on host "'..data.to..'".' }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
471 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
472 return { status = "completed", error = { message = 'Failed to reload module "'..fields.module..'" on host "'..data.to.. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
473 '". Error was: "'..tostring(err)..'"' } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
474 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
475 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
476 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
477 return { status = "executing", form = { layout = layout; values = { module = modules } } }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
478 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
479 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
480 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
481 function send_to_online(message, server) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
482 if server then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
483 sessions = { [server] = hosts[server] }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
484 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
485 sessions = hosts; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
486 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
487 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
488 local c = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
489 for domain, session in pairs(sessions) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
490 for user in pairs(session.sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
491 c = c + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
492 message.attr.from = domain; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
493 message.attr.to = user.."@"..domain; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
494 core_post_stanza(session, message); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
495 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
496 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
497 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
498 return c; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
499 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
500 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
501 function shut_down_service_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
502 local shut_down_service_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
503 title = "Shutting Down the Service"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
504 instructions = "Fill out this form to shut down the service."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
505 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
506 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
507 { name = "delay", type = "list-single", label = "Time delay before shutting down", |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
508 value = { {label = "30 seconds", value = "30"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
509 {label = "60 seconds", value = "60"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
510 {label = "90 seconds", value = "90"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
511 {label = "2 minutes", value = "120"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
512 {label = "3 minutes", value = "180"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
513 {label = "4 minutes", value = "240"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
514 {label = "5 minutes", value = "300"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
515 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
516 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
517 { name = "announcement", type = "text-multi", label = "Announcement" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
518 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
519 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
520 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
521 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
522 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
523 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
524 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
525 local fields = shut_down_service_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
526 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
527 if fields.announcement and #fields.announcement > 0 then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
528 local message = st.message({type = "headline"}, fields.announcement):up() |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
529 :tag("subject"):text("Server is shutting down"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
530 send_to_online(message); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
531 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
532 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
533 timer_add_task(tonumber(fields.delay or "5"), prosody.shutdown); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
534 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
535 return { status = "completed", info = "Server is about to shut down" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
536 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
537 return { status = "executing", form = shut_down_service_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
538 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
539 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
540 return true; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
541 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
542 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
543 -- TODO: Allow unloading multiple modules (depends on list-multi) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
544 function unload_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
545 local layout = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
546 title = "Unload module"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
547 instructions = "Select the module to be unloaded"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
548 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
549 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#unload" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
550 { name = "module", type = "list-single", required = true, label = "Module to be unloaded:"}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
551 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
552 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
553 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
554 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
555 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
556 local fields = layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
557 if (not fields.module) or (fields.module == "") then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
558 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
559 message = "Please specify a module. (This means your client misbehaved, as this field is required)" |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
560 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
561 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
562 local ok, err = modulemanager.unload(data.to, fields.module); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
563 if ok then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
564 return { status = "completed", info = 'Module "'..fields.module..'" successfully unloaded on host "'..data.to..'".' }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
565 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
566 return { status = "completed", error = { message = 'Failed to unload module "'..fields.module..'" on host "'..data.to.. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
567 '". Error was: "'..tostring(err)..'"' } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
568 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
569 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
570 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
571 return { status = "executing", form = { layout = layout; values = { module = modules } } }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
572 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
573 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
574 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
575 local add_user_desc = adhoc_new("Add User", "http://jabber.org/protocol/admin#add-user", add_user_command_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
576 local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
577 local delete_user_desc = adhoc_new("Delete User", "http://jabber.org/protocol/admin#delete-user", delete_user_command_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
578 local end_user_session_desc = adhoc_new("End User Session", "http://jabber.org/protocol/admin#end-user-session", end_user_session_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
579 local get_user_password_desc = adhoc_new("Get User Password", "http://jabber.org/protocol/admin#get-user-password", get_user_password_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
580 local get_user_roster_desc = adhoc_new("Get User Roster","http://jabber.org/protocol/admin#get-user-roster", get_user_roster_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
581 local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin"); |
3540
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
3487
diff
changeset
|
582 local get_online_users_desc = adhoc_new("Get List of Online Users", "http://jabber.org/protocol/admin#get-online-users", get_online_users_command_handler, "admin"); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
583 local list_modules_desc = adhoc_new("List loaded modules", "http://prosody.im/protocol/modules#list", list_modules_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
584 local load_module_desc = adhoc_new("Load module", "http://prosody.im/protocol/modules#load", load_module_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
585 local reload_modules_desc = adhoc_new("Reload module", "http://prosody.im/protocol/modules#reload", reload_modules_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
586 local shut_down_service_desc = adhoc_new("Shut Down Service", "http://jabber.org/protocol/admin#shutdown", shut_down_service_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
587 local unload_modules_desc = adhoc_new("Unload module", "http://prosody.im/protocol/modules#unload", unload_modules_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
588 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
589 module:add_item("adhoc", add_user_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
590 module:add_item("adhoc", change_user_password_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
591 module:add_item("adhoc", delete_user_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
592 module:add_item("adhoc", end_user_session_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
593 module:add_item("adhoc", get_user_password_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
594 module:add_item("adhoc", get_user_roster_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
595 module:add_item("adhoc", get_user_stats_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
596 module:add_item("adhoc", get_online_users_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
597 module:add_item("adhoc", list_modules_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
598 module:add_item("adhoc", load_module_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
599 module:add_item("adhoc", reload_modules_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
600 module:add_item("adhoc", shut_down_service_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
601 module:add_item("adhoc", unload_modules_desc); |