Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 3256:d96172f78ec2
MUC: Added a 'Make Room Members-Only?' field to the room config dialog.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 13 Jun 2010 20:52:37 +0500 |
parent | 3255:6bffb5c63131 |
child | 3257:fae054e15e03 |
comparison
equal
deleted
inserted
replaced
3255:6bffb5c63131 | 3256:d96172f78ec2 |
---|---|
489 :tag("value"):text(self:get_password() or ""):up() | 489 :tag("value"):text(self:get_password() or ""):up() |
490 :up() | 490 :up() |
491 :tag("field", {type='boolean', label='Make Room Moderated?', var='muc#roomconfig_moderatedroom'}) | 491 :tag("field", {type='boolean', label='Make Room Moderated?', var='muc#roomconfig_moderatedroom'}) |
492 :tag("value"):text(self:is_moderated() and "1" or "0"):up() | 492 :tag("value"):text(self:is_moderated() and "1" or "0"):up() |
493 :up() | 493 :up() |
494 :tag("field", {type='boolean', label='Make Room Members-Only?', var='muc#roomconfig_membersonly'}) | |
495 :tag("value"):text(self:is_members_only() and "1" or "0"):up() | |
496 :up() | |
494 ); | 497 ); |
495 end | 498 end |
496 | 499 |
497 local valid_whois = { | 500 local valid_whois = { |
498 moderators = true, | 501 moderators = true, |
527 if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true; | 530 if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true; |
528 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | 531 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end |
529 dirty = dirty or (self:is_moderated() ~= moderated) | 532 dirty = dirty or (self:is_moderated() ~= moderated) |
530 module:log("debug", "moderated=%s", tostring(moderated)); | 533 module:log("debug", "moderated=%s", tostring(moderated)); |
531 | 534 |
535 local membersonly = fields['muc#roomconfig_membersonly']; | |
536 if membersonly == "0" or membersonly == "false" then membersonly = nil; elseif membersonly == "1" or membersonly == "true" then membersonly = true; | |
537 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | |
538 dirty = dirty or (self:is_members_only() ~= membersonly) | |
539 module:log("debug", "membersonly=%s", tostring(membersonly)); | |
540 | |
532 local public = fields['muc#roomconfig_publicroom']; | 541 local public = fields['muc#roomconfig_publicroom']; |
533 if public == "0" or public == "false" then public = nil; elseif public == "1" or public == "true" then public = true; | 542 if public == "0" or public == "false" then public = nil; elseif public == "1" or public == "true" then public = true; |
534 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | 543 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end |
535 dirty = dirty or (self._data.hidden ~= (not public and true or nil)) | 544 dirty = dirty or (self._data.hidden ~= (not public and true or nil)) |
536 self._data.hidden = not public and true or nil; | 545 self._data.hidden = not public and true or nil; |
547 local password = fields['muc#roomconfig_roomsecret']; | 556 local password = fields['muc#roomconfig_roomsecret']; |
548 if password then | 557 if password then |
549 self:set_password(password); | 558 self:set_password(password); |
550 end | 559 end |
551 self:set_moderated(moderated); | 560 self:set_moderated(moderated); |
561 self:set_members_only(membersonly); | |
552 | 562 |
553 if self.save then self:save(true); end | 563 if self.save then self:save(true); end |
554 origin.send(st.reply(stanza)); | 564 origin.send(st.reply(stanza)); |
555 | 565 |
556 if dirty or whois_changed then | 566 if dirty or whois_changed then |