summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-04-08 00:19:07 -0500
committerAdam <Adam@anope.org>2013-04-08 00:19:07 -0500
commit1a37e1c0480f8bd11f57dfba514069a4e9c7d8de (patch)
tree41798df9056ef555f00c4a6c0964f1219c357dc3 /src/channels.cpp
parentfb7fef7a849342ab8463743497e781c5c3e6ae88 (diff)
Made auto* chanserv privileges not hard coded.
Made cs_statusupdate not remove status on users if they still match other entries. Move privilege descriptions out of the config
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index f3a061e94..62c6462d6 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -922,13 +922,6 @@ void Channel::Hold()
void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
{
- ChannelMode *owner = ModeManager::FindChannelModeByName("OWNER"),
- *admin = ModeManager::FindChannelModeByName("PROTECT"),
- *op = ModeManager::FindChannelModeByName("OP"),
- *halfop = ModeManager::FindChannelModeByName("HALFOP"),
- *voice = ModeManager::FindChannelModeByName("VOICE"),
- *registered = ModeManager::FindChannelModeByName("REGISTERED");
-
if (user == NULL)
return;
@@ -938,39 +931,33 @@ void Channel::SetCorrectModes(User *user, bool give_modes, bool check_noop)
Log(LOG_DEBUG) << "Setting correct user modes for " << user->nick << " on " << this->name << " (" << (give_modes ? "" : "not ") << "giving modes)";
AccessGroup u_access = ci->AccessFor(user);
+ ChannelMode *registered = ModeManager::FindChannelModeByName("REGISTERED");
- if (give_modes && (!user->Account() || user->Account()->HasExt("AUTOOP")) && (!check_noop || !ci->HasExt("NOAUTOOP")))
- {
- if (owner && u_access.HasPriv("AUTOOWNER"))
- this->SetMode(NULL, owner, user->GetUID());
- else if (admin && u_access.HasPriv("AUTOPROTECT"))
- this->SetMode(NULL, admin, user->GetUID());
-
- if (op && u_access.HasPriv("AUTOOP"))
- this->SetMode(NULL, op, user->GetUID());
- else if (halfop && u_access.HasPriv("AUTOHALFOP"))
- this->SetMode(NULL, halfop, user->GetUID());
- else if (voice && u_access.HasPriv("AUTOVOICE"))
- this->SetMode(NULL, voice, user->GetUID());
- }
+ /* Only give modes if autoop isn't set */
+ give_modes &= (!user->Account() || user->Account()->HasExt("AUTOOP")) && (!check_noop || !ci->HasExt("NOAUTOOP"));
/* If this channel has secureops, or the registered channel mode exists and the channel does not have +r set (aka the channel
* was created just now or while we were off), or the registered channel mode does not exist and channel is syncing (aka just
* created *to us*) and the user's server is synced (aka this isn't us doing our initial uplink - without this we would be deopping all
* users with no access on a non-secureops channel on startup), and the user's server isn't ulined, then set negative modes.
*/
- if ((ci->HasExt("SECUREOPS") || (registered && !this->HasMode("REGISTERED")) || (!registered && this->HasExt("SYNCING") && user->server->IsSynced())) && !user->server->IsULined())
- {
- if (owner && !u_access.HasPriv("AUTOOWNER") && !u_access.HasPriv("OWNERME"))
- this->RemoveMode(NULL, owner, user->GetUID());
+ bool take_modes = (ci->HasExt("SECUREOPS") || (registered && !this->HasMode("REGISTERED")) || (!registered && this->HasExt("SYNCING") && user->server->IsSynced())) && !user->server->IsULined();
- if (admin && !u_access.HasPriv("AUTOPROTECT") && !u_access.HasPriv("PROTECTME"))
- this->RemoveMode(NULL, admin, user->GetUID());
-
- if (op && this->HasUserStatus(user, "OP") && !u_access.HasPriv("AUTOOP") && !u_access.HasPriv("OPDEOPME"))
- this->RemoveMode(NULL, op, user->GetUID());
+ bool given = false;
+ for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
+ {
+ ChannelModeStatus *cm = ModeManager::GetStatusChannelModesByRank()[i];
+ bool has_priv = u_access.HasPriv("AUTO" + cm->name);
- if (halfop && !u_access.HasPriv("AUTOHALFOP") && !u_access.HasPriv("HALFOPME"))
- this->RemoveMode(NULL, halfop, user->GetUID());
+ /* If we have already given one mode, don't give more until it has a symbol */
+ if (give_modes && has_priv && (!given || cm->symbol))
+ {
+ this->SetMode(NULL, cm, user->GetUID());
+ /* Now if this contains a symbol don't give any more modes, to prevent setting +qaohv etc on users */
+ give_modes = !cm->symbol;
+ given = true;
+ }
+ else if (take_modes && !has_priv)
+ this->RemoveMode(NULL, cm, user->GetUID());
}
// Check mlock