]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_cap Add Capability::OnList() hook
authorAttila Molnar <attilamolnar@hush.com>
Sat, 5 Dec 2015 14:42:04 +0000 (15:42 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Sat, 5 Dec 2015 14:42:04 +0000 (15:42 +0100)
include/modules/cap.h
src/modules/m_cap.cpp

index 4ca3911a5512e6bb31f4575231be21373b353ed9..a00089260295f2806b862432f32e8fe6d741215f 100644 (file)
@@ -199,5 +199,15 @@ namespace Cap
                {
                        return true;
                }
+
+               /** Called when a user requests a list of all capabilities and this capability is about to be included in the list.
+                * The default behavior always includes the cap in the list.
+                * @param user User querying a list capabilities
+                * @return True to add this cap to the list sent to the user, false to not list it
+                */
+               virtual bool OnList(LocalUser* user)
+               {
+                       return true;
+               }
        };
 }
index bb5a506c95c0b928e23fb1c70a53d80092debf2a..2b4055e3cf0805dd11b1f68550a6789df75a2594 100644 (file)
@@ -149,6 +149,9 @@ class Cap::ManagerImpl : public Cap::Manager
                        if (!(show_caps & cap->GetMask()))
                                continue;
 
+                       if ((show_all) && (!cap->OnList(user)))
+                               continue;
+
                        if (minus_prefix)
                                out.push_back('-');
                        out.append(cap->GetName()).push_back(' ');