X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodes%2Fcmode_h.cpp;h=9bd061cd26684d9d19b0fb81dd5a146893d747ff;hb=a7cbd51d457a5e3b435396092bc7e2fcf79168e1;hp=493d4f7766e63d525d5e3c13b61787f089104f39;hpb=f9636a2eff46f6829bf9e01c711ab1ba45a7d50a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modes/cmode_h.cpp b/src/modes/cmode_h.cpp index 493d4f776..9bd061cd2 100644 --- a/src/modes/cmode_h.cpp +++ b/src/modes/cmode_h.cpp @@ -1,23 +1,31 @@ -#include -#include -#include "inspircd_config.h" +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + #include "configreader.h" -#include "hash_map.h" #include "inspircd.h" #include "mode.h" #include "channels.h" #include "users.h" -#include "helperfuncs.h" -#include "commands.h" #include "modules.h" -#include "inspstring.h" -#include "hashcomp.h" #include "modes/cmode_h.h" -extern time_t TIME; +ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false, '%') +{ +} -ModeChannelHalfOp::ModeChannelHalfOp(InspIRCd* Instance) : ModeHandler(Instance, 'h', 1, 1, true, MODETYPE_CHANNEL, false) +unsigned int ModeChannelHalfOp::GetPrefixRank() { + return HALFOP_VALUE; } ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* channel, const std::string ¶meter) @@ -25,7 +33,7 @@ ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* cha userrec* x = ServerInstance->FindNick(parameter); if (x) { - if (channel->GetStatus(x) == STATUS_HOP) + if (channel->GetStatusFlags(x) & UCMODE_HOP) { return std::make_pair(true, x->nick); } @@ -37,6 +45,32 @@ ModePair ModeChannelHalfOp::ModeSet(userrec* source, userrec* dest, chanrec* cha return std::make_pair(false, parameter); } +void ModeChannelHalfOp::RemoveMode(chanrec* channel) +{ + CUList* list = channel->GetHalfoppedUsers(); + CUList copy; + char moderemove[MAXBUF]; + userrec* n = new userrec(ServerInstance); + n->SetFd(FD_MAGIC_NUMBER); + + for (CUList::iterator i = list->begin(); i != list->end(); i++) + { + userrec* n = i->second; + copy.insert(std::make_pair(n,n)); + } + for (CUList::iterator i = copy.begin(); i != copy.end(); i++) + { + sprintf(moderemove,"-%c",this->GetModeChar()); + const char* parameters[] = { channel->name, moderemove, i->second->nick }; + ServerInstance->SendMode(parameters, 3, n); + } + delete n; +} + +void ModeChannelHalfOp::RemoveMode(userrec* user) +{ +} + ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) { /* If halfops are not enabled in the conf, we don't execute @@ -64,12 +98,15 @@ ModeAction ModeChannelHalfOp::OnModeChange(userrec* source, userrec* dest, chanr * the return value and is always MODEACTION_DENY if the mode is supposed to have * a parameter. */ - return MODEACTION_ALLOW; + if (parameter.length()) + return MODEACTION_ALLOW; + else + return MODEACTION_DENY; } std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec *chan,int status) { - userrec *d = ServerInstance->ModeGrok->SanityChecks(user,dest,chan,status); + userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -82,7 +119,7 @@ std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((status < STATUS_OP) && (!is_uline(user->server))) + if ((status < STATUS_OP) && (!ServerInstance->ULine(user->server))) { user->WriteServ("482 %s %s :You're not a channel operator",user->nick, chan->name); return ""; @@ -90,14 +127,14 @@ std::string ModeChannelHalfOp::AddHalfOp(userrec *user,const char* dest,chanrec } } - return ServerInstance->ModeGrok->Grant(d,chan,UCMODE_HOP); + return ServerInstance->Modes->Grant(d,chan,UCMODE_HOP); } return ""; } std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec *chan,int status) { - userrec *d = ServerInstance->ModeGrok->SanityChecks(user,dest,chan,status); + userrec *d = ServerInstance->Modes->SanityChecks(user,dest,chan,status); if (d) { @@ -110,7 +147,7 @@ std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec return ""; if (MOD_RESULT == ACR_DEFAULT) { - if ((user != d) && ((status < STATUS_OP) && (!is_uline(user->server)))) + if ((user != d) && ((status < STATUS_OP) && (!ServerInstance->ULine(user->server)))) { user->WriteServ("482 %s %s :You are not a channel operator",user->nick, chan->name); return ""; @@ -118,7 +155,7 @@ std::string ModeChannelHalfOp::DelHalfOp(userrec *user,const char *dest,chanrec } } - return ServerInstance->ModeGrok->Revoke(d,chan,UCMODE_HOP); + return ServerInstance->Modes->Revoke(d,chan,UCMODE_HOP); } return ""; }