	[% META title="Resources &raquo; User Permissions" %]
<!-- BEGIN [% template.name %] -->

    [% # INCLUDE dumper.tt dump = data %]
    [% # INCLUDE dumper.tt dump = functions %]
    [% # INCLUDE dumper.tt dump = unlock_actions %]


    <h2>[% c.cfg('settings').lab_name_abbreviation %] user permissions</h2>

    <script type="text/javascript" src="/js/floating-1.8.js"></script>
    <script type="text/javascript">
        floatingMenu.add('floatdiv',
            {
                // Represents distance from left or right browser window
                // border depending upon property used. Only one should be
                // specified.
                // targetLeft: 0,
                targetRight: 50,

                // Represents distance from top or bottom browser window
                // border depending upon property used. Only one should be
                // specified.
                targetTop: 200,
                // targetBottom: 0,

                // Uncomment one of those if you need centering on
                // X- or Y- axis.
                // centerX: true,
                // centerY: true,

                // Remove this one if you don't want snap effect (snap into position)
                snap: true
            });
    </script>

    [% nsorted_functions = natural_sort(functions.keys); # PROCESS dumper.tt dump = nsorted_functions %]

    [% BLOCK header %]
    <tr>
        <td align="right">Function ID:</td>
        [% FOREACH f IN nsorted_functions;
            title = functions.item(f);
        %]
            <th>
                <span title="[% 'unlock + ' IF unlock_actions.item(f); title %]"
                    class="acronym">[% f %]</span>
            </th>
        [% END %]
    </tr>
    [% END %]

    <div id="floatdiv" style="
        position:absolute;
        width:300px; height:50px; top:10px; right:10px;
        padding: 0px; background:#fff;
        border:none;
        z-index:100">
        <table class="tiny bkgd_grey">
        [% FOREACH f IN nsorted_functions;
            description = functions.item(f);
        %]
            <tr>
                <td align="right">[% f %]</td>
                <td>[% 'unlock + ' IF unlock_actions.item(f); description %]</td>
            </tr>
        [% END %]
        </table>
    </div>

    <form action="[% c.query.self_url %]">
        <p class="indent">Select function to restrict:
            <select name="function_id">
                <option value=""></option>
                [% FOREACH f IN functions.sort;
                    description = functions.item(f);
                %]
                    <option value="[% f %]"
                        [% 'selected' IF f == c.query.param('function_id') %]>
                        [% description; ' [+ unlock]' IF unlock_actions.item(f); %]
                    </option>
                [% END %]
                <input type="checkbox" name="invert" value="1"
                    [% 'checked' IF c.query.param('invert') %] />invert
            </select>
            [% site.html.go_btn %]
        </p>
    </form>

    <table class="tiny indent">
    [% INCLUDE header %]
    [% FOREACH user IN data.keys.sort; # PROCESS dumper.tt dump = user;
        IF c.query.param('function_id');
            IF c.query.param('invert');
                NEXT IF data.item(user).item( c.query.param('function_id') );
            ELSE;
                NEXT UNLESS data.item(user).item( c.query.param('function_id') );
            END;
        END;
    %]
        <tr>
            <td>
                [% IF c.user_can('do_admin') %]
                <a href="[% app_url %]/admin/user/get_user?username=[% user %]"
                   target="_new">[% user | upper %]</a>
                [% ELSE; user | upper; END %]
            </td>
            [% FOREACH f IN nsorted_functions;
                bkgd = # data.item(user).item(f) ? 'f00' : 'fff'; # using tick.gif now
                    'fff' %]
                <td style="background: #[% bkgd %]">
                    [% IF data.item(user).item(f) %]
                        <img src="/images/tick.gif" />
                    [% END %]
                </td>
            [% END %]
        [% INCLUDE header IF loop.count.match(0) # every 10 rows %]
        </tr>
    [% END %]
    [% # INCLUDE header %]
    </table>
<!-- END [% template.name %] -->
