Diff

plugins/muc/muc.lib.lua @ 5541:1997671d5e46

MUC: Allow plugins to add and handle options in the MUC config form
author Matthew Wild <mwild1@gmail.com>
date Mon, 29 Apr 2013 11:21:37 +0100
parent 5519:06e188268df1
child 5542:329ebdfb39a2
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Mon Apr 29 10:52:23 2013 +0100
+++ b/plugins/muc/muc.lib.lua	Mon Apr 29 11:21:37 2013 +0100
@@ -580,10 +580,9 @@
 end
 
 function room_mt:get_form_layout()
-	local title = "Configuration for "..self.jid;
-	return dataform.new({
-		title = title,
-		instructions = title,
+	local form = dataform.new({
+		title = "Configuration for "..self.jid,
+		instructions = "Complete and submit this form to configure the room.",
 		{
 			name = 'FORM_TYPE',
 			type = 'hidden',
@@ -653,6 +652,7 @@
 			value = tostring(self:get_historylength())
 		}
 	});
+	return module:fire_event("muc-config-form", { room = self, form = form }) or form;
 end
 
 local valid_whois = {
@@ -673,6 +673,10 @@
 
 	local dirty = false
 
+	local event = { room = self, fields = fields, changed = dirty };
+	module:fire_event("muc-config-submitted", event);
+	dirty = event.changed or dirty;
+
 	local name = fields['muc#roomconfig_roomname'];
 	if name ~= self:get_name() then
 		self:set_name(name);