]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ojoin.cpp
Fix left/right inversion in ListDifference
[user/henk/code/inspircd.git] / src / modules / m_ojoin.cpp
index a98c5e01d46e4a38e8a6965842668ea343a2b0b0..38497f1bb640630092337895e5094e3b6e91e9f3 100644 (file)
@@ -83,8 +83,7 @@ class CommandOjoin : public Command
                        modes.push_back(parameters[0]);
                        modes.push_back("+Y");
                        modes.push_back(user->nick);
-                       ServerInstance->SendMode(modes, ServerInstance->FakeClient);
-                       ServerInstance->PI->SendMode(parameters[0], ServerInstance->Modes->GetLastParseParams(), ServerInstance->Modes->GetLastParseTranslate());
+                       ServerInstance->SendGlobalMode(modes, ServerInstance->FakeClient);
                }
                return CMD_SUCCESS;
        }
@@ -133,71 +132,28 @@ class NetworkPrefix : public ModeHandler
                }
        }
 
-       User* FindAndVerify(std::string &parameter, Channel* channel)
+       unsigned int GetPrefixRank()
        {
-               User* theuser = ServerInstance->FindNick(parameter);
-               if ((!theuser) || (!channel->HasUser(theuser)))
-               {
-                       parameter.clear();
-                       return NULL;
-               }
-               return theuser;
+               return NETWORK_VALUE;
        }
 
-       ModeAction HandleChange(User* source, User* theuser, bool adding, Channel* channel, std::string &parameter)
+       void RemoveMode(User* user, irc::modestacker* stack)
        {
-               Membership* m = channel->GetUser(theuser);
-               if (m && adding)
-               {
-                       if (!m->hasMode('Y'))
-                       {
-                               parameter = theuser->nick;
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               else if (m && !adding)
-               {
-                       if (m->hasMode('Y'))
-                       {
-                               parameter = theuser->nick;
-                               return MODEACTION_ALLOW;
-                       }
-               }
-               return MODEACTION_DENY;
        }
 
-       unsigned int GetPrefixRank()
+       ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
        {
-               return NETWORK_VALUE;
-       }
+               User* theuser = ServerInstance->FindNick(parameter);
+               // remove own privs?
+               if (source == theuser && !adding)
+                       return MOD_RES_ALLOW;
 
-       void RemoveMode(User* user, irc::modestacker* stack)
-       {
+               return MOD_RES_PASSTHRU;
        }
 
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
-               User* theuser = FindAndVerify(parameter, channel);
-
-               if (!theuser)
-                       return MODEACTION_DENY;
-
-                // source is a server, or ulined, we'll let them +-Y the user.
-               if (source == ServerInstance->FakeClient ||
-                       ((source == theuser) && (!adding)) ||
-                       (ServerInstance->ULine(source->nick.c_str())) ||
-                       (ServerInstance->ULine(source->server)) ||
-                       (!IS_LOCAL(source))
-                       )
-               {
-                       return HandleChange(source, theuser, adding, channel, parameter);
-               }
-               else
-               {
-                       // bzzzt, wrong answer!
-                       source->WriteNumeric(482, "%s %s :Only servers may change this mode.", source->nick.c_str(), channel->name.c_str());
-                       return MODEACTION_DENY;
-               }
+               return MODEACTION_ALLOW;
        }
 
 };
@@ -211,6 +167,10 @@ class ModuleOjoin : public Module
 
        ModuleOjoin()
                : np(NULL), mycommand(this)
+       {
+       }
+
+       void init()
        {
                /* Load config stuff */
                OnRehash(NULL);
@@ -218,13 +178,8 @@ class ModuleOjoin : public Module
                /* Initialise module variables */
                np = new NetworkPrefix(this);
 
-               if (!ServerInstance->Modes->AddMode(np))
-               {
-                       delete np;
-                       throw ModuleException("Could not add new mode!");
-               }
-
-               ServerInstance->AddCommand(&mycommand);
+               ServerInstance->Modules->AddService(*np);
+               ServerInstance->Modules->AddService(mycommand);
 
                Implementation eventlist[] = { I_OnUserPreJoin, I_OnUserPreKick, I_OnRehash };
                ServerInstance->Modules->Attach(eventlist, this, 3);
@@ -290,7 +245,7 @@ class ModuleOjoin : public Module
 
        Version GetVersion()
        {
-               return Version("Network Buisness Join", VF_COMMON | VF_VENDOR);
+               return Version("Network Buisness Join", VF_VENDOR);
        }
 };