summaryrefslogtreecommitdiff
path: root/src/modules/m_regonlycreate.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-14 18:39:38 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-10-14 18:39:38 +0000
commite80a1296a096ff2c495b3cd2a3913d5e5f6ec450 (patch)
treeb8e37d6b9eeb0d0bed0ae4d4cbaa249631405c8d /src/modules/m_regonlycreate.cpp
parent37fd031da06761c8a050105b55d73a8ab499fb74 (diff)
Move static map of extensions into ServerInstance, add const-correctness
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11873 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_regonlycreate.cpp')
-rw-r--r--src/modules/m_regonlycreate.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/modules/m_regonlycreate.cpp b/src/modules/m_regonlycreate.cpp
index 3354c1132..a25ba8edc 100644
--- a/src/modules/m_regonlycreate.cpp
+++ b/src/modules/m_regonlycreate.cpp
@@ -12,20 +12,20 @@
*/
#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()
- {
+ {
Implementation eventlist[] = { I_OnUserPreJoin };
ServerInstance->Modules->Attach(eventlist, this, 1);
}
-
- virtual ModResult 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 MOD_RES_PASSTHRU;
@@ -33,23 +33,25 @@ class ModuleRegOnlyCreate : public Module
if (IS_OPER(user))
return MOD_RES_PASSTHRU;
- if (user->GetExtList().find("accountname") == user->GetExtList().end() && !user->IsModeSet('r'))
- {
- // 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;
- }
+ if (user->IsModeSet('r'))
+ return MOD_RES_PASSTHRU;
+
+ const AccountExtItem* ext = GetAccountExtItem();
+ if (ext && ext->get(user))
+ return MOD_RES_PASSTHRU;
- return MOD_RES_PASSTHRU;
+ // 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("Prevents users who's nicks are not registered from creating new channels", VF_VENDOR, API_VERSION);
+ return Version("Prevents users whose nicks are not registered from creating new channels", VF_VENDOR);
}
};