Annotate

plugins/mod_admin_adhoc.lua @ 4296:b991ffa0f2c5

mod_admin_adhoc: Only allow global admins to shut the server down
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 03 Jun 2011 02:01:31 +0200
parent 4292:894ffea639e9
child 4594:565ea0c1a7ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4292
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
1 -- Copyright (C) 2009-2011 Florian Zeitz
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
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
4292
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
104 function config_reload_handler(self, data, state)
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
105 local ok, err = prosody.reload_config();
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
106 if ok then
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
107 return { status = "completed", info = "Configuration reloaded (modules may need to be reloaded for this to have an effect)" };
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
108 else
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
109 return { status = "completed", error = { message = "Failed to reload config: " .. tostring(err) } };
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
110 end
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
111 end
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
112
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
113
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
114 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
115 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
116 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
117 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
118
b5c92275910b mod_admin_adhoc: New module with 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 { 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
120 { 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
121 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 "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
142 (#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
143 "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
144 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
145 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
146 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
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
b5c92275910b mod_admin_adhoc: New module with 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 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
150 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
151 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
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161
b5c92275910b mod_admin_adhoc: New module with 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 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
163 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
164 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
165 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
166
b5c92275910b mod_admin_adhoc: New module with 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 { 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
168 { 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
169 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
172 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
173 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
174 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
175
b5c92275910b mod_admin_adhoc: New module with 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 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 "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
189 (#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
190 "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
191 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
192 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
193 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
194 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
195
b5c92275910b mod_admin_adhoc: New module with 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 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
197 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
198 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
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 = "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
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
b5c92275910b mod_admin_adhoc: New module with 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 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
206 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
207 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
208 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
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 { 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
211 { 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
212 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
215 { 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
216 { 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
217 { 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
218 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244
b5c92275910b mod_admin_adhoc: New module with 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 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
246 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
247 { 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
248 { 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
249 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
252 { 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
253 { 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
254 { 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
255 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
258 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
259 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
260 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
261
b5c92275910b mod_admin_adhoc: New module with 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 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
263
b5c92275910b mod_admin_adhoc: New module with 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 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
265 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
266 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
267
b5c92275910b mod_admin_adhoc: New module with 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 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
269 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
270 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
271 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
272 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
273 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
274 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
275
b5c92275910b mod_admin_adhoc: New module with 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 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
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 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
286 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
287 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
288 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
289 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
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
b5c92275910b mod_admin_adhoc: New module with 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 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
293 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
294
b5c92275910b mod_admin_adhoc: New module with 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 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
296 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
297 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
298 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
299 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
300 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
301 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
302
b5c92275910b mod_admin_adhoc: New module with 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 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
304 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
305 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
306 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
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 { 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
309 { 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
310 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
313 { 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
314 { 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
315 { 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
316 { 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
317 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
320 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
321 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
322 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
323
b5c92275910b mod_admin_adhoc: New module with 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 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
325
b5c92275910b mod_admin_adhoc: New module with 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 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
327 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
328 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
329
b5c92275910b mod_admin_adhoc: New module with 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 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
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 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
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 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
357 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
358 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
359 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
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 { 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
362 { 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
363 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
364 { 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
365 };
b5c92275910b mod_admin_adhoc: New module with 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 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
368 { 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
369 { 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
370 };
b5c92275910b mod_admin_adhoc: New module with 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
b5c92275910b mod_admin_adhoc: New module with 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 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
373 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
374 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
375 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
376
b5c92275910b mod_admin_adhoc: New module with 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 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
378
b5c92275910b mod_admin_adhoc: New module with 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 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
380 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
381 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
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391 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
392 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
393 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
394 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
395 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
396 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
397 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
398 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
399 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
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 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
402 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
403 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
404 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
405 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
406 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
407 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
408 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
409 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
410 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
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 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
413 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
414 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
415
b5c92275910b mod_admin_adhoc: New module with 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 { 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
417 { 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
418 };
b5c92275910b mod_admin_adhoc: New module with 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 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
421
b5c92275910b mod_admin_adhoc: New module with 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 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
423 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
424
b5c92275910b mod_admin_adhoc: New module with 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 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
426 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
427 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
428 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
429
b5c92275910b mod_admin_adhoc: New module with 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 { 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
431 { 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
432 };
b5c92275910b mod_admin_adhoc: New module with 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 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
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 } };
b5c92275910b mod_admin_adhoc: New module with 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 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 '". 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
452 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
453 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
454 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
455 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
456 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
457 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
458
b5c92275910b mod_admin_adhoc: New module with 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 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
460 local layout = dataforms_new {
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
461 title = "Reload modules";
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
462 instructions = "Select the modules to be reloaded";
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
463
b5c92275910b mod_admin_adhoc: New module with 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 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#reload" };
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
465 { name = "modules", type = "list-multi", required = true, label = "Modules to be reloaded:"};
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
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 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
468 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
469 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
470 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
471 local fields = layout:data(data.form);
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
472 if #fields.modules == 0 then
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
473 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
474 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
475 } };
b5c92275910b mod_admin_adhoc: New module with 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 end
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
477 local ok_list, err_list = {}, {};
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
478 for _, module in ipairs(fields.modules) do
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
479 local ok, err = modulemanager.reload(data.to, module);
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
480 if ok then
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
481 ok_list[#ok_list + 1] = module;
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
482 else
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
483 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")";
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
484 end
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
485 end
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
486 local info = (#ok_list > 0 and ("The following modules were successfully reloaded on host "..data.to..":\n"..t_concat(ok_list, "\n")) or "")..
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
487 (#err_list > 0 and ("Failed to reload the following modules on host "..data.to..":\n"..t_concat(err_list, "\n")) or "");
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
488 return { status = "completed", info = info };
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
489 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
490 local modules = array.collect(keys(hosts[data.to].modules)):sort();
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
491 return { status = "executing", form = { layout = layout; values = { modules = modules } } }, "executing";
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
492 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
493 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
494
b5c92275910b mod_admin_adhoc: New module with 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 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
496 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
497 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
498 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
499 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
500 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
501
b5c92275910b mod_admin_adhoc: New module with 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 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
503 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
504 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
505 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
506 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
507 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
508 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
509 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
510 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
511
b5c92275910b mod_admin_adhoc: New module with 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 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
513 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
514
b5c92275910b mod_admin_adhoc: New module with 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 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
516 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
517 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
518 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
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 { 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
521 { 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
522 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
523 {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
524 {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
525 {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
526 {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
527 {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
528 {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
529 };
b5c92275910b mod_admin_adhoc: New module with 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 };
b5c92275910b mod_admin_adhoc: New module with 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 { 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
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
b5c92275910b mod_admin_adhoc: New module with 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 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
535 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
536 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
537 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
538
b5c92275910b mod_admin_adhoc: New module with 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 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
540
b5c92275910b mod_admin_adhoc: New module with 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 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
542 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
543 :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
544 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
545 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
546
b5c92275910b mod_admin_adhoc: New module with 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 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
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 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
550 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
551 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
552 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
553 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
554
b5c92275910b mod_admin_adhoc: New module with 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 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
556 local layout = dataforms_new {
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
557 title = "Unload modules";
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
558 instructions = "Select the modules to be unloaded";
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
559
b5c92275910b mod_admin_adhoc: New module with 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 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#unload" };
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
561 { name = "modules", type = "list-multi", required = true, label = "Modules to be unloaded:"};
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
562 };
b5c92275910b mod_admin_adhoc: New module with 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 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
564 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
565 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
566 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
567 local fields = layout:data(data.form);
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
568 if #fields.modules == 0 then
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
569 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
570 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
571 } };
b5c92275910b mod_admin_adhoc: New module with 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
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
573 local ok_list, err_list = {}, {};
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
574 for _, module in ipairs(fields.modules) do
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
575 local ok, err = modulemanager.unload(data.to, module);
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
576 if ok then
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
577 ok_list[#ok_list + 1] = module;
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
578 else
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
579 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")";
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
580 end
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
581 end
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
582 local info = (#ok_list > 0 and ("The following modules were successfully unloaded on host "..data.to..":\n"..t_concat(ok_list, "\n")) or "")..
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
583 (#err_list > 0 and ("Failed to unload the following modules on host "..data.to..":\n"..t_concat(err_list, "\n")) or "");
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
584 return { status = "completed", info = info };
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
585 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
586 local modules = array.collect(keys(hosts[data.to].modules)):sort();
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
587 return { status = "executing", form = { layout = layout; values = { modules = modules } } }, "executing";
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
588 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
589 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
590
b5c92275910b mod_admin_adhoc: New module with 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 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
592 local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin");
4292
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
593 local config_reload_desc = adhoc_new("Reload configuration", "http://prosody.im/protocol/config#reload", config_reload_handler, "global_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
594 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
595 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
596 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
597 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
598 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
599 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
600 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
601 local load_module_desc = adhoc_new("Load module", "http://prosody.im/protocol/modules#load", load_module_handler, "admin");
3777
5ecbcef42ffb mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3540
diff changeset
602 local reload_modules_desc = adhoc_new("Reload modules", "http://prosody.im/protocol/modules#reload", reload_modules_handler, "admin");
4296
b991ffa0f2c5 mod_admin_adhoc: Only allow global admins to shut the server down
Florian Zeitz <florob@babelmonkeys.de>
parents: 4292
diff changeset
603 local shut_down_service_desc = adhoc_new("Shut Down Service", "http://jabber.org/protocol/admin#shutdown", shut_down_service_handler, "global_admin");
3778
bd1845f9d5a4 mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents: 3777
diff changeset
604 local unload_modules_desc = adhoc_new("Unload modules", "http://prosody.im/protocol/modules#unload", unload_modules_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
605
b5c92275910b mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff changeset
606 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
607 module:add_item("adhoc", change_user_password_desc);
4292
894ffea639e9 mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents: 3778
diff changeset
608 module:add_item("adhoc", config_reload_desc);
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
609 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
610 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
611 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
612 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
613 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
614 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
615 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
616 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
617 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
618 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
619 module:add_item("adhoc", unload_modules_desc);