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
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
<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>