]> 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 53004ff79bf9406c3d192e211c22759b77dabb4b..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, "permanent", '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,8 +173,8 @@ 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);
        }
@@ -217,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())
                        {
@@ -295,7 +290,7 @@ public:
 
        virtual Version GetVersion()
        {
-               return Version("Provides support for channel mode +P to provide permanent channels",VF_COMMON|VF_VENDOR);
+               return Version("Provides support for channel mode +P to provide permanent channels",VF_VENDOR);
        }
 
        virtual ModResult OnChannelPreDelete(Channel *c)