~ubuntu-branches/ubuntu/trusty/znc/trusty

« back to all changes in this revision

Viewing changes to modules/blockuser.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-05-06 09:18:27 UTC
  • mfrom: (21.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20130506091827-08sixjiyy3hjfx6b
Tags: 1.0-4
* Change section from znc-tcl to interpreters.
* Uploading to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004-2011  See the AUTHORS file for details.
 
2
 * Copyright (C) 2004-2012  See the AUTHORS file for details.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of the GNU General Public License version 2 as published
6
6
 * by the Free Software Foundation.
7
7
 */
8
8
 
9
 
#include "User.h"
10
 
#include "IRCSock.h"
11
 
#include "znc.h"
 
9
#include <znc/User.h>
 
10
#include <znc/IRCNetwork.h>
 
11
#include <znc/IRCSock.h>
 
12
#include <znc/znc.h>
 
13
 
 
14
using std::vector;
12
15
 
13
16
#define MESSAGE "Your account has been disabled. Contact your administrator."
14
17
 
15
 
class CBlockUser : public CGlobalModule {
 
18
class CBlockUser : public CModule {
16
19
public:
17
 
        GLOBALMODCONSTRUCTOR(CBlockUser) {}
 
20
        MODCONSTRUCTOR(CBlockUser) {}
18
21
 
19
22
        virtual ~CBlockUser() {}
20
23
 
147
150
                        return false;
148
151
 
149
152
                // Disconnect all clients
150
 
                vector<CClient*>& vpClients = pUser->GetClients();
 
153
                vector<CClient*> vpClients = pUser->GetAllClients();
151
154
                vector<CClient*>::iterator it;
152
155
                for (it = vpClients.begin(); it != vpClients.end(); ++it) {
153
156
                        (*it)->PutStatusNotice(MESSAGE);
154
157
                        (*it)->Close(Csock::CLT_AFTERWRITE);
155
158
                }
156
159
 
157
 
                // Disconnect from IRC...
158
 
                CIRCSock *pIRCSock = pUser->GetIRCSock();
159
 
                if (pIRCSock) {
160
 
                        pIRCSock->Quit();
 
160
                // Disconnect all networks from irc
 
161
                vector<CIRCNetwork*> vNetworks = pUser->GetNetworks();
 
162
                for (vector<CIRCNetwork*>::iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) {
 
163
                        (*it2)->SetIRCConnectEnabled(false);
161
164
                }
162
165
 
163
 
                // ...and don't reconnect
164
 
                pUser->SetIRCConnectEnabled(false);
165
 
 
166
166
                SetNV(pUser->GetUserName(), "");
167
167
                return true;
168
168
        }
170
170
 
171
171
template<> void TModInfo<CBlockUser>(CModInfo& Info) {
172
172
        Info.SetWikiPage("blockuser");
 
173
        Info.SetHasArgs(true);
 
174
        Info.SetArgsHelpText("Enter one or more user names. Separate them by spaces.");
173
175
}
174
176
 
175
177
GLOBALMODULEDEFS(CBlockUser, "Block certain users from logging in")