Software /
code /
prosody
Annotate
plugins/mod_admin_adhoc.lua @ 6300:4b0172dc5e3a
mod_dialback: Keep the same dialback secret across module reloads
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 03 Jul 2014 15:38:53 +0200 |
parent | 5818:5733a277237a |
child | 6457:ddcb29a35409 |
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 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
13 local module_host = module:get_host(); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
14 |
5371
706206e191e8
mod_motd, mod_register, mod_private, mod_http_errors, mod_admin_adhoc: Remove unused imports
Kim Alvefur <zash@zash.se>
parents:
5329
diff
changeset
|
15 local keys = require "util.iterators".keys; |
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
|
16 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
|
17 local usermanager_create_user = require "core.usermanager".create_user; |
5100
65207b768f60
mod_admin_adhoc: Use usermanager.delete_user to delete users
Kim Alvefur <zash@zash.se>
parents:
5076
diff
changeset
|
18 local usermanager_delete_user = require "core.usermanager".delete_user; |
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
|
19 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
|
20 local usermanager_set_password = require "core.usermanager".set_password; |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
21 local hostmanager_activate = require "core.hostmanager".activate; |
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
22 local hostmanager_deactivate = require "core.hostmanager".deactivate; |
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
|
23 local rm_load_roster = require "core.rostermanager".load_roster; |
5371
706206e191e8
mod_motd, mod_register, mod_private, mod_http_errors, mod_admin_adhoc: Remove unused imports
Kim Alvefur <zash@zash.se>
parents:
5329
diff
changeset
|
24 local st, jid = require "util.stanza", require "util.jid"; |
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
|
25 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
|
26 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
|
27 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
|
28 local modulemanager = require "modulemanager"; |
5013
ab693eea0869
mod_admin_adhoc, mod_admin_telnet, mod_bosh, mod_c2s, mod_component, mod_pep, mod_presence, mod_roster, mod_s2s: Import core_post_stanza from the global prosody table.
Kim Alvefur <zash@zash.se>
parents:
4993
diff
changeset
|
29 local core_post_stanza = prosody.core_post_stanza; |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
30 local adhoc_simple = require "util.adhoc".new_simple_form; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
31 local adhoc_initial = require "util.adhoc".new_initial_data_form; |
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
|
32 |
4780
4b8f2b91826c
mod_admin_adhoc: Small style fix
Matthew Wild <mwild1@gmail.com>
parents:
4595
diff
changeset
|
33 module:depends("adhoc"); |
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
|
34 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
|
35 |
4932
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
36 local function generate_error_message(errors) |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
37 local errmsg = {}; |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
38 for name, err in pairs(errors) do |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
39 errmsg[#errmsg + 1] = name .. ": " .. err; |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
40 end |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
41 return { status = "completed", error = { message = t_concat(errmsg, "\n") } }; |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
42 end |
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
43 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
44 -- Adding a new user |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
45 local add_user_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
46 title = "Adding a User"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
47 instructions = "Fill out this form to add a user."; |
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
|
48 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
49 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
50 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for the account to be added" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
51 { name = "password", type = "text-private", label = "The password for this account" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
52 { name = "password-verify", type = "text-private", label = "Retype password" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
53 }; |
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
|
54 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
55 local add_user_command_handler = adhoc_simple(add_user_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
56 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
57 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
58 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
59 local username, host, resource = jid.split(fields.accountjid); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
60 if module_host ~= host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
61 return { status = "completed", error = { message = "Trying to add a user on " .. host .. " but command was sent to " .. module_host}}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
62 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
63 if (fields["password"] == fields["password-verify"]) and username and host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
64 if usermanager_user_exists(username, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
65 return { status = "completed", error = { message = "Account already exists" } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
66 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
67 if usermanager_create_user(username, fields.password, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
68 module:log("info", "Created new account %s@%s", username, host); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
69 return { status = "completed", info = "Account successfully created" }; |
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
|
70 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
71 return { status = "completed", error = { message = "Failed to write data to disk" } }; |
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
|
72 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
|
73 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
|
74 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
75 module:log("debug", "Invalid data, password mismatch or empty username while creating account for %s", fields.accountjid or "<nil>"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
76 return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } }; |
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
|
77 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
78 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
|
79 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
80 -- Changing a user's password |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
81 local change_user_password_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
82 title = "Changing a User Password"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
83 instructions = "Fill out this form to change a user's password."; |
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
|
84 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
85 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
86 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for this account" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
87 { name = "password", type = "text-private", required = true, label = "The password for this account" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
88 }; |
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
|
89 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
90 local change_user_password_command_handler = adhoc_simple(change_user_password_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
91 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
92 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
93 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
94 local username, host, resource = jid.split(fields.accountjid); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
95 if module_host ~= host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
96 return { status = "completed", error = { message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. module_host}}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
97 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
98 if usermanager_user_exists(username, host) and usermanager_set_password(username, fields.password, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
99 return { status = "completed", info = "Password successfully changed" }; |
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
|
100 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
101 return { status = "completed", error = { message = "User does not exist" } }; |
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
|
102 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
103 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
|
104 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
105 -- Reloading the config |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
106 local function config_reload_handler(self, data, state) |
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
107 local ok, err = prosody.reload_config(); |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
108 if ok then |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
109 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
|
110 else |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
111 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
|
112 end |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
113 end |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
114 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
115 -- Deleting a user's account |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
116 local delete_user_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
117 title = "Deleting a User"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
118 instructions = "Fill out this form to delete a user."; |
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
119 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
120 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
121 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) to delete" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
122 }; |
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
|
123 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
124 local delete_user_command_handler = adhoc_simple(delete_user_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
125 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
126 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
127 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
128 local failed = {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
129 local succeeded = {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
130 for _, aJID in ipairs(fields.accountjids) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
131 local username, host, resource = jid.split(aJID); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
132 if (host == module_host) and usermanager_user_exists(username, host) and usermanager_delete_user(username, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
133 module:log("debug", "User %s has been deleted", aJID); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
134 succeeded[#succeeded+1] = aJID; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
135 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
136 module:log("debug", "Tried to delete non-existant user %s", aJID); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
137 failed[#failed+1] = aJID; |
4932
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
138 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
|
139 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
140 return {status = "completed", info = (#succeeded ~= 0 and |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
141 "The following accounts were successfully deleted:\n"..t_concat(succeeded, "\n").."\n" or "").. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
142 (#failed ~= 0 and |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
143 "The following accounts could not be deleted:\n"..t_concat(failed, "\n") or "") }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
144 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
|
145 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
146 -- Ending a user's session |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
147 local function disconnect_user(match_jid) |
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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 if not givenResource or (resource == givenResource) then |
4993
5243b74a4cbb
Hopefully inert commit to clean up logging across a number of modules, removing all cases of concatenation when building log messages
Matthew Wild <mwild1@gmail.com>
parents:
4956
diff
changeset
|
153 module:log("debug", "Disconnecting %s@%s/%s", node, hostname, resource); |
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
|
154 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
|
155 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
|
156 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
|
157 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
|
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 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
160 local end_user_session_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
161 title = "Ending a User Session"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
162 instructions = "Fill out this form to end a user's session."; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
163 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
164 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
165 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to end sessions" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
166 }; |
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
|
167 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
168 local end_user_session_handler = adhoc_simple(end_user_session_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
169 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
170 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
171 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
172 local failed = {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
173 local succeeded = {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
174 for _, aJID in ipairs(fields.accountjids) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
175 local username, host, resource = jid.split(aJID); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
176 if (host == module_host) and usermanager_user_exists(username, host) and disconnect_user(aJID) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
177 succeeded[#succeeded+1] = aJID; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
178 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
179 failed[#failed+1] = aJID; |
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
|
180 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
181 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
182 return {status = "completed", info = (#succeeded ~= 0 and |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
183 "The following accounts were successfully disconnected:\n"..t_concat(succeeded, "\n").."\n" or "").. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
184 (#failed ~= 0 and |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
185 "The following accounts could not be disconnected:\n"..t_concat(failed, "\n") or "") }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
186 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
|
187 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
188 -- Getting a user's password |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
189 local get_user_password_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
190 title = "Getting User's Password"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
191 instructions = "Fill out this form to get a user's password."; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
192 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
193 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
194 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the password" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
195 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
196 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
197 local get_user_password_result_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
198 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
199 { name = "accountjid", type = "jid-single", label = "JID" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
200 { name = "password", type = "text-single", label = "Password" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
201 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
202 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
203 local get_user_password_handler = adhoc_simple(get_user_password_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
204 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
205 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
206 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
207 local user, host, resource = jid.split(fields.accountjid); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
208 local accountjid = ""; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
209 local password = ""; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
210 if host ~= module_host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
211 return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. module_host } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
212 elseif usermanager_user_exists(user, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
213 accountjid = fields.accountjid; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
214 password = usermanager_get_password(user, host); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
215 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
216 return { status = "completed", error = { message = "User does not exist" } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
217 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
218 return { status = "completed", result = { layout = get_user_password_result_layout, values = {accountjid = accountjid, password = password} } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
219 end); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
220 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
221 -- Getting a user's roster |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
222 local get_user_roster_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
223 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
224 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the roster" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
225 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
226 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
227 local get_user_roster_result_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
228 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
229 { name = "accountjid", type = "jid-single", label = "This is the roster for" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
230 { name = "roster", type = "text-multi", label = "Roster XML" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
231 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
232 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
233 local get_user_roster_handler = adhoc_simple(get_user_roster_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
234 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
235 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
236 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
237 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
238 local user, host, resource = jid.split(fields.accountjid); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
239 if host ~= module_host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
240 return { status = "completed", error = { message = "Tried to get roster for a user on " .. host .. " but command was sent to " .. module_host } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
241 elseif not usermanager_user_exists(user, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
242 return { status = "completed", error = { message = "User does not exist" } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
243 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
244 local roster = rm_load_roster(user, host); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
245 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
246 local query = st.stanza("query", { xmlns = "jabber:iq:roster" }); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
247 for jid in pairs(roster) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
248 if jid ~= "pending" and jid then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
249 query:tag("item", { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
250 jid = jid, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
251 subscription = roster[jid].subscription, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
252 ask = roster[jid].ask, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
253 name = roster[jid].name, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
254 }); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
255 for group in pairs(roster[jid].groups) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
256 query:tag("group"):text(group):up(); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
257 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
258 query:up(); |
4932
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
259 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
260 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
261 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
262 local query_text = tostring(query):gsub("><", ">\n<"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
263 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
264 local result = get_user_roster_result_layout:form({ accountjid = user.."@"..host, roster = query_text }, "result"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
265 result:add_child(query); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
266 return { status = "completed", other = result }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
267 end); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
268 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
269 -- Getting user statistics |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
270 local get_user_stats_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
271 title = "Get User Statistics"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
272 instructions = "Fill out this form to gather user statistics."; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
273 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
274 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
275 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for statistics" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
276 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
277 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
278 local get_user_stats_result_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
279 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
280 { name = "ipaddresses", type = "text-multi", label = "IP Addresses" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
281 { name = "rostersize", type = "text-single", label = "Roster size" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
282 { name = "onlineresources", type = "text-multi", label = "Online Resources" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
283 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
284 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
285 local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
286 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
287 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
288 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
289 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
290 local user, host, resource = jid.split(fields.accountjid); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
291 if host ~= module_host then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
292 return { status = "completed", error = { message = "Tried to get stats for a user on " .. host .. " but command was sent to " .. module_host } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
293 elseif not usermanager_user_exists(user, host) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
294 return { status = "completed", error = { message = "User does not exist" } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
295 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
296 local roster = rm_load_roster(user, host); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
297 local rostersize = 0; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
298 local IPs = ""; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
299 local resources = ""; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
300 for jid in pairs(roster) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
301 if jid ~= "pending" and jid then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
302 rostersize = rostersize + 1; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
303 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
304 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
305 for resource, session in pairs((hosts[host].sessions[user] and hosts[host].sessions[user].sessions) or {}) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
306 resources = resources .. "\n" .. resource; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
307 IPs = IPs .. "\n" .. session.ip; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
308 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
309 return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = tostring(rostersize), |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
310 onlineresources = resources}} }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
311 end); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
312 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
313 -- Getting a list of online users |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
314 local get_online_users_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
315 title = "Getting List of Online Users"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
316 instructions = "How many users should be returned at most?"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
317 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
318 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
319 { name = "max_items", type = "list-single", label = "Maximum number of users", |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
320 value = { "25", "50", "75", "100", "150", "200", "all" } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
321 { name = "details", type = "boolean", label = "Show details" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
322 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
323 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
324 local get_online_users_result_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
325 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
326 { name = "onlineuserjids", type = "text-multi", label = "The list of all online users" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
327 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
328 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
329 local get_online_users_command_handler = adhoc_simple(get_online_users_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
330 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
331 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
332 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
333 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
334 local max_items = nil |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
335 if fields.max_items ~= "all" then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
336 max_items = tonumber(fields.max_items); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
337 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
338 local count = 0; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
339 local users = {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
340 for username, user in pairs(hosts[module_host].sessions or {}) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
341 if (max_items ~= nil) and (count >= max_items) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
342 break; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
343 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
344 users[#users+1] = username.."@"..module_host; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
345 count = count + 1; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
346 if fields.details then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
347 for resource, session in pairs(user.sessions or {}) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
348 local status, priority = "unavailable", tostring(session.priority or "-"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
349 if session.presence then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
350 status = session.presence:child_with_name("show"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
351 if status then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
352 status = status:get_text() or "[invalid!]"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
353 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
354 status = "available"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
355 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
356 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
357 users[#users+1] = " - "..resource..": "..status.."("..priority..")"; |
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
|
358 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
|
359 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
|
360 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
361 return { status = "completed", result = {layout = get_online_users_result_layout, values = {onlineuserjids=t_concat(users, "\n")}} }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
362 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
|
363 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
364 -- Getting a list of loaded modules |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
365 local list_modules_result = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
366 title = "List of loaded modules"; |
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
|
367 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
368 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#list" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
369 { name = "modules", type = "text-multi", label = "The following modules are loaded:" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
370 }; |
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
|
371 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
372 local function list_modules_handler(self, data, state) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
373 local modules = array.collect(keys(hosts[module_host].modules)):sort():concat("\n"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
374 return { status = "completed", result = { layout = list_modules_result; values = { modules = modules } } }; |
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
|
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 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
377 -- Loading a module |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
378 local load_module_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
379 title = "Load module"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
380 instructions = "Specify the module to be loaded"; |
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
|
381 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
382 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#load" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
383 { name = "module", type = "text-single", required = true, label = "Module to be loaded:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
384 }; |
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
|
385 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
386 local load_module_handler = adhoc_simple(load_module_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
387 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
388 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
389 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
390 if modulemanager.is_loaded(module_host, fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
391 return { status = "completed", info = "Module already loaded" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
392 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
393 local ok, err = modulemanager.load(module_host, fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
394 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
395 return { status = "completed", info = 'Module "'..fields.module..'" successfully loaded on host "'..module_host..'".' }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
396 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
397 return { status = "completed", error = { message = 'Failed to load module "'..fields.module..'" on host "'..module_host.. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
398 '". Error was: "'..tostring(err or "<unspecified>")..'"' } }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
399 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
400 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
|
401 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
402 -- Globally loading a module |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
403 local globally_load_module_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
404 title = "Globally load module"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
405 instructions = "Specify the module to be loaded on all hosts"; |
4932
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
406 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
407 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#global-load" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
408 { name = "module", type = "text-single", required = true, label = "Module to globally load:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
409 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
410 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
411 local globally_load_module_handler = adhoc_simple(globally_load_module_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
412 local ok_list, err_list = {}, {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
413 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
414 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
415 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
416 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
|
417 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
418 local ok, err = modulemanager.load(module_host, fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
419 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
420 ok_list[#ok_list + 1] = module_host; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
421 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
422 err_list[#err_list + 1] = module_host .. " (Error: " .. tostring(err) .. ")"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
423 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
424 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
425 -- Is this a global module? |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
426 if modulemanager.is_loaded("*", fields.module) and not modulemanager.is_loaded(module_host, fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
427 return { status = "completed", info = 'Global module '..fields.module..' loaded.' }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
428 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
429 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
430 -- This is either a shared or "normal" module, load it on all other hosts |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
431 for host_name, host in pairs(hosts) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
432 if host_name ~= module_host and host.type == "local" then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
433 local ok, err = modulemanager.load(host_name, fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
434 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
435 ok_list[#ok_list + 1] = host_name; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
436 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
437 err_list[#err_list + 1] = host_name .. " (Error: " .. tostring(err) .. ")"; |
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
|
438 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
|
439 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
|
440 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
|
441 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
442 local info = (#ok_list > 0 and ("The module "..fields.module.." was successfully loaded onto the hosts:\n"..t_concat(ok_list, "\n")) or "") |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
443 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
444 (#err_list > 0 and ("Failed to load the module "..fields.module.." onto the hosts:\n"..t_concat(err_list, "\n")) or ""); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
445 return { status = "completed", info = info }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
446 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
|
447 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
448 -- Reloading modules |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
449 local reload_modules_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
450 title = "Reload modules"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
451 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
|
452 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
453 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#reload" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
454 { name = "modules", type = "list-multi", required = true, label = "Modules to be reloaded:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
455 }; |
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
|
456 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
457 local reload_modules_handler = adhoc_initial(reload_modules_layout, function() |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
458 return { modules = array.collect(keys(hosts[module_host].modules)):sort() }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
459 end, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
460 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
461 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
462 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
463 local ok_list, err_list = {}, {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
464 for _, module in ipairs(fields.modules) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
465 local ok, err = modulemanager.reload(module_host, module); |
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 if ok then |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
467 ok_list[#ok_list + 1] = module; |
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
|
468 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
469 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; |
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
|
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 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
472 local info = (#ok_list > 0 and ("The following modules were successfully reloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
473 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
474 (#err_list > 0 and ("Failed to reload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
475 return { status = "completed", info = info }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
476 end); |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
477 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
478 -- Globally reloading a module |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
479 local globally_reload_module_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
480 title = "Globally reload module"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
481 instructions = "Specify the module to reload on all hosts"; |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
482 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
483 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#global-reload" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
484 { name = "module", type = "list-single", required = true, label = "Module to globally reload:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
485 }; |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
486 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
487 local globally_reload_module_handler = adhoc_initial(globally_reload_module_layout, function() |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
488 local loaded_modules = array(keys(modulemanager.get_modules("*"))); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
489 for _, host in pairs(hosts) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
490 loaded_modules:append(array(keys(host.modules))); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
491 end |
5818
5733a277237a
mod_admin_adhoc: As the only user of set:items(), update... it's now an iterator, and the extra keys() iterator is now unnecessary
Matthew Wild <mwild1@gmail.com>
parents:
5721
diff
changeset
|
492 loaded_modules = array(set.new(loaded_modules):items()):sort(); |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
493 return { module = loaded_modules }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
494 end, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
495 local is_global = false; |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
496 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
497 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
498 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
499 end |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
500 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
501 if modulemanager.is_loaded("*", fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
502 local ok, err = modulemanager.reload("*", fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
503 if not ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
504 return { status = "completed", info = 'Global module '..fields.module..' failed to reload: '..err }; |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
505 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
506 is_global = true; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
507 end |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
508 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
509 local ok_list, err_list = {}, {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
510 for host_name, host in pairs(hosts) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
511 if modulemanager.is_loaded(host_name, fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
512 local ok, err = modulemanager.reload(host_name, fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
513 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
514 ok_list[#ok_list + 1] = host_name; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
515 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
516 err_list[#err_list + 1] = host_name .. " (Error: " .. tostring(err) .. ")"; |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
517 end |
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
518 end |
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
519 end |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
520 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
521 if #ok_list == 0 and #err_list == 0 then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
522 if is_global then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
523 return { status = "completed", info = 'Successfully reloaded global module '..fields.module }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
524 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
525 return { status = "completed", info = 'Module '..fields.module..' not loaded on any host.' }; |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
526 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
527 end |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
528 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
529 local info = (#ok_list > 0 and ("The module "..fields.module.." was successfully reloaded on the hosts:\n"..t_concat(ok_list, "\n")) or "") |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
530 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
531 (#err_list > 0 and ("Failed to reload the module "..fields.module.." on the hosts:\n"..t_concat(err_list, "\n")) or ""); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
532 return { status = "completed", info = info }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
533 end); |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
534 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
535 local function send_to_online(message, server) |
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
|
536 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
|
537 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
|
538 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
|
539 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
|
540 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
|
541 |
b5c92275910b
mod_admin_adhoc: New module with 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 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
552 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
|
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 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
555 -- Shutting down the service |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
556 local shut_down_service_layout = dataforms_new{ |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
557 title = "Shutting Down the Service"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
558 instructions = "Fill out this form to shut down the service."; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
559 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
560 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
561 { name = "delay", type = "list-single", label = "Time delay before shutting down", |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
562 value = { {label = "30 seconds", value = "30"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
563 {label = "60 seconds", value = "60"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
564 {label = "90 seconds", value = "90"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
565 {label = "2 minutes", value = "120"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
566 {label = "3 minutes", value = "180"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
567 {label = "4 minutes", value = "240"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
568 {label = "5 minutes", value = "300"}, |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
569 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
570 }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
571 { name = "announcement", type = "text-multi", label = "Announcement" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
572 }; |
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
|
573 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
574 local shut_down_service_handler = adhoc_simple(shut_down_service_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
575 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
576 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
577 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
578 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
579 if fields.announcement and #fields.announcement > 0 then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
580 local message = st.message({type = "headline"}, fields.announcement):up() |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
581 :tag("subject"):text("Server is shutting down"); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
582 send_to_online(message); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
583 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
|
584 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
585 timer_add_task(tonumber(fields.delay or "5"), function(time) prosody.shutdown("Shutdown by adhoc command") end); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
586 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
587 return { status = "completed", info = "Server is about to shut down" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
588 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
|
589 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
590 -- Unloading modules |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
591 local unload_modules_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
592 title = "Unload modules"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
593 instructions = "Select the modules to be unloaded"; |
4932
212e81ac6ebb
mod_admin_web: Use util.dataforms' own error checking
Florian Zeitz <florob@babelmonkeys.de>
parents:
4926
diff
changeset
|
594 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
595 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#unload" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
596 { name = "modules", type = "list-multi", required = true, label = "Modules to be unloaded:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
597 }; |
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
|
598 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
599 local unload_modules_handler = adhoc_initial(unload_modules_layout, function() |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
600 return { modules = array.collect(keys(hosts[module_host].modules)):sort() }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
601 end, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
602 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
603 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
604 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
605 local ok_list, err_list = {}, {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
606 for _, module in ipairs(fields.modules) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
607 local ok, err = modulemanager.unload(module_host, module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
608 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
609 ok_list[#ok_list + 1] = module; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
610 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
611 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; |
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
|
612 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
613 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
614 local info = (#ok_list > 0 and ("The following modules were successfully unloaded on host "..module_host..":\n"..t_concat(ok_list, "\n")) or "") |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
615 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
616 (#err_list > 0 and ("Failed to unload the following modules on host "..module_host..":\n"..t_concat(err_list, "\n")) or ""); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
617 return { status = "completed", info = info }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
618 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
|
619 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
620 -- Globally unloading a module |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
621 local globally_unload_module_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
622 title = "Globally unload module"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
623 instructions = "Specify a module to unload on all hosts"; |
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
|
624 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
625 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#global-unload" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
626 { name = "module", type = "list-single", required = true, label = "Module to globally unload:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
627 }; |
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
|
628 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
629 local globally_unload_module_handler = adhoc_initial(globally_unload_module_layout, function() |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
630 local loaded_modules = array(keys(modulemanager.get_modules("*"))); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
631 for _, host in pairs(hosts) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
632 loaded_modules:append(array(keys(host.modules))); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
633 end |
5818
5733a277237a
mod_admin_adhoc: As the only user of set:items(), update... it's now an iterator, and the extra keys() iterator is now unnecessary
Matthew Wild <mwild1@gmail.com>
parents:
5721
diff
changeset
|
634 loaded_modules = array(set.new(loaded_modules):items()):sort(); |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
635 return { module = loaded_modules }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
636 end, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
637 local is_global = false; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
638 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
639 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
640 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
641 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
642 if modulemanager.is_loaded("*", fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
643 local ok, err = modulemanager.unload("*", fields.module); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
644 if not ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
645 return { status = "completed", info = 'Global module '..fields.module..' failed to unload: '..err }; |
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
|
646 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
647 is_global = true; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
648 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
649 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
650 local ok_list, err_list = {}, {}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
651 for host_name, host in pairs(hosts) do |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
652 if modulemanager.is_loaded(host_name, fields.module) then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
653 local ok, err = modulemanager.unload(host_name, fields.module); |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
654 if ok then |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
655 ok_list[#ok_list + 1] = host_name; |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
656 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
657 err_list[#err_list + 1] = host_name .. " (Error: " .. tostring(err) .. ")"; |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
658 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
|
659 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
|
660 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
|
661 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
662 if #ok_list == 0 and #err_list == 0 then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
663 if is_global then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
664 return { status = "completed", info = 'Successfully unloaded global module '..fields.module }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
665 else |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
666 return { status = "completed", info = 'Module '..fields.module..' not loaded on any host.' }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
667 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
668 end |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
669 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
670 local info = (#ok_list > 0 and ("The module "..fields.module.." was successfully unloaded on the hosts:\n"..t_concat(ok_list, "\n")) or "") |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
671 .. ((#ok_list > 0 and #err_list > 0) and "\n" or "") .. |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
672 (#err_list > 0 and ("Failed to unload the module "..fields.module.." on the hosts:\n"..t_concat(err_list, "\n")) or ""); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
673 return { status = "completed", info = info }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
674 end); |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
675 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
676 -- Activating a host |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
677 local activate_host_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
678 title = "Activate host"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
679 instructions = ""; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
680 |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
681 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/hosts#activate" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
682 { name = "host", type = "text-single", required = true, label = "Host:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
683 }; |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
684 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
685 local activate_host_handler = adhoc_simple(activate_host_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
686 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
687 return generate_error_message(err); |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
688 end |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
689 local ok, err = hostmanager_activate(fields.host); |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
690 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
691 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
692 return { status = "completed", info = fields.host .. " activated" }; |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
693 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
694 return { status = "canceled", error = err } |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
695 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
696 end); |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
697 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
698 -- Deactivating a host |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
699 local deactivate_host_layout = dataforms_new { |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
700 title = "Deactivate host"; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
701 instructions = ""; |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
702 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
703 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/hosts#activate" }; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
704 { name = "host", type = "text-single", required = true, label = "Host:"}; |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
705 }; |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
706 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
707 local deactivate_host_handler = adhoc_simple(deactivate_host_layout, function(fields, err) |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
708 if err then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
709 return generate_error_message(err); |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
710 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
711 local ok, err = hostmanager_deactivate(fields.host); |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
712 |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
713 if ok then |
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
714 return { status = "completed", info = fields.host .. " deactivated" }; |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
715 else |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
716 return { status = "canceled", error = err } |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
717 end |
5514
1091d7c3b4d2
mod_admin_adhoc: Use util.adhoc
Florian Zeitz <florob@babelmonkeys.de>
parents:
5371
diff
changeset
|
718 end); |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
719 |
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
720 |
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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 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
|
727 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
|
728 local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin"); |
5721
579c51cbc12c
mod_admin_adhoc: Fix node of the "Get List of Online Users" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
5514
diff
changeset
|
729 local get_online_users_desc = adhoc_new("Get List of Online Users", "http://jabber.org/protocol/admin#get-online-users-list", 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
|
730 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
|
731 local load_module_desc = adhoc_new("Load module", "http://prosody.im/protocol/modules#load", load_module_handler, "admin"); |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
732 local globally_load_module_desc = adhoc_new("Globally load module", "http://prosody.im/protocol/modules#global-load", globally_load_module_handler, "global_admin"); |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
733 local reload_modules_desc = adhoc_new("Reload modules", "http://prosody.im/protocol/modules#reload", reload_modules_handler, "admin"); |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
734 local globally_reload_module_desc = adhoc_new("Globally reload module", "http://prosody.im/protocol/modules#global-reload", globally_reload_module_handler, "global_admin"); |
4296
b991ffa0f2c5
mod_admin_adhoc: Only allow global admins to shut the server down
Florian Zeitz <florob@babelmonkeys.de>
parents:
4292
diff
changeset
|
735 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
|
736 local unload_modules_desc = adhoc_new("Unload modules", "http://prosody.im/protocol/modules#unload", unload_modules_handler, "admin"); |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
737 local globally_unload_module_desc = adhoc_new("Globally unload module", "http://prosody.im/protocol/modules#global-unload", globally_unload_module_handler, "global_admin"); |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
738 local activate_host_desc = adhoc_new("Activate host", "http://prosody.im/protocol/hosts#activate", activate_host_handler, "global_admin"); |
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
739 local deactivate_host_desc = adhoc_new("Deactivate host", "http://prosody.im/protocol/hosts#deactivate", deactivate_host_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
|
740 |
4926
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
741 module:provides("adhoc", add_user_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
742 module:provides("adhoc", change_user_password_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
743 module:provides("adhoc", config_reload_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
744 module:provides("adhoc", delete_user_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
745 module:provides("adhoc", end_user_session_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
746 module:provides("adhoc", get_user_password_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
747 module:provides("adhoc", get_user_roster_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
748 module:provides("adhoc", get_user_stats_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
749 module:provides("adhoc", get_online_users_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
750 module:provides("adhoc", list_modules_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
751 module:provides("adhoc", load_module_desc); |
5325
97bf651e32a4
mod_admin_adhoc: Implement global module loading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5324
diff
changeset
|
752 module:provides("adhoc", globally_load_module_desc); |
4926
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
753 module:provides("adhoc", reload_modules_desc); |
5327
b0c36b043f00
mod_admin_adhoc: Implement global module reloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5326
diff
changeset
|
754 module:provides("adhoc", globally_reload_module_desc); |
4926
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
755 module:provides("adhoc", shut_down_service_desc); |
58714123f600
mod_adhoc, mod_admin_adhoc, mod_announce: Use module:provides() to manage Ad-Hoc commands
Florian Zeitz <florob@babelmonkeys.de>
parents:
4780
diff
changeset
|
756 module:provides("adhoc", unload_modules_desc); |
5328
5e15e6700412
mod_admin_adhoc: Implement global module unloading
Florian Zeitz <florob@babelmonkeys.de>
parents:
5327
diff
changeset
|
757 module:provides("adhoc", globally_unload_module_desc); |
5135
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
758 module:provides("adhoc", activate_host_desc); |
52eafe0e9772
mod_admin_adhoc: Add commands for activating and deactivating hosts
Kim Alvefur <zash@zash.se>
parents:
5100
diff
changeset
|
759 module:provides("adhoc", deactivate_host_desc); |