3 #include "inspircd_config.h"
4 #include "configreader.h"
13 #include "inspstring.h"
15 #include "modes/cmode_h.h"
17 ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%')
21 unsigned int ModeChannelHalfOp::GetPrefixRank()
26 ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
28 userrec* x = ServerInstance->FindNick(parameter);
31 if (channel->GetStatus(x) == STATUS_HOP)
33 return std::make_pair(true, x->nick);
37 return std::make_pair(false, parameter);
40 return std::make_pair(false, parameter);
43 ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
45 /* If halfops are not enabled in the conf, we don't execute
46 * anything in this class at all.
48 if (!ServerInstance->Config->AllowHalfop)
51 return MODEACTION_DENY;
54 int status = channel->GetStatus(source);
56 /* Call the correct method depending on wether we're adding or removing the mode */
59 parameter = this->AddHalfOp(source, parameter.c_str(), channel, status);
63 parameter = this->DelHalfOp(source, parameter.c_str(), channel, status);
65 /* If the method above 'ate' the parameter by reducing it to an empty string, then
66 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
67 * the return value and is always MODEACTION_DENY if the mode is supposed to have
70 return MODEACTION_ALLOW;
73 std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status)
75 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
82 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_HALFOP));
84 if (MOD_RESULT == ACR_DENY)
86 if (MOD_RESULT == ACR_DEFAULT)
88 if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))
90 user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
96 return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP);
101 std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status)
103 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
110 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEHALFOP));
112 if (MOD_RESULT == ACR_DENY)
114 if (MOD_RESULT == ACR_DEFAULT)
116 if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))))
118 user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
124 return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP);