summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2015-03-11 14:36:56 -0400
committerAdam <Adam@anope.org>2015-03-11 14:36:56 -0400
commit310e95a92e64a9546247fe57d4643328fa4ebe9b (patch)
tree59f02aa933d7bf766c26e38253f546c478b166f2
parent78bff86dab32dc484164e5da8a535b3ec24c5c03 (diff)
Allow cs clone to clone levels too
-rw-r--r--include/regchannel.h5
-rw-r--r--modules/commands/cs_clone.cpp21
-rw-r--r--src/regchannel.cpp5
3 files changed, 29 insertions, 2 deletions
diff --git a/include/regchannel.h b/include/regchannel.h
index 416b0280d..50e0ceed2 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -198,6 +198,11 @@ class CoreExport ChannelInfo : public Serializable, public Extensible
*/
void ClearAkick();
+ /** Get the level entries for the channel.
+ * @return The levels for the channel.
+ */
+ const Anope::map<int16_t> &GetLevelEntries();
+
/** Get the level for a privilege
* @param priv The privilege name
* @return the level
diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp
index a7dcdd9ec..cbf53e892 100644
--- a/modules/commands/cs_clone.cpp
+++ b/modules/commands/cs_clone.cpp
@@ -96,6 +96,18 @@ class CommandCSClone : public Command
source.Reply(_("All badword entries from \002%s\002 have been cloned to \002%s\002."), ci->name.c_str(), target_ci->name.c_str());
}
+ void CopyLevels(CommandSource &source, ChannelInfo *ci, ChannelInfo *target_ci)
+ {
+ const Anope::map<int16_t> &cilevels = ci->GetLevelEntries();
+
+ for (Anope::map<int16_t>::const_iterator it = cilevels.begin(); it != cilevels.end(); ++it)
+ {
+ target_ci->SetLevel(it->first, it->second);
+ }
+
+ source.Reply(_("All level entries from \002%s\002 have been cloned into \002%s\002."), ci->name.c_str(), target_ci->name.c_str());
+ }
+
public:
CommandCSClone(Module *creator) : Command(creator, "chanserv/clone", 2, 3)
{
@@ -191,6 +203,7 @@ public:
CopyAccess(source, ci, target_ci);
CopyAkick(source, ci, target_ci);
CopyBadwords(source, ci, target_ci);
+ CopyLevels(source, ci, target_ci);
FOREACH_MOD(OnChanRegistered, (target_ci));
@@ -208,6 +221,10 @@ public:
{
CopyBadwords(source, ci, target_ci);
}
+ else if (what.equals_ci("LEVELS"))
+ {
+ CopyLevels(source, ci, target_ci);
+ }
else
{
this->OnSyntaxError(source, "");
@@ -222,8 +239,8 @@ public:
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Copies all settings, access, akicks, etc from \002channel\002 to the\n"
- "\002target\002 channel. If \037what\037 is \002ACCESS\002, \002AKICK\002, or \002BADWORDS\002\n"
- "then only the respective settings are cloned.\n"
+ "\002target\002 channel. If \037what\037 is \002ACCESS\002, \002AKICK\002, \002BADWORDS\002,\n"
+ "or \002LEVELS\002 then only the respective settings are cloned.\n"
"You must be the founder of \037channel\037 and \037target\037."));
return true;
}
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 4bb38afef..397a6f28b 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -551,6 +551,11 @@ void ChannelInfo::ClearAkick()
delete this->akick->back();
}
+const Anope::map<int16_t> &ChannelInfo::GetLevelEntries()
+{
+ return this->levels;
+}
+
int16_t ChannelInfo::GetLevel(const Anope::string &priv) const
{
if (PrivilegeManager::FindPrivilege(priv) == NULL)