summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2008-08-04 17:43:15 +0000
committerom <om@e03df62e-2008-0410-955e-edbf42e46eb7>2008-08-04 17:43:15 +0000
commitfe4001942d2b82566133099388c0908e10223c87 (patch)
tree72580b3937b4cd2b251d74e36408fe76c2e83bbf
parent333b19d80c2255044cefc67148a19c06e13695bf (diff)
Add optional 3rd parameter to Channel::SetTopic() which overrides all access checks.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10085 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/channels.h3
-rw-r--r--src/channels.cpp34
2 files changed, 21 insertions, 16 deletions
diff --git a/include/channels.h b/include/channels.h
index 605ac8216..9c231008a 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -235,8 +235,9 @@ class CoreExport Channel : public Extensible
/** Sets the channel topic.
* @param u The user setting the topic
* @param t The topic to set it to. Non-const, as it may be modified by a hook.
+ * @param forceset If set to true then all access checks will be bypassed.
*/
- int SetTopic(User *u, std::string &t);
+ int SetTopic(User *u, std::string &t, bool forceset = false);
/** Obtain the channel "user counter"
* This returns the channel reference counter, which is initialized
diff --git a/src/channels.cpp b/src/channels.cpp
index a0ba81a5f..2dc668f31 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -73,27 +73,31 @@ std::string Channel::GetModeParameter(char mode)
return "";
}
-int Channel::SetTopic(User *u, std::string &ntopic)
+int Channel::SetTopic(User *u, std::string &ntopic, bool forceset)
{
if (IS_LOCAL(u))
{
- int MOD_RESULT = 0;
- /* 0: check status, 1: don't, -1: disallow change silently */
-
- FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(u,this,ntopic));
- if (MOD_RESULT == 1)
- return CMD_FAILURE;
- else if (MOD_RESULT == 0)
+ if(!forceset)
{
- if (!this->HasUser(u))
- {
- u->WriteNumeric(442, "%s %s :You're not on that channel!",u->nick.c_str(), this->name.c_str());
+ int MOD_RESULT = 0;
+ /* 0: check status, 1: don't, -1: disallow change silently */
+
+ FOREACH_RESULT(I_OnLocalTopicChange,OnLocalTopicChange(u,this,ntopic));
+
+ if (MOD_RESULT == 1)
return CMD_FAILURE;
- }
- if ((this->IsModeSet('t')) && (this->GetStatus(u) < STATUS_HOP))
+ else if (MOD_RESULT == 0)
{
- u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str());
- return CMD_FAILURE;
+ 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->GetStatus(u) < STATUS_HOP))
+ {
+ u->WriteNumeric(482, "%s %s :You must be at least a half-operator to change the topic on this channel", u->nick.c_str(), this->name.c_str());
+ return CMD_FAILURE;
+ }
}
}