]>
jfr.im git - irc/evilnet/mod.chanfix.git/blob - DELHOSTCommand.cc
4 * 08/26/2005 - Jimmy Lipham <music0m@alltel.net>
7 * Deletes this hostmask from the user's list of hostmasks
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 #include "gnuworld_config.h"
30 #include "responses.h"
31 #include "StringTokenizer.h"
32 #include "sqlcfUser.h"
41 void DELHOSTCommand::Exec(iClient
* theClient
, sqlcfUser
* theUser
, const std::string
& Message
)
43 StringTokenizer
st(Message
);
45 sqlcfUser
* targetUser
= bot
->isAuthed(st
[1]);
47 bot
->SendTo(theClient
,
48 bot
->getResponse(theUser
,
49 language::no_such_user
,
50 std::string("No such user %s.")).c_str(), st
[1].c_str());
54 /* Can't delete a host from an owner unless you're an owner. */
55 if (targetUser
->getFlag(sqlcfUser::F_OWNER
) && !theUser
->getFlag(sqlcfUser::F_OWNER
)) {
56 bot
->SendTo(theClient
,
57 bot
->getResponse(theUser
,
58 language::cant_del_host_an_owner
,
59 std::string("You cannot delete a host from an owner unless you're an owner.")).c_str());
63 /* Can only delete a host from a user manager if you're an owner. */
64 if (targetUser
->getFlag(sqlcfUser::F_USERMANAGER
) && !theUser
->getFlag(sqlcfUser::F_OWNER
)) {
65 bot
->SendTo(theClient
,
66 bot
->getResponse(theUser
,
67 language::cant_del_host_manager
,
68 std::string("You cannot delete a host from a user manager unless you're an owner.")).c_str());
72 /* A serveradmin can only add flags to users on his/her own group. */
73 if (theUser
->getFlag(sqlcfUser::F_SERVERADMIN
) &&
74 !theUser
->getFlag(sqlcfUser::F_USERMANAGER
)) {
75 if (targetUser
->getGroup() != theUser
->getGroup()) {
76 bot
->SendTo(theClient
,
77 bot
->getResponse(theUser
,
78 language::cant_del_host_diff_group
,
79 std::string("You cannot delete a host from a user in a different group.")).c_str());
84 if (!targetUser
->hasHost(st
[2].c_str())) {
85 bot
->SendTo(theClient
,
86 bot
->getResponse(theUser
,
87 language::user_doesnt_have_host
,
88 std::string("User %s doesn't have hostmask %s.")).c_str(),
89 targetUser
->getUserName().c_str(), st
[2].c_str());
93 if (!targetUser
->delHost(bot
->getLocalDBHandle(),st
[2].c_str())) {
94 bot
->SendTo(theClient
,
95 bot
->getResponse(theUser
,
96 language::failed_deleting_host
,
97 std::string("Failed deleting hostmask %s from user %s.")).c_str(),
98 st
[2].c_str(), targetUser
->getUserName().c_str());
102 targetUser
->setLastUpdated(bot
->currentTime());
103 targetUser
->setLastUpdatedBy( std::string( "("
104 + theUser
->getUserName()
106 + theClient
->getRealNickUserHost() ) );
107 targetUser
->commit(bot
->getLocalDBHandle());
109 bot
->SendTo(theClient
,
110 bot
->getResponse(theUser
,
111 language::deleted_hostmask
,
112 std::string("Deleted hostmask %s from user %s.")).c_str(),
113 st
[2].c_str(), targetUser
->getUserName().c_str());
115 bot
->logAdminMessage("%s (%s) DELHOST %s %s",
116 theUser
->getUserName().c_str(),
117 theClient
->getRealNickUserHost().c_str(),
118 targetUser
->getUserName().c_str(), st
[2].c_str());
120 bot
->logLastComMessage(theClient
, Message
);
126 } //namespace gnuworld