X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=d0533aee68d20848223a0b6695b88353828eb3fb;hb=c2ec183ffe0fd0db4fe3c06874a888f84738f49c;hp=7c60b54f0ba85d27ac0e8d7dae7d5ae4eae65a12;hpb=8b96626119ecdcece7541e5debdf7e234edbee3a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index 7c60b54f0..d0533aee6 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -81,29 +81,26 @@ std::string Channel::GetModeParameter(ModeHandler* mode) int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) { - if (u) + if (!u) + u = ServerInstance->FakeClient; + if (IS_LOCAL(u) && !forceset) { - if(!forceset) - { - ModResult res; - /* 0: check status, 1: don't, -1: disallow change silently */ - - FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic)); + ModResult res; + FIRST_MOD_RESULT(OnPreTopicChange, res, (u,this,ntopic)); - if (res == MOD_RES_DENY) - return CMD_FAILURE; - if (res != MOD_RES_ALLOW) + if (res == MOD_RES_DENY) + return CMD_FAILURE; + if (res != MOD_RES_ALLOW) + { + FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (u,this,"topiclock")); + bool defok = IsModeSet('t') ? GetPrefixValue(u) >= HALFOP_VALUE : HasUser(u); + if (!res.check(defok)) { if (!this->HasUser(u)) - { u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str()); - return CMD_FAILURE; - } - if ((this->IsModeSet('t')) && (this->GetPrefixValue(u) < HALFOP_VALUE)) - { + else u->WriteNumeric(482, "%s %s :You do not have access to change the topic on this channel", u->nick.c_str(), this->name.c_str()); - return CMD_FAILURE; - } + return CMD_FAILURE; } } } @@ -122,11 +119,7 @@ int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) this->topicset = ServerInstance->Time(); - // XXX: this check for 'u' is probably pre-fake-user, and it fucking sucks anyway. we need to change this. - if (u) - { - FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic)); - } + FOREACH_MOD(I_OnPostTopicChange,OnPostTopicChange(u, this, this->topic)); return CMD_SUCCESS; } @@ -753,20 +746,14 @@ void Channel::UserList(User *user) { char list[MAXBUF]; size_t dlen, curlen; - ModResult call_modules; if (!IS_LOCAL(user)) return; - FIRST_MOD_RESULT(OnUserList, call_modules, (user, this)); - - if (call_modules != MOD_RES_ALLOW) + if (this->IsModeSet('s') && !this->HasUser(user) && !user->HasPrivPermission("channels/auspex")) { - if ((this->IsModeSet('s')) && (!this->HasUser(user))) - { - user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str()); - return; - } + user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), this->name.c_str()); + return; } dlen = curlen = snprintf(list,MAXBUF,"%s %c %s :", user->nick.c_str(), this->IsModeSet('s') ? '@' : this->IsModeSet('p') ? '*' : '=', this->name.c_str()); @@ -793,14 +780,11 @@ void Channel::UserList(User *user) std::string prefixlist = this->GetPrefixChar(i->first); std::string nick = i->first->nick; - if (call_modules != MOD_RES_DENY) - { - FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick)); + FOREACH_MOD(I_OnNamesListItem, OnNamesListItem(user, i->second, prefixlist, nick)); - /* Nick was nuked, a module wants us to skip it */ - if (nick.empty()) - continue; - } + /* Nick was nuked, a module wants us to skip it */ + if (nick.empty()) + continue; size_t ptrlen = 0;