diff --git a/include/opertype.h b/include/opertype.h index 364343f25..f76fc07b1 100644 --- a/include/opertype.h +++ b/include/opertype.h @@ -104,12 +104,12 @@ class CoreExport OperType /** Gets the icommands for this opertype * @return A list of commands */ - const std::list &GetCommands() const; + const std::list GetCommands() const; /** Gets the privileges for this opertype * @return A list of privileges */ - const std::list &GetPrivs() const; + const std::list GetPrivs() const; }; #endif // OPERTYPE_H diff --git a/src/opertype.cpp b/src/opertype.cpp index 9d6a4086f..5d9c666b4 100644 --- a/src/opertype.cpp +++ b/src/opertype.cpp @@ -94,13 +94,29 @@ void OperType::Inherits(OperType *ot) this->inheritances.insert(ot); } -const std::list &OperType::GetCommands() const +const std::list OperType::GetCommands() const { - return this->commands; + std::list cmd_list = this->commands; + for (std::set::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it) + { + OperType *ot = *it; + std::list cmds = ot->GetPrivs(); + for (std::list::const_iterator it2 = cmds.begin(), it2_end = cmds.end(); it2 != it2_end; ++it2) + cmd_list.push_back(*it2); + } + return cmd_list; } -const std::list &OperType::GetPrivs() const +const std::list OperType::GetPrivs() const { - return this->privs; + std::list priv_list = this->privs; + for (std::set::const_iterator it = this->inheritances.begin(), it_end = this->inheritances.end(); it != it_end; ++it) + { + OperType *ot = *it; + std::list priv = ot->GetPrivs(); + for (std::list::const_iterator it2 = priv.begin(), it2_end = priv.end(); it2 != it2_end; ++it2) + priv_list.push_back(*it2); + } + return priv_list; }