]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_permchannels.cpp
Add access checking for m_autoop
[user/henk/code/inspircd.git] / src / modules / m_permchannels.cpp
index a409078e4ab29eb5c41bb940ae156e6ede168c34..a3d023ffe39fdd57f8eed96f474bc8c16a90d63e 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
@@ -110,16 +110,10 @@ static bool WriteDatabase()
 class PermChannel : public ModeHandler
 {
  public:
-       PermChannel(Module* Creator) : ModeHandler(Creator, 'P', PARAM_NONE, MODETYPE_CHANNEL) { }
+       PermChannel(Module* Creator) : ModeHandler(Creator, "permanent", 'P', PARAM_NONE, MODETYPE_CHANNEL) { oper = true; }
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
-               if (!source->HasPrivPermission("channels/set-permanent"))
-               {
-                       source->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges", source->nick.c_str());
-                       return MODEACTION_DENY;
-               }
-
                if (adding)
                {
                        if (!channel->IsModeSet('P'))
@@ -179,15 +173,14 @@ public:
        {
                if (!ServerInstance->Modes->AddMode(&p))
                        throw ModuleException("Could not add new modes!");
-               Implementation eventlist[] = { I_OnChannelPreDelete, I_OnPostTopicChange, I_OnRawMode };
-               ServerInstance->Modules->Attach(eventlist, this, 3);
+               Implementation eventlist[] = { I_OnChannelPreDelete, I_OnPostTopicChange, I_OnRawMode, I_OnRehash };
+               ServerInstance->Modules->Attach(eventlist, this, 4);
 
                OnRehash(NULL);
        }
 
-       virtual ~ModulePermanentChannels()
+       CullResult cull()
        {
-               ServerInstance->Modes->DelMode(&p);
                /*
                 * DelMode can't remove the +P mode on empty channels, or it will break
                 * merging modes with remote servers. Remove the empty channels now as
@@ -201,12 +194,15 @@ public:
                        {
                                chan_hash::iterator at = iter;
                                iter++;
+                               FOREACH_MOD(I_OnChannelDelete, OnChannelDelete(c));
                                ServerInstance->chanlist->erase(at);
-                               delete c;
+                               ServerInstance->GlobalCulls.AddItem(c);
                        }
                        else
                                iter++;
                }
+               ServerInstance->Modes->DelMode(&p);
+               return Module::cull();
        }
 
        virtual void OnRehash(User *user)
@@ -215,15 +211,16 @@ public:
                 * Process config-defined list of permanent channels.
                 * -- w00t
                 */
-               ConfigReader MyConf;
 
-               permchannelsconf = MyConf.ReadValue("permchanneldb", "filename", "", 0, false);
+               permchannelsconf = ServerInstance->Config->ConfValue("permchanneldb")->getString("filename");
 
-               for (int i = 0; i < MyConf.Enumerate("permchannels"); i++)
+               ConfigTagList permchannels = ServerInstance->Config->ConfTags("permchannels");
+               for (ConfigIter i = permchannels.first; i != permchannels.second; ++i)
                {
-                       std::string channel = MyConf.ReadValue("permchannels", "channel", i);
-                       std::string topic = MyConf.ReadValue("permchannels", "topic", i);
-                       std::string modes = MyConf.ReadValue("permchannels", "modes", i);
+                       ConfigTag* tag = i->second;
+                       std::string channel = tag->getString("channel");
+                       std::string topic = tag->getString("topic");
+                       std::string modes = tag->getString("modes");
 
                        if (channel.empty())
                        {
@@ -293,7 +290,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for channel mode +P to provide permanent channels",VF_COMMON|VF_VENDOR,API_VERSION);
+               return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);
        }
 
        virtual ModResult OnChannelPreDelete(Channel *c)