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