]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modes/umode_n.cpp
Small api change with wide reaching effects in modules - Allows modification of whats...
[user/henk/code/inspircd.git] / src / modes / umode_n.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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_n.h"
19
20 ModeUserServerNoticeMask::ModeUserServerNoticeMask(InspIRCd* Instance) : ModeHandler(Instance, 'n', 1, 0, false, MODETYPE_USER, true)
21 {
22 }
23
24 ModeAction ModeUserServerNoticeMask::OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
25 {
26         /* Only opers can change other users modes */
27         if ((source != dest) && (!*source->oper))
28                 return MODEACTION_DENY;
29
30         /* Set the bitfields */
31         if (adding)
32         {
33                 parameter = dest->ProcessNoticeMasks(parameter.c_str());
34                 dest->modes[UM_SNOMASK] = true;
35                 if (!dest->modes[UM_SERVERNOTICE])
36                 {
37                         const char* newmodes[] = { dest->nick, "+s" };
38                         ServerInstance->Modes->Process(newmodes, 2, source, true);
39                 }
40                 return MODEACTION_ALLOW;
41         }
42         else if (dest->modes[UM_SNOMASK] != false)
43         {
44                 dest->modes[UM_SNOMASK] = false;
45                 return MODEACTION_ALLOW;
46         }
47
48         /* Allow the change */
49         return MODEACTION_DENY;
50 }
51