]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modes/umode_o.cpp
Replace OnAccessCheck with OnPreMode to remove a number of redundant checks
[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(Instance, NULL, 'o', 0, 0, false, MODETYPE_USER, true)
21 {
22 }
23
24 ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, std::string&, bool adding)
25 {
26         /* Only opers can execute this class at all */
27         if (!ServerInstance->ULine(source->nick.c_str()) && !ServerInstance->ULine(source->server) && source->oper.empty())
28                 return MODEACTION_DENY;
29
30         /* Not even opers can GIVE the +o mode, only take it away */
31         if (adding)
32                 return MODEACTION_DENY;
33
34         /* Set the bitfields.
35          * Note that oper status is only given in cmd_oper.cpp
36          * NOT here. It is impossible to directly set +o without
37          * verifying as an oper and getting an opertype assigned
38          * to your User!
39          */
40         char snomask = IS_LOCAL(dest) ? 'o' : 'O';
41         ServerInstance->SNO->WriteToSnoMask(snomask, "User %s de-opered (by %s)", dest->nick.c_str(),
42                 source->nick.empty() ? source->server : source->nick.c_str());
43         dest->UnOper();
44
45         return MODEACTION_ALLOW;
46 }
47
48 unsigned int ModeUserOperator::GetCount()
49 {
50         return count;
51 }