comparison mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua @ 33:f3225c55288f

mod_adhoc_cmd_admin: More utils.dataforms sugar
author Florian Zeitz <florob@babelmonkeys.de>
date Sat, 10 Oct 2009 04:01:45 +0200
parents 00d5e133c84d
children fc374b724270
comparison
equal deleted inserted replaced
32:00d5e133c84d 33:f3225c55288f
81 :tag("note", {type="error"}):text("Invalid data.\nPasswords missmatch, or empy username")); 81 :tag("note", {type="error"}):text("Invalid data.\nPasswords missmatch, or empy username"));
82 sessions[stanza.tags[1].attr.sessionid] = nil; 82 sessions[stanza.tags[1].attr.sessionid] = nil;
83 return true; 83 return true;
84 end 84 end
85 else 85 else
86 sessionid=uuid.generate(); 86 local sessionid=uuid.generate();
87 sessions[sessionid] = "executing"; 87 sessions[sessionid] = "executing";
88 local form = {
89 title= "Adding a User";
90 instructions = "Fill out this form to add a user.";
91
92 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" };
93 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for the account to be added" };
94 { name = "password", type = "text-private", label = "The password for this account" };
95 { name = "password-verify", type = "text-private", label = "Retype password" };
96 };
97 dataforms_new(form);
88 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands", 98 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands",
89 node="http://jabber.org/protocol/admin#add-user", sessionid=sessionid, 99 node="http://jabber.org/protocol/admin#add-user", sessionid=sessionid,
90 status="executing"}) 100 status="executing"}):add_child(form:form()));
91 :tag("x", { xmlns = "jabber:x:data", type = "form" })
92 :tag("title"):text("Adding a User"):up()
93 :tag("instructions"):text("Fill out this form to add a user."):up()
94 :tag("field", { type = "hidden", var = "FORM_TYPE" })
95 :tag("value"):text("http://jabber.org/protocol/admin"):up():up()
96 :tag("field", { label = "The Jabber ID for the account to be added",
97 type = "jid-single", var = "accountjid" })
98 :tag("required"):up():up()
99 :tag("field", { label = "The password for this account",
100 type = "text-private", var = "password" }):up()
101 :tag("field", { label = "Retype password", type = "text-private",
102 var = "password-verify" }):up():up()
103 );
104 end 101 end
105 return true; 102 return true;
106 end 103 end
107 104
108 local descriptor = { name="Add User", node="http://jabber.org/protocol/admin#add-user", handler=add_user_command_handler }; 105 local descriptor = { name="Add User", node="http://jabber.org/protocol/admin#add-user", handler=add_user_command_handler };