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
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
<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>