Mercurial > prosody-modules
comparison mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua @ 92:7dad958aad15
mod_adhoc_cmd_admin: Change to upcoming XEP version
| author | Florian Zeitz <florob@babelmonkeys.de> |
|---|---|
| date | Fri, 13 Nov 2009 21:01:24 +0100 |
| parents | 63bf00fd8f6e |
| children | e172f02726d9 |
comparison
equal
deleted
inserted
replaced
| 91:63bf00fd8f6e | 92:7dad958aad15 |
|---|---|
| 39 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; | 39 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
| 40 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) to delete" }; | 40 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) to delete" }; |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 local get_user_password_layout = dataforms_new{ | 43 local get_user_password_layout = dataforms_new{ |
| 44 title = "Getting Users' Passwords"; | 44 title = "Getting User's Password"; |
| 45 instructions = "Fill out this form to get users' passwords."; | 45 instructions = "Fill out this form to get a user's password."; |
| 46 | 46 |
| 47 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; | 47 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
| 48 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to retrieve the password" }; | 48 { name = "accountjid", type = "jid-single", label = "The Jabber ID for which to retrieve the password" }; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 local get_online_users_layout = dataforms_new{ | 51 local get_online_users_layout = dataforms_new{ |
| 52 title = "Getting List of Online Users"; | 52 title = "Getting List of Online Users"; |
| 53 instructions = "How many users should be returned at most?"; | 53 instructions = "How many users should be returned at most?"; |
| 158 sessions[stanza.tags[1].attr.sessionid] = nil; | 158 sessions[stanza.tags[1].attr.sessionid] = nil; |
| 159 return true; | 159 return true; |
| 160 end | 160 end |
| 161 local form = stanza.tags[1]:child_with_ns("jabber:x:data"); | 161 local form = stanza.tags[1]:child_with_ns("jabber:x:data"); |
| 162 local fields = get_user_password_layout:data(form); | 162 local fields = get_user_password_layout:data(form); |
| 163 local accountjids = st.stanza("field", {var="accountjids", label = "JIDs", type="jid-multi"}); | 163 local accountjid = st.stanza("field", {var="accountjid", label = "JID", type="jid-single"}); |
| 164 local passwords = st.stanza("field", {var="password", label = "Passwords", type="text-multi"}); | 164 local password = st.stanza("field", {var="password", label = "Password", type="text-single"}); |
| 165 for _, aJID in ipairs(fields.accountjids) do | 165 user, host, resource = jid.split(fields.accountjid); |
| 166 user, host, resource = jid.split(aJID); | 166 if usermanager_user_exists(user, host) then |
| 167 if usermanager_user_exists(user, host) then | 167 accountjid:tag("value"):text(fields.accountjid):up(); |
| 168 accountjids:tag("value"):text(aJID):up(); | 168 password:tag("value"):text(usermanager_get_password(user, host)):up(); |
| 169 passwords:tag("value"):text(usermanager_get_password(user, host)):up(); | 169 else |
| 170 end | 170 origin.send(st.error_reply(stanza, "cancel", "item-not-found", "User does not exist") |
| 171 :add_child(item:cmdtag("canceled", stanza.tags[1].attr.sessionid) | |
| 172 :tag("note", {type="error"}):text("User does not exist"))); | |
| 173 sessions[stanza.tags[1].attr.sessionid] = nil; | |
| 174 return true; | |
| 171 end | 175 end |
| 172 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", stanza.tags[1].attr.sessionid) | 176 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", stanza.tags[1].attr.sessionid) |
| 173 :tag("x", {xmlns="jabber:x:data", type="result"}) | 177 :tag("x", {xmlns="jabber:x:data", type="result"}) |
| 174 :tag("field", {type="hidden", var="FORM_TYPE"}) | 178 :tag("field", {type="hidden", var="FORM_TYPE"}) |
| 175 :tag("value"):text("http://jabber.org/protocol/admin"):up():up() | 179 :tag("value"):text("http://jabber.org/protocol/admin"):up():up() |
| 176 :add_child(accountjids) | 180 :add_child(accountjid) |
| 177 :add_child(passwords))); | 181 :add_child(password))); |
| 178 sessions[stanza.tags[1].attr.sessionid] = nil; | 182 sessions[stanza.tags[1].attr.sessionid] = nil; |
| 179 return true; | 183 return true; |
| 180 else | 184 else |
| 181 local sessionid=uuid.generate(); | 185 local sessionid=uuid.generate(); |
| 182 sessions[sessionid] = "executing"; | 186 sessions[sessionid] = "executing"; |
