diff options
Diffstat (limited to 'modules/chanserv')
| -rw-r--r-- | modules/chanserv/access.cpp | 22 | ||||
| -rw-r--r-- | modules/chanserv/main/chanaccess.cpp | 20 | ||||
| -rw-r--r-- | modules/chanserv/mode.cpp | 29 |
3 files changed, 49 insertions, 22 deletions
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index a29524a73..8342e5973 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -60,20 +60,20 @@ class AccessChanAccessImpl : public AccessChanAccess } } - bool operator>(ChanServ::ChanAccess &other) override + int Compare(ChanAccess *other) override { - if (this->GetSerializableType() != other.GetSerializableType()) - return ChanServ::ChanAccess::operator>(other); - else - return this->GetLevel() > anope_dynamic_static_cast<AccessChanAccess *>(&other)->GetLevel(); - } + if (this->GetSerializableType() != other->GetSerializableType()) + return ChanAccess::Compare(other); - bool operator<(ChanServ::ChanAccess &other) override - { - if (this->GetSerializableType() != other.GetSerializableType()) - return ChanAccess::operator<(other); + int lev = this->GetLevel(); + int theirlev = anope_dynamic_static_cast<AccessChanAccess *>(other)->GetLevel(); + + if (lev > theirlev) + return 1; + else if (lev < theirlev) + return -1; else - return this->GetLevel() < anope_dynamic_static_cast<AccessChanAccess *>(&other)->GetLevel(); + return 0; } }; diff --git a/modules/chanserv/main/chanaccess.cpp b/modules/chanserv/main/chanaccess.cpp index f2b170989..bc2778bc3 100644 --- a/modules/chanserv/main/chanaccess.cpp +++ b/modules/chanserv/main/chanaccess.cpp @@ -110,3 +110,23 @@ bool ChanAccessImpl::Matches(const User *u, NickServ::Account *acc) return false; } + +int ChanAccessImpl::Compare(ChanAccess *other) +{ + const std::vector<ChanServ::Privilege> &privs = ChanServ::service->GetPrivileges(); + for (unsigned int i = privs.size(); i > 0; --i) + { + bool this_p = this->HasPriv(privs[i - 1].name), + other_p = other->HasPriv(privs[i - 1].name); + + if (!this_p && !other_p) + continue; + + if (this_p && !other_p) + return 1; + else if (!this_p && other_p) + return -1; + } + + return 0; +} diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index f0acd8456..7687c3576 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -334,6 +334,12 @@ class CommandCSMode : public Command break; } + if (cm->type == MODE_STATUS && !CanSet(source, ci, cm, false)) + { + source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), cm->name, ci->GetName()); + break; + } + if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c)) { source.Reply(_("List for mode \002{0}\002 is full."), cm->mchar); @@ -492,9 +498,6 @@ class CommandCSMode : public Command spacesepstream sep(params.size() > 3 ? params[3] : ""); Anope::string modes = params[2], param; - logger.Command(source, ci, _("{source} used {command} on {channel} to set {3}"), - params[2] + (params.size() > 3 ? " " + params[3] : "")); - int adding = -1; for (size_t i = 0; i < modes.length(); ++i) { @@ -560,20 +563,19 @@ class CommandCSMode : public Command if (param.find_first_of("*?") != Anope::string::npos) { - if (!this->CanSet(source, ci, cm, false) && !source.IsOverride()) + if (!this->CanSet(source, ci, cm, false) && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; } - for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end;) + for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; - ++it; ChanServ::AccessGroup targ_access = ci->AccessFor(uc->user); - if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !source.IsOverride())) + if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !source.HasOverridePriv("chanserv/administration"))) { source.Reply(_("You do not have the access to change the modes of \002{0}\002."), uc->user->nick.c_str()); continue; @@ -591,13 +593,13 @@ class CommandCSMode : public Command else { User *target = User::Find(param, true); - if (target == NULL) + if (target == nullptr) { source.Reply(_("User \002{0}\002 isn't currently online."), param); break; } - if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !source.IsOverride()) + if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; @@ -606,12 +608,13 @@ class CommandCSMode : public Command if (source.GetUser() != target) { ChanServ::AccessGroup targ_access = ci->AccessFor(target); - if (ci->IsPeace() && targ_access >= u_access && !source.IsOverride()) + if (ci->IsPeace() && targ_access >= u_access && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("You do not have the access to change the modes of \002{0}\002"), target->nick); break; } - else if (target->IsProtected()) + + if (target->IsProtected()) { source.Reply(_("Access denied. \002{0}\002 is protected and can not have their modes changed."), target->nick); break; @@ -645,6 +648,10 @@ class CommandCSMode : public Command } } } + + logger.Command(source, ci, _("{source} used {command} on {channel} to set {0}"), + params[2] + (params.size() > 3 ? " " + params[3] : "")); + } void DoClear(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) |
