3 #include "inspircd_config.h"
4 #include "configreader.h"
10 #include "helperfuncs.h"
13 #include "inspstring.h"
15 #include "modes/cmode_o.h"
17 extern InspIRCd* ServerInstance;
19 extern std::vector<Module*> modules;
20 extern std::vector<ircd_module*> factory;
24 ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL, false)
28 ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
30 userrec* x = ServerInstance->FindNick(parameter);
33 if (channel->GetStatus(x) == STATUS_OP)
35 return std::make_pair(true, x->nick);
39 return std::make_pair(false, parameter);
42 return std::make_pair(false, parameter);
45 ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
47 int status = channel->GetStatus(source);
49 /* Call the correct method depending on wether we're adding or removing the mode */
52 parameter = this->AddOp(source, parameter.c_str(), channel, status);
56 parameter = this->DelOp(source, parameter.c_str(), channel, status);
58 /* If the method above 'ate' the parameter by reducing it to an empty string, then
59 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
60 * the return value and is always MODEACTION_DENY if the mode is supposed to have
63 return MODEACTION_ALLOW;
66 std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status)
68 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
75 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP));
77 if (MOD_RESULT == ACR_DENY)
79 if (MOD_RESULT == ACR_DEFAULT)
81 if ((status < STATUS_OP) && (!is_uline(user->server)))
83 user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
89 return ModeParser::Grant(d,chan,UCMODE_OP);
94 std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status)
96 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
103 log(DEBUG,"Call OnAccessCheck for AC_DEOP");
104 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP));
106 log(DEBUG,"Returns %d",MOD_RESULT);
108 if (MOD_RESULT == ACR_DENY)
110 if (MOD_RESULT == ACR_DEFAULT)
112 if ((status < STATUS_OP) && (!is_uline(user->server)) && (IS_LOCAL(user)))
114 user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
120 return ModeParser::Revoke(d,chan,UCMODE_OP);