summaryrefslogtreecommitdiff
path: root/src/mode.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-01 16:12:45 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-01 16:12:45 +0000
commitf3abcf2bcfe36d3389b74caa9eef8582901fbe15 (patch)
tree2ebd9c1c6615939d850cf95866e9e982cb2b18d1 /src/mode.cpp
parent61416a1885d1490550175b6a73b724ba0843d729 (diff)
Simple user/channel mode patch
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9596 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/mode.cpp')
-rw-r--r--src/mode.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index e5efaffdf..91a64f89b 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -149,6 +149,71 @@ bool ModeHandler::CheckTimeStamp(time_t theirs, time_t ours, const std::string&,
return (ours < theirs);
}
+SimpleUserModeHandler::SimpleUserModeHandler(InspIRCd* Instance, char modeletter) : ModeHandler(Instance, modeletter, 0, 0, false, MODETYPE_USER, false)
+{
+}
+
+SimpleUserModeHandler::~SimpleUserModeHandler()
+{
+}
+
+SimpleChannelModeHandler::~SimpleChannelModeHandler()
+{
+}
+
+SimpleChannelModeHandler::SimpleChannelModeHandler(InspIRCd* Instance, char modeletter) : ModeHandler(Instance, modeletter, 0, 0, false, MODETYPE_CHANNEL, false)
+{
+}
+
+ModeAction SimpleUserModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
+{
+ /* Only opers can change other users modes */
+ if (source != dest)
+ return MODEACTION_DENY;
+
+ if (adding)
+ {
+ if (!dest->IsModeSet(this->GetModeChar()))
+ {
+ dest->SetMode(this->GetModeChar(),true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (dest->IsModeSet(this->GetModeChar()))
+ {
+ dest->SetMode(this->GetModeChar(),false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+}
+
+
+ModeAction SimpleChannelModeHandler::OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool servermode)
+{
+ if (adding)
+ {
+ if (!channel->IsModeSet(this->GetModeChar()))
+ {
+ channel->SetMode(this->GetModeChar(),true);
+ return MODEACTION_ALLOW;
+ }
+ }
+ else
+ {
+ if (channel->IsModeSet(this->GetModeChar()))
+ {
+ channel->SetMode(this->GetModeChar(),false);
+ return MODEACTION_ALLOW;
+ }
+ }
+
+ return MODEACTION_DENY;
+}
+
ModeWatcher::ModeWatcher(InspIRCd* Instance, char modeletter, ModeType type) : ServerInstance(Instance), mode(modeletter), m_type(type)
{
}