3 #include "inspircd_config.h"
4 #include "configreader.h"
10 #include "helperfuncs.h"
14 #include "inspstring.h"
16 #include "modes/cmode_o.h"
18 extern InspIRCd* ServerInstance;
19 extern ServerConfig* Config;
20 extern std::vector<Module*> modules;
21 extern std::vector<ircd_module*> factory;
25 ModeChannelOp::ModeChannelOp() : ModeHandler('o', 1, 1, true, MODETYPE_CHANNEL, false)
29 ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
31 int status = cstatus(source, channel);
33 /* Call the correct method depending on wether we're adding or removing the mode */
36 parameter = this->AddOp(source, parameter.c_str(), channel, status);
40 parameter = this->DelOp(source, parameter.c_str(), channel, status);
42 /* If the method above 'ate' the parameter by reducing it to an empty string, then
43 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
44 * the return value and is always MODEACTION_DENY if the mode is supposed to have
47 return MODEACTION_ALLOW;
50 std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status)
52 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
59 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP));
61 if (MOD_RESULT == ACR_DENY)
63 if (MOD_RESULT == ACR_DEFAULT)
65 if ((status < STATUS_OP) && (!is_uline(user->server)))
67 WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
73 return ModeParser::Grant(d,chan,UCMODE_OP);
78 std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status)
80 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
87 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP));
89 if (MOD_RESULT == ACR_DENY)
91 if (MOD_RESULT == ACR_DEFAULT)
93 if ((status < STATUS_OP) && (!is_uline(user->server)) && (IS_LOCAL(user)))
95 WriteServ(user->fd,"482 %s %s :You are not a channel operator",user->nick, chan->name);
101 return ModeParser::Revoke(d,chan,UCMODE_OP);