]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modes/umode_o.cpp
ec9b4ad5b5a9efc491a371a573c289d2db340fea
[user/henk/code/inspircd.git] / src / modes / umode_o.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "mode.h"
16 #include "channels.h"
17 #include "users.h"
18 #include "modes/umode_o.h"
19
20 ModeUserOperator::ModeUserOperator(InspIRCd* Instance) : ModeHandler(NULL, 'o', PARAM_NONE, MODETYPE_USER)
21 {
22         oper = true;
23 }
24
25 ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding)
26 {
27         /* Only opers can execute this class at all */
28         if (!ServerInstance->ULine(source->nick.c_str()) && !ServerInstance->ULine(source->server) && source->oper.empty())
29                 return MODEACTION_DENY;
30
31         /* Not even opers can GIVE the +o mode, only take it away */
32         if (adding)
33                 return MODEACTION_DENY;
34
35         /* Set the bitfields.
36          * Note that oper status is only given in cmd_oper.cpp
37          * NOT here. It is impossible to directly set +o without
38          * verifying as an oper and getting an opertype assigned
39          * to your User!
40          */
41         char snomask = IS_LOCAL(dest) ? 'o' : 'O';
42         ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(),
43                 source->nick.empty() ? source->server : source->nick.c_str());
44         dest->UnOper();
45
46         return MODEACTION_ALLOW;
47 }
48
49 unsigned int ModeUserOperator::GetCount()
50 {
51         return count;
52 }