Software / code / prosody
Comparison
plugins/muc/muc.lib.lua @ 3252:22062c50eabe
MUC: Added a 'Make Room Moderated?' field to the room config dialog.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 13 Jun 2010 20:24:55 +0500 |
| parent | 3251:f2f9fe088f6e |
| child | 3253:23a30abcc76e |
comparison
equal
deleted
inserted
replaced
| 3251:f2f9fe088f6e | 3252:22062c50eabe |
|---|---|
| 251 return self._data.password; | 251 return self._data.password; |
| 252 end | 252 end |
| 253 function room_mt:set_moderated(moderated) | 253 function room_mt:set_moderated(moderated) |
| 254 moderated = moderated and true or nil; | 254 moderated = moderated and true or nil; |
| 255 if self._data.moderated ~= moderated then | 255 if self._data.moderated ~= moderated then |
| 256 self._data.moderated = | 256 self._data.moderated = moderated; |
| 257 if self.save then self:save(true); end | 257 if self.save then self:save(true); end |
| 258 end | 258 end |
| 259 end | 259 end |
| 260 function room_mt:is_moderated() | 260 function room_mt:is_moderated() |
| 261 return self._data.moderated; | 261 return self._data.moderated; |
| 473 :up() | 473 :up() |
| 474 :up() | 474 :up() |
| 475 :tag("field", {type='text-private', label='Password', var='muc#roomconfig_roomsecret'}) | 475 :tag("field", {type='text-private', label='Password', var='muc#roomconfig_roomsecret'}) |
| 476 :tag("value"):text(self:get_password() or ""):up() | 476 :tag("value"):text(self:get_password() or ""):up() |
| 477 :up() | 477 :up() |
| 478 :tag("field", {type='boolean', label='Make Room Moderated?', var='muc#roomconfig_moderatedroom'}) | |
| 479 :tag("value"):text(self:is_moderated() and "1" or "0"):up() | |
| 480 :up() | |
| 478 ); | 481 ); |
| 479 end | 482 end |
| 480 | 483 |
| 481 local valid_whois = { | 484 local valid_whois = { |
| 482 moderators = true, | 485 moderators = true, |
| 505 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | 508 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end |
| 506 dirty = dirty or (self._data.persistent ~= persistent) | 509 dirty = dirty or (self._data.persistent ~= persistent) |
| 507 self._data.persistent = persistent; | 510 self._data.persistent = persistent; |
| 508 module:log("debug", "persistent=%s", tostring(persistent)); | 511 module:log("debug", "persistent=%s", tostring(persistent)); |
| 509 | 512 |
| 513 local moderated = fields['muc#roomconfig_moderatedroom']; | |
| 514 if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true; | |
| 515 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | |
| 516 dirty = dirty or (self:is_moderated() ~= moderated) | |
| 517 module:log("debug", "moderated=%s", tostring(moderated)); | |
| 518 | |
| 510 local public = fields['muc#roomconfig_publicroom']; | 519 local public = fields['muc#roomconfig_publicroom']; |
| 511 if public == "0" or public == "false" then public = nil; elseif public == "1" or public == "true" then public = true; | 520 if public == "0" or public == "false" then public = nil; elseif public == "1" or public == "true" then public = true; |
| 512 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end | 521 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end |
| 513 dirty = dirty or (self._data.hidden ~= (not public and true or nil)) | 522 dirty = dirty or (self._data.hidden ~= (not public and true or nil)) |
| 514 self._data.hidden = not public and true or nil; | 523 self._data.hidden = not public and true or nil; |
| 524 | 533 |
| 525 local password = fields['muc#roomconfig_roomsecret']; | 534 local password = fields['muc#roomconfig_roomsecret']; |
| 526 if password then | 535 if password then |
| 527 self:set_password(password); | 536 self:set_password(password); |
| 528 end | 537 end |
| 538 self:set_moderated(moderated); | |
| 529 | 539 |
| 530 if self.save then self:save(true); end | 540 if self.save then self:save(true); end |
| 531 origin.send(st.reply(stanza)); | 541 origin.send(st.reply(stanza)); |
| 532 | 542 |
| 533 if dirty or whois_changed then | 543 if dirty or whois_changed then |