-
Notifications
You must be signed in to change notification settings - Fork 1
/
ManageComments.ascx.cs
173 lines (154 loc) · 6.78 KB
/
ManageComments.ascx.cs
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//Engage: Locator - http://www.engagemodules.com
//Copyright (c) 2004-2007
//by Engage Software ( http://www.engagesoftware.com )
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
//TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
//THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
//CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
//DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Globalization;
using System.Web.UI.WebControls;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Localization;
using DotNetNuke.UI.UserControls;
using DotNetNuke.UI.Utilities;
using Engage.Dnn.Locator.Data;
using Engage.Dnn.Locator;
using Engage.Dnn.Locator.Maps;
using FileInfo=DotNetNuke.Services.FileSystem.FileInfo;
using Globals=DotNetNuke.Common.Globals;
namespace Engage.Dnn.Locator
{
partial class ManageComments : ModuleBase
{
protected TextEditor teLocationDetails;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (DotNetNuke.Framework.AJAX.IsInstalled())
{
DotNetNuke.Framework.AJAX.RegisterScriptManager();
}
lbSettings.Visible = IsEditable;
lbImportFile.Visible = IsEditable;
lbManageLocations.Visible = IsEditable;
lbLocationTypes.Visible = IsEditable;
}
protected void btnBack_Click(object sender, EventArgs e)
{
Response.Redirect(Globals.NavigateURL(TabId));
}
protected void Page_Load(object sender, EventArgs e)
{
// Global navigation
if (UserInfo.IsSuperUser)
{
lbManageComments.Enabled = false;
lbManageComments.CssClass = "mnavDisabled";
lbManageComments.ImageUrl = "~/desktopmodules/EngageLocator/images/commentsBtDisabled.gif";
}
string error = String.Empty;
if (MainDisplay.IsConfigured(TabModuleId, ref error))
{
if (!Page.IsPostBack)
{
if (Request.QueryString["lid"] != null && Request.QueryString["approved"] != null)
{
bool approved = Convert.ToBoolean(Request.QueryString["approved"], CultureInfo.InvariantCulture);
Location location = Location.GetLocation(Convert.ToInt32(Request.QueryString["lid"], CultureInfo.InvariantCulture));
Localization.LocalizeDataGrid(ref dgSubmittedComments, LocalResourceFile);
dgSubmittedComments.DataSource = location.GetComments(approved);
dgSubmittedComments.DataBind();
}
else
{
Localization.LocalizeDataGrid(ref dgSubmittedComments, LocalResourceFile);
lblConfigured.Visible = false;
divPanelTab.Visible = true;
BindData();
ClientAPI.AddButtonConfirm(btnDeleteComment, Localization.GetString("confirmDeleteComment", LocalResourceFile));
}
}
}
else
{
divPanelTab.Visible = false;
lblConfigured.Visible = true;
lblConfigured.Text = lblConfigured.Text + " " + error;
}
}
private void BindData()
{
DataTable comments = Location.GetNewSubmittedComments(PortalId, false);
dgSubmittedComments.DataSource = comments;
dgSubmittedComments.DataBind();
lblNoPending.Visible = (comments.Rows.Count == 0);
btnAcceptComment.Visible = (comments.Rows.Count > 0);
btnDeleteComment.Visible = (comments.Rows.Count > 0);
dgSubmittedComments.PagerStyle.Visible = (comments.Rows.Count > 0);
}
protected void dgComments_DeleteCommand(object source, DataGridCommandEventArgs e)
{
Label lblCommentId = (Label)e.Item.FindControl("lblCommentId");
if (lblCommentId.Text != "")
{
Comment.DeleteComment(Convert.ToInt32(lblCommentId.Text, CultureInfo.InvariantCulture));
}
if (dgSubmittedComments.Items.Count > 0)
{
BindData();
}
else
{
Response.Redirect(Globals.NavigateURL());
}
}
protected void btnReject_Click(object sender, EventArgs e)
{
foreach (DataGridItem row in dgSubmittedComments.Items)
{
CheckBox cbApproved = (CheckBox)row.FindControl("cbCommentApproved");
if (cbApproved.Checked)
{
Label lblCommentId = (Label)row.FindControl("lblCommentId");
Comment.DeleteComment(Convert.ToInt32(lblCommentId.Text, CultureInfo.InvariantCulture));
}
}
BindData();
}
protected void btnApprove_Click(object sender, EventArgs e)
{
foreach (DataGridItem row in dgSubmittedComments.Items)
{
CheckBox cbApproved = (CheckBox)row.FindControl("cbCommentApproved");
if (cbApproved.Checked)
{
Label lblCommentId = (Label)row.FindControl("lblCommentId");
Comment comment = Comment.GetComment(Convert.ToInt32(lblCommentId.Text, CultureInfo.InvariantCulture));
comment.Approved = true;
comment.Update();
}
}
BindData();
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect(Globals.NavigateURL(TabId));
}
protected void dgComments_ItemCreated(object sender, DataGridItemEventArgs e)
{
//if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
//{
// TableCell cell = e.Item.Cells[e.Item.Cells.Count - 1];
// LinkButton button = (LinkButton)cell.Controls[0];
// ClientAPI.AddButtonConfirm(button, Localization.GetString("confirmDeleteComment", LocalResourceFile));
//}
}
}
}