mirror of
https://github.com/anope/anope.git
synced 2026-06-25 22:06:39 +02:00
Made opertypes inheritable
This commit is contained in:
+25
-2
@@ -16,26 +16,44 @@ OperType::OperType(const ci::string &nname) : name(nname)
|
||||
|
||||
bool OperType::HasCommand(const std::string &cmdstr) const
|
||||
{
|
||||
for (std::list<std::string>::const_iterator it = this->commands.begin(); it != this->commands.end(); it++)
|
||||
for (std::list<std::string>::const_iterator it = this->commands.begin(); it != this->commands.end(); ++it)
|
||||
{
|
||||
if (Anope::Match(cmdstr, *it))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(); iit != this->inheritances.end(); ++iit)
|
||||
{
|
||||
OperType *ot = *iit;
|
||||
|
||||
if (ot->HasCommand(cmdstr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OperType::HasPriv(const std::string &privstr) const
|
||||
{
|
||||
for (std::list<std::string>::const_iterator it = this->privs.begin(); it != this->privs.end(); it++)
|
||||
for (std::list<std::string>::const_iterator it = this->privs.begin(); it != this->privs.end(); ++it)
|
||||
{
|
||||
if (Anope::Match(privstr, *it))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (std::set<OperType *>::const_iterator iit = this->inheritances.begin(); iit != this->inheritances.end(); ++iit)
|
||||
{
|
||||
OperType *ot = *iit;
|
||||
|
||||
if (ot->HasPriv(privstr))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -55,3 +73,8 @@ const ci::string &OperType::GetName() const
|
||||
return this->name;
|
||||
}
|
||||
|
||||
void OperType::Inherits(OperType *ot)
|
||||
{
|
||||
this->inheritances.insert(ot);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user