+ int Total = OverOps + OverDeops + OverVoices + OverDevoices + OverHalfops + OverDehalfops;
+ if (Total == 0)
+ return;
+
+ ServerInstance->SNO->WriteToSnoMask('G',std::string(user->nick)+" Overriding modes: "+ServerInstance->Modes->GetLastParse()+" "+(Total ? "[Detail: " : "")+
+ (OverOps ? ConvToStr(OverOps)+" op"+(OverOps != 1 ? "s" : "")+" " : "")+
+ (OverDeops ? ConvToStr(OverDeops)+" deop"+(OverDeops != 1 ? "s" : "")+" " : "")+
+ (OverVoices ? ConvToStr(OverVoices)+" voice"+(OverVoices != 1 ? "s" : "")+" " : "")+
+ (OverDevoices ? ConvToStr(OverDevoices)+" devoice"+(OverDevoices != 1 ? "s" : "")+" " : "")+
+ (OverHalfops ? ConvToStr(OverHalfops)+" halfop"+(OverHalfops != 1 ? "s" : "")+" " : "")+
+ (OverDehalfops ? ConvToStr(OverDehalfops)+" dehalfop"+(OverDehalfops != 1 ? "s" : "") : "")
+ +(Total ? "]" : ""));
+
+ OverriddenMode = false;
+ OverOps = OverDeops = OverVoices = OverDevoices = OverHalfops = OverDehalfops = 0;
+ }
+ }
+
+ virtual void On005Numeric(std::string &output)
+ {
+ output.append(" OVERRIDE");
+ }
+
+ virtual bool CanOverride(User* source, const char* token)
+ {
+ // checks to see if the oper's type has <type:override>
+ override_t::iterator j = overrides.find(source->oper);
+
+ if (j != overrides.end())
+ {
+ // its defined or * is set, return its value as a boolean for if the token is set
+ return ((j->second.find(token, 0) != std::string::npos) || (j->second.find("*", 0) != std::string::npos));
+ }
+
+ // its not defined at all, count as false
+ return false;
+ }
+
+
+ virtual int OnLocalTopicChange(User *source, Channel *channel, const std::string &topic)
+ {
+ if (IS_OPER(source) && CanOverride(source, "TOPIC"))
+ {
+ if (!channel->HasUser(source) || (channel->IsModeSet('t') && channel->GetStatus(source) < STATUS_HOP))
+ {
+ ServerInstance->SNO->WriteToSnoMask('G',std::string(source->nick)+" used oper override to change a topic on "+std::string(channel->name));
+ }
+
+ // Explicit allow
+ return -1;
+ }
+
+ return 0;
+ }
+
+ virtual int OnUserPreKick(User* source, User* user, Channel* chan, const std::string &reason)
+ {
+ if (IS_OPER(source) && CanOverride(source,"KICK"))
+ {
+ // If the kicker's status is less than the target's, or the kicker's status is less than or equal to voice
+ if ((chan->GetStatus(source) < chan->GetStatus(user)) || (chan->GetStatus(source) <= STATUS_VOICE))
+ {
+ ServerInstance->SNO->WriteToSnoMask('G',std::string(source->nick)+" used oper override to kick "+std::string(user->nick)+" on "+std::string(chan->name)+" ("+reason+")");
+ }
+ /* Returning -1 explicitly allows the kick */
+ return -1;
+ }
+ return 0;
+ }
+
+ virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
+ {
+ if (IS_OPER(source))
+ {
+ if (source && channel)