-
-
-/** Handles the +P channel mode
- */
-class PermChannel : public ModeHandler
-{
- public:
- PermChannel(Module* Creator) : ModeHandler(Creator, "permanent", 'P', PARAM_NONE, MODETYPE_CHANNEL) { }
-
- ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
- {
- if (!source->HasPrivPermission("channels/set-permanent"))
- {
- source->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges", source->nick.c_str());
- return MODEACTION_DENY;
- }
-
- if (adding)
- {
- if (!channel->IsModeSet('P'))
- {
- channel->SetMode('P',true);
-
- // Save permchannels db if needed.
- WriteDatabase();
- return MODEACTION_ALLOW;
- }
- }
- else
- {
- if (channel->IsModeSet('P'))
- {
- if (channel->GetUserCounter() == 0 && !IS_SERVER(source))
- {
- /*
- * ugh, ugh, UGH!
- *
- * We can't delete this channel the way things work at the moment,
- * because of the following scenario:
- * s1:#c <-> s2:#c
- *
- * s1 has a user in #c, s2 does not. s2 has +P set. s2 has a losing TS.
- *
- * On netmerge, s2 loses, so s2 removes all modes (including +P) which
- * would subsequently delete the channel here causing big fucking problems.
- *
- * I don't think there's really a way around this, so just deny -P on a 0 user chan.
- * -- w00t
- *
- * delete channel;
- */
- return MODEACTION_DENY;
- }
-
- /* for servers, remove +P (to avoid desyncs) but don't bother trying to delete. */
- channel->SetMode('P',false);
-
- // Save permchannels db if needed.
- WriteDatabase();
- return MODEACTION_ALLOW;
- }
- }
-
- return MODEACTION_DENY;
- }
-};
-