summaryrefslogtreecommitdiff
path: root/Project-Unite/Views/Admin/AccessControl.cshtml
blob: 8d51d5407ed9c749aebd29ff47fd5b6bfeb3c954 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@model Project_Unite.Models.AdminAccessControlViewModel


@{
    ViewBag.Title = "Access control";

    Dictionary<string, string> EnumNames = new Dictionary<string, string> {
        { "None", "No permissions" },
        { "CanRead", "Read only" },
        { "CanPost", "Can post new topics" },
        {"CanReply", "Can reply" }
    };

    var availablePermissions = new List<SelectListItem>();
    foreach (var v in Enum.GetValues(typeof(Project_Unite.Models.PermissionPreset)))
    {
        availablePermissions.Add(new SelectListItem
        {
            Value = v.ToString(),
            Text = EnumNames[v.ToString()]
        });
    }

}

<h2>Access control</h2>

<p>Below, you can modify the access control list (ACL) definitions for all forum categories.</p>

    @foreach (var key in Model.IDs)
    {
        <h4>@key</h4>
        <table class="table">
            <tr>
                <th>Role ID</th>
                <th>Value</th>
            </tr>
            @foreach (var p in Model.ACLList.Where(x => x.CategoryId == key))
            {
                <tr>
                    <td>@Html.DisplayFor(v => p.RoleId)</td>
                    <td>
                        @foreach(var r in EnumNames)
                        {
                            if(r.Key == p.Permissions.ToString())
                            {
                                <a href="#" class="btn btn-primary">@r.Value</a>
                            }
                            else
                            {
                                @Html.ActionLink(r.Value, "SetPermission", "Admin", new { id=p.CategoryId, role=p.RoleId, permission=r.Key}, new { @class = "btn btn-default" })
                            }
                        }
                    </td>
                </tr>                
            }
        </table>
        
    }