From b49d529981f4336347c5f7c17d8ce656ad50b1e5 Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 5 Sep 2009 22:48:00 +0000 Subject: [PATCH] Likewise, convert OnLocalTopicChange to OnPreTopicChange and to be run for both local and remote changes, for API consistency. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11678 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/modules.h | 9 +++++---- src/channels.cpp | 4 ++-- src/modules.cpp | 2 +- src/modules/m_override.cpp | 6 +++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/modules.h b/include/modules.h index 4af979118..3f779fe80 100644 --- a/include/modules.h +++ b/include/modules.h @@ -422,7 +422,7 @@ enum Implementation I_OnUserPostNick, I_OnAccessCheck, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckExtBan, I_OnCheckStringExtBan, - I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange, + I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnPreTopicChange, I_OnPostTopicChange, I_OnEvent, I_OnRequest, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan, I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete, @@ -1210,17 +1210,18 @@ class CoreExport Module : public Extensible */ virtual ModResult OnChangeLocalUserGECOS(User* user, const std::string &newhost); - /** Called whenever a topic is changed by a local user. + /** Called before a topic is changed. * Return 1 to deny the topic change, 0 to check details on the change, -1 to let it through with no checks + * As with other 'pre' events, you should only ever block a local event. * @param user The user changing the topic * @param chan The channels who's topic is being changed * @param topic The actual topic text * @param 1 to block the topic change, 0 to allow */ - virtual ModResult OnLocalTopicChange(User* user, Channel* chan, const std::string &topic); + virtual ModResult OnPreTopicChange(User* user, Channel* chan, const std::string &topic); /** Called whenever a topic has been changed. - * To block topic changes you must use OnLocalTopicChange instead. + * To block topic changes you must use OnPreTopicChange instead. * @param user The user changing the topic * @param chan The channels who's topic is being changed * @param topic The actual topic text diff --git a/src/channels.cpp b/src/channels.cpp index e559f399f..4915b1614 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -63,14 +63,14 @@ std::string Channel::GetModeParameter(char mode) int Channel::SetTopic(User *u, std::string &ntopic, bool forceset) { - if (u && IS_LOCAL(u)) + if (u) { if(!forceset) { ModResult res; /* 0: check status, 1: don't, -1: disallow change silently */ - FIRST_MOD_RESULT(ServerInstance, OnLocalTopicChange, res, (u,this,ntopic)); + FIRST_MOD_RESULT(ServerInstance, OnPreTopicChange, res, (u,this,ntopic)); if (res == MOD_RES_DENY) return CMD_FAILURE; diff --git a/src/modules.cpp b/src/modules.cpp index fe7f3fb02..59b52b5b1 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -151,7 +151,7 @@ ModResult Module::OnCheckStringExtBan(const std::string &s, Channel *c, char typ ModResult Module::OnStats(char, User*, string_list&) { return MOD_RES_PASSTHRU; } ModResult Module::OnChangeLocalUserHost(User*, const std::string&) { return MOD_RES_PASSTHRU; } ModResult Module::OnChangeLocalUserGECOS(User*, const std::string&) { return MOD_RES_PASSTHRU; } -ModResult Module::OnLocalTopicChange(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; } +ModResult Module::OnPreTopicChange(User*, Channel*, const std::string&) { return MOD_RES_PASSTHRU; } void Module::OnEvent(Event*) { return; } const char* Module::OnRequest(Request*) { return NULL; } ModResult Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index ae18803d3..d0ec5d8fe 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -41,7 +41,7 @@ class ModuleOverride : public Module } OverriddenMode = OverOther = false; OverOps = OverDeops = OverVoices = OverDevoices = OverHalfops = OverDehalfops = 0; - Implementation eventlist[] = { I_OnRehash, I_OnAccessCheck, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPostCommand, I_OnLocalTopicChange, I_OnRequest }; + Implementation eventlist[] = { I_OnRehash, I_OnAccessCheck, I_On005Numeric, I_OnUserPreJoin, I_OnUserPreKick, I_OnPostCommand, I_OnPreTopicChange, I_OnRequest }; ServerInstance->Modules->Attach(eventlist, this, 8); } @@ -116,9 +116,9 @@ class ModuleOverride : public Module } - virtual ModResult OnLocalTopicChange(User *source, Channel *channel, const std::string &topic) + virtual ModResult OnPreTopicChange(User *source, Channel *channel, const std::string &topic) { - if (IS_OPER(source) && CanOverride(source, "TOPIC")) + if (IS_LOCAL(source) && IS_OPER(source) && CanOverride(source, "TOPIC")) { if (!channel->HasUser(source) || (channel->IsModeSet('t') && channel->GetStatus(source) < STATUS_HOP)) { -- 2.39.5