3 #include "inspircd_config.h"
4 #include "configreader.h"
13 #include "inspstring.h"
15 #include "modes/cmode_o.h"
17 ModeChannelOp::ModeChannelOp(InspIRCd* Instance) : ModeHandler(Instance, 'o', 1, 1, true, MODETYPE_CHANNEL, false, '@')
21 unsigned int ModeChannelOp::GetPrefixRank()
26 ModePair ModeChannelOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter)
28 userrec* x = ServerInstance->FindNick(parameter);
31 if (channel->GetStatusFlags(x) & UCMODE_OP)
33 return std::make_pair(true, x->nick);
37 return std::make_pair(false, parameter);
40 return std::make_pair(false, parameter);
43 ModeAction ModeChannelOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
45 int status = channel->GetStatus(source);
47 /* Call the correct method depending on wether we're adding or removing the mode */
50 parameter = this->AddOp(source, parameter.c_str(), channel, status);
54 parameter = this->DelOp(source, parameter.c_str(), channel, status);
56 /* If the method above 'ate' the parameter by reducing it to an empty string, then
57 * it won't matter wether we return ALLOW or DENY here, as an empty string overrides
58 * the return value and is always MODEACTION_DENY if the mode is supposed to have
61 return MODEACTION_ALLOW;
64 std::string ModeChannelOp::AddOp(userrec *user,const char* dest,chanrec *chan,int status)
66 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
73 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_OP));
75 if (MOD_RESULT == ACR_DENY)
77 if (MOD_RESULT == ACR_DEFAULT)
79 if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))
81 user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name);
87 return ServerInstance->Modes->Grant(d,chan,UCMODE_OP);
92 std::string ModeChannelOp::DelOp(userrec *user,const char *dest,chanrec *chan,int status)
94 userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status);
101 ServerInstance->Log(DEBUG,"Call OnAccessCheck for AC_DEOP");
102 FOREACH_RESULT(I_OnAccessCheck,OnAccessCheck(user,d,chan,AC_DEOP));
104 ServerInstance->Log(DEBUG,"Returns %d",MOD_RESULT);
106 if (MOD_RESULT == ACR_DENY)
108 if (MOD_RESULT == ACR_DEFAULT)
110 if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)) && (IS_LOCAL(user)))
112 user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name);
118 return ServerInstance->Modes->Revoke(d,chan,UCMODE_OP);