Changeset

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 32:00d5e133c84d
children 34:fc374b724270
files mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua
diffstat 1 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua	Sat Oct 10 03:24:41 2009 +0200
+++ b/mod_adhoc_cmd_admin/mod_adhoc_cmd_admin.lua	Sat Oct 10 04:01:45 2009 +0200
@@ -83,24 +83,21 @@
 			return true;
 		end
 	else
-		sessionid=uuid.generate();
+		local sessionid=uuid.generate();
 		sessions[sessionid] = "executing";
+		local form = {
+			title= "Adding a User";
+			instructions = "Fill out this form to add a user.";
+
+			{ name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" };
+			{ name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for the account to be added" };
+			{ name = "password", type = "text-private", label = "The password for this account" };
+			{ name = "password-verify", type = "text-private", label = "Retype password" };
+		};
+		dataforms_new(form);
 		origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands",
 			node="http://jabber.org/protocol/admin#add-user", sessionid=sessionid,
-			status="executing"})
-			:tag("x", { xmlns = "jabber:x:data", type = "form" })
-				:tag("title"):text("Adding a User"):up()
-				:tag("instructions"):text("Fill out this form to add a user."):up()
-				:tag("field", { type = "hidden", var = "FORM_TYPE" })
-					:tag("value"):text("http://jabber.org/protocol/admin"):up():up()
-				:tag("field", { label = "The Jabber ID for the account to be added",
-					type = "jid-single", var = "accountjid" })
-					:tag("required"):up():up()
-				:tag("field", { label = "The password for this account",
-					type = "text-private", var = "password" }):up()
-				:tag("field", { label = "Retype password", type = "text-private",
-					var = "password-verify" }):up():up()
-		);
+			status="executing"}):add_child(form:form()));
 	end
 	return true;
 end