]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modes/umode_n.cpp
Make User:: nick/ident/dhost/fullname and some other things std::string instead of...
[user/henk/code/inspircd.git] / src / modes / umode_n.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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(User* source, User* dest, Channel*, std::string &parameter, bool adding, bool servermode)
25 {
26         /* Only opers can change other users modes */
27         if ((source != dest) && (!IS_OPER(source)))
28                 return MODEACTION_DENY;
29
30         /* Set the array fields */
31         if (adding)
32         {
33                 /* Fix for bug #310 reported by Smartys */
34                 if (!dest->modes[UM_SNOMASK])
35                         memset(dest->snomasks, 0, sizeof(dest->snomasks));
36
37                 parameter = dest->ProcessNoticeMasks(parameter.c_str());
38                 dest->modes[UM_SNOMASK] = true;
39                 if (!dest->modes[UM_SERVERNOTICE])
40                 {
41                         std::vector<std::string> newmodes;
42                         newmodes.push_back(dest->nick);
43                         newmodes.push_back("+s");
44                         ServerInstance->Modes->Process(newmodes, source, true);
45                 }
46                 return MODEACTION_ALLOW;
47         }
48         else
49         {
50                 if (dest->modes[UM_SNOMASK] != false)
51                 {
52                         dest->modes[UM_SNOMASK] = false;
53                         return MODEACTION_ALLOW;
54                 }
55         }
56
57         /* Allow the change */
58         return MODEACTION_DENY;
59 }
60