Comparison

plugins/muc/muc.lib.lua @ 3508:9e4c2b048f9a

MUC: Added a 'Description' property (muc#roomconfig_roomdesc)
author Kim Alvefur <zash@zash.se>
date Sun, 26 Sep 2010 18:15:30 +0200
parent 3507:b639042bb0d5
child 3509:72cb8b6536b9
comparison
equal deleted inserted replaced
3507:b639042bb0d5 3508:9e4c2b048f9a
218 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up() 218 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up()
219 :tag("feature", {var=self:is_members_only() and "muc_membersonly" or "muc_open"}):up() 219 :tag("feature", {var=self:is_members_only() and "muc_membersonly" or "muc_open"}):up()
220 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up() 220 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up()
221 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up() 221 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up()
222 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() 222 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
223 :tag("x", {xmlns="jabber:x:data", type="result"})
224 :tag("field", {var="FORM_TYPE", type="hidden"})
225 :tag("value"):text("http://jabber.org/protocol/muc#roominfo"):up()
226 :up()
227 :tag("field", {var="muc#roominfo_description", label="Description"})
228 :tag("value"):text(self:get_description()):up()
229 :up()
230 :up()
223 ; 231 ;
224 end 232 end
225 function room_mt:get_disco_items(stanza) 233 function room_mt:get_disco_items(stanza)
226 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); 234 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");
227 for room_jid in pairs(self._occupants) do 235 for room_jid in pairs(self._occupants) do
258 if self.save then self:save(true); end 266 if self.save then self:save(true); end
259 end 267 end
260 end 268 end
261 function room_mt:get_name() 269 function room_mt:get_name()
262 return self._data.name; 270 return self._data.name;
271 end
272 function room_mt:set_description(description)
273 if description == "" or type(description) ~= "string" then description = nil; end
274 if self._data.description ~= description then
275 self._data.description = description;
276 if self.save then self:save(true); end
277 end
278 end
279 function room_mt:get_description()
280 return self._data.description;
263 end 281 end
264 function room_mt:set_password(password) 282 function room_mt:set_password(password)
265 if password == "" or type(password) ~= "string" then password = nil; end 283 if password == "" or type(password) ~= "string" then password = nil; end
266 if self._data.password ~= password then 284 if self._data.password ~= password then
267 self._data.password = password; 285 self._data.password = password;
509 local title = "Configuration for "..self.jid; 527 local title = "Configuration for "..self.jid;
510 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner") 528 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner")
511 :tag("x", {xmlns='jabber:x:data', type='form'}) 529 :tag("x", {xmlns='jabber:x:data', type='form'})
512 :tag("title"):text(title):up() 530 :tag("title"):text(title):up()
513 :tag("instructions"):text(title):up() 531 :tag("instructions"):text(title):up()
514 :tag("field", {type='text-single', label='Room Title', var='muc#roomconfig_roomname'}) 532 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up()
533 :tag("field", {type='text-single', label='Name', var='muc#roomconfig_roomname'})
515 :tag("value"):text(self:get_name() or ""):up() 534 :tag("value"):text(self:get_name() or ""):up()
516 :up() 535 :up()
517 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() 536 :tag("field", {type='text-single', label='Description', var='muc#roomconfig_roomdesc'})
537 :tag("value"):text(self:get_description() or ""):up()
538 :up()
518 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'}) 539 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'})
519 :tag("value"):text(self:is_persistent() and "1" or "0"):up() 540 :tag("value"):text(self:is_persistent() and "1" or "0"):up()
520 :up() 541 :up()
521 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'}) 542 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'})
522 :tag("value"):text(self:is_hidden() and "0" or "1"):up() 543 :tag("value"):text(self:is_hidden() and "0" or "1"):up()
565 local dirty = false 586 local dirty = false
566 587
567 local name = fields['muc#roomconfig_roomname']; 588 local name = fields['muc#roomconfig_roomname'];
568 if name then 589 if name then
569 self:set_name(name); 590 self:set_name(name);
591 end
592
593 local description = fields['muc#roomconfig_roomdesc'];
594 if description then
595 self:set_description(description);
570 end 596 end
571 597
572 local persistent = fields['muc#roomconfig_persistentroom']; 598 local persistent = fields['muc#roomconfig_persistentroom'];
573 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true; 599 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true;
574 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 600 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end