Skip to content

Commit 191448c

Browse files
authored
Merge pull request #6 from valadas/Issue5
Brings the module Dnn 9.2 compatible
2 parents 4dbf6fc + 9401684 commit 191448c

22 files changed

+332
-252
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
## Ignore VS2015/Roslyn artifacts
1616
*.sln.ide/
1717
.vs/
18+
*.lock
1819

1920
## Ignore Webstorm artifacts
2021
*.idea/
@@ -40,13 +41,15 @@
4041
.builds
4142
*.dotCover
4243
*.ldf
44+
*.zip
4345

4446
# git merge artifacts
4547
*.orig
4648
*.gitmodules
4749

4850
## TODO: If you have NuGet Package Restore enabled, uncomment this
4951
[Pp]ackages/
52+
[Bb]in/
5053

5154
# Visual Studio profiler
5255
*.psess

AnnouncementsEdit.ascx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<%@ Register TagPrefix="dnn" TagName="FilePickerUploader" Src="~/controls/filepickeruploader.ascx" %>
1010
<%@ Import Namespace="DotNetNuke.Services.Localization" %>
1111
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %>
12-
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %>
12+
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web.Deprecated" %>
1313
<div class="dnnForm dnnAnnouncementForm dnnClear" id="AnnouncementsForm">
1414
<ul class="dnnAdminTabNav dnnClear" id="">
1515
<li id="contentTab" runat="server"><a href="#dnnContent"><%=LocalizeString("content.Tab")%></a></li>

