]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_regonlycreate.cpp
Update documentation links.
[user/henk/code/inspircd.git] / src / modules / m_regonlycreate.cpp
index 5f43a7e22cea8d1c73dc59c32d4fffcad239db61..61f94c0bd1b81f26bc4cf9ea2bcdb10d8d84c0c2 100644 (file)
@@ -1,56 +1,66 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
+#include "account.h"
 
-/* $ModDesc: Prevents users who's nicks are not registered from creating new channels */
+/* $ModDesc: Prevents users whose nicks are not registered from creating new channels */
 
 class ModuleRegOnlyCreate : public Module
 {
  public:
-       ModuleRegOnlyCreate(InspIRCd* Me)
-               : Module(Me)
+       void init()
        {
                Implementation eventlist[] = { I_OnUserPreJoin };
-               ServerInstance->Modules->Attach(eventlist, this, 1);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-
-       virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
+       ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
        {
                if (chan)
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                if (IS_OPER(user))
-                       return 0;
+                       return MOD_RES_PASSTHRU;
+
+               if (user->IsModeSet('r'))
+                       return MOD_RES_PASSTHRU;
 
-               if ((!user->IsModeSet('r')) && (!user->GetExt("accountname")))
-               {
-                       // XXX. there may be a better numeric for this..
-                       user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have a registered nickname to create a new channel", user->nick.c_str(), cname);
-                       return 1;
-               }
+               const AccountExtItem* ext = GetAccountExtItem();
+               if (ext && ext->get(user))
+                       return MOD_RES_PASSTHRU;
 
-               return 0;
+               // XXX. there may be a better numeric for this..
+               user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have a registered nickname to create a new channel", user->nick.c_str(), cname);
+               return MOD_RES_DENY;
        }
 
-       virtual ~ModuleRegOnlyCreate()
+       ~ModuleRegOnlyCreate()
        {
        }
 
-       virtual Version GetVersion()
+       Version GetVersion()
        {
-               return Version("$Id$", VF_VENDOR, API_VERSION);
+               return Version("Prevents users whose nicks are not registered from creating new channels", VF_VENDOR);
        }
 };