visible_for_admins

   Usages of this macro
Shows the HTML elements returned by the selector parameter if the current visitor is an administrator. This is very helpful in cached pages, where you can't use the visitor command. So the solution is to use javascript to perform this check.
... in visible_for_admins.naml
1
2
3
4
5
6
7
8
9
10
11
<override_macro name="visible_for_admins" parameters="selector">
    <n.put_in_head
Binary
Namespace: HtmlNamespace
Parameters: in_head
.>
        <n.array_of_user_ids
Macro
Parameters: var_name, group
 var_name="site_admins" group="[n.administrators_group
Binary
Namespace: NabbleNamespace
/]"/>
    </n.put_in_head.>
    <script type="text/javascript">
        $(document).ready(function() {
            if (Nabble.userId && site_admins.indexOf(Number(Nabble.userId)) >= 0)
                $('<n.selector/>').show();
        });
    </script>
</override_macro>
Overrides default macro
... in utilities.naml
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
<macro name="visible_for_admins" parameters="selector">
    <n.put_in_head.>
        <n.array_of_user_ids var_name="site_admins" group="[n.administrators_group/]"/>
    </n.put_in_head.>
    <script type="text/javascript">
        $(document).ready(function() {
            if (Nabble.userId && site_admins.indexOf(Number(Nabble.userId)) >= 0)
                $('<n.selector/>').show();
        });
    </script>
</macro>