Skip to content

Commit f5f7359

Browse files
committed
Generate URLs consistently
Also apply changes from Create to GroupEdit
1 parent 0f64c1b commit f5f7359

2 files changed

Lines changed: 26 additions & 31 deletions

File tree

DNN Platform/Modules/Groups/Create.ascx.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ protected void Page_Load(object sender, EventArgs e)
102102

103103
private void Cancel_Click(object sender, EventArgs e)
104104
{
105-
this.Response.Redirect(this.ModuleContext.NavigateUrl(this.TabId, string.Empty, false, null));
105+
var groupListingUrl = this.navigationManager.NavigateURL(this.TabId);
106+
this.Response.Redirect(groupListingUrl);
106107
}
107108

108109
private void Create_Click(object sender, EventArgs e)
@@ -215,6 +216,7 @@ private void Create_Click(object sender, EventArgs e)
215216
GroupUtilities.CreateJournalEntry(roleInfo, this.UserInfo);
216217
}
217218

218-
this.Response.Redirect(this.ModuleContext.NavigateUrl(this.TabId, string.Empty, false, null));
219+
var groupListingUrl = this.navigationManager.NavigateURL(this.TabId);
220+
this.Response.Redirect(groupListingUrl);
219221
}
220222
}

DNN Platform/Modules/Groups/GroupEdit.ascx.cs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,31 @@ protected override void OnInit(EventArgs e)
6868
/// <param name="e">The event args.</param>
6969
protected void Page_Load(object sender, EventArgs e)
7070
{
71-
JavaScript.RequestRegistration(this.appStatus, this.eventLogger, this.PortalSettings, CommonJs.DnnPlugins);
72-
73-
this.imgGroup.Src = this.Page.ResolveUrl("~/DesktopModules/SocialGroups/Images/") + "sample-group-profile.jpg";
74-
if (this.Page.IsPostBack || this.GroupId <= 0)
75-
{
76-
return;
77-
}
78-
7971
var roleInfo = this.roleController.GetRoleById(this.PortalId, this.GroupId);
80-
if (roleInfo == null)
72+
if (this.GroupId > 0 && roleInfo == null)
8173
{
82-
this.Response.Redirect(this.ModuleContext.NavigateUrl(this.TabId, string.Empty, false));
74+
var groupListingUrl = this.navigationManager.NavigateURL(this.TabId);
75+
this.Response.Redirect(groupListingUrl);
8376
return;
8477
}
8578

8679
if (!this.UserInfo.IsInRole(this.PortalSettings.AdministratorRoleName))
8780
{
8881
if (roleInfo.CreatedByUserID != this.UserInfo.UserID)
8982
{
90-
this.Response.Redirect(
91-
this.ModuleContext.NavigateUrl(this.TabId, string.Empty, false, $"groupid={this.GroupId}"));
83+
var viewGroupUrl = this.navigationManager.NavigateURL(this.TabId, string.Empty, $"groupid={this.GroupId}");
84+
this.Response.Redirect(viewGroupUrl);
9285
}
9386
}
9487

88+
JavaScript.RequestRegistration(this.appStatus, this.eventLogger, this.PortalSettings, CommonJs.DnnPlugins);
89+
90+
this.imgGroup.Src = this.Page.ResolveUrl("~/DesktopModules/SocialGroups/Images/sample-group-profile.jpg");
91+
if (this.Page.IsPostBack || this.GroupId <= 0)
92+
{
93+
return;
94+
}
95+
9596
this.txtGroupName.Visible = !roleInfo.IsSystemRole;
9697
this.reqGroupName.Enabled = !roleInfo.IsSystemRole;
9798

@@ -118,7 +119,8 @@ protected void Page_Load(object sender, EventArgs e)
118119

119120
private void Cancel_Click(object sender, EventArgs e)
120121
{
121-
this.Response.Redirect(this.ModuleContext.NavigateUrl(this.TabId, string.Empty, false, $"groupid={this.GroupId}"));
122+
var viewGroupUrl = this.navigationManager.NavigateURL(this.TabId, string.Empty, $"groupid={this.GroupId}");
123+
this.Response.Redirect(viewGroupUrl);
122124
}
123125

124126
private void Save_Click(object sender, EventArgs e)
@@ -161,14 +163,7 @@ private void Save_Click(object sender, EventArgs e)
161163
roleInfo.Description = this.txtDescription.Text;
162164
roleInfo.IsPublic = this.rdAccessTypePublic.Checked;
163165

164-
if (roleInfo.Settings.ContainsKey("ReviewMembers"))
165-
{
166-
roleInfo.Settings["ReviewMembers"] = this.chkMemberApproved.Checked.ToString();
167-
}
168-
else
169-
{
170-
roleInfo.Settings.Add("ReviewMembers", this.chkMemberApproved.Checked.ToString());
171-
}
166+
roleInfo.Settings["ReviewMembers"] = this.chkMemberApproved.Checked.ToString();
172167

173168
this.roleController.UpdateRoleSettings(roleInfo, true);
174169
this.roleController.UpdateRole(roleInfo);
@@ -178,19 +173,17 @@ private void Save_Click(object sender, EventArgs e)
178173
var groupFolder = this.folderManager.GetFolder(this.PortalSettings.PortalId, $"Groups/{roleInfo.RoleID}") ??
179174
this.folderManager.AddFolder(this.PortalSettings.PortalId, $"Groups/{roleInfo.RoleID}");
180175

181-
if (groupFolder != null)
182-
{
183-
var fileName = Path.GetFileName(this.inpFile.PostedFile.FileName);
184-
var fileInfo = this.fileManager.AddFile(groupFolder, fileName, this.inpFile.PostedFile.InputStream, true, true, this.fileContentTypeManager.GetContentType(Path.GetExtension(fileName)));
185-
roleInfo.IconFile = $"FileID={fileInfo.FileId}";
186-
this.roleController.UpdateRole(roleInfo);
187-
}
176+
var fileName = Path.GetFileName(this.inpFile.PostedFile.FileName);
177+
var fileInfo = this.fileManager.AddFile(groupFolder, fileName, this.inpFile.PostedFile.InputStream, true, true, this.fileContentTypeManager.GetContentType(Path.GetExtension(fileName)));
178+
roleInfo.IconFile = $"FileID={fileInfo.FileId}";
179+
this.roleController.UpdateRole(roleInfo);
188180
}
189181

190182
// Clear Roles Cache
191183
DataCache.RemoveCache("GetRoles");
192184
}
193185

194-
this.Response.Redirect(this.navigationManager.NavigateURL(this.TabId, string.Empty, $"groupid={this.GroupId}"));
186+
var viewGroupUrl = this.navigationManager.NavigateURL(this.TabId, string.Empty, $"groupid={this.GroupId}");
187+
this.Response.Redirect(viewGroupUrl);
195188
}
196189
}

0 commit comments

Comments
 (0)