-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsqlcfUser.h
183 lines (134 loc) · 4.47 KB
/
sqlcfUser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**
* sqlcfUser.h
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*
* $Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $
*/
#ifndef __sqlcfUser_H
#define __sqlcfUser_H "$Id: sqlcfUser.h,v 1.4 2008/01/16 02:03:40 buzlip01 Exp $"
#include <string>
#include <vector>
#include <ctime>
#include <sstream>
#include "dbHandle.h"
using namespace std;
namespace gnuworld
{
class iClient;
namespace cf
{
class sqlManager;
class sqlcfUser
{
public:
sqlcfUser(sqlManager*);
virtual ~sqlcfUser();
typedef unsigned short int flagType ;
static const flagType F_SERVERADMIN; /* +a */
static const flagType F_BLOCK; /* +b */
static const flagType F_COMMENT; /* +c */
static const flagType F_CHANFIX; /* +f */
static const flagType F_OWNER; /* +o */
static const flagType F_USERMANAGER; /* +u */
static const flagType F_PERMBLOCKER; /* +p */
static const flagType F_LOGGEDIN;
typedef std::list< std::string > hostListType;
/* Methods to get data attributes. */
inline const unsigned int& getID() const
{ return id ; }
inline const std::string& getUserName() const
{ return user_name; }
inline const int getCreated() const
{ return created; }
inline const time_t getLastSeen() const
{ return last_seen; }
inline const time_t getLastUpdated() const
{ return last_updated; }
inline const std::string& getLastUpdatedBy() const
{ return last_updated_by; }
inline const unsigned int& getLanguageId() const
{ return language_id ; }
inline const std::string& getGroup() const
{ return group; }
inline bool getFlag( const flagType& whichFlag ) const
{ return ((flags & F_OWNER) || (flags & whichFlag)) ; }
inline const flagType& getFlags() const
{ return flags ; }
inline const bool getIsSuspended() const
{ return isSuspended; }
inline const bool getUseNotice() const
{ return useNotice; }
inline const bool getNeedOper() const
{ return needOper; }
inline const hostListType& getHostList() const
{ return hostList; }
/* Mutators */
inline void setUserName(const std::string& _user_name)
{ user_name = _user_name; }
inline void setCreated(const unsigned int _created)
{ created = _created; }
inline void setLastSeen(const unsigned int _last_seen)
{ last_seen = _last_seen; }
inline void setLastUpdated(const unsigned int _last_updated)
{ last_updated = _last_updated; }
inline void setLastUpdatedBy(const std::string& _last_updated_by)
{ last_updated_by = _last_updated_by; }
inline void setLanguageId(const unsigned int _language_id)
{ language_id = _language_id; }
inline void setGroup(const std::string& _group)
{ group = string_lower(_group); }
inline void setFlag(const flagType& whichFlag)
{ flags |= whichFlag; }
inline void removeFlag(const flagType& whichFlag)
{ flags &= ~whichFlag; }
inline void setSuspended(const bool _isSuspended)
{ isSuspended = _isSuspended; }
inline void setNotice(const bool _useNotice)
{ useNotice = _useNotice; }
inline void setNeedOper(const bool _needOper)
{ needOper = _needOper; }
/* Methods to alter our SQL status */
void setAllMembers(dbHandle*, int);
bool commit(dbHandle*);
bool Insert(dbHandle*);
bool Delete(dbHandle*);
/** Static member for keeping track of max user id */
static unsigned long int maxUserId;
void loadHostList(dbHandle*);
bool addHost(dbHandle*, const std::string&);
bool delHost(dbHandle*, const std::string&);
bool matchHost(const std::string&);
bool hasHost(const std::string&);
private:
unsigned int id;
std::string user_name;
unsigned int created;
unsigned int last_seen;
unsigned int last_updated;
std::string last_updated_by;
unsigned int language_id;
std::string group;
flagType flags;
bool isSuspended;
bool useNotice;
bool needOper;
hostListType hostList;
sqlManager* myManager;
}; // class sqlcfUser
} // namespace cf
} // namespace gnuworld
#endif // __sqlcfUser_H