]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/opertype.cpp
m_spanningtree Move all server-to-server command handlers into handler classes
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / opertype.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #include "inspircd.h"
22 #include "commands.h"
23 #include "treeserver.h"
24 #include "utils.h"
25
26 /** Because the core won't let users or even SERVERS set +o,
27  * we use the OPERTYPE command to do this.
28  */
29 CmdResult CommandOpertype::Handle(User* u, std::vector<std::string>& params)
30 {
31         const std::string& opertype = params[0];
32         if (!u->IsOper())
33                 ServerInstance->Users->all_opers.push_back(u);
34
35         ModeHandler* opermh = ServerInstance->Modes->FindMode('o', MODETYPE_USER);
36         u->SetMode(opermh, true);
37
38         OperIndex::iterator iter = ServerInstance->Config->OperTypes.find(opertype);
39         if (iter != ServerInstance->Config->OperTypes.end())
40                 u->oper = iter->second;
41         else
42         {
43                 u->oper = new OperInfo;
44                 u->oper->name = opertype;
45         }
46
47         if (Utils->quiet_bursts)
48         {
49                 /*
50                  * If quiet bursts are enabled, and server is bursting or silent uline (i.e. services),
51                  * then do nothing. -- w00t
52                  */
53                 TreeServer* remoteserver = Utils->FindServer(u->server);
54                 if (remoteserver->bursting || ServerInstance->SilentULine(u->server))
55                         return CMD_SUCCESS;
56         }
57
58         ServerInstance->SNO->WriteToSnoMask('O',"From %s: User %s (%s@%s) is now an IRC operator of type %s",u->server.c_str(), u->nick.c_str(),u->ident.c_str(), u->host.c_str(), opertype.c_str());
59         return CMD_SUCCESS;
60 }
61