AnnouncementsEdit.ascx.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using DotNetNuke.Common;
3232
using DotNetNuke.Common.Utilities;
3333
using DotNetNuke.Framework;
34+
using DotNetNuke.Framework.JavaScriptLibraries;
3435
using DotNetNuke.Modules.Announcements.Components.Business;
3536
using DotNetNuke.Modules.Announcements.Components.Common;
3637
using DotNetNuke.Modules.Announcements.MVP.Models;
@@ -67,8 +68,8 @@ public partial class AnnouncementsEdit : ModuleView<AnnouncementsEditModel>, IAn
6768
override protected void OnInit(EventArgs e)
6869
{
6970
base.OnInit(e);
70-
71-
jQuery.RequestDnnPluginsRegistration();
71+
72+
JavaScript.RequestRegistration(CommonJs.DnnPlugins);
7273

7374
ClientResourceManager.RegisterStyleSheet(Page, Globals.ApplicationPath + "/DesktopModules/Announcements/AnnouncementsEdit.css", FileOrder.Css.ModuleCss);
7475

AnnouncementsSettings.ascx.cs

+20-4
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,30 @@ protected override void OnSettingsLoaded()
7373

7474
try
7575
{
76-
txtHistory.Text = Model.Settings.History.ToDnnString();
77-
txtDescriptionLength.Text = Model.Settings.DescriptionLength.ToDnnString();
78-
txtEditorHeight.Text = Model.Settings.EditorHeight.ToDnnString();
7976
foreach (Enum i in Enum.GetValues(typeof(ViewTypes)))
8077
{
8178
ddlViewType.Items.Add(new ListItem(Localization.GetString(Enum.GetName(typeof(ViewTypes), i), LocalResourceFile), Enum.GetName(typeof(ViewTypes), i)));
8279
}
83-
ddlViewType.SelectedValue = Utilities.ViewTypeToString(Model.Settings.DefaultViewType);
80+
81+
// This is not perfect, but the only way I found how to fix the settings reading issue, original code commented below.
82+
if (Model.ModuleSettings != null)
83+
{
84+
if (Model.ModuleSettings.ContainsKey("history"))
85+
txtHistory.Text = Model.ModuleSettings["history"].ToString();
86+
if (Model.ModuleSettings.ContainsKey("descriptionLength"))
87+
txtDescriptionLength.Text = Model.ModuleSettings["descriptionLength"].ToString();
88+
if (Model.ModuleSettings.ContainsKey("editorHeight"))
89+
txtEditorHeight.Text = Model.ModuleSettings["editorHeight"].ToString();
90+
if (Model.ModuleSettings.ContainsKey("defaultViewType"))
91+
ddlViewType.SelectedValue = Model.ModuleSettings["defaultViewType"].ToString();
92+
}
93+
//if (Model.Settings != null)
94+
//{
95+
// txtHistory.Text = Model.Settings.History.ToDnnString();
96+
// txtDescriptionLength.Text = Model.Settings.DescriptionLength.ToDnnString();
97+
// txtEditorHeight.Text = Model.Settings.EditorHeight.ToDnnString();
98+
// ddlViewType.SelectedValue = Utilities.ViewTypeToString(Model.Settings.DefaultViewType);
99+
//}
84100
}
85101
catch (Exception exc)
86102
{

AnnouncementsView.ascx.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ protected override void OnLoad(EventArgs e)
4040
var localTemplate = (BaseTemplate)Model.Template;
4141
if (!string.IsNullOrEmpty(localTemplate.JsFile) && File.Exists(Server.MapPath(localTemplate.JsFile)))
4242
{
43-
Framework.jQuery.RegisterJQuery(Page);
43+
// Framework.jQuery.RegisterJQuery(Page);
44+
// Should not be required, jQuery is loaded by default
45+
4446
ClientResourceManager.RegisterScript(Page, localTemplate.JsFile);
4547
}
4648
if (!string.IsNullOrEmpty(localTemplate.CssFile) && File.Exists(Server.MapPath(localTemplate.CssFile)))

AssemblyInfo.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// Runtime Version:4.0.30319.42000
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
[assembly: System.Reflection.AssemblyVersion("07.02.00.00")]
12+
13+

Components/Business/AnnouncementInfo.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ private bool CheckFileOrTab(string link, string contentType)
239239
// the link is a file. Check wether it exists in the portal
240240
if (Int32.TryParse(link.Replace("FileID=", ""), out intId))
241241
{
242-
var objFileController = new FileController();
243-
FileInfo objFile = objFileController.GetFileById(intId, portal.PortalId);
242+
var objFile = FileManager.Instance.GetFile(intId);
244243
if (objFile != null)
245244
{
246245
if ((!(string.IsNullOrEmpty(contentType))) && (!(objFile.ContentType.StartsWith(contentType, StringComparison.OrdinalIgnoreCase))))
@@ -354,7 +353,7 @@ public void WriteXml(XmlWriter writer)
354353

355354
public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
356355
{
357-
PortalSettings portalSettings = PortalController.GetCurrentPortalSettings();
356+
PortalSettings portalSettings = PortalController.Instance.GetCurrentPortalSettings();
358357
string outputFormat = strFormat == string.Empty ? "D" : strFormat;
359358
switch (strPropertyName.ToLowerInvariant())
360359
{
@@ -398,9 +397,8 @@ public string GetProperty(string strPropertyName, string strFormat, CultureInfo
398397
// this is now legacy, from version 7.0.0, a real filename is saved in the DB
399398
if (ImageSource.StartsWith("FileID="))
400399
{
401-
var fileCnt = new FileController();
402-
FileInfo objFile = fileCnt.GetFileById(Convert.ToInt32(strValue.Substring(7)),
403-
portalSettings.PortalId);
400+
401+
var objFile = FileManager.Instance.GetFile(Convert.ToInt32(strValue.Substring(7)));
404402
if (objFile != null)
405403
{
406404
strValue = portalSettings.HomeDirectory + objFile.Folder + objFile.FileName;

Components/Business/AnnouncementsController.cs

+36-37
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
using DotNetNuke.Entities.Users;
4242
using DotNetNuke.Services.Journal;
4343
using DotNetNuke.Services.Search;
44+
using DotNetNuke.Services.Search.Entities;
4445
using DotNetNuke.Services.Social.Messaging;
4546
using DotNetNuke.Services.Social.Notifications;
4647

@@ -53,7 +54,7 @@ namespace DotNetNuke.Modules.Announcements.Components.Business
5354
/// The AnnouncementsController Class represents the Announcments Business Layer
5455
/// Methods in this class call methods in the Data Layer
5556
/// </summary>
56-
public class AnnouncementsController : IAnnouncementsController, ISearchable, IPortable
57+
public class AnnouncementsController : ModuleSearchBase, IAnnouncementsController, IPortable
5758
{
5859

5960
#region Public Methods
@@ -191,7 +192,7 @@ public IEnumerable<AnnouncementInfo> GetExpiredAnnouncements(int moduleId)
191192
}
192193

193194

194-
public void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, String journalType)
195+
public void AddAnnouncementToJournal(AnnouncementInfo announcement, String journalType, ModuleInfo moduleInfo)
195196
{
196197

197198
var objJournalType = JournalController.Instance.GetJournalType(journalType);
@@ -214,7 +215,7 @@ public void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, S
214215
journalItem.JournalTypeId = objJournalType.JournalTypeId;
215216
journalItem.SecuritySet = "E,";
216217

217-
JournalController.Instance.SaveJournalItem(journalItem, tabId);
218+
JournalController.Instance.SaveJournalItem(journalItem, moduleInfo);
218219

219220
}
220221

@@ -248,48 +249,46 @@ public void SendNotifications(AnnouncementInfo announcement)
248249

249250
#endregion
250251

251-
#region ISearchable Implementation
252+
#region ModuleSearchBase Implementation
252253

253-
/// <summary>
254-
/// GetSearchItems implements the ISearchable Interface
255-
/// </summary>
256-
/// <remarks>
257-
/// </remarks>
258-
public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo)
254+
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
259255
{
260-
Hashtable moduleSettings = Entities.Portals.PortalSettings.GetModuleSettings(ModInfo.ModuleID);
261-
int descriptionLength = 100;
262-
if (Convert.ToString(moduleSettings["descriptionLength"]) != "")
256+
var moduleSettings = moduleInfo.ModuleSettings;
257+
int descriptionLenght = 100;
258+
if (moduleSettings["descriptionLength"].ToString() != "")
263259
{
264-
descriptionLength = int.Parse(Convert.ToString(moduleSettings["descriptionLength"]));
265-
if (descriptionLength < 1)
266-
{
267-
descriptionLength = 1950;
268-
//max length of description is 2000 char, take a bit less to make sure it fits...
269-
}
260+
int.TryParse(moduleSettings["descriptionLength"].ToString(), out descriptionLenght);
261+
if (descriptionLenght < 1) { descriptionLenght = 1950; }
262+
//max length of description is 2000 char, take a bit less to make sure it fits...
270263
}
271-
272-
var searchItemCollection = new SearchItemInfoCollection();
273-
274-
IEnumerable<AnnouncementInfo> announcements = GetCurrentAnnouncements(ModInfo.ModuleID, Null.NullDate);
275-
276-
foreach (AnnouncementInfo objAnnouncement in announcements)
264+
var searchDocuments = new List<SearchDocument>();
265+
var announcements = GetAnnouncements(moduleInfo.ModuleID, beginDateUtc, DateTime.MaxValue);
266+
foreach (var announcement in announcements)
277267
{
278-
var tempVar = objAnnouncement;
279-
string strContent = System.Web.HttpUtility.HtmlDecode(tempVar.Title + " " + tempVar.Description);
280-
string strDescription =
281-
HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(tempVar.Description), false),
282-
descriptionLength, "...");
283-
var searchItem = new SearchItemInfo(ModInfo.ModuleTitle + " - " + tempVar.Title, strDescription,
284-
tempVar.CreatedByUserID, tempVar.PublishDate.Value, ModInfo.ModuleID,
285-
tempVar.ItemID.ToString(CultureInfo.InvariantCulture), strContent,
286-
"ItemID=" + tempVar.ItemID.ToString(CultureInfo.InvariantCulture));
287-
searchItemCollection.Add(searchItem);
268+
var document = new SearchDocument();
269+
document.AuthorUserId = announcement.CreatedByUserID;
270+
document.Body = announcement.Description;
271+
document.CultureCode = moduleInfo.CultureCode;
272+
document.Description = announcement.Description;
273+
document.IsActive = CheckIfAnnouncementIsActive(announcement);
274+
document.ModifiedTimeUtc = announcement.LastModifiedOnDate;
275+
document.ModuleDefId = moduleInfo.ModuleDefID;
276+
document.ModuleId = moduleInfo.ModuleID;
277+
document.PortalId = moduleInfo.PortalID;
278+
document.TabId = moduleInfo.TabID;
279+
document.Title = announcement.Title;
280+
document.UniqueKey = moduleInfo.ModuleID.ToString();
281+
searchDocuments.Add(document);
288282
}
283+
return searchDocuments;
284+
}
289285

290-
return searchItemCollection;
286+
private bool CheckIfAnnouncementIsActive(AnnouncementInfo announcement)
287+
{
288+
return (announcement.PublishDate < DateTime.Now && (announcement.ExpireDate == null || announcement.ExpireDate > DateTime.Now));
291289
}
292290

291+
293292
#endregion
294293

295294
#region IPortable Implementation
@@ -440,7 +439,7 @@ private AnnouncementInfo ImportAnnouncement(XmlNode xmlAnnouncement)
440439
{
441440
return null;
442441
}
443-
}
442+
}
444443

445444
#endregion
446445

Components/Business/IAnnouncementsController.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
using System;
2828
using System.Collections.Generic;
29-
29+
using DotNetNuke.Entities.Modules;
3030
using DotNetNuke.Entities.Users;
3131

3232
#endregion
@@ -53,7 +53,7 @@ public interface IAnnouncementsController
5353

5454
IEnumerable<AnnouncementInfo> GetExpiredAnnouncements(int moduleId);
5555

56-
void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, String journalType);
56+
void AddAnnouncementToJournal(AnnouncementInfo announcement, String journalType, ModuleInfo moduleInfo);
5757

5858
void SendNotifications(AnnouncementInfo announcement);
5959

Components/Settings/Settings.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public Settings(int moduleId, int tabModuleId)
8080
_moduleId = moduleId;
8181
_tabModuleId = tabModuleId;
8282

83-
var mc = new ModuleController();
84-
ModuleSettings = mc.GetModuleSettings(_moduleId);
85-
TabModuleSettings = mc.GetTabModuleSettings(_tabModuleId);
83+
var moduleInfo = new ModuleController().GetModule(_moduleId);
84+
ModuleSettings = moduleInfo.ModuleSettings;
85+
TabModuleSettings = moduleInfo.TabModuleSettings;
8686

8787
History = TabModuleSettings.GetInteger(SettingName.History, _History);
8888
DescriptionLength = TabModuleSettings.GetInteger(SettingName.DescriptionLength, _DescriptionLength);
@@ -120,7 +120,9 @@ public void Update()
120120

121121

122122
ModuleController.SynchronizeModule(_moduleId);
123-
DataCache.RemoveCache(ModuleController.CacheKey(_moduleId) + "_viewType");
123+
// DataCache.RemoveCache(ModuleController.CacheKey(_moduleId) + "_viewType");
124+
// Module caching has been updated in 5.2.0, this method is no longer used
125+
124126
DataCache.RemoveCache(CacheConstants.SettingsCacheKeyFormat(_moduleId, _tabModuleId));
125127

126128
}

Documentation/releasenotes.txt

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
MODULE: DotNetNuke Announcements Module
2+
3+
Version: 07.02.00
4+
Minimum Required DNN Version: 8.0.0
5+
6+
* Replaced all deprecated APIs usage
7+
* Tested for Dnn 9.2.0 compatibility
8+
9+
------------------------------------
10+
211
Version: 07.00.00 CTP
312
Minimum Required DNN Version: 7.0.0 RC
413

0 commit comments

Comments
 (0)