From 7f971043bc0b552e0ec2f3a88bf123cecb007387 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 3 Jul 2013 22:45:00 -0400 Subject: Allow channels on access lists --- include/access.h | 14 ++++++++++++-- include/modules.h | 6 +++--- include/regchannel.h | 9 +++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/access.h b/include/access.h index f60625ad9..19b6b3b02 100644 --- a/include/access.h +++ b/include/access.h @@ -75,6 +75,13 @@ class CoreExport AccessProvider : public Service class CoreExport ChanAccess : public Serializable { public: + typedef std::multimap Set; + /* shows the 'path' taken to determine if an access entry matches a user + * .first are access entries checked + * .second are access entries which match + */ + typedef std::pair Path; + /* The provider that created this access entry */ AccessProvider *provider; /* Channel this access entry is on */ @@ -95,8 +102,9 @@ class CoreExport ChanAccess : public Serializable /** Check if this access entry matches the given user or account * @param u The user * @param nc The account + * @param p The path to the access object which matches will be put here */ - virtual bool Matches(const User *u, const NickCore *nc) const; + virtual bool Matches(const User *u, const NickCore *nc, Path &p) const; /** Check if this access entry has the given privilege. * @param name The privilege name @@ -127,8 +135,10 @@ class CoreExport ChanAccess : public Serializable class CoreExport AccessGroup : public std::vector { public: - /* Channel these access entries are on */ + /* Channel these access entries are on */ const ChannelInfo *ci; + /* Path from these entries to other entries that they depend on */ + ChanAccess::Path path; /* Account these entries affect, if any */ const NickCore *nc; /* super_admin always gets all privs. founder is a special case where ci->founder == nc */ diff --git a/include/modules.h b/include/modules.h index ffb8bbcc7..8948d3389 100644 --- a/include/modules.h +++ b/include/modules.h @@ -597,10 +597,10 @@ class CoreExport Module : public Extensible */ virtual void OnBotDelete(BotInfo *bi) { throw NotImplementedException(); } - /** Called when access is deleted from a channel + /** Called after an access entry is deleted from a channel * @param ci The channel * @param source The source of the command - * @param access The access entry being removed + * @param access The access entry that was removed */ virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); } @@ -704,7 +704,7 @@ class CoreExport Module : public Extensible * @param priv The privilege being checked for * @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing */ - virtual EventReturn OnCheckPriv(ChanAccess *access, const Anope::string &priv) { throw NotImplementedException(); } + virtual EventReturn OnCheckPriv(const ChanAccess *access, const Anope::string &priv) { throw NotImplementedException(); } /** Check whether an access group has a privilege * @param group The group diff --git a/include/regchannel.h b/include/regchannel.h index f04156d89..49fc882e2 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -137,13 +137,18 @@ class CoreExport ChannelInfo : public Serializable, public Extensible */ unsigned GetAccessCount() const; + /** Get the number of access entries for this channel, + * including those that are on other channels. + */ + unsigned GetDeepAccessCount() const; + /** Erase an entry from the channel access list * * @param index The index in the access list vector * - * Clears the memory used by the given access entry and removes it from the vector. + * @return The erased entry */ - void EraseAccess(unsigned index); + ChanAccess *EraseAccess(unsigned index); /** Clear the entire channel access list * -- cgit