3 #include "inspircd_config.h"
4 #include "configreader.h"
10 #include "helperfuncs.h"
14 #include "inspstring.h"
16 #include "modes/cmode_h.h"
18 extern InspIRCd* ServerInstance;
19 extern ServerConfig* Config;
20 extern std::vector<Module*> modules;
21 extern std::vector<ircd_module*> factory;
25 ModeChannelHalfOp::ModeChannelHalfOp() : ModeHandler('h', 1, 1, true, MODETYPE_CHANNEL, false)
29 ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
31 /* If halfops are not enabled in the conf, we don't execute
32 * anything in this class at all.
34 if (!Config->AllowHalfop)
37 return MODEACTION_DENY;
40 int status = cstatus(source, channel);
42 /* Call the correct method depending on wether we're adding or removing the mode */
45 parameter = this->AddHalfOp(source, parameter.c_str(), channel, status);
49 parameter = this->DelHalfOp(source, parameter.c_str(), channel, status);
51 /* If the method above 'ate' the parameter by reducing it to an empty string, then
52 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
53 * the return value and is always MODEACTION_DENY if the mode is supposed to have
56 return MODEACTION_ALLOW;
59 std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status)
61 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
68 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_HALFOP));
70 if (MOD_RESULT == ACR_DENY)
72 if (MOD_RESULT == ACR_DEFAULT)
74 if ((status < STATUS_OP) && (!is_uline(user->server)))
76 WriteServ(user->fd,"482 %s %s :You're not a channel operator",user->nick, chan->name);
82 return ModeParser::Grant(d,chan,UCMODE_HOP);
87 std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status)
89 userrec *d = ModeParser::SanityChecks(user,dest,chan,status);
96 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEHALFOP));
98 if (MOD_RESULT == ACR_DENY)
100 if (MOD_RESULT == ACR_DEFAULT)
102 if ((user != d) && ((status < STATUS_OP) && (!is_uline(user->server))))
104 WriteServ(user->fd,"482 %s %s :You are not a channel operator",user->nick, chan->name);
110 return ModeParser::Revoke(d,chan,UCMODE_HOP);