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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
@model Project_Unite.Models.ApplicationUser
@{
ViewBag.Moderator = true;
ViewBag.Title = "User details";
}
<h2>User details</h2>
<h4>@Html.UserLink(Model.Id)</h4>
<ul>
<li><strong>Email address: </strong><a href="mailto:@Model.Email">Email @Model.Email</a></li>
<li><strong>Display name: </strong> <div id="[email protected]">@Model.DisplayName</div>
@if (User.Identity.IsAdmin())
{
if (ACL.CanManageRole(User.Identity.Name, Model.HighestRole.Id))
{
<!-- Trigger the modal with a button -->
<a data-toggle="modal" data-target="#[email protected]" href="#"><span class="glyphicon glyphicon-pencil"></span> Change</a>
<!-- Modal -->
<div id="[email protected]" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
@using (Html.BeginForm("ChangeUsername", "Moderator", new { id = Model.Id }, FormMethod.Post, new { name = "changeusername_" + Model.Id }))
{
@Html.AntiForgeryToken()
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Change username</h4>
</div>
<div class="modal-body">
<p>Please enter a username for this user.</p>
<p><strong>@Html.DisplayNameFor(Model => Model.DisplayName)</strong>: @Html.TextBoxFor(Model => Model.DisplayName, new { id="new_username_" + Model.Id, @class = "form-control" })</p>
</div>
<div class="modal-footer">
<a class="btn btn-primary" data-dismiss="modal" href="#" id="[email protected]"><span class="glyphicon glyphicon-ok"></span> Change</a>
<a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>
</div>
}
</div>
</div>
</div>
}
}
</li>
<li><strong>Last known IP address: </strong>@Model.LastKnownIPAddress</li>
<li><strong>Banned: </strong>
@if (Model.IsBanned)
{
<em>Yes</em>
if (Model.UserName != User.Identity.Name && ACL.CanManageRole(User.Identity.Name, Model.HighestRole.Id))
{
@Html.ActionLink("Unban", "Unban", "Moderator", new { id = Model.Id }, null)
}
}
else
{
<em>No</em>
if (Model.UserName != User.Identity.Name && ACL.CanManageRole(User.Identity.Name, Model.HighestRole.Id))
{
@Html.ActionLink("Ban", "Ban", "Moderator", new { id = Model.Id }, null)
}
}
</li>
@if(Model.IsBanned == true)
{
<li><strong>Banned on: </strong>@Model.BannedAt</li>
<li><strong>Banned by: </strong>@Html.UserLink(Model.BannedBy)</li>
}
<li>
<strong>Muted: </strong>
@if (Model.IsMuted)
{
<em>Yes</em>
if (Model.UserName != User.Identity.Name && ACL.CanManageRole(User.Identity.Name, Model.HighestRole.Id))
{
@Html.ActionLink("Unmute", "Unmute", "Moderator", new { id = Model.Id }, null)
}
}
else
{
<em>No</em>
if (Model.UserName != User.Identity.Name && ACL.CanManageRole(User.Identity.Name, Model.HighestRole.Id))
{
@Html.ActionLink("Mute", "Mute", "Moderator", new { id = Model.Id }, null)
}
}
</li>
@if (Model.IsMuted == true)
{
<li><strong>Muted on: </strong>@Model.MutedAt</li>
<li><strong>Muted by: </strong>@Html.UserLink(Model.MutedBy)</li>
}
<li><strong>Bio:</strong>
<p>@Html.Markdown(Model.Bio)</p>
</li>
<li>
<strong>Interests:</strong>
<p>@Model.Interests</p>
</li>
<li>
<strong>Hobbies:</strong>
<p>@Model.Hobbies</p>
</li>
</ul>
<a data-toggle="modal" href="#" data-target="#[email protected]" id="[email protected]" class="hidden">I'm a callback.</a>
<script type="text/javascript">
$('#[email protected]').click(function (e) { //Never gets called.
e.preventDefault();
$.ajax({
type: 'GET',
cache: true,
url: './Moderator/ChangeUsername/@Model.Id?newName=' + encodeURIComponent($('#[email protected]').val()),
success: function (msg) {
$.ajax({
type: "GET",
cache: true,
url: "./Moderator/GetUsername/@Model.Id",
success: function (result) {
$('#[email protected]').val(result);
$('#[email protected]').val(result);
}
});
}
});
});
</script>
|