diff --git a/.gitignore b/.gitignore index 57a1574..d75c90d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,51 +1,32 @@ +################# +## Visual Studio +################# + ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user -*.userosscache *.sln.docstates +*.local.sln +*.sln.GhostDoc.xml -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studo 2015 cache/options directory +## Ignore VS2015/Roslyn artifacts +*.sln.ide/ .vs/ -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c +## Ignore Webstorm artifacts +*.idea/ +# Build results +[Rr]elease *_i.c *_p.c -*_i.h *.ilk *.meta *.obj *.pch -*.pdb *.pgc *.pgd *.rsp @@ -54,143 +35,184 @@ dlldata.c *.tli *.tlh *.tmp -*.tmp_proj -*.log +*.eml *.vspscc -*.vssscc .builds -*.pidb -*.svclog -*.scc +*.dotCover +*.ldf -# Chutzpah Test files -_Chutzpah* +# git merge artifacts +*.orig +*.gitmodules -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile +## TODO: If you have NuGet Package Restore enabled, uncomment this +[Pp]ackages/ # Visual Studio profiler *.psess *.vsp -*.vspx - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState # ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding addin-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Windows Azure Build Output -csx/ -*.build.csdef - -# Windows Store app package directory -AppPackages/ +_ReSharper* # Others -*.[Cc]ache -ClientBin/ -[Ss]tyle[Cc]op.* + +[Oo]bj +TestResults +*.Cache +ClientBin +stylecop.* ~$* -*~ *.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg -# Visual Studio 6 workspace options file -*.opt +############ +## DNN +############ + +# Ignore artifacts from deployed/installed site + +DNN_*.zip + +!DNN [Pp]latform/[Cc]omponents +!DNN [Pp]latform/[Cc]ontrols +DNN [Pp]latform/[Cc]omponents/[Cc]lient[Dd]ependency/[Ss]ource/[Bb]in +DNN [Pp]latform/[Cc]ontrols/[Cc]ountry[Ll]ist[Bb]ox/[Bb]in/* + +DNN [Pp]latform/*/[Bb]in +DNN [Pp]latform/Tests/*/[Bb]in/* +DNN [Pp]latform/Modules/*/[Bb]in/* +DNN [Pp]latform/Admin Modules/*/[Bb]in/* +DNN [Pp]latform/MVC Modules/*/[Bb]in/* +DNN [Pp]latform/[Pp]roviders/*/*/[Bb]in/* +DNN [Pp]latform/[Pp]roviders/*/*/*/[Bb]in/* +DNN [Pp]latform/Syndication/[Bb]in/* + + +[Ww]ebsite/*/[Dd]efault.aspx + +[Ww]ebsite/[Aa]dmin/[Pp]ersonabar + +[Ww]ebsite/[Aa]pp_[Cc]ode + +[Ww]ebsite/[Aa]pp_[Dd]ata + +[Ww]ebsite/[Bb]in + +[Ww]ebsite/[Cc]onfig + +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Ff]ifty[Oo]ne[Cc]lient[Cc]apability[Pp]rovider +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Rr]ad[Ee]ditor[Pp]rovider +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Tt]axonomy +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Uu]rl[Mm]anagement +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Hh]tml[Ee]ditor[Mm]anager +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Rr]ecycle[Bb]in +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]dmin/[Nn]ewsletters + +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]uthentication[Ss]ervices/[Ff]acebook +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]uthentication[Ss]ervices/[Gg]oogle +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]uthentication[Ss]ervices/[Ll]ive +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]uthentication[Ss]ervices/[Tt]witter +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]uthentication[Ss]ervices/DNN[Pp]ro_[Aa]ctive[Dd]irectory + +[Ww]ebsite/[Dd]esktop[Mm]odules/[Cc]ore[Mm]essaging +[Ww]ebsite/[Dd]esktop[Mm]odules/DDRMenu +[Ww]ebsite/[Dd]esktop[Mm]odules/[Dd]evice[Pp]review[Mm]anagement +[Ww]ebsite/[Dd]esktop[Mm]odules/[Dd]igital[Aa]ssets +[Ww]ebsite/[Dd]esktop[Mm]odules/DNNCorp +[Ww]ebsite/[Dd]esktop[Mm]odules/[Dd][Nn][Nn] +[Ww]ebsite/[Dd]esktop[Mm]odules/HTML +[Ww]ebsite/[Dd]esktop[Mm]odules/MVC +[Ww]ebsite/[Dd]esktop[Mm]odules/[Jj]ournal +[Ww]ebsite/[Dd]esktop[Mm]odules/[Mm]ember[Dd]irectory +[Ww]ebsite/[Dd]esktop[Mm]odules/[Mm]obile[Mm]anagement +[Ww]ebsite/[Dd]esktop[Mm]odules/[Rr]azor[Mm]odules +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ss]ocial[Gg]roups +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ss]ubscriptions[Mm]gmt +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ii]dentity[Ss]witcher +[Ww]ebsite/[Dd]esktop[Mm]odules/[Bb]log +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ii][Ff]rame +[Ww]ebsite/[Dd]esktop[Mm]odules/[Aa]nnouncements +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ee]vents +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ff]eedback +[Ww]ebsite/[Dd]esktop[Mm]odules/[Ff][Aa][Qq]s +[Ww]ebsite/[Dd]esktop[Mm]odules/[Mm]edia +[Ww]ebsite/[Dd]esktop[Mm]odules/[Uu]ser[Dd]efined[Tt]able +[Ww]ebsite/[Dd]esktop[Mm]odules/dnnGlimpse +[Ww]ebsite/[Dd]esktop[Mm]odules/[Tt]est* + +[Ww]ebsite/[Ii]nstall/*/*.zip +[Ww]ebsite/[Ii]nstall/*/*.resources +[Ww]ebsite/[Ii]nstall/[Cc]leanup +[Ww]ebsite/[Ii]nstall/[Cc]onfig +[Ww]ebsite/[Ii]nstall/[Dd]ot[Nn]et[Nn]uke.install.config +[Ww]ebsite/[Ii]nstall/installstat.log.resources.txt +[Ww]ebsite/[Ii]nstall/upgradestat.log.resources.txt + +[Ww]ebsite/[Ll]icenses/*.txt + +[Ww]ebsite/[Mm]odules + +[Ww]ebsite/[Pp]ortals/_default/[Ll]ogs +[Ww]ebsite/[Pp]ortals/_default/[Mm]erged[Tt]emplate +[Ww]ebsite/[Pp]ortals/_default/[Bb]lank [Ww]ebsite*.* +[Ww]ebsite/[Pp]ortals/_default/[Dd]efault [Ww]ebsite*.* +[Ww]ebsite/[Pp]ortals/_default/[Mm]obile [Ww]ebsite*.* +[Ww]ebsite/[Pp]ortals/_default/[Cc]ontainers/*/thumbnail*.jpg +[Ww]ebsite/[Pp]ortals/_default/[Cc]ontainers/[Cc]avalier/*.* +[Ww]ebsite/[Pp]ortals/_default/[Ss]kins/*/thumbnail*.jpg +[Ww]ebsite/[Pp]ortals/_default/[Ss]kins/[Cc]avalier +[Ww]ebsite/[Pp]ortals/_default/[Ss]kins/[Cc]avalier/*/*.* + +[Ww]ebsite/[Pp]ortals/_default/[Uu]ser* +[Ww]ebsite/[Pp]ortals/[0-9]*/ + +[Ww]ebsite/[Pp]roviders/[Dd]ata[Pp]roviders/*/*.resources +[Ww]ebsite/[Pp]roviders/*/*/license.txt +[Ww]ebsite/[Pp]roviders/*/*/release[Nn]otes.txt +[Ww]ebsite/[Pp]roviders/[Ff]older[Pp]roviders + +[Ww]ebsite/[Rr]esources/[Ll]ibraries + +[Ww]ebsite/[Ss]ignatures + +[Ww]ebsite/51[Dd]egrees.mobi.config +[Ww]ebsite/[Dd]ot[Nn]et[Nn]uke.log4net.config +[Ww]ebsite/[Dd]ot[Nn]et[Nn]uke.config +[Ww]ebsite/[Ss]ite[Aa]nalytics.config +[Ww]ebsite/[Ss]ite[Uu]rls.config +[Ww]ebsite/web.config +[Ww]ebsite/app_offline.htm + +# ignore all other language resx files +*.de-DE.resx +*.es-ES.resx +*.fr-FR.resx +*.it-IT.resx +*.nl-NL.resx + +# but do track translations in the Install folder +![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.de-DE.resx +![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.es-ES.resx +![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.fr-FR.resx +![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.it-IT.resx +![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.nl-NL.resx + +*.zip.manifest + +############ +## Windows +############ + +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini +Website/Install/Temp/ diff --git a/07.00.00.txt b/07.00.00.txt new file mode 100644 index 0000000..5845e99 --- /dev/null +++ b/07.00.00.txt @@ -0,0 +1,32 @@ +Install\Module\Announcements_03.04.00_Install.resources +Install\Module\Announcements_03.04.00_Source.resources +Install\Module\Announcements_03.04.00_Install.zip +Install\Module\Announcements_03.04.00_Source.zip +Install\Module\Announcements_03.03.05_Install.resources +Install\Module\Announcements_03.03.05_Source.resources +Install\Module\Announcements_03.03.05_Install.resources +Install\Module\Announcements_03.03.05_Source.resources +Install\Module\Announcements_03.03.04_Install.resources +Install\Module\Announcements_03.03.04_Source.resources +Install\Module\Announcements_03.03.03_Install.resources +Install\Module\Announcements_03.03.03_Source.resources +Install\Module\Announcements_03.03.02_Install.resources +Install\Module\Announcements_03.03.02_Source.resources +Install\Module\Announcements_04.00.00_Install.resources +Install\Module\Announcements_04.00.00_Source.resources +Install\Module\Announcements_04.00.00_Install.zip +Install\Module\Announcements_04.00.00_Source.zip +Install\Module\Announcements_04.00.01_Install.resources +Install\Module\Announcements_04.00.01_Source.resources +Install\Module\Announcements_04.00.01_Install.zip +Install\Module\Announcements_04.00.01_Source.zip +Install\Module\Announcements_04.00.02_Install.resources +Install\Module\Announcements_04.00.02_Source.resources +Install\Module\Announcements_04.00.02_Install.zip +Install\Module\Announcements_04.00.02_Source.zip +DesktopModules\Announcements\04.00.00.txt +DesktopModules\Announcements\04.00.01.txt +DesktopModules\Announcements\04.00.02.txt +DesktopModules\Announcements\uninstall.sqldataprovider +DesktopModules\Announcements\04.00.03.txt +bin\DotNetNuke.Modules.Announcements.SqlDataProvider.dll \ No newline at end of file diff --git a/AnnouncementsEdit.ascx b/AnnouncementsEdit.ascx new file mode 100644 index 0000000..ec2c6cc --- /dev/null +++ b/AnnouncementsEdit.ascx @@ -0,0 +1,137 @@ +<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="AnnouncementsEdit.ascx.cs" + Inherits="DotNetNuke.Modules.Announcements.AnnouncementsEdit" %> +<%@ Register Assembly="DotNetNuke" Namespace="DotNetNuke.UI.UserControls" TagPrefix="dnn" %> +<%@ Register TagPrefix="dnn" TagName="TextEditor" Src="~/controls/TextEditor.ascx" %> +<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +<%@ Register TagPrefix="dnn" TagName="Tracking" Src="~/controls/URLTrackingControl.ascx" %> +<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %> +<%@ Register TagPrefix="dnn" TagName="URL" Src="~/controls/URLControl.ascx" %> +<%@ Register TagPrefix="dnn" TagName="FilePickerUploader" Src="~/controls/filepickeruploader.ascx" %> +<%@ Import Namespace="DotNetNuke.Services.Localization" %> +<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %> +<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %> +
+ +
+
+
+
+ + + +
+
+

+ + <%=LocalizeString("plDescription")%>

+
+
+ + + +
+
+
+
+ +
+
+
+ + + + +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
<%=LocalizeString("plAudit")%>
+ +
+
+
<%=LocalizeString("plTracking")%>
+ +
+
+
+ +
+
+ + diff --git a/AnnouncementsEdit.ascx.cs b/AnnouncementsEdit.ascx.cs new file mode 100644 index 0000000..980db12 --- /dev/null +++ b/AnnouncementsEdit.ascx.cs @@ -0,0 +1,298 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Data.SqlTypes; +using System.Globalization; + +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Framework; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Presenters; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Web.Client; +using DotNetNuke.Web.Client.ClientResourceManagement; +using DotNetNuke.Web.Mvp; +using DotNetNuke.Web.UI.WebControls; + +using WebFormsMvp; + +#endregion + +namespace DotNetNuke.Modules.Announcements +{ + + /// + /// The EditAnnouncements PortalModuleBase is used to manage Announcements + /// + /// + /// + [PresenterBinding(typeof(AnnouncementsEditPresenter))] + public partial class AnnouncementsEdit : ModuleView, IAnnouncementsEdit + { + + public event EventHandler GetSettings; + public event EventHandler GetItem; + public event EventHandler GetAnnouncement; + public event EventHandler DeleteAnnouncement; + public event EventHandler UpdateAnnouncement; + + override protected void OnInit(EventArgs e) + { + base.OnInit(e); + + jQuery.RequestDnnPluginsRegistration(); + + ClientResourceManager.RegisterStyleSheet(Page, Globals.ApplicationPath + "/DesktopModules/Announcements/AnnouncementsEdit.css", FileOrder.Css.ModuleCss); + + cmdDelete.Click += CmdDeleteClick; + cmdUpdate.Click += CmdUpdateClick; + } + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + try + { + + GetSettings(this, EventArgs.Empty); + GetItem(this, new EditItemEventArgs(Request.QueryString["ItemID"])); + GetAnnouncement(this, new EditItemEventArgs(Model.ItemId)); + + ApplySettings(); + if (Page.IsPostBack == false) + { + BindForm(); + } + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + /// + /// cmdDelete_Click runs when the delete button is clicked + /// + /// + /// + /// + private void CmdDeleteClick(object sender, EventArgs e) + { + try + { + DeleteAnnouncement(this, new EditItemEventArgs(Model.ItemId)); + Response.Redirect(ReturnURL, false); + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + + /// + /// cmdUpdate_Click runs when the update button is clicked + /// + /// + /// + /// + private void CmdUpdateClick(object sender, EventArgs e) + { + try + { + // verify data + if (Page.IsValid) + { + AnnouncementInfo announcement; + if (Model.IsAddMode) + { + // new item, create new announcement + announcement = new AnnouncementInfo + { + ItemID = Model.ItemId, + ModuleID = ModuleContext.ModuleId, + PortalID = ModuleContext.PortalId, + CreatedByUserID = ModuleContext.PortalSettings.UserId, + CreatedOnDate = DateTime.Now + }; + } + else + { + // updating existing item, load it + announcement = Model.AnnouncementInfo; + } + + announcement.Title = txtTitle.Text; + announcement.ImageSource = urlImage.FilePath; + announcement.Description = teDescription.Text; + announcement.URL = ctlURL.Url; + announcement.PublishDate = GetDateTimeValue(publishDate, publishTime, DateTime.Now); + announcement.ExpireDate = GetDateTimeValue(expireDate, expireTime); + announcement.LastModifiedByUserID = ModuleContext.PortalSettings.UserId; + announcement.LastModifiedOnDate = DateTime.Now; + if (txtViewOrder.Text != "") + { + announcement.ViewOrder = Convert.ToInt32(txtViewOrder.Text); + } + + UpdateAnnouncement(this, new EditItemEventArgs(announcement)); + + // url tracking + var objUrls = new UrlController(); + objUrls.UpdateUrl(ModuleContext.PortalId, ctlURL.Url, ctlURL.UrlType, ctlURL.Log, ctlURL.Track, ModuleContext.ModuleId, ctlURL.NewWindow); + + // redirect back to page + Response.Redirect(ReturnURL, true); + + } + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + private void BindForm() + { + if (!Model.IsAddMode) + { + if (Model.AnnouncementInfo != null) + { + txtTitle.Text = Model.AnnouncementInfo.Title; + urlImage.FilePath = Model.AnnouncementInfo.ImageSource; + teDescription.Text = Model.AnnouncementInfo.Description; + ctlURL.Url = Model.AnnouncementInfo.URL; + if (!Null.IsNull(Model.AnnouncementInfo.ViewOrder)) + { + txtViewOrder.Text = Convert.ToString(Model.AnnouncementInfo.ViewOrder); + } + if ((!Null.IsNull(Model.AnnouncementInfo.PublishDate)) && + (Model.AnnouncementInfo.PublishDate != (DateTime)SqlDateTime.Null)) + { + publishDate.SelectedDate = Model.AnnouncementInfo.PublishDate; + publishTime.SelectedDate = Model.AnnouncementInfo.PublishDate; + } + if ((!Null.IsNull(Model.AnnouncementInfo.ExpireDate)) && + (Model.AnnouncementInfo.ExpireDate != (DateTime)SqlDateTime.Null)) + { + expireDate.SelectedDate = Model.AnnouncementInfo.ExpireDate; + expireTime.SelectedDate = Model.AnnouncementInfo.ExpireDate; + } + + ctlAudit.CreatedDate = Model.AnnouncementInfo.CreatedOnDate.ToString(CultureInfo.InvariantCulture); + ctlAudit.CreatedByUser = Model.AnnouncementInfo.CreatedByUserID.ToString(CultureInfo.InvariantCulture); + ctlAudit.LastModifiedByUser = Model.AnnouncementInfo.LastModifiedByUserID.ToString(CultureInfo.InvariantCulture); + ctlAudit.LastModifiedDate = Model.AnnouncementInfo.LastModifiedOnDate.ToString(CultureInfo.InvariantCulture); + ctlTracking.URL = Model.AnnouncementInfo.URL; + ctlTracking.ModuleID = ModuleContext.ModuleId; + } + } + } + + private void ApplySettings() + { + teDescription.Height = Model.Settings.EditorHeight; + cancelHyperLink.NavigateUrl = ReturnURL; + + urlImage.FileFilter = Globals.glbImageFileTypes; + + ctlURL.ShowLog = true; + ctlURL.ShowNewWindow = true; + ctlURL.ShowTrack = true; + ctlURL.ShowUsers = true; + + cmdDelete.Visible = !Model.IsAddMode; + ctlAudit.Visible = !Model.IsAddMode; + ctlTracking.Visible = !Model.IsAddMode; + + + } + + protected string ActiveDnnTab + { + get + { + var activeTab = Request.QueryString["activeTab"]; + if (!string.IsNullOrEmpty(activeTab)) + { + var tabControl = FindControl(activeTab); + if (tabControl != null) + { + return tabControl.ClientID; + } + } + + return string.Empty; + } + } + + private string ReturnURL + { + get + { + var returnValue = UrlUtils.ValidReturnUrl(Request.Params["ReturnURL"]); + if (string.IsNullOrEmpty(returnValue)) + returnValue = Globals.NavigateURL(); + return returnValue; + } + } + + private DateTime? GetDateTimeValue(DnnDatePicker dnnDatePicker, DnnTimePicker dnnTimePicker) + { + DateTime? resultValue = null; + + if (dnnDatePicker.SelectedDate != null) + { + resultValue = dnnDatePicker.SelectedDate; + } + if ((dnnTimePicker.SelectedTime != null) && (resultValue.HasValue)) + { + resultValue = resultValue.Value.Add((TimeSpan)dnnTimePicker.SelectedTime); + } + return resultValue; + } + + private DateTime? GetDateTimeValue(DnnDatePicker dnnDatePicker, DnnTimePicker dnnTimePicker, DateTime defaultValue) + { + DateTime? resultValue = GetDateTimeValue(dnnDatePicker, dnnTimePicker); + + if (!resultValue.HasValue) + { + resultValue = defaultValue; + } + + return resultValue; + } + + + } + +} \ No newline at end of file diff --git a/AnnouncementsEdit.ascx.designer.cs b/AnnouncementsEdit.ascx.designer.cs new file mode 100644 index 0000000..7e93a54 --- /dev/null +++ b/AnnouncementsEdit.ascx.designer.cs @@ -0,0 +1,276 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetNuke.Modules.Announcements { + + + public partial class AnnouncementsEdit { + + /// + /// contentTab control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl contentTab; + + /// + /// imageLinksTab control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl imageLinksTab; + + /// + /// publishingTab control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl publishingTab; + + /// + /// auditingTab control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl auditingTab; + + /// + /// plTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plTitle; + + /// + /// txtTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtTitle; + + /// + /// valTitle control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator valTitle; + + /// + /// teDescription control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.TextEditor teDescription; + + /// + /// valDescription control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RequiredFieldValidator valDescription; + + /// + /// plImage control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plImage; + + /// + /// urlImage control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.DnnFilePickerUploader urlImage; + + /// + /// plURL control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plURL; + + /// + /// ctlURL control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.UrlControl ctlURL; + + /// + /// plViewOrder control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plViewOrder; + + /// + /// txtViewOrder control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtViewOrder; + + /// + /// valViewOrder control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CompareValidator valViewOrder; + + /// + /// plPublishDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plPublishDate; + + /// + /// publishDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.DnnDatePicker publishDate; + + /// + /// plPublishTime control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plPublishTime; + + /// + /// publishTime control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.DnnTimePicker publishTime; + + /// + /// plExpireDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plExpireDate; + + /// + /// expireDate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.DnnDatePicker expireDate; + + /// + /// plExpireTime control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plExpireTime; + + /// + /// expireTime control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.Web.UI.WebControls.DnnTimePicker expireTime; + + /// + /// ctlAudit control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.ModuleAuditControl ctlAudit; + + /// + /// ctlTracking control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.URLTrackingControl ctlTracking; + + /// + /// cmdUpdate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdUpdate; + + /// + /// cmdDelete control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdDelete; + + /// + /// cancelHyperLink control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HyperLink cancelHyperLink; + } +} diff --git a/AnnouncementsEdit.css b/AnnouncementsEdit.css new file mode 100644 index 0000000..a1248ec --- /dev/null +++ b/AnnouncementsEdit.css @@ -0,0 +1,44 @@ +.dnnAnnouncementForm .urlControl { + width: 420px; +} + +.dateDiv { display: inline-block;width: 75px; margin-bottom: 20px} + +.urlControlLinkType span, .dnnFormItem .urlControlLinkType span { +float: none; +display: inline; +width: auto; +text-align: left; +} + +/*.rcTimePopup { +background-image: url('images/clock.gif'); +position: absolute!important; +right: 3px; +bottom: 5px; +}*/ + +table.RadCalendarTimeView { + background-color: #fff!important; +} + +.dnnAnn_Audit { + background: #f5f5f5; /* Old browsers */ + background: -moz-linear-gradient(top, #f5f5f5 0%, #ececec 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f5f5), color-stop(100%,#ececec)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #f5f5f5 0%,#ececec 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #f5f5f5 0%,#ececec 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #f5f5f5 0%,#ececec 100%); /* IE10+ */ + background: linear-gradient(top, #f5f5f5 0%,#ececec 100%); /* W3C */ + + text-shadow: 0px 1px 0px #ffffff; + color:#555; + + padding: 10px; + margin-bottom: 10px; + width: 90% +} + +.dnnAnn_bold { + font-weight: bold; +} \ No newline at end of file diff --git a/AnnouncementsSettings.ascx b/AnnouncementsSettings.ascx new file mode 100644 index 0000000..d9d9f1f --- /dev/null +++ b/AnnouncementsSettings.ascx @@ -0,0 +1,40 @@ +<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="AnnouncementsSettings.ascx.cs" Inherits="DotNetNuke.Modules.Announcements.AnnouncementsSettings" %> +<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +<%@ Register TagPrefix="Portal" TagName="URL" Src="~/controls/URLControl.ascx" %> + +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
diff --git a/AnnouncementsSettings.ascx.cs b/AnnouncementsSettings.ascx.cs new file mode 100644 index 0000000..ba99491 --- /dev/null +++ b/AnnouncementsSettings.ascx.cs @@ -0,0 +1,113 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Web.UI.WebControls; + +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Presenters; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Services.Localization; +using DotNetNuke.Web.Mvp; + +using WebFormsMvp; + +#endregion + +namespace DotNetNuke.Modules.Announcements +{ + + /// + /// The Settings ModuleSettingsBase is used to manage the + /// settings for the Links Module + /// + /// + /// + [PresenterBinding(typeof(AnnouncementsSettingsPresenter))] + public partial class AnnouncementsSettings : SettingsView, IAnnouncementsSettings + { + public event EventHandler GetSettings; + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + try + { + GetSettings(this, EventArgs.Empty); + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + + } + + protected override void OnSettingsLoaded() + { + base.OnSettingsLoaded(); + + try + { + txtHistory.Text = Model.Settings.History.ToDnnString(); + txtDescriptionLength.Text = Model.Settings.DescriptionLength.ToDnnString(); + txtEditorHeight.Text = Model.Settings.EditorHeight.ToDnnString(); + foreach (Enum i in Enum.GetValues(typeof(ViewTypes))) + { + ddlViewType.Items.Add(new ListItem(Localization.GetString(Enum.GetName(typeof(ViewTypes), i), LocalResourceFile), Enum.GetName(typeof(ViewTypes), i))); + } + ddlViewType.SelectedValue = Utilities.ViewTypeToString(Model.Settings.DefaultViewType); + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + protected override void OnSavingSettings() + { + base.OnSavingSettings(); + try + { + + Model.Settings.DefaultViewType = Utilities.StringToViewType(ddlViewType.SelectedValue); + Model.Settings.History = txtHistory.Text.ToDnnInt(); + Model.Settings.DescriptionLength = txtDescriptionLength.Text.ToDnnInt(); + Model.Settings.EditorHeight = txtEditorHeight.Text.ToDnnInt(); + + Model.Settings.Update(); + + } + catch (Exception exc) + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + } + +} diff --git a/AnnouncementsSettings.ascx.designer.cs b/AnnouncementsSettings.ascx.designer.cs new file mode 100644 index 0000000..7876def --- /dev/null +++ b/AnnouncementsSettings.ascx.designer.cs @@ -0,0 +1,114 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetNuke.Modules.Announcements { + + + public partial class AnnouncementsSettings { + + /// + /// plHistory control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UserControl plHistory; + + /// + /// txtHistory control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtHistory; + + /// + /// valHistory control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CompareValidator valHistory; + + /// + /// plDefaultView control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UserControl plDefaultView; + + /// + /// ddlViewType control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DropDownList ddlViewType; + + /// + /// plDescriptionLength control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UserControl plDescriptionLength; + + /// + /// txtDescriptionLength control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtDescriptionLength; + + /// + /// valDescriptionLength control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CompareValidator valDescriptionLength; + + /// + /// plEditorHeight control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.UserControl plEditorHeight; + + /// + /// txtEditorHeight control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtEditorHeight; + + /// + /// valEditorHeight control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CompareValidator valEditorHeight; + } +} diff --git a/AnnouncementsView.ascx b/AnnouncementsView.ascx new file mode 100644 index 0000000..baacc6f --- /dev/null +++ b/AnnouncementsView.ascx @@ -0,0 +1,2 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AnnouncementsView.ascx.cs" Inherits="DotNetNuke.Modules.Announcements.AnnouncementsView" %> + diff --git a/AnnouncementsView.ascx.cs b/AnnouncementsView.ascx.cs new file mode 100644 index 0000000..1603f88 --- /dev/null +++ b/AnnouncementsView.ascx.cs @@ -0,0 +1,84 @@ +using System; +using System.IO; + +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Modules.Actions; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Template; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Presenters; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Security; +using DotNetNuke.Services.Localization; +using DotNetNuke.Web.Client.ClientResourceManagement; +using DotNetNuke.Web.Mvp; + +using WebFormsMvp; + +namespace DotNetNuke.Modules.Announcements +{ + [PresenterBinding(typeof(AnnouncementsViewPresenter))] + public partial class AnnouncementsView : ModuleView, IAnnouncementsView, IActionable + { + public event EventHandler GetSettings; + public event EventHandler GetAnnouncements; + public event EventHandler GetPermissions; + public event EventHandler GetTemplate; + public event EventHandler GetRenderedTemplate; + + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + GetSettings(this, EventArgs.Empty); + GetPermissions(this, EventArgs.Empty); + GetAnnouncements(this, EventArgs.Empty); + GetTemplate(this, EventArgs.Empty); + GetRenderedTemplate(this, EventArgs.Empty); + + litAnnouncements.Text = Model.RenderedTemplate; + + var localTemplate = (BaseTemplate)Model.Template; + if (!string.IsNullOrEmpty(localTemplate.JsFile) && File.Exists(Server.MapPath(localTemplate.JsFile))) + { + Framework.jQuery.RegisterJQuery(Page); + ClientResourceManager.RegisterScript(Page, localTemplate.JsFile); + } + if (!string.IsNullOrEmpty(localTemplate.CssFile) && File.Exists(Server.MapPath(localTemplate.CssFile))) + { + ClientResourceManager.RegisterStyleSheet(Page, localTemplate.CssFile); + } + + } + + #region IActionable Implementation + + /// ----------------------------------------------------------------------------- + /// + /// Gets the modules custom Actions + /// + /// ----------------------------------------------------------------------------- + public ModuleActionCollection ModuleActions + { + get + { + var actionCollection = new ModuleActionCollection + { + { + + ModuleContext.GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, LocalResourceFile), + ModuleActionType.AddContent, "", "add.gif", ModuleContext.EditUrl(), false, SecurityAccessLevel.Edit, true, false + } + }; + var moduleSecurity = new ModuleSecurity(ModuleContext.Configuration); + if (moduleSecurity.HasEditTemplatePermission) + { + actionCollection.Add(ModuleContext.GetNextActionID(), Localization.GetString("TemplateConfiguration.Action", LocalResourceFile), "Template", "", "icon_configuration_16px.png", ModuleContext.EditUrl("Template"), false, SecurityAccessLevel.View, true, false); + } + return actionCollection; + } + } + + #endregion + + } +} \ No newline at end of file diff --git a/AnnouncementsView.ascx.designer.cs b/AnnouncementsView.ascx.designer.cs new file mode 100644 index 0000000..db18b97 --- /dev/null +++ b/AnnouncementsView.ascx.designer.cs @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetNuke.Modules.Announcements { + + + public partial class AnnouncementsView { + + /// + /// litAnnouncements control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litAnnouncements; + } +} diff --git a/App_LocalResources/AnnouncementsEdit.ascx.resx b/App_LocalResources/AnnouncementsEdit.ascx.resx new file mode 100644 index 0000000..cd44a64 --- /dev/null +++ b/App_LocalResources/AnnouncementsEdit.ascx.resx @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Title + + + Enter a Title for the Announcment. Depending on the Skin and the template for this module, this title will appear in bold. + + + Description + + + Enter a description of the Announcement + + + Link + + + The Announcment can optionally link to an external URL, a Page within this site or to a File within this site. + + + Publish Date + + + Enter an Publish Date for the Announcement. The Announcement will only display from this date. + + + <br />You must enter a title for the announcement + + + <br />You must enter a description of the announcement + + + <br />You have entered an invalid date! + + + View Order + + + Enter the View Order for the Announcement. + + + <br />View order must be an integer value. + + + <h1>About the Announcements Module</h1> +<p>The Announcements Module produces a list of simple text announcements consisting +of a title and brief description. Options include a read more link to a file, page +or other site. Link click tracking and logging are also available. Announcements +are ordered from newest to oldest, unless a view order is specified.</p> +<h2>Adding or updating an announcement</h2> +<div> +<ol> + <li>Add an <b>Announcements</b> module, or go to an existing <b>Announcements</b> + module.</li> + <li>Click <b>Add New Announcement</b>. </li> + <li>At least complete the following <b>required</b> fields:<ol style="list-style-type:lower-alpha"> + <li>At <b>Title</b>, enter a title for the announcement.</li> + <li>At <b>Description</b>, enter a description of the Announcement.</li> + </ol> + </li> + <li>Additionally, you can enter information for the following <b>optional</b> + fields:<ol style="list-style-type:lower-alpha"> + <li>At <b>Image</b>, select an image to be displayed with this announcement</li> + <li>At <b>Link Type</b>, select <b>URL</b>, <b>Page</b>, <b>File + or User</b> + and then at <b>Link</b> select or enter the required link, page, file or + user + </li> + <li>At <b>Track Number Of Times This Link Is Clicked?</b> , check + the box if required.</li> + <li>At <b>Log The User, Date, And Time For Every Link Click</b>, + check the box if required.</li> + <li>At <b>Publish Date</b>, enter the date and time you want to publish the + announcement</li> + <li>At <b>Expire Date</b>, enter the date and time the announcement should expire + (hidden from view)</li> + <li>At <b>View Order</b>, enter the View Order for the Announcement. </li> + </ol> + </li> + <li>Click <b>Add </b>or<b> Update</b>.</li> +</ol> +</div> + + + Edit Announcements + + + <br />You must enter a date + + + Expire Date + + + <br />You have entered an invalid date! + + + The expiration date is the date from when the Announcement will be hidden from the normal view. + + + Image + + + Select and Image for the Announcement. + + + Content + + + Image & Link + + + Publishing + + + Optionally enter an exact expiration time. In conjuction with the expiration date, this will cause the Announcement to be hidden at this exact time. + + + Expiration Time + + + Optionaly, also enter a specific Publish Time. If ommited, the announcement will be published at midnight of the Publish Date exactly. + + + Publish Time + + + Auditing + + + Audit + + + URL Tracking + + \ No newline at end of file diff --git a/App_LocalResources/AnnouncementsSettings.ascx.resx b/App_LocalResources/AnnouncementsSettings.ascx.resx new file mode 100644 index 0000000..1942720 --- /dev/null +++ b/App_LocalResources/AnnouncementsSettings.ascx.resx @@ -0,0 +1,443 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + History (Days) + + + You Must Enter A Valid Number Of Days + + + Item Template + + + <h1> + About the Announcements Module</h1> +<p> + The Announcements Module produces a list of simple text announcements consisting + of a title and brief description. Options include a read more link to a file, page + or other site. Link click tracking and logging are also available. Announcements + are ordered from newest to oldest, unless a view order is specified.</p> +<h2> + Module Specific Settings</h2> +<p> + The following module specific settings are available:</p> +<ol> + <li><b>History Day(s)</b>: this is the number of days to display announcements for. + Announcements published longer than the entered number of days ago will not be displayed. + Eg. if you enter a value of 4, all announcements older than 4 days will not be displayed. + If you leave this field blank, then all announcements will be displayed</li> + <li><b>Default View</b>: you can select which view is visible for regular users (with + no edit rights for this module). <b>Tip</b>: if you put a copy of the same module + on a different page, this will allow you so easily make available archived/expired + items</li> + <li><strong>Description Length (Search and RSS)</strong>: with this option you can define + how many characters should be used to display a content sample for search and rss.</li> + <li><b>Editor Height</b>: this allows you to modify the height of the editor in the + edit view of the module</li> + <li><b>Templates</b>: This is the template that is used to display each announcement. + In this template you can use tokens to define where specific information of the + announcement items should be placed. NOTE: all tokens are case sensitive, and should + be capitals only. The following templates are available: Header, Item, Alternate + (odd), Separator and Footer</li> +</ol> +<p> + <b>This is the default template:<br /> + </b> + <table border="1" style="border-collapse: collapse"> + <tr> + <td valign="top" class="normalbold"> + <strong>Header Template </strong> + </td> + <td class="style5" valign="top" style="width: 901px"> + <span style="font-family: Courier New">&lt;table class=&quot;DNN_ANN_DesignTable&quot; + cellspacing=&quot;0&quot; Summary=&quot;Announcements Design Table&quot; border=&quot;0&quot; + style=&quot;border-collapse:collapse;&quot;&gt;&lt;tr&gt;&lt;td&gt;</span> + </td> + </tr> + <tr> + <td valign="top" class="normalbold"> + <strong>Item Template </strong> + </td> + <td class="style5" valign="top" style="width: 901px"> + <span style="font-family: Courier New">&lt;table&gt;&lt;tr&gt;&lt;td&gt;[IMAGESOURCE]&lt;/td&gt;&lt;td + valign="top"&gt;&lt;span class="SubHead"&gt;[EDIT][TITLE] - [PUBLISHDATE]&lt;/span&gt;&lt;div + class="Normal DNN_ANN_Description"&gt;[DESCRIPTION]&amp;nbsp;[READMORE]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</span> + </td> + </tr> + <tr> + <td valign="top" class="normalbold"> + <strong>Alternate Item Template </strong> + </td> + <td class="style5" valign="top" style="width: 901px"> + &nbsp; + </td> + </tr> + <tr> + <td valign="top" class="normalbold"> + <strong>Separator Template </strong> + </td> + <td class="style5" valign="top" style="width: 901px"> + &nbsp; + </td> + </tr> + <tr> + <td valign="top" class="normalbold"> + <strong>Footer Template </strong> + </td> + <td class="style5" valign="top" style="width: 901px"> + <span style="font-family: Courier New">&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</span> + </td> + </tr> + </table> +</p> +<p class="subhead"> + the following tokens can be used in templates:</p> +<table border="1" style="border-collapse: collapse" class="normal"> + <tr> + <td valign="top"> + <strong>[EDIT] </strong> + </td> + <td valign="top" class="Normal"> + This will render an edit pencil, if, and only if, the logged on user had edit rights + for the module. You MUST add this token to the Item Template (and alternate item + template if you are using that), in order to be able to edit items + </td> + </tr> + <tr> + <td valign="top"> + <strong>[ITEMID] </strong> + </td> + <td valign="top" class="Normal"> + This will render the item id of the announcement + </td> + </tr> + <tr> + <td valign="top"> + <strong>[MODULEID] </strong> + </td> + <td valign="top" class="Normal"> + This will render the module id of the module the announcement belongs to + </td> + </tr> + <tr> + <td valign="top"> + <strong>[CREATEDBYUSER] </strong> + </td> + <td valign="top" class="Normal"> + This will display the display name of the user that created the Announcement. <b>NOTE</b>: + on sites with many users adding this token to a template will cause a performance + hit, as for every Announcement a user record has to be found and displayed. Many + announcements and many users will cause a large amount of extra database hits. + </td> + </tr> + <tr> + <td valign="top" height="25"> + <strong>[CREATEDDATE] </strong> + </td> + <td valign="top" height="25" class="Normal"> + This will show the item creation date, in localized long date forum + </td> + </tr> + <tr> + <td valign="top"> + <strong>[DESCRIPTION] </strong> + </td> + <td valign="top" class="Normal"> + This will display the announcement discription + </td> + </tr> + <tr> + <td valign="top"> + <strong>[EXPIREDATE] </strong> + </td> + <td valign="top" class="Normal"> + This will display the announcements expire date + </td> + </tr> + <tr> + <td valign="top"> + <strong>[RAWIMAGE] </strong> + </td> + <td valign="top" class="Normal"> + Thsi will display the raw image url + </td> + </tr> + <tr> + <td valign="top"> + <strong>[IMAGESOURCE] </strong> + </td> + <td valign="top" class="Normal"> + This will display the announcement image as defined in the announcement. A complete + image tag will be rendered + </td> + </tr> + <tr> + <td valign="top"> + <strong>[MODULEID] </strong> + </td> + <td valign="top" class="Normal"> + This will display the moduleid of the module.<br> + <b>TIP</b>: You could use this value to use a module specific css classname, for + instance like this: <font face="Courier New"> + <br> + &lt;span class=&quot;SubHead_[MODULEID]&quot;&gt;[TITLE]&lt;/span&gt;</font> + </td> + </tr> + <tr> + <td valign="top"> + <strong>[MORE] </strong> + </td> + <td valign="top" class="Normal"> + This will display the &quot;read more...&quot; text, without hyperlink. A full read + more hyperlink would look like this:<br> + <font face="Courier New">&lt;a href=&quot;[URL]&quot; target=&quot;[NEWWINDOW]&quot;&gt;[MORE]&lt;/a&gt;</font> + </td> + </tr> + <tr> + <td valign="top"> + <strong>[READMORE] </strong> + </td> + <td valign="top" class="Normal"> + This will display a complete &quot;read more...&quot; link. If no url is defined + in the announcement, no link will be rendered + </td> + </tr> + <tr> + <td valign="top"> + <strong>[NEWWINDOW] </strong> + </td> + <td valign="top" class="Normal"> + This token can be used to open the link in a new window, based on the selection + made in the announcement, for example: br> <font face="Courier New">&lt;a href=&quot;[URL]&quot; + target=&quot;[NEWWINDOW]&quot;&gt;[MORE]&lt;/a&gt;</font> + </td> + </tr> + <tr> + <td valign="top"> + <strong>[PUBLISHDATE] </strong> + </td> + <td valign="top" class="Normal"> + This will show the item publish date, in localized long date forum + </td> + </tr> + <tr> + <td valign="top"> + <strong>[TITLE] </strong> + </td> + <td valign="top" class="Normal"> + This will display the announcement title + </td> + </tr> + <tr> + <td valign="top"> + <strong>[TRACKCLICKS] </strong> + </td> + <td valign="top" class="Normal"> + This will render &quot;Yes&quot; or &quot;No&quot;, depending on whether to track + clicks or not + </td> + </tr> + <tr> + <td valign="top"> + <strong>[URL] </strong> + </td> + <td valign="top" class="Normal"> + This will display the url the announcement should point to. In order to use this + url as a clickable hyperlink, use something like this:< /br> <font face="Courier New"> + &lt;a href=&quot;[URL]&quot;&gt;[MORE]&lt;/a&gt;</font> + </td> + </tr> + <tr> + <td valign="top"> + <strong>[VIEWORDER] </strong> + </td> + <td valign="top" class="Normal"> + This will show the view order of the item + </td> + </tr> +</table> + + + Announcements Settings + + + This is the template that is used to display each item.<br><b>NOTE:</b> See Module Help for information about which tokens can be used. + + + Enter a number of days to display announcements for. Announcements published longer than the entered number of days ago will not be displayed. Leave blank to display all announcements. + + + This option lets you select wether you want to display items that have not been published yet (due to a publish date that lies in the future) + + + Display Future Items + + + Description Length (Search & RSS) + + + Specify the number of characters in the description used in search results and rss feeds<br /><b>Tip: </b>use 0 to use the maximum text length (2000 characters) + + + This is the template that is used to display alternate items. If no template is defined, then the normal item template is used for alternate items. + + + Alternate Item Template + + + This is the template that is used after displaying the last item + + + Footer Template + + + This is the template that is used prior to displaying the first item + + + Header Template + + + This is the template for the seperator + + + Separator Template + + + Are you sure? This will overwrite the existing template. + + + Load Default + + + This will load the default template for this item from the resource file + + + Select here the default view for the module + + + Default view + + + Enter a height for the editor. If empty, the default value of 300 will be used + + + Editor Height (px) + + \ No newline at end of file diff --git a/App_LocalResources/AnnouncementsView.ascx.resx b/App_LocalResources/AnnouncementsView.ascx.resx new file mode 100644 index 0000000..06f9363 --- /dev/null +++ b/App_LocalResources/AnnouncementsView.ascx.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Add New Announcement + + + <h1>About the Announcements Module</h1> +<p>The Announcements Module produces a list of simple text announcements consisting +of a title and brief description. Options include a read more link to a file, page +or other site. Link click tracking and logging are also available. Announcements +are ordered from newest to oldest, unless a view order is specified.</p> +<h2>Add an Announcement</h2> +<ol> + <li>Add an <b>Announcements</b> module, or go to an existing <b>Announcements</b> + module.</li> + <li>Click <b>Add New Announcement</b>. </li> + <li>At <b>Title</b>, enter a title for the announcement.</li> + <li>At <b>Add Date</b> (optional), remove the tick if you do not want the current + day and date to be displayed beside the title.</li> + <li>At <b>Description</b>, enter a description of the Announcement.</li> + <li>At <b>Link Type</b> (optional), select <b>URL</b>, <b>Page</b> or <b>File</b> + and then at <b>Link</b> select or enter the required link, page or file. + </li> + <li>At <b>Track Number Of Times This Link Is Clicked?</b> (optional), check + the box if required.</li> + <li>At <b>Log The User, Date, And Time For Every Link Click</b> (optional), + check the box if required.</li> + <li>At <b>View Order</b> (optional), enter the View Order for the Announcement. + </li> + <li>Click <b>Update</b>.</li> +</ol> + + + + Select View + + + Select one of the available views + + + No [EDIT] token found in your item template. Please update the template to include an [EDIT] token. + + + Template Configuration + + + Subscribe + + + Unsubscribe + + + This shows whether or not you are subscribed to this module + + + Subscription Status + + \ No newline at end of file diff --git a/App_LocalResources/SharedResources.resx b/App_LocalResources/SharedResources.resx new file mode 100644 index 0000000..ae6c9cd --- /dev/null +++ b/App_LocalResources/SharedResources.resx @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + <div class="DNN_ANN_ImageDiv">[IMAGESOURCE]</div><div><span class="SubHead">[EDIT][TITLE] - [PUBLISHDATE]</span><div class="Normal DNN_ANN_Description">[DESCRIPTION]&nbsp;[READMORE]</div></div> + + + read more ... + + + Unknown User + + + + + + </div> + + + <div class="DNN_ANN_DesignTable"> + + + + + + Edit Announcement + + + All + + + Current + + + Expired + + + Future + + + Edit Template + + \ No newline at end of file diff --git a/App_LocalResources/TemplateConfiguration.ascx.resx b/App_LocalResources/TemplateConfiguration.ascx.resx new file mode 100644 index 0000000..a7f1a34 --- /dev/null +++ b/App_LocalResources/TemplateConfiguration.ascx.resx @@ -0,0 +1,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + History (Days) + + + Item Template + + + Template Configuration + + + This is the template that is used to display each item.<br><b>NOTE:</b> See Module Help for information about which tokens can be used. + + + Enter a number of days to display announcements for. Announcements published longer than the entered number of days ago will not be displayed. Leave blank to display all announcements. + + + This is the template that is used to display alternate items. If no template is defined, then the normal item template is used for alternate items. + + + Alternate Item Template + + + This is the template that is used prior to displaying the first item + + + Header Template + + + This is the template for the seperator + + + Separator Template + + + Are you sure? This will overwrite the existing template. + + + This will load the default template for this item from the resource file + + + Load Default + + + <style> + .tableLeftColumn + { + width: 200px; + vertical-align: top; + } + + .tableRightColumn + { + width: 500px; + vertical-align: top; + } + .tableRow { + border: 1px; + border-color: black; + border-style: double; + } + .code { + font-family: Inconsolata, Consolas, Lucida Console, Monaco, Courier New, Courier, monospace; + background-color: lightyellow ; + } + </style> + <p><b>This is the default template:</b></p> + <table style="border-collapse: collapse;"> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>Header Template </strong> + </td> + <td class="normal tableRightColumn"> + <div class="code">&lt;table class=&quot;DNN_ANN_DesignTable&quot; + cellspacing=&quot;0&quot; Summary=&quot;Announcements Design Table&quot; border=&quot;0&quot; + style=&quot;border-collapse:collapse;&quot;&gt;&lt;tr&gt;&lt;td&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>Item Template </strong> + </td> + <td class="normal tableRightColumn"> + <div class="code">&lt;table&gt;&lt;tr&gt;&lt;td&gt;[IMAGESOURCE]&lt;/td&gt;&lt;td + &gt;&lt;span class="SubHead"&gt;[EDIT][TITLE] - [PUBLISHDATE]&lt;/span&gt;&lt;div + class="Normal DNN_ANN_Description"&gt;[DESCRIPTION]&amp;nbsp;[READMORE]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>Alternate Item Template </strong> + </td> + <td class="normal tableRightColumn">&nbsp; + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>Separator Template </strong> + </td> + <td class="normal tableRightColumn">&nbsp; + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>Footer Template </strong> + </td> + <td class="normal tableRightColumn"> + <div class="code">&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</div> + </td> + </tr> + </table> + <p><b>The following tokens can be used in templates:</b></p> + <table style="border-collapse: collapse;" > + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[EDIT] </strong> + </td> + <td class="normal tableRightColumn">This will render an edit pencil, if, and only if, the logged on user had edit rights + for the module. You MUST add this token to the Item Template (and alternate item + template if you are using that), in order to be able to edit items + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[ITEMID] </strong> + </td> + <td class="normal tableRightColumn">This will render the item id of the announcement + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[MODULEID] </strong> + </td> + <td class="normal tableRightColumn">This will render the module id of the module the announcement belongs to + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[CREATEDBYUSER] </strong> + </td> + <td class="normal tableRightColumn">This will display the display name of the user that created the Announcement. <b>NOTE</b>: + on sites with many users adding this token to a template will cause a performance + hit, as for every Announcement a user record has to be found and displayed. Many + announcements and many users will cause a large amount of extra database hits. + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[CREATEDDATE] </strong> + </td> + <td height="25" class="normal tableRightColumn">This will show the item creation date, in localized long date forum + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[DESCRIPTION] </strong> + </td> + <td class="normal tableRightColumn">This will display the announcement discription + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[EXPIREDATE] </strong> + </td> + <td class="normal tableRightColumn">This will display the announcements expire date + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[RAWIMAGE] </strong> + </td> + <td class="normal tableRightColumn">Thsi will display the raw image url + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[IMAGESOURCE] </strong> + </td> + <td class="normal tableRightColumn">This will display the announcement image as defined in the announcement. A complete + image tag will be rendered + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[MODULEID] </strong> + </td> + <td class="normal tableRightColumn">This will display the moduleid of the module.<br /> + <b>TIP</b>: You could use this value to use a module specific css classname, for + instance like this: <br /><div class="code">&lt;span class=&quot;SubHead_[MODULEID]&quot;&gt;[TITLE]&lt;/span&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[MORE] </strong> + </td> + <td class="normal tableRightColumn">This will display the &quot;read more...&quot; text, without hyperlink. A full read + more hyperlink would look like this:<br /> + <div class="code">&lt;a href=&quot;[URL]&quot; target=&quot;[NEWWINDOW]&quot;&gt;[MORE]&lt;/a&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[READMORE] </strong> + </td> + <td class="normal tableRightColumn">This will display a complete &quot;read more...&quot; link. If no url is defined + in the announcement, no link will be rendered + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[NEWWINDOW] </strong> + </td> + <td class="normal tableRightColumn">This token can be used to open the link in a new window, based on the selection + made in the announcement, for example:<br /> <div class="code">&lt;a href=&quot;[URL]&quot; + target=&quot;[NEWWINDOW]&quot;&gt;[MORE]&lt;/a&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[PUBLISHDATE] </strong> + </td> + <td class="normal tableRightColumn">This will show the item publish date, in localized long date forum + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[TITLE] </strong> + </td> + <td class="normal tableRightColumn">This will display the announcement title + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[TRACKCLICKS] </strong> + </td> + <td class="normal tableRightColumn">This will render &quot;Yes&quot; or &quot;No&quot;, depending on whether to track + clicks or not + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[URL] </strong> + </td> + <td class="normal tableRightColumn">This will display the url the announcement should point to. In order to use this + url as a clickable hyperlink, use something like this:<br/> <div class="code"> + &lt;a href=&quot;[URL]&quot;&gt;[MORE]&lt;/a&gt;</div> + </td> + </tr> + <tr class="tableRow"> + <td class="normalbold tableLeftColumn"> + <strong>[VIEWORDER] </strong> + </td> + <td class="normal tableRightColumn">This will show the view order of the item + </td> + </tr> + </table> + + + This is the template that is used after displaying the last item + + + Footer Template + + + Template Help + + \ No newline at end of file diff --git a/Components/Business/AnnouncementInfo.cs b/Components/Business/AnnouncementInfo.cs new file mode 100644 index 0000000..cdbce65 --- /dev/null +++ b/Components/Business/AnnouncementInfo.cs @@ -0,0 +1,482 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.ComponentModel; +using System.Globalization; +using System.Runtime.Serialization; +using System.Web; +using System.Web.Caching; +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.ComponentModel.DataAnnotations; +using DotNetNuke.Entities.Content; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Entities.Users; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Services.FileSystem; +using DotNetNuke.Services.Localization; +using DotNetNuke.Services.Tokens; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Business +{ + + /// + /// The AnnouncementInfo Class provides the Announcements Business Object + /// + [Serializable, XmlRoot("Announcement")] + [TableName("Announcements")] + [PrimaryKey("ItemID")] + [Scope("ModuleID")] + [Cacheable("Announcements", CacheItemPriority.Default, 20)] + public class AnnouncementInfo : IPropertyAccess, IXmlSerializable + { + #region Constructors + + /// ----------------------------------------------------------------------------- + /// + /// Constructs a new AnnouncementInfo instance + /// + /// + /// [erikvb] 11/19/2007 Described + /// + /// ----------------------------------------------------------------------------- + public AnnouncementInfo() + { + CreatedOnDate = DateTime.Now; + ExpireDate = null; + PublishDate = null; + CreatedByUserID = Null.NullInteger; + LastModifiedByUserID = Null.NullInteger; + LastModifiedOnDate = CreatedOnDate; + } + + #endregion + + #region DB Fields + + public int ItemID { get; set; } + public int ModuleID { get; set; } + public string Title { get; set; } + public string URL { get; set; } + public DateTime? ExpireDate { get; set; } + public string Description { get; set; } + public int ViewOrder { get; set; } + public DateTime? PublishDate { get; set; } + public string ImageSource { get; set; } + public int PortalID { get; set; } + public int ContentItemID { get; set; } + [IgnoreColumn] + public bool IsEditable { get; set; } + [Browsable(false), XmlIgnore] + public int CreatedByUserID { get; set; } + [Browsable(false), XmlIgnore] + public DateTime CreatedOnDate { get; set; } + [Browsable(false), XmlIgnore] + public int LastModifiedByUserID { get; set; } + [Browsable(false), XmlIgnore] + public DateTime LastModifiedOnDate { get; set; } + + #endregion + + #region NonDB Fields + + [IgnoreColumn] + public UserInfo CreatedByUser(int portalId) + { + if (CreatedByUserID > Null.NullInteger) + { + UserInfo user = UserController.GetUserById(portalId, CreatedByUserID); + return user; + } + return null; + } + + [IgnoreColumn] + public UserInfo LastModifiedByUser(int portalId) + { + if (LastModifiedByUserID > Null.NullInteger) + { + UserInfo user = UserController.GetUserById(portalId, LastModifiedByUserID); + return user; + } + return null; + } + + [IgnoreColumn] + public String Permalink() + { + string cacheKey = string.Format("announcement_{0}_{1}", ModuleID, ItemID); + return + CBO.GetCachedObject( + new CacheItemArgs(cacheKey, + DataCache.ModuleCacheTimeOut, + DataCache.ModuleControlsCachePriority, + ModuleID, + ItemID), PermalinkCallback); + } + + private object PermalinkCallback(CacheItemArgs cacheItemArgs) + { + var moduleID = (int) cacheItemArgs.ParamList[0]; + var itemID = (int) cacheItemArgs.ParamList[1]; + + var moduleInfo = new ModuleController().GetModule(moduleID); + var url = Globals.NavigateURL(moduleInfo.TabID, "", string.Format("itemid={0}", itemID)); + return url; + } + + private ContentItem _contentItem; + [IgnoreColumn] + public ContentItem ContentItem + { + get + { + if ((_contentItem == null) && ContentItemID != Null.NullInteger) + { + _contentItem = new ContentController().GetContentItem(ContentItemID); + } + return _contentItem; + } + } + + + + private UrlTrackingInfo _urlTrackingInfo; + + private UrlTrackingInfo UrlTrackingInfo + { + get { return _urlTrackingInfo ?? (_urlTrackingInfo = new UrlController().GetUrlTracking(PortalID, URL, ModuleID)); } + } + + private bool _trackClicks; + + [IgnoreColumn] + public bool TrackClicks + { + get { return UrlTrackingInfo.TrackClicks; } + set { _trackClicks = value; } + } + + private bool _newWindow; + + [IgnoreColumn] + public bool NewWindow + { + get { return UrlTrackingInfo != null && UrlTrackingInfo.NewWindow; } + set { _newWindow = value; } + } + + #endregion + + #region IXmlSerializable Implementation + + /// ----------------------------------------------------------------------------- + /// + /// GetSchema returns the XmlSchema for this class + /// + /// GetSchema is implemented as a stub method as it is not required + /// + /// [cnurse] 08/17/2007 Created + /// + /// ----------------------------------------------------------------------------- + public XmlSchema GetSchema() + { + return null; + } + + + private string readElement(XmlReader reader, string ElementName) + { + if ((reader.NodeType != XmlNodeType.Element) || reader.Name != ElementName) + { + reader.ReadToFollowing(ElementName); + } + return reader.NodeType == XmlNodeType.Element ? reader.ReadElementContentAsString() : ""; + } + + private bool CheckFileOrTab(string link) + { + return CheckFileOrTab(link, ""); + } + + private bool CheckFileOrTab(string link, string contentType) + { + int intId; + PortalSettings portal = Globals.GetPortalSettings(); + if (link.StartsWith("FileID=", StringComparison.OrdinalIgnoreCase)) + { + // the link is a file. Check wether it exists in the portal + if (Int32.TryParse(link.Replace("FileID=", ""), out intId)) + { + var objFileController = new FileController(); + FileInfo objFile = objFileController.GetFileById(intId, portal.PortalId); + if (objFile != null) + { + if ((!(string.IsNullOrEmpty(contentType))) && (!(objFile.ContentType.StartsWith(contentType, StringComparison.OrdinalIgnoreCase)))) + { + // the file exists but is of the wrong type + return false; + } + } + else + { + // the file does not exist for this portal + return false; + } + } + } + else if (Int32.TryParse(link, out intId)) + { + // the link is a tab + var objTabController = new Entities.Tabs.TabController(); + if (objTabController.GetTab(intId, portal.PortalId, false) == null) + { + // the tab does not exist + return false; + } + } + + // no reasons where found to reject the file + return true; + + } + + /// + /// ReadXml fills the object (de-serializes it) from the XmlReader passed + /// + /// + /// The XmlReader that contains the xml for the object + public void ReadXml(XmlReader reader) + { + try + { + + // when importing, ItemID will always be null.nullinteger (or -1) + Title = readElement(reader, "Title"); + URL = readElement(reader, "URL"); + if (!(CheckFileOrTab(URL))) + { + // check whether the the fileid exists in the portal and is in fact an image. + URL = ""; + } + int tempInt; + ViewOrder = !(Int32.TryParse(readElement(reader, "ViewOrder"), out tempInt)) ? Null.NullInteger : tempInt; + Description = readElement(reader, "Description"); + ImageSource = readElement(reader, "ImageSource"); + if (!(CheckFileOrTab(ImageSource, "image/"))) + { + // check whether the fileid exists in the portal and is in fact an image. + ImageSource = ""; + } + + + Boolean tempVar; + bool.TryParse(readElement(reader, "TrackClicks"), out tempVar); + TrackClicks = tempVar; + Boolean tempVar2; + bool.TryParse(readElement(reader, "NewWindow"), out tempVar2); + NewWindow = tempVar2; + + DateTime tempDateTime; + PublishDate = !(DateTime.TryParse(readElement(reader, "PublishDate"), out tempDateTime)) ? Null.NullDate : tempDateTime; + ExpireDate = !(DateTime.TryParse(readElement(reader, "ExpireDate"), out tempDateTime)) ? DateTime.MaxValue : tempDateTime; + + } + catch (Exception ex) + { + // log exception as DNN import routine does not do that + Exceptions.LogException(ex); + // re-raise exception to make sure import routine displays a visible error to the user + throw new Exception("An error occured during import of an Announcement", ex); + } + + } + + /// + /// WriteXml converts the object to Xml (serializes it) and writes it using the XmlWriter passed + /// + /// + /// The XmlWriter that contains the xml for the object + public void WriteXml(XmlWriter writer) + { + writer.WriteStartElement("Announcement"); + writer.WriteElementString("ItemID", ItemID.ToString(CultureInfo.InvariantCulture)); + writer.WriteElementString("ModuleID", ModuleID.ToString(CultureInfo.InvariantCulture)); + writer.WriteElementString("Title", Title); + writer.WriteElementString("URL", URL); + writer.WriteElementString("ViewOrder", ViewOrder.ToString(CultureInfo.InvariantCulture)); + writer.WriteElementString("Description", Description); + writer.WriteElementString("ImageSource", ImageSource); + writer.WriteElementString("TrackClicks", TrackClicks.ToString()); + writer.WriteElementString("NewWindow", NewWindow.ToString()); + writer.WriteElementString("PublishDate", PublishDate.ToString()); + writer.WriteElementString("ExpireDate", ExpireDate.ToString()); + writer.WriteEndElement(); + } + + #endregion + + #region IPropertyAccess Implementation + + private string _localResourceFile = Globals.ApplicationPath + "/DesktopModules/Announcements/App_LocalResources/Announcements.ascx"; + + + public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound) + { + PortalSettings portalSettings = PortalController.GetCurrentPortalSettings(); + string outputFormat = strFormat == string.Empty ? "D" : strFormat; + switch (strPropertyName.ToLowerInvariant()) + { + case "edit": + if (IsEditable) + { + string editUrl = Globals.NavigateURL(portalSettings.ActiveTab.TabID, false, portalSettings, + "Edit", + CultureInfo.CurrentCulture.Name, + "mid=" + ModuleID.ToString(CultureInfo.InvariantCulture), + "itemid=" + ItemID.ToString(CultureInfo.InvariantCulture)); + if (portalSettings.EnablePopUps) + { + editUrl = UrlUtils.PopUpUrl(editUrl, null, portalSettings, false, false); + } + return "\"""; + } + return string.Empty; + case "itemid": + return (ItemID.ToString(outputFormat, formatProvider)); + case "moduleid": + return (ModuleID.ToString(outputFormat, formatProvider)); + case "title": + return PropertyAccess.FormatString(Title, strFormat); + case "url": + return PropertyAccess.FormatString(string.IsNullOrEmpty(URL) ? URL : Utilities.FormatUrl(URL, portalSettings.ActiveTab.TabID, ModuleID, TrackClicks), strFormat); + case "description": + return HttpUtility.HtmlDecode(Description); + case "imagesource": + case "rawimage": + string strValue = ImageSource; + if (strPropertyName.ToLowerInvariant() == "imagesource" && string.IsNullOrEmpty(strFormat)) + { + strFormat = "\"""; + } + + //Retrieve the path to the imagefile + if (strValue != "") + { + //Get path from filesystem only when the image comes from within DNN. + // this is now legacy, from version 7.0.0, a real filename is saved in the DB + if (ImageSource.StartsWith("FileID=")) + { + var fileCnt = new FileController(); + FileInfo objFile = fileCnt.GetFileById(Convert.ToInt32(strValue.Substring(7)), + portalSettings.PortalId); + if (objFile != null) + { + strValue = portalSettings.HomeDirectory + objFile.Folder + objFile.FileName; + } + else + { + strValue = ""; + } + } + else + { + if (!ImageSource.ToLowerInvariant().StartsWith("http")) + { + strValue = portalSettings.HomeDirectory + ImageSource; + } + } + strValue = PropertyAccess.FormatString(strValue, strFormat); + } + return strValue; + case "vieworder": + return (ViewOrder.ToString(outputFormat, formatProvider)); + case "createdbyuserid": + return (CreatedByUserID.ToString(outputFormat, formatProvider)); + case "createdbyuser": + UserInfo tmpUser = CreatedByUser(portalSettings.PortalId); + return tmpUser != null ? tmpUser.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile); + case "lastmodifiedbyuserid": + return (LastModifiedByUserID.ToString(outputFormat, formatProvider)); + case "lastmodifiedbyuser": + UserInfo tmpUser2 = LastModifiedByUser(portalSettings.PortalId); + return tmpUser2 != null ? tmpUser2.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile); + case "trackclicks": + return (PropertyAccess.Boolean2LocalizedYesNo(TrackClicks, formatProvider)); + case "newwindow": + return NewWindow ? "_blank" : "_self"; + case "createddate": + case "createdondate": + return (CreatedOnDate.ToString(outputFormat, formatProvider)); + case "lastmodifiedondate": + return (LastModifiedOnDate.ToString(outputFormat, formatProvider)); + case "publishdate": + return PublishDate.HasValue ? (PublishDate.Value.ToString(outputFormat, formatProvider)) : ""; + case "expiredate": + return ExpireDate.HasValue ? (ExpireDate.Value.ToString(outputFormat, formatProvider)) : ""; + case "more": + return Localization.GetString("More.Text", _localResourceFile); + case "readmore": + string strTarget = NewWindow ? "_new" : "_self"; + + return !(string.IsNullOrEmpty(URL)) + ? "" + Localization.GetString("More.Text", _localResourceFile) + + "" + : ""; + case "permalink": + return Permalink(); + case "subscribe": + + default: + PropertyNotFound = true; + break; + } + + return Null.NullString; + } + + [IgnoreColumn] + public CacheLevel Cacheability + { + get + { + return CacheLevel.fullyCacheable; + } + } + + #endregion + } +} + diff --git a/Components/Business/AnnouncementsController.cs b/Components/Business/AnnouncementsController.cs new file mode 100644 index 0000000..c1b9642 --- /dev/null +++ b/Components/Business/AnnouncementsController.cs @@ -0,0 +1,450 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Xml; +using System.Xml.Serialization; +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Data; +using DotNetNuke.Entities.Content; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Users; +using DotNetNuke.Services.Journal; +using DotNetNuke.Services.Search; +using DotNetNuke.Services.Social.Messaging; +using DotNetNuke.Services.Social.Notifications; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Business +{ + + /// + /// The AnnouncementsController Class represents the Announcments Business Layer + /// Methods in this class call methods in the Data Layer + /// + public class AnnouncementsController : IAnnouncementsController, ISearchable, IPortable + { + + #region Public Methods + + public void AddAnnouncement(AnnouncementInfo announcement) + { + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + + var objContentItem = new ContentItem + { + Content = announcement.Description, + ContentTitle = announcement.Title, + Indexed = false, + ModuleID = announcement.ModuleID, + TabID = Null.NullInteger, + ContentKey = null, + ContentTypeId = 4 + }; + + announcement.ContentItemID = new ContentController().AddContentItem(objContentItem); + repository.Insert(announcement); + } + } + + public void UpdateAnnouncement(AnnouncementInfo announcement) + { + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + + var objContentItem = new ContentItem + { + ContentItemId = announcement.ContentItemID, + Content = announcement.Description, + ContentTitle = announcement.Title, + Indexed = false, + ModuleID = announcement.ModuleID, + TabID = Null.NullInteger, + ContentKey = null, + ContentTypeId = 4 + }; + + if (objContentItem.ContentItemId == Null.NullInteger) + { + announcement.ContentItemID = new ContentController().AddContentItem(objContentItem); + } + else + { + new ContentController().UpdateContentItem(objContentItem); + } + + repository.Update(announcement); + + } + + } + + + public void DeleteAnnouncement(int moduleID, int itemID) + { + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + repository.Delete("WHERE ItemID = @0 AND ModuleId = @1", itemID, moduleID); + } + } + + public AnnouncementInfo GetAnnouncement(int itemID, int moduleID) + { + AnnouncementInfo announcement; + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + announcement = repository.GetById(itemID, moduleID); + } + return announcement; + } + + public IEnumerable GetAnnouncements(int moduleId, DateTime startDate, DateTime endDate) + { + + IEnumerable announcements; + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + announcements = + repository.Find( + "WHERE ModuleID = @0 AND ( ((PublishDate >= @1) OR @1 IS NULL) AND ((PublishDate <= @2) OR @2 IS NULL) )", + moduleId, Null.GetNull(startDate, DBNull.Value), Null.GetNull(endDate, DBNull.Value)).OrderBy( + a => a.ViewOrder).ThenByDescending(a => a.PublishDate); + } + return announcements; + } + + public IEnumerable GetCurrentAnnouncements(int moduleId) + { + return GetCurrentAnnouncements(moduleId, Null.NullDate); + } + + public IEnumerable GetCurrentAnnouncements(int moduleId, DateTime startDate) + { + + IEnumerable announcements; + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + announcements = repository.Find("WHERE ModuleID = @0 " + + "AND ( ((PublishDate >= @1) OR @1 IS NULL) AND (PublishDate <= GETDATE()) ) " + + "AND ( (ExpireDate > GETDATE()) OR (ExpireDate IS NULL) )", + moduleId, Null.GetNull(startDate, DBNull.Value)).OrderBy( + a => a.ViewOrder).ThenByDescending(a => a.PublishDate); + } + return announcements; + } + + public IEnumerable GetExpiredAnnouncements(int moduleId) + { + + IEnumerable announcements; + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + announcements = + repository.Find("WHERE ModuleID = @0 AND ExpireDate <= GETDATE()", moduleId).OrderBy( + a => a.ViewOrder).ThenByDescending(a => a.PublishDate); + } + return announcements; + } + + + public void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, String journalType) + { + + var objJournalType = JournalController.Instance.GetJournalType(journalType); + + var journalItem = new JournalItem + { + PortalId = announcement.PortalID, + ProfileId = announcement.LastModifiedByUserID, + UserId = announcement.LastModifiedByUserID, + ContentItemId = announcement.ContentItemID, + Title = announcement.Title + }; + var data = new ItemData + { + Url = announcement.Permalink() + }; + journalItem.ItemData = data; + journalItem.Summary = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "..."); + journalItem.Body = announcement.Description; + journalItem.JournalTypeId = objJournalType.JournalTypeId; + journalItem.SecuritySet = "E,"; + + JournalController.Instance.SaveJournalItem(journalItem, tabId); + + } + + + private void AddAnnouncementNotification(string subject, string body, UserInfo user, UserInfo sender, int portalId) + { + var notificationType = NotificationsController.Instance.GetNotificationType(Common.NotificationType.Announcements); + var notification = new Notification { NotificationTypeID = notificationType.NotificationTypeId, Subject = subject, Body = body, IncludeDismissAction = true, SenderUserID = sender.UserID }; + NotificationsController.Instance.SendNotification(notification, portalId, null, new List { user }); + } + + private void AddAnnouncementMessage(string subject, string body, UserInfo user, UserInfo sender, int portalId) + { + var m = new Message { Subject = subject, Body = body }; + + MessagingController.Instance.SendMessage(m, null, new List { user }, null, sender); + + } + + public void SendNotifications(AnnouncementInfo announcement) + { + IEnumerable subscribers = SubscriberController.GetSubscribers(announcement.ModuleID); + foreach (var subscriber in subscribers) + { + var receiver = UserController.GetUserById(announcement.PortalID, subscriber.UserID); + var sender = UserController.GetUserById(announcement.PortalID, announcement.LastModifiedByUserID); + AddAnnouncementNotification(announcement.Title, announcement.Description, receiver, sender, announcement.PortalID); + } + } + + + #endregion + + #region ISearchable Implementation + + /// + /// GetSearchItems implements the ISearchable Interface + /// + /// + /// + public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) + { + Hashtable moduleSettings = Entities.Portals.PortalSettings.GetModuleSettings(ModInfo.ModuleID); + int descriptionLength = 100; + if (Convert.ToString(moduleSettings["descriptionLength"]) != "") + { + descriptionLength = int.Parse(Convert.ToString(moduleSettings["descriptionLength"])); + if (descriptionLength < 1) + { + descriptionLength = 1950; + //max length of description is 2000 char, take a bit less to make sure it fits... + } + } + + var searchItemCollection = new SearchItemInfoCollection(); + + IEnumerable announcements = GetCurrentAnnouncements(ModInfo.ModuleID, Null.NullDate); + + foreach (AnnouncementInfo objAnnouncement in announcements) + { + var tempVar = objAnnouncement; + string strContent = System.Web.HttpUtility.HtmlDecode(tempVar.Title + " " + tempVar.Description); + string strDescription = + HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(tempVar.Description), false), + descriptionLength, "..."); + var searchItem = new SearchItemInfo(ModInfo.ModuleTitle + " - " + tempVar.Title, strDescription, + tempVar.CreatedByUserID, tempVar.PublishDate.Value, ModInfo.ModuleID, + tempVar.ItemID.ToString(CultureInfo.InvariantCulture), strContent, + "ItemID=" + tempVar.ItemID.ToString(CultureInfo.InvariantCulture)); + searchItemCollection.Add(searchItem); + } + + return searchItemCollection; + } + + #endregion + + #region IPortable Implementation + + /// + /// ExportModule implements the IPortable ExportModule Interface using an XmlWriter + /// and the IXmlSerializable Interface on the AnnoucnementInfo object + /// + /// The Id of the module to be exported + public string ExportModule(int ModuleID) + { + var sb = new StringBuilder(); + var settings = new XmlWriterSettings + { + ConformanceLevel = ConformanceLevel.Fragment, + OmitXmlDeclaration = true + }; + + IEnumerable arrAnnouncements = GetAnnouncements(ModuleID, Null.NullDate, Null.NullDate); + var announcementInfos = arrAnnouncements as IList ?? arrAnnouncements.ToList(); + if (announcementInfos.Count() != 0) + { + XmlWriter writer = XmlWriter.Create(sb, settings); + + //Write start of Annoucements Node + writer.WriteStartElement("Announcements"); + + foreach (AnnouncementInfo announcement in announcementInfos) + { + announcement.WriteXml(writer); + } + + //Write end of Annoucements Node + writer.WriteEndElement(); + + writer.Close(); + } + + return sb.ToString(); + + + } + + /// + /// ImportModule implements the IPortable ImportModule Interface using an XmlReader + /// and the IXmlSerializable Interface + /// + /// The Id of the module to be imported + public void ImportModule(int ModuleID, string Content, string Version, int UserId) + { + + if (Version.StartsWith("03.04")) + { + // this is the legacy import function for version 03.04.00 + //INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#: + // XmlNode xmlAnnouncement = null; + XmlNode xmlAnnouncements = Globals.GetContent(Content, "Announcements"); + foreach (XmlNode xmlAnnouncement in xmlAnnouncements) + { + AnnouncementInfo objAnnouncement = ImportAnnouncement(xmlAnnouncement); + if (objAnnouncement != null) + { + objAnnouncement.ModuleID = ModuleID; + objAnnouncement.CreatedByUserID = UserId; + objAnnouncement.CreatedOnDate = DateTime.Now; + + AddAnnouncement(objAnnouncement); + + } + } + } + else if (Version.StartsWith("03")) + { + // this is the legacy import function for all versions prior to version 03.04 + XmlNode xmlAnnouncements = Globals.GetContent(Content, "announcements"); + foreach (XmlNode xmlAnnouncement in xmlAnnouncements) + { + var objAnnouncement = new AnnouncementInfo + { + ModuleID = ModuleID, + Title = XmlUtils.GetNodeValue(xmlAnnouncement, "title"), + URL = Globals.ImportUrl(ModuleID, XmlUtils.GetNodeValue(xmlAnnouncement, "url")), + Description = XmlUtils.GetNodeValue(xmlAnnouncement, "description"), + ViewOrder = XmlUtils.GetNodeValueInt(xmlAnnouncement, "vieworder"), + CreatedOnDate = XmlUtils.GetNodeValueDate(xmlAnnouncement, "createddate", DateTime.Now) + }; + objAnnouncement.PublishDate = objAnnouncement.CreatedOnDate; + objAnnouncement.CreatedByUserID = UserId; + AddAnnouncement(objAnnouncement); + } + } + else + { + // this is the current import function + using (XmlReader reader = XmlReader.Create(new StringReader(Content))) + { + if (reader.Read()) + { + reader.ReadStartElement("Announcements"); + if (reader.ReadState != ReadState.EndOfFile & reader.NodeType != XmlNodeType.None & reader.LocalName != "") + { + do + { + reader.ReadStartElement("Announcement"); + var announcement = new AnnouncementInfo(); + + //Deserialize announcement + announcement.ReadXml(reader); + + //initialize values of the new announcement to this module and this user + announcement.ItemID = Null.NullInteger; + announcement.ModuleID = ModuleID; + announcement.CreatedByUserID = UserId; + announcement.CreatedOnDate = DateTime.Now; + + //Save announcement + AddAnnouncement(announcement); + } while (reader.ReadToNextSibling("Announcement")); + } + } + + reader.Close(); + } + } + } + + /// + /// Deserializes announcementInfo xml into new AnnouncementInfo instance. + /// If an error occurs, Nothing is returned + /// + /// deprecated + /// + /// the xml to be deserialized + /// AnnouncementInfo instance + /// + /// + private AnnouncementInfo ImportAnnouncement(XmlNode xmlAnnouncement) + { + + try + { + var xSer = new XmlSerializer(typeof(AnnouncementInfo)); + var objAnnouncement = (AnnouncementInfo)xSer.Deserialize(new StringReader(xmlAnnouncement.OuterXml)); + return objAnnouncement; + + } + catch + { + return null; + } + } + + #endregion + + } + +} + diff --git a/Components/Business/AnnouncementsSubscriberInfo.cs b/Components/Business/AnnouncementsSubscriberInfo.cs new file mode 100644 index 0000000..9f47c0b --- /dev/null +++ b/Components/Business/AnnouncementsSubscriberInfo.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Web; +using System.Web.Caching; +using System.Xml.Serialization; + +using DotNetNuke.Common.Utilities; +using DotNetNuke.ComponentModel.DataAnnotations; +using DotNetNuke.Entities.Users; + +namespace DotNetNuke.Modules.Announcements.Components.Business +{ + [Serializable, XmlRoot("AnnouncementsSubscriber")] + [TableName("AnnouncementsSubscribers")] + [PrimaryKey("AnnouncementsSubscriberID")] + [Scope("ModuleID")] + public class AnnouncementsSubscriberInfo + { + + public AnnouncementsSubscriberInfo() + { + CreatedOnDate = DateTime.Now; + CreatedByUserID = Null.NullInteger; + LastModifiedByUserID = Null.NullInteger; + LastModifiedOnDate = CreatedOnDate; + } + + #region DBFields + + public int AnnouncementsSubscriberID { get; set; } + public int ModuleID { get; set; } + public int UserID { get; set; } + + [Browsable(false), XmlIgnore] + public int CreatedByUserID { get; set; } + + [Browsable(false), XmlIgnore] + public DateTime CreatedOnDate { get; set; } + + [Browsable(false), XmlIgnore] + public int LastModifiedByUserID { get; set; } + + [Browsable(false), XmlIgnore] + public DateTime LastModifiedOnDate { get; set; } + + #endregion + + #region NonDB Fields + + [IgnoreColumn] + public UserInfo CreatedByUser(int portalId) + { + if (CreatedByUserID > Null.NullInteger) + { + UserInfo user = UserController.GetUserById(portalId, CreatedByUserID); + return user; + } + return null; + } + + [IgnoreColumn] + public UserInfo LastModifiedByUser(int portalId) + { + if (LastModifiedByUserID > Null.NullInteger) + { + UserInfo user = UserController.GetUserById(portalId, LastModifiedByUserID); + return user; + } + return null; + } + #endregion + + + } +} \ No newline at end of file diff --git a/Components/Business/IAnnouncementsController.cs b/Components/Business/IAnnouncementsController.cs new file mode 100644 index 0000000..ded17db --- /dev/null +++ b/Components/Business/IAnnouncementsController.cs @@ -0,0 +1,63 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; + +using DotNetNuke.Entities.Users; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Business +{ + + public interface IAnnouncementsController + { + + void AddAnnouncement(AnnouncementInfo announcement); + + void UpdateAnnouncement(AnnouncementInfo announcement); + + void DeleteAnnouncement(int moduleID, int itemID); + + AnnouncementInfo GetAnnouncement(int itemID, int moduleID); + + IEnumerable GetAnnouncements(int moduleId, DateTime startDate, DateTime endDate); + + IEnumerable GetCurrentAnnouncements(int moduleId); + + IEnumerable GetCurrentAnnouncements(int moduleId, DateTime startDate); + + IEnumerable GetExpiredAnnouncements(int moduleId); + + void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, String journalType); + + void SendNotifications(AnnouncementInfo announcement); + + } + +} + diff --git a/Components/Business/SubscriberController.cs b/Components/Business/SubscriberController.cs new file mode 100644 index 0000000..168caa1 --- /dev/null +++ b/Components/Business/SubscriberController.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using DotNetNuke.Common.Utilities; +using DotNetNuke.Data; + +namespace DotNetNuke.Modules.Announcements.Components.Business +{ + public class SubscriberController + { + + public static void AddSubscriber(AnnouncementsSubscriberInfo subscriber) + { + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + + repository.Insert(subscriber); + } + } + + public static void UpdateSubscriber(AnnouncementsSubscriberInfo subscriber) + { + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + repository.Update(subscriber); + + } + + } + + public static void DeleteSubscriber(int userId, int moduleId) + { + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + repository.Delete("WHERE UserID = @0 AND ModuleID = @1", userId, moduleId); + } + } + + public static AnnouncementsSubscriberInfo GetSubscriber(int userId, int moduleId) + { + AnnouncementsSubscriberInfo subscriber; + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + subscriber = repository.Find("WHERE ModuleID = @0 AND UserID=@1", moduleId, userId).FirstOrDefault(); + } + return subscriber; + } + + public static IEnumerable GetSubscribers(int moduleId) + { + + IEnumerable subscribers; + + using (IDataContext context = DataContext.Instance()) + { + var repository = context.GetRepository(); + subscribers = + repository.Find("WHERE ModuleID = @0",moduleId); + } + return subscribers; + } + } +} \ No newline at end of file diff --git a/Components/Common/AnnouncementTokenReplace.cs b/Components/Common/AnnouncementTokenReplace.cs new file mode 100644 index 0000000..7cc3a44 --- /dev/null +++ b/Components/Common/AnnouncementTokenReplace.cs @@ -0,0 +1,65 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Services.Tokens; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + + /// + /// The AnnouncementsTokenReplace Class is a custom token replace class for parsing + /// Announcment templates + /// + public class AnnouncementsTokenReplace : TokenReplace + { + + public AnnouncementsTokenReplace() : base(Scope.DefaultSettings) + { + this.UseObjectLessExpression = true; + } + + public AnnouncementsTokenReplace(AnnouncementInfo announcement) : base(Scope.DefaultSettings) + { + this.UseObjectLessExpression = true; + this.PropertySource[ObjectLessToken] = announcement; + } + + public void SetPropertySource(AnnouncementInfo announcement) + { + this.PropertySource[ObjectLessToken] = announcement; + } + + public string ReplaceAnnouncmentTokens(string strSourceText) + { + return base.ReplaceTokens(strSourceText); + } + + } + +} \ No newline at end of file diff --git a/Components/Common/EventArguments.cs b/Components/Common/EventArguments.cs new file mode 100644 index 0000000..929c357 --- /dev/null +++ b/Components/Common/EventArguments.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using DotNetNuke.Modules.Announcements.Components.Business; + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + public class EditItemEventArgs : EventArgs + { + public string ItemIdString { get; set; } + public int ItemId { get; set; } + public AnnouncementInfo Item { get; set; } + + public EditItemEventArgs(string itemId) + { + ItemIdString = itemId; + } + public EditItemEventArgs(int itemId) + { + ItemId = itemId; + } + public EditItemEventArgs(AnnouncementInfo item) + { + Item = item; + } + + } +} \ No newline at end of file diff --git a/Components/Common/ExtensionMethods.cs b/Components/Common/ExtensionMethods.cs new file mode 100644 index 0000000..79d6cc5 --- /dev/null +++ b/Components/Common/ExtensionMethods.cs @@ -0,0 +1,124 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections; +using System.Globalization; +using DotNetNuke.Common.Utilities; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + public static class HashtableExtensions + { + + public static string GetString(this Hashtable valueTable, string valueName, string defaultValue) + { + string resultValue = defaultValue; + if ((valueTable[valueName] != null)) + { + resultValue = (string)valueTable[valueName]; + } + return resultValue; + } + + public static int GetInteger(this Hashtable valueTable, string valueName, int defaultValue) + { + int resultValue = defaultValue; + if ((valueTable[valueName] != null)) + { + if (!int.TryParse((string)valueTable[valueName],out resultValue)) + { + resultValue = defaultValue; + } + } + return resultValue; + } + + public static bool GetBoolean(this Hashtable valueTable, string valueName, bool defaultValue) + { + bool resultValue = defaultValue; + if ((valueTable[valueName] != null)) + { + if (!bool.TryParse((string)valueTable[valueName],out resultValue)) + { + resultValue = defaultValue; + } + } + return resultValue; + } + + public static DateTime GetDateTime(this Hashtable valueTable, string valueName, DateTime defaultValue) + { + DateTime resultValue = defaultValue; + if ((valueTable[valueName] != null)) + { + if (!DateTime.TryParse((string)valueTable[valueName], CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out resultValue)) + { + resultValue = defaultValue; + } + } + return resultValue; + } + + } + + public static class StringExtensions + { + public static int ToDnnInt(this string s) + { + return ToDnnInt(s, Null.NullInteger); + } + + public static int ToDnnInt(this string s, int defaultValue) + { + int resultValue = defaultValue; + if (!String.IsNullOrEmpty(s)) + { + if (!int.TryParse(s, out resultValue)) + { + resultValue = defaultValue; + } + } + return resultValue; + + } + } + + public static class IntExtensions + { + public static string ToDnnString(this int i) + { + return i == Null.NullInteger ? "" : i.ToString(CultureInfo.InvariantCulture); + } + + public static bool IsDnnNull(this int i) + { + return i == Null.NullInteger; + } + } +} \ No newline at end of file diff --git a/Components/Common/GlobalConstants.cs b/Components/Common/GlobalConstants.cs new file mode 100644 index 0000000..00cfca7 --- /dev/null +++ b/Components/Common/GlobalConstants.cs @@ -0,0 +1,91 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +using System.Web.Caching; + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + public class ModuleDefinition + { + public const string FriendlyName = "Announcements"; + } + + public class CacheConstants + { + private const string _TemplateCacheKey = "dnnAnnouncements_Template_{0}"; + public static string TemplateCacheKeyFormat(int tabModuleId) + { + return string.Format(_TemplateCacheKey, tabModuleId); + } + public const int TemplateCacheTimeOut = 20; + public const CacheItemPriority TemplateCachePriority = CacheItemPriority.Normal; + private const string _ModuleSettingsCacheKey = "dnnAnnouncements_Settings_{0}_{1}"; + public static string SettingsCacheKeyFormat(int moduleId, int tabModuleId) + { + return string.Format(_ModuleSettingsCacheKey, moduleId, tabModuleId); + } + public const int SettingsCacheTimeOut = 20; + public const CacheItemPriority SettingsCachePriority = CacheItemPriority.Normal; + } + + public class PermissionName + { + public const string Code = "DNNANNOUNCEMENTS"; + public const string HasEditTemplatePermission = "EDITTEMPLATE"; + public const string HasSubscribePermission = "CANSUBSCRIBE"; + } + + public class SettingName + { + public const string TemplateType = "SimpleTemplate"; + public const string History = "history"; + public const string DescriptionLength = "descriptionLength"; + public const string EditorHeight = "editorHeight"; + public const string DefaultViewType = "defaultViewType"; + public const string ConnectedModule = "ConnectedModule"; + public const string Legacy = "Legacy"; + public const string TemplateName = "TemplateName"; + public const string TemplateLocation = "TemplateLocation"; + + //legacy + public const string ItemTemplate = "template"; + public const string AltItemTemplate = "altitemtemplate"; + public const string Separator = "separator"; + public const string HeaderTemplate = "headertemplate"; + public const string FooterTemplate = "footertemplate"; + + } + + public class JournalType + { + public const string AnnouncementAdd = "AnnouncementAdd"; + public const string AnnouncementUpdate = "AnnouncementUpdate"; + } + + public class NotificationType + { + public const string Announcements = "DNNAnnouncements"; + } + +} \ No newline at end of file diff --git a/Components/Common/ModuleSecurity.cs b/Components/Common/ModuleSecurity.cs new file mode 100644 index 0000000..333eb54 --- /dev/null +++ b/Components/Common/ModuleSecurity.cs @@ -0,0 +1,61 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using DotNetNuke.Common; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Security; +using DotNetNuke.Security.Permissions; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + public class ModuleSecurity + { + private readonly bool _hasEditTemplatePermission; + + public ModuleSecurity(ModuleInfo moduleInfo) + { + var modulePermissionCollection = moduleInfo.ModulePermissions; + _hasEditTemplatePermission = ModulePermissionController.HasModulePermission(modulePermissionCollection, + PermissionName.HasEditTemplatePermission); + + } + + public bool HasEditTemplatePermission + { + get { return _hasEditTemplatePermission; } + } + + public static bool IsAdministrator() + { + var administratorRoleName = Globals.GetPortalSettings().AdministratorRoleName; + return PortalSecurity.IsInRole(administratorRoleName); + } + } + + +} \ No newline at end of file diff --git a/Components/Common/Utilities.cs b/Components/Common/Utilities.cs new file mode 100644 index 0000000..92e0d8d --- /dev/null +++ b/Components/Common/Utilities.cs @@ -0,0 +1,56 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Web; +using DotNetNuke.Common; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + + public class Utilities + { + + public static string FormatUrl(string url, int tabId, int moduleId, bool trackClicks) + { + return HttpUtility.HtmlEncode(Globals.LinkClick(url, tabId, moduleId, trackClicks)); + } + + public static string ViewTypeToString(ViewTypes viewType) + { + return Enum.GetName(typeof (ViewTypes), viewType); + } + + public static ViewTypes StringToViewType(string s) + { + return (ViewTypes) Enum.Parse(typeof (ViewTypes), s); + } + + } + +} diff --git a/Components/Common/ViewTypes.cs b/Components/Common/ViewTypes.cs new file mode 100644 index 0000000..01381e4 --- /dev/null +++ b/Components/Common/ViewTypes.cs @@ -0,0 +1,41 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Common +{ + + /// + /// The ViewTypes Enumeration the types of announcements + /// + public enum ViewTypes + { + Current, + Expired, + Future, + All + } + + +} + diff --git a/Components/Settings/ISettingsController.cs b/Components/Settings/ISettingsController.cs new file mode 100644 index 0000000..d54144c --- /dev/null +++ b/Components/Settings/ISettingsController.cs @@ -0,0 +1,9 @@ +using DotNetNuke.Modules.Announcements.Components.Common; + +namespace DotNetNuke.Modules.Announcements.Components.Settings +{ + public interface ISettingsController + { + Settings GetModuleSettings(int moduleId, int tabModuleId); + } +} \ No newline at end of file diff --git a/Components/Settings/Settings.cs b/Components/Settings/Settings.cs new file mode 100644 index 0000000..7c5d2c9 --- /dev/null +++ b/Components/Settings/Settings.cs @@ -0,0 +1,167 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections; +using System.Globalization; + +using DotNetNuke.Common.Utilities; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Modules.Announcements.Components.Common; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Settings +{ + public class Settings + { + #region constants + private readonly int _History = Null.NullInteger; + private const int _DescriptionLength = 100; + private const int _EditorHeight = 300; + private readonly string _DefaultViewType = Utilities.ViewTypeToString(ViewTypes.Current); + private const bool _Legacy = false; + private const string _TemplateType = "SimpleTemplate"; + private const string _TemplateName = "ModernAnnouncements"; + private const string _TemplateLocation = "system"; + #endregion + + #region private properties + private readonly int _moduleId = -1; + private readonly int _tabModuleId = -1; + private readonly Hashtable ModuleSettings; + private readonly Hashtable TabModuleSettings; + #endregion + + #region public properties + public int History { get; set; } + public int DescriptionLength { get; set; } + public int EditorHeight { get; set; } + public ViewTypes DefaultViewType { get; set; } + public bool Legacy { get; set; } + public string TemplateType { get; set; } + public string TemplateName { get; set; } + public string TemplateLocation { get; set; } + + // legacy settings + public string ItemTemplate { get; set; } + public string AltItemTemplate { get; set; } + public string Separator { get; set; } + public string HeaderTemplate { get; set; } + public string FooterTemplate { get; set; } + #endregion + + #region constructors + public Settings(int moduleId, int tabModuleId) + { + _moduleId = moduleId; + _tabModuleId = tabModuleId; + + var mc = new ModuleController(); + ModuleSettings = mc.GetModuleSettings(_moduleId); + TabModuleSettings = mc.GetTabModuleSettings(_tabModuleId); + + History = TabModuleSettings.GetInteger(SettingName.History, _History); + DescriptionLength = TabModuleSettings.GetInteger(SettingName.DescriptionLength, _DescriptionLength); + EditorHeight = TabModuleSettings.GetInteger(SettingName.EditorHeight, _EditorHeight); + DefaultViewType = Utilities.StringToViewType(TabModuleSettings.GetString(SettingName.DefaultViewType,_DefaultViewType)); + TemplateType = TabModuleSettings.GetString(SettingName.TemplateType, _TemplateType); + TemplateName = TabModuleSettings.GetString(SettingName.TemplateName, _TemplateName); + TemplateLocation = TabModuleSettings.GetString(SettingName.TemplateLocation, _TemplateLocation); + + + //legacy + ItemTemplate = TabModuleSettings.GetString(SettingName.ItemTemplate, Null.NullString); + AltItemTemplate = TabModuleSettings.GetString(SettingName.AltItemTemplate, Null.NullString); + Separator = TabModuleSettings.GetString(SettingName.HeaderTemplate, Null.NullString); + HeaderTemplate = TabModuleSettings.GetString(SettingName.HeaderTemplate, Null.NullString); + FooterTemplate = TabModuleSettings.GetString(SettingName.FooterTemplate, Null.NullString); + + Legacy = ModuleSettings.GetBoolean(SettingName.Legacy, _Legacy) || !Legacy && !string.IsNullOrEmpty(ItemTemplate); + } + #endregion + + + public void Update() + { + var objModules = new ModuleController(); + + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.History, History.ToString(CultureInfo.InvariantCulture)); + objModules.UpdateModuleSetting(_moduleId, SettingName.DescriptionLength, DescriptionLength.ToString(CultureInfo.InvariantCulture)); + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.EditorHeight, EditorHeight.ToString(CultureInfo.InvariantCulture)); + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.DefaultViewType, Utilities.ViewTypeToString(DefaultViewType)); + objModules.UpdateModuleSetting(_moduleId, SettingName.Legacy, Legacy.ToString(CultureInfo.InvariantCulture)); + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.TemplateType, TemplateType); + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.TemplateName, TemplateName); + objModules.UpdateTabModuleSetting(_tabModuleId, SettingName.TemplateLocation, TemplateLocation); + + + ModuleController.SynchronizeModule(_moduleId); + DataCache.RemoveCache(ModuleController.CacheKey(_moduleId) + "_viewType"); + DataCache.RemoveCache(CacheConstants.SettingsCacheKeyFormat(_moduleId, _tabModuleId)); + + } + + public bool TryGetValue(string key, out string value) + { + bool returnValue = false; + string outValue = Null.NullString; + try + { + + if (ModuleSettings != null) + { + if (ModuleSettings.ContainsKey(key)) + { + outValue = ModuleSettings[key] as string; + returnValue = true; + } + } + if (Null.IsNull(outValue)) + { + if (TabModuleSettings != null) + { + if (TabModuleSettings.ContainsKey(key)) + { + outValue = TabModuleSettings[key] as string; + returnValue = true; + } + } + } + } + catch (Exception) + { + outValue = Null.NullString; + returnValue = false; + } + + value = outValue; + return returnValue; + + } + + } +} \ No newline at end of file diff --git a/Components/Settings/SettingsController.cs b/Components/Settings/SettingsController.cs new file mode 100644 index 0000000..8c51ac5 --- /dev/null +++ b/Components/Settings/SettingsController.cs @@ -0,0 +1,23 @@ +using DotNetNuke.Common.Utilities; +using DotNetNuke.Modules.Announcements.Components.Common; + +namespace DotNetNuke.Modules.Announcements.Components.Settings +{ + public class SettingsController : ISettingsController + { + public Settings GetModuleSettings(int moduleId, int tabModuleId) + { + return CBO.GetCachedObject(new CacheItemArgs(CacheConstants.SettingsCacheKeyFormat(moduleId, tabModuleId), CacheConstants.SettingsCacheTimeOut, CacheConstants.SettingsCachePriority, moduleId, tabModuleId), GetSettingsCallback); + } + + private object GetSettingsCallback(CacheItemArgs cacheItemArgs) + { + var moduleId = (int)cacheItemArgs.ParamList[0]; + var tabModuleId = (int)cacheItemArgs.ParamList[1]; + return new Settings(moduleId, tabModuleId); + + } + + + } +} \ No newline at end of file diff --git a/Components/Template/BaseTemplate.cs b/Components/Template/BaseTemplate.cs new file mode 100644 index 0000000..33081e2 --- /dev/null +++ b/Components/Template/BaseTemplate.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Web; +using System.Xml.Serialization; + +using DotNetNuke.Common; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Settings; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public abstract class BaseTemplate : ITemplate + { + + protected BaseTemplate(int moduleId, int tabModuleId, string templateName) + { + ModuleId = moduleId; + TabModuleId = tabModuleId; + _settings = new SettingsController().GetModuleSettings(ModuleId, TabModuleId); + Name = templateName; + + } + + public virtual void LoadTemplate() + { + var serializer = new XmlSerializer(typeof(TemplateInfo)); + using (var reader = new StreamReader(TemplatePath + "Template.xml")) + { + TemplateInfo = (TemplateInfo)serializer.Deserialize(reader); + } + } + + public abstract void UpdateTemplate(); + + public abstract string RenderTemplate(IEnumerable announcements, bool editEnabled); + + protected string ModuleResourceFile = Globals.ApplicationPath + "/DesktopModules/Announcements/App_LocalResources/AnnouncementsView.ascx"; + + private string _templatePath; + protected string TemplatePath + { + get + { + return _templatePath ?? (_templatePath = HttpContext.Current.Server.MapPath( + Globals.ResolveUrl(string.Format(@"~/DesktopModules/Announcements/Templates/{0}/", Name)))); + } + } + + private Settings.Settings _settings; + protected Settings.Settings Settings + { + get { return _settings ?? (_settings = new SettingsController().GetModuleSettings(ModuleId, TabModuleId)); } + } + + protected bool Legacy + { + get { return Settings.Legacy; } + } + public string Name { get; set; } + public string Type { get; set; } + public int ModuleId { get; set; } + public int TabModuleId { get; set; } + public TemplateInfo TemplateInfo { get; set; } + public string JsFile { get; set; } + public string CssFile { get; set; } + + protected PortalSettings PortalSettings + { + get { return Globals.GetPortalSettings(); } + } + } +} \ No newline at end of file diff --git a/Components/Template/ITemplate.cs b/Components/Template/ITemplate.cs new file mode 100644 index 0000000..03a9943 --- /dev/null +++ b/Components/Template/ITemplate.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +using DotNetNuke.Modules.Announcements.Components.Business; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public interface ITemplate + { + void LoadTemplate(); + + void UpdateTemplate(); + + string RenderTemplate(IEnumerable announcements, bool editEnabled); + } + +} \ No newline at end of file diff --git a/Components/Template/ITemplateController.cs b/Components/Template/ITemplateController.cs new file mode 100644 index 0000000..b0915d1 --- /dev/null +++ b/Components/Template/ITemplateController.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public interface ITemplateController + { + ITemplate GetTemplate(int moduleId, int tabModuleId); + } +} \ No newline at end of file diff --git a/Components/Template/SimpleTemplate.cs b/Components/Template/SimpleTemplate.cs new file mode 100644 index 0000000..fc43a8c --- /dev/null +++ b/Components/Template/SimpleTemplate.cs @@ -0,0 +1,195 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; + +using DotNetNuke.Framework; +using DotNetNuke.Instrumentation; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Services.Localization; +using DotNetNuke.Services.Tokens; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + + public class SimpleTemplate : BaseTemplate + { + + private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(SimpleTemplate)); + + #region Public Properties + public string ItemTemplate { get; set; } + public string AltItemTemplate { get; set; } + public string Separator { get; set; } + public string HeaderTemplate { get; set; } + public string FooterTemplate { get; set; } + + private bool TokenReplaceNeeded + { + get + { + return (!(string.IsNullOrEmpty(HeaderTemplate))) | (!(string.IsNullOrEmpty(FooterTemplate))) | (!(string.IsNullOrEmpty(Separator))); + } + } + #endregion + + #region Private Methods + private string GetTemplate(string settingName) + { + if (Legacy) + { + string setting; + if (Settings.TryGetValue(settingName.ToLowerInvariant(), out setting)) + { + // legacy template + return Convert.ToString(setting); + } + Logger.ErrorFormat("legacy template expected, but not found, settingName: {0}, loading new style template", settingName); + } + return GetTemplate(settingName, true); + } + + private string GetTemplate(string settingName, bool forceDefault) + { + if (!string.IsNullOrEmpty(settingName)) + { + if (File.Exists(TemplatePath + settingName)) + { + return File.ReadAllText(TemplatePath + settingName, Encoding.UTF8); + } + Logger.ErrorFormat("error loading template, file does not exist: {0}", TemplatePath + settingName); + } + else + { + Logger.ErrorFormat("error loading template, settingname empty {0}", settingName); + } + return ""; + } + + private void WriteTemplate(string settingName, string value) + { + if (!string.IsNullOrEmpty(settingName)) + { + using (var streamWriter = new StreamWriter(File.Open(TemplatePath + settingName, FileMode.Create), Encoding.UTF8)) + { + streamWriter.Write(value); + } + } + } + + #endregion + + public SimpleTemplate(int moduleId, int tabModuleId, string templateName) + : base(moduleId, tabModuleId, templateName) + { + + } + + public override void LoadTemplate() + { + base.LoadTemplate(); + + ItemTemplate = GetTemplate(TemplateInfo.ItemTemplate); + AltItemTemplate = GetTemplate(TemplateInfo.AltItemTemplate); + Separator = GetTemplate(TemplateInfo.SeparatorTemplate); + HeaderTemplate = GetTemplate(TemplateInfo.HeaderTemplate); + FooterTemplate = GetTemplate(TemplateInfo.FooterTemplate); + JsFile = GetTemplate(TemplateInfo.JsFile); + CssFile = GetTemplate(TemplateInfo.CssFile); + + } + + + public override void UpdateTemplate() + { + WriteTemplate(TemplateInfo.ItemTemplate, ItemTemplate); + WriteTemplate(TemplateInfo.AltItemTemplate, AltItemTemplate); + WriteTemplate(TemplateInfo.SeparatorTemplate, Separator); + WriteTemplate(TemplateInfo.HeaderTemplate, HeaderTemplate); + WriteTemplate(TemplateInfo.FooterTemplate, FooterTemplate); + WriteTemplate(TemplateInfo.JsFile, JsFile); + WriteTemplate(TemplateInfo.CssFile, CssFile); + //DataCache.RemoveCache(TemplateCachKey); + + } + + public override string RenderTemplate(IEnumerable announcements, bool editEnabled) + { + var output = new StringBuilder(); + + + TokenReplace dnnTokenReplace = null; + if (TokenReplaceNeeded) + { + dnnTokenReplace = new TokenReplace(Scope.DefaultSettings, CultureInfo.CurrentCulture.Name, PortalSettings, PortalSettings.UserInfo); + } + bool altItemTemplateAvailable = !(string.IsNullOrEmpty(AltItemTemplate)); + if (dnnTokenReplace != null) + { + output.Append(dnnTokenReplace.ReplaceEnvironmentTokens(HeaderTemplate)); + } + int counter = 0; + var tokenReplace = new AnnouncementsTokenReplace(); + var announcementInfos = announcements as IList ?? announcements.ToList(); + foreach (var announcement in announcementInfos) + { + //we have to pass IsEditable to the announcement, because it is used to draw the edit icon + announcement.IsEditable = editEnabled; + + //Create a Token Replace and replace the tokens for this template + tokenReplace.SetPropertySource(announcement); + if ((counter % 2 == 0) | (!altItemTemplateAvailable)) + { + output.Append(tokenReplace.ReplaceAnnouncmentTokens(ItemTemplate)); + } + else + { + output.Append(tokenReplace.ReplaceAnnouncmentTokens(AltItemTemplate)); + } + if ((dnnTokenReplace != null) && (counter < announcementInfos.Count() - 1)) + { + output.Append(dnnTokenReplace.ReplaceEnvironmentTokens(Separator)); + } + counter += 1; + + } + if (dnnTokenReplace != null) + { + output.Append(dnnTokenReplace.ReplaceEnvironmentTokens(FooterTemplate)); + } + + return output.ToString(); + } + } +} diff --git a/Components/Template/TempateRendererTokenReplace.cs b/Components/Template/TempateRendererTokenReplace.cs new file mode 100644 index 0000000..89cdf8b --- /dev/null +++ b/Components/Template/TempateRendererTokenReplace.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public class TempateRendererTokenReplace: TemplateRenderer + + { + public override string RenderOutput() + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Components/Template/Template.cs b/Components/Template/Template.cs new file mode 100644 index 0000000..d731d0d --- /dev/null +++ b/Components/Template/Template.cs @@ -0,0 +1,170 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Web; +using System.Xml.Serialization; + +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Services.Localization; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + [Serializable] + public class Template + { + + #region Private Members + + private string _localResourceFile = Globals.ApplicationPath + "/DesktopModules/Announcements/App_LocalResources/AnnouncementsView.ascx"; + private Dictionary _settings; + + private int _tabModuleId = -1; + + #endregion + + + #region Public Properties + + /// + /// Gets and sets the name of the template + /// + public string Name { get; set; } + + /// + /// Gets and sets the Item Template + /// + public string ItemTemplate { get; set; } + + /// + /// Gets and sets the alternate item template + /// + public string AltItemTemplate { get; set; } + + /// + /// Gets and sets the Separator + /// + public string Separator { get; set; } + + /// + /// Gets and sets the HeaderTemplate + /// + public string HeaderTemplate { get; set; } + + /// + /// Gets and sets the FooterTemplate + /// + public string FooterTemplate { get; set; } + + public bool TokenReplaceNeeded + { + get + { + return (!(string.IsNullOrEmpty(HeaderTemplate))) | (!(string.IsNullOrEmpty(FooterTemplate))) | (!(string.IsNullOrEmpty(Separator))); + } + } + #endregion + + + public string GetTemplate(string templateName, string settingsName) + { + string _setting; + if (_settings.TryGetValue(settingsName.ToLowerInvariant(), out _setting)) + { + // legacy template + return Convert.ToString(_setting); + } + return GetTemplate(templateName, settingsName, true); + } + + public string GetTemplate(string templateName, string settingsName, bool forceDefault) + { + + if (!string.IsNullOrEmpty(settingsName)) + { + if (File.Exists(TemplatePath + settingsName)) + { + return File.ReadAllText(TemplatePath + settingsName); + } + } + return ""; + } + + private string _templatePath; + private string TemplatePath + { + get + { + return _templatePath ?? (_templatePath = HttpContext.Current.Server.MapPath( + Globals.ResolveUrl(string.Format(@"~/DesktopModules/Announcements/Templates/{0}/", Name)))); + } + } + + public Template(int tabModuleId, Dictionary settings) + { + Name = "SimpleAnnouncements"; + _settings = settings; + _tabModuleId = tabModuleId; + + TemplateInfo templateInfo; + XmlSerializer serializer = new XmlSerializer(typeof(TemplateInfo)); + using (StreamReader reader = new StreamReader(TemplatePath + "Template.xml")) + { + templateInfo = (TemplateInfo)serializer.Deserialize(reader); + } + + + ItemTemplate = GetTemplate(Name, templateInfo.ItemTemplate); + AltItemTemplate = GetTemplate(Name, templateInfo.AltItemTemplate); + Separator = GetTemplate(Name, templateInfo.SeparatorTemplate); + HeaderTemplate = GetTemplate(Name, templateInfo.HeaderTemplate); + FooterTemplate = GetTemplate(Name, templateInfo.FooterTemplate); + + } + + public void UpdateTemplate() + { + //var moduleController = new Entities.Modules.ModuleController(); + //moduleController.UpdateTabModuleSetting(_tabModuleId, "template", ItemTemplate); + //moduleController.UpdateTabModuleSetting(_tabModuleId, "altitemtemplate", AltItemTemplate); + //moduleController.UpdateTabModuleSetting(_tabModuleId, "separator", Separator); + //moduleController.UpdateTabModuleSetting(_tabModuleId, "headertemplate", HeaderTemplate); + //moduleController.UpdateTabModuleSetting(_tabModuleId, "footertemplate", FooterTemplate); + + //DataCache.RemoveCache(TemplateCachKey); + + } + + } +} diff --git a/Components/Template/TemplateController.cs b/Components/Template/TemplateController.cs new file mode 100644 index 0000000..7f51da8 --- /dev/null +++ b/Components/Template/TemplateController.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +using DotNetNuke.Common.Utilities; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Settings; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public class TemplateController : ITemplateController + { + public ITemplate GetTemplate(int moduleId, int tabModuleId) + { + return CBO.GetCachedObject(new CacheItemArgs(CacheConstants.TemplateCacheKeyFormat(tabModuleId), CacheConstants.TemplateCacheTimeOut, CacheConstants.TemplateCachePriority, moduleId, tabModuleId), GetTemplateCallback); + } + + /// + /// Callback method that dynamically loads a type of template, using reflection + /// + /// Arguments, containing moduleid and tabModuleId + /// ITemplate + private object GetTemplateCallback(CacheItemArgs cacheItemArgs) + { + var moduleId = (int)cacheItemArgs.ParamList[0]; + var tabModuleId = (int)cacheItemArgs.ParamList[1]; + var moduleSettings = new SettingsController().GetModuleSettings(moduleId, tabModuleId); + + + Type type = Type.GetType("DotNetNuke.Modules.Announcements.Components.Template." + moduleSettings.TemplateType); + if (type != null && type.IsClass) + { + var template = Activator.CreateInstance(type, + new object[] { moduleId, tabModuleId, moduleSettings.TemplateName }); + return template; + } + return null; + + } + + } +} \ No newline at end of file diff --git a/Components/Template/TemplateInfo.cs b/Components/Template/TemplateInfo.cs new file mode 100644 index 0000000..8ad3ab9 --- /dev/null +++ b/Components/Template/TemplateInfo.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace DotNetNuke.Modules.Announcements.Components.Template +{ + public class TemplateInfo + { + public string Type { get; set; } + public string ItemTemplate { get; set; } + public string AltItemTemplate { get; set; } + public string HeaderTemplate { get; set; } + public string FooterTemplate { get; set; } + public string SeparatorTemplate { get; set; } + public string DetailTemplate { get; set; } + public string CssFile { get; set; } + public string JsFile { get; set; } + public string Version { get; set; } + public DateTime LastModifiedDate { get; set; } + + } +} \ No newline at end of file diff --git a/Documentation/License.txt b/Documentation/License.txt new file mode 100644 index 0000000..172d5e6 --- /dev/null +++ b/Documentation/License.txt @@ -0,0 +1,7 @@ +Copyright (c) 2002-2011 DotNetNuke Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/Documentation/releasenotes.txt b/Documentation/releasenotes.txt new file mode 100644 index 0000000..cf15f65 --- /dev/null +++ b/Documentation/releasenotes.txt @@ -0,0 +1,11 @@ +MODULE: DotNetNuke Announcements Module +Version: 07.00.00 CTP +Minimum Required DNN Version: 7.0.0 RC + +This is a major new version of the module. Changes in this version include + +* Update of the UI of the module to match the DotNetNuke 7 UI +* Replacement of DAL 1 by DAL 2, the module now uses the DotNetNuke PetaPoco MicroORM, and does not use any SQL Stored Procedures anymore +* Addition of support for the DotNetNuke WebAPI Service Framework +* Rewritten in C# +* Updated to .NET 4.0 diff --git a/DotNetNuke.Announcements.csproj b/DotNetNuke.Announcements.csproj new file mode 100644 index 0000000..1df71dd --- /dev/null +++ b/DotNetNuke.Announcements.csproj @@ -0,0 +1,349 @@ + + + + + {349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Local + 9.0.30729 + 2.0 + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3} + Debug + AnyCPU + + + + + DotNetNuke.Modules.Announcements + + + None + JScript + Grid + IE50 + false + Library + Properties + DotNetNuke.Modules.Announcements + + + + + Windows + + + SAK + SAK + SAK + SAK + 4.0 + v4.0 + + + + bin\ + bin\DotNetNuke.Modules.Announcements.xml + 1117585408 + + + TRACE;DEBUG; + true + false + false + false + false + 1 + 1 + full + false + false + + + bin\ + bin\DotNetNuke.Modules.Announcements.xml + 1117585408 + + + TRACE; + false + true + false + false + false + 1 + none + false + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + + + + + + + + + + + + + + + + + + + + + AnnouncementsEdit.ascx + ASPXCodeBehind + + + AnnouncementsEdit.ascx + + + + + + + + + + + AnnouncementsView.ascx + ASPXCodeBehind + + + AnnouncementsView.ascx + + + + + + + + TemplateConfiguration.ascx + ASPXCodeBehind + + + TemplateConfiguration.ascx + + + + + + AnnouncementsSettings.ascx + ASPXCodeBehind + + + AnnouncementsSettings.ascx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Designer + + + Designer + + + Designer + + + Designer + + + + + + + + + + + + + + + + + + + + + + _Dependencies\DotNetNuke.dll + False + False + + + _Dependencies\DotNetNuke.Instrumentation.dll + False + False + + + _Dependencies\DotNetNuke.Web.dll + False + False + + + _Dependencies\DotNetNuke.Web.Client.dll + False + False + + + + + + False + ..\..\bin\System.Net.Http.dll + False + + + False + ..\..\bin\System.Net.Http.Formatting.dll + False + + + + + + + + + + False + ..\..\bin\System.Web.Http.dll + False + + + + + _Dependencies\Telerik.Web.UI.dll + False + False + + + _Dependencies\WebFormsMvp.dll + False + + + + + Designer + + + + + Designer + + + + + Designer + + + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + true + bin\ + TRACE;DEBUG; + 1117585408 + bin\DotNetNuke.Modules.Announcements.xml + 1 + full + AnyCPU + MinimumRecommendedRules.ruleset + false + + + true + bin\ + TRACE;DEBUG; + 1117585408 + bin\DotNetNuke.Modules.Announcements.xml + 1 + full + AnyCPU + MinimumRecommendedRules.ruleset + false + + + + + + True + + + + + + + + + \ No newline at end of file diff --git a/DotNetNuke.Announcements.dnn b/DotNetNuke.Announcements.dnn new file mode 100644 index 0000000..55ccc8a --- /dev/null +++ b/DotNetNuke.Announcements.dnn @@ -0,0 +1,205 @@ + + + + Announcements + This module renders a list of announcements. The way the announcements are rendered is completely customizable by templating. + DesktopModules/Announcements/Images/icon-announcements-32px.png + + DotNetNuke + DotNetNuke Corporation + http://www.dotnetnuke.com + support@dotnetnuke.com + + + + true + + 07.01.01 + + + + + DesktopModules\Announcements + + + + + + + + + + + + + + + + + + + + + DNN_Announcements + Announcements + DotNetNuke.Modules.Announcements.Components.Business.AnnouncementsController, DotNetNuke.Modules.Announcements + + + + + Supported + + + Announcements + -1 + + + + DesktopModules/Announcements/AnnouncementsView.ascx + False + + View + + http://help.dotnetnuke.com/070000/default.htm#Building Your Site/Project Modules/Announcements/About the Announcements Module.htm + False + 0 + + + Edit + DesktopModules/Announcements/AnnouncementsEdit.ascx + False + Edit Announcements + Edit + + + True + 0 + + + Template + DesktopModules/Announcements/TemplateConfiguration.ascx + False + Template Configuration + Edit + + + True + 0 + + + Settings + DesktopModules/Announcements/AnnouncementsSettings.ascx + False + Announcement Settings + Edit + + + False + 0 + + + + + + + + + + + + + bin + + bin + DotNetNuke.Modules.Announcements.dll + bin\DotNetNuke.Modules.Announcements.dll + + + + + + DesktopModules\Announcements + + resources.zip + + + + + + + diff --git a/DotNetNuke.Announcements.sln b/DotNetNuke.Announcements.sln new file mode 100644 index 0000000..3df8ab9 --- /dev/null +++ b/DotNetNuke.Announcements.sln @@ -0,0 +1,49 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2D426765-F89F-41C7-9650-A8A5758AE94B}" + ProjectSection(SolutionItems) = preProject + Providers\DataProviders\SqlDataProvider\07.00.00.SqlDataProvider = Providers\DataProviders\SqlDataProvider\07.00.00.SqlDataProvider + Providers\DataProviders\SqlDataProvider\07.00.01.SqlDataProvider = Providers\DataProviders\SqlDataProvider\07.00.01.SqlDataProvider + DotNetNuke.Announcements.dnn = DotNetNuke.Announcements.dnn + Installation\Project.targets = Installation\Project.targets + Providers\DataProviders\SqlDataProvider\Uninstall.SqlDataProvider = Providers\DataProviders\SqlDataProvider\Uninstall.SqlDataProvider + Installation\version.txt = Installation\version.txt + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetNuke.Announcements", "DotNetNuke.Announcements.csproj", "{F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}" +EndProject +Global + GlobalSection(TeamFoundationVersionControl) = preSolution + SccNumberOfProjects = 2 + SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} + SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs03 + SccLocalPath0 = . + SccProjectUniqueName1 = DotNetNuke.Announcements.csproj + SccLocalPath1 = . + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + DebugDeploy|Any CPU = DebugDeploy|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.DebugDeploy|Any CPU.ActiveCfg = DebugDeploy|Any CPU + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.DebugDeploy|Any CPU.Build.0 = DebugDeploy|Any CPU + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2A89441-0CB8-4FB2-91BF-C81E9D2626E3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(VaultVsipSolution-v1) = preSolution + VaultHost = http://source.dotnetnuke.com/VaultService + VaultRepositoryID = 9 + VaultRepositoryGUID = 903b6ec9-202e-47f1-9171-d32957566e59 + ProjectCount = 3 + ProjectRelativeDiskPath1 = DotNetNuke.Announcements.sln + ProjectRelativeDiskPath2 = DotNetNuke.Announcements.vbproj + ProjectRelativeDiskPath3 = Providers\DataProviders\SqlDataProvider\DotNetNuke.Announcements.SqlDataProvider.vbproj + EndGlobalSection +EndGlobal diff --git a/DotNetNuke.Announcements.vssscc b/DotNetNuke.Announcements.vssscc new file mode 100644 index 0000000..6cb031b --- /dev/null +++ b/DotNetNuke.Announcements.vssscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/Images/clock.gif b/Images/clock.gif new file mode 100644 index 0000000..953e356 Binary files /dev/null and b/Images/clock.gif differ diff --git a/Images/icon-announcements-32px.png b/Images/icon-announcements-32px.png new file mode 100644 index 0000000..cb0b6b5 Binary files /dev/null and b/Images/icon-announcements-32px.png differ diff --git a/Installation/Project.targets b/Installation/Project.targets new file mode 100644 index 0000000..6377d8c --- /dev/null +++ b/Installation/Project.targets @@ -0,0 +1,281 @@ + + + + + DotNetNuke + Announcements + Images\icon-announcements-32px.png + E:\websites\DotNetNuke_Enterprise_7.1.1.382_Install + http://dnndev.me + $(DotNetNukeDir)\DesktopModules\Announcements + + $(MSBuildProjectDirectory)\Installation + $(MSBuildProjectDirectory)\bin + + + + + + $(MSBuildExtensionsPath64)\ExtensionPack\4.0\ + $(MSBuildExtensionsPath32)\ExtensionPack\4.0\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Installation/version.txt b/Installation/version.txt new file mode 100644 index 0000000..8635fef --- /dev/null +++ b/Installation/version.txt @@ -0,0 +1 @@ +7.0.1.0 diff --git a/MVP/Models/AnnouncementsEditModel.cs b/MVP/Models/AnnouncementsEditModel.cs new file mode 100644 index 0000000..4fd3978 --- /dev/null +++ b/MVP/Models/AnnouncementsEditModel.cs @@ -0,0 +1,14 @@ +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Settings; + +namespace DotNetNuke.Modules.Announcements.MVP.Models +{ + public class AnnouncementsEditModel + { + public Settings Settings { get; set; } + public int ItemId { get; set; } + public AnnouncementInfo AnnouncementInfo { get; set; } + public bool IsAddMode { get; set; } + public bool ItemIdError { get; set; } + } +} \ No newline at end of file diff --git a/MVP/Models/AnnouncementsSettingsModel.cs b/MVP/Models/AnnouncementsSettingsModel.cs new file mode 100644 index 0000000..9d583be --- /dev/null +++ b/MVP/Models/AnnouncementsSettingsModel.cs @@ -0,0 +1,11 @@ +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Models +{ + public class AnnouncementsSettingsModel : SettingsModel + { + public Settings Settings { get; set; } + + } +} \ No newline at end of file diff --git a/MVP/Models/AnnouncementsViewModel.cs b/MVP/Models/AnnouncementsViewModel.cs new file mode 100644 index 0000000..75a7c64 --- /dev/null +++ b/MVP/Models/AnnouncementsViewModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; + +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.Components.Template; + +namespace DotNetNuke.Modules.Announcements.MVP.Models +{ + public class AnnouncementsViewModel + { + public Settings Settings { get; set; } + public ITemplate Template { get; set; } + public bool EditEnabled { get; set; } + public bool CanEdit { get; set; } + public bool CanSubscribe { get; set; } + public IEnumerable Announcements { get; set; } + public string RenderedTemplate { get; set; } + } +} \ No newline at end of file diff --git a/MVP/Models/TemplateConfigurationModel.cs b/MVP/Models/TemplateConfigurationModel.cs new file mode 100644 index 0000000..4315575 --- /dev/null +++ b/MVP/Models/TemplateConfigurationModel.cs @@ -0,0 +1,12 @@ +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.Components.Template; + +namespace DotNetNuke.Modules.Announcements.MVP.Models +{ + public class TemplateConfigurationModel + { + public Settings Settings { get; set; } + public ITemplate Template { get; set; } + + } +} \ No newline at end of file diff --git a/MVP/Presenters/AnnouncementsEditPresenter.cs b/MVP/Presenters/AnnouncementsEditPresenter.cs new file mode 100644 index 0000000..8e487be --- /dev/null +++ b/MVP/Presenters/AnnouncementsEditPresenter.cs @@ -0,0 +1,87 @@ +using System; + +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Presenters +{ + public class AnnouncementsEditPresenter : ModulePresenter + { + private readonly IAnnouncementsController _announcementsController; + + public AnnouncementsEditPresenter(IAnnouncementsEdit announcementsEdit) + : this(announcementsEdit, new AnnouncementsController()) + { + } + + public AnnouncementsEditPresenter(IAnnouncementsEdit announcementsEdit, IAnnouncementsController announcementsController) + : base(announcementsEdit) + { + Requires.NotNull("announcementsController", announcementsController); + _announcementsController = announcementsController; + + View.GetSettings += GetSettings; + View.GetItem += GetItem; + View.GetAnnouncement += GetAnnouncement; + View.DeleteAnnouncement += DeleteAnnouncement; + View.UpdateAnnouncement += UpdateAnnouncement; + } + + private void UpdateAnnouncement(object sender, EditItemEventArgs e) + { + if (View.Model.IsAddMode) + { + _announcementsController.AddAnnouncement(e.Item); + _announcementsController.AddAnnouncementToJournal(e.Item, TabId, JournalType.AnnouncementAdd); + _announcementsController.SendNotifications(e.Item); + } + else + { + _announcementsController.UpdateAnnouncement(e.Item); + _announcementsController.AddAnnouncementToJournal(e.Item, TabId, JournalType.AnnouncementUpdate); + } + + } + + private void DeleteAnnouncement(object sender, EditItemEventArgs e) + { + if (!Null.IsNull(e.ItemId)) + { + _announcementsController.DeleteAnnouncement(ModuleId, e.ItemId); + } + } + + private void GetSettings(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Settings = new SettingsController().GetModuleSettings(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + + private void GetItem(object sender, EditItemEventArgs e) + { + int resultValue; + if (!int.TryParse(e.ItemIdString, out resultValue)) + { + View.Model.ItemIdError = e.ItemIdString != null; + resultValue = Null.NullInteger; + } + View.Model.ItemId = resultValue; + View.Model.IsAddMode = Null.IsNull(resultValue) && !View.Model.ItemIdError; + } + + private void GetAnnouncement(object sender, EventArgs e) + { + if (!View.Model.IsAddMode && !Null.IsNull(View.Model.ItemId)) + { + View.Model.AnnouncementInfo = _announcementsController.GetAnnouncement(View.Model.ItemId, ModuleId); + } + } + + } +} \ No newline at end of file diff --git a/MVP/Presenters/AnnouncementsSettingsPresenter.cs b/MVP/Presenters/AnnouncementsSettingsPresenter.cs new file mode 100644 index 0000000..51260a1 --- /dev/null +++ b/MVP/Presenters/AnnouncementsSettingsPresenter.cs @@ -0,0 +1,29 @@ +using System; + +using DotNetNuke.Common; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Presenters +{ + public class AnnouncementsSettingsPresenter : ModuleSettingsPresenter + { + private readonly IAnnouncementsController _announcementsController; + + public AnnouncementsSettingsPresenter(IAnnouncementsSettings announcementsSettings) + : base(announcementsSettings) + { + View.GetSettings += GetSettings; + + } + + private void GetSettings(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Settings = new SettingsController().GetModuleSettings(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + } +} \ No newline at end of file diff --git a/MVP/Presenters/AnnouncementsViewPresenter.cs b/MVP/Presenters/AnnouncementsViewPresenter.cs new file mode 100644 index 0000000..0f88bdf --- /dev/null +++ b/MVP/Presenters/AnnouncementsViewPresenter.cs @@ -0,0 +1,103 @@ +using System; + +using DotNetNuke.Common; +using DotNetNuke.Common.Utilities; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Modules.Announcements.Components.Business; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.Components.Template; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Security; +using DotNetNuke.Security.Permissions; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Presenters +{ + public class AnnouncementsViewPresenter : ModulePresenter + { + private readonly IAnnouncementsController _announcementsController; + + public AnnouncementsViewPresenter(IAnnouncementsView announcementsView) + : this(announcementsView, new AnnouncementsController()) + { + } + + public AnnouncementsViewPresenter(IAnnouncementsView announcementsView, IAnnouncementsController announcementsController) + : base(announcementsView) + { + Requires.NotNull("announcementsController", announcementsController); + + _announcementsController = announcementsController; + + View.GetSettings += GetSettings; + View.GetAnnouncements += GetAnnouncements; + View.GetTemplate += GetTemplate; + View.GetPermissions += GetPermissions; + View.GetRenderedTemplate += GetRenderedTemplate; + + } + + private void GetRenderedTemplate(object sender, EventArgs e) + { + View.Model.Template.LoadTemplate(); + View.Model.RenderedTemplate = View.Model.Template.RenderTemplate(View.Model.Announcements, View.Model.EditEnabled); + } + + private void GetSettings(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Settings = new SettingsController().GetModuleSettings(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + + private void GetPermissions(object sender, EventArgs e) + { + View.Model.CanEdit = PortalSecurity.HasNecessaryPermission(SecurityAccessLevel.Edit, ModuleContext.PortalSettings, ModuleInfo, ModuleContext.PortalSettings.UserInfo); + View.Model.EditEnabled = (ModuleContext.PortalSettings.UserMode != PortalSettings.Mode.View) && View.Model.CanEdit; + View.Model.CanSubscribe = ModulePermissionController.HasModulePermission(ModuleInfo.ModulePermissions, PermissionName.HasSubscribePermission); + } + + private void GetTemplate(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Template = new TemplateController().GetTemplate(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + + + /// + /// Handler for the GetAnnouncements event. This handler sets a value to View.Model.Announcements + /// + /// + /// + private void GetAnnouncements(object sender, EventArgs e) + { + + // bind data + DateTime datStartDate = Null.NullDate; + if (!View.Model.Settings.History.IsDnnNull()) + { + datStartDate = DateTime.Now.AddDays(-View.Model.Settings.History); + } + + switch (View.Model.Settings.DefaultViewType) + { + case ViewTypes.Current: + View.Model.Announcements = _announcementsController.GetCurrentAnnouncements(ModuleId, datStartDate); + break; + case ViewTypes.Expired: + View.Model.Announcements = _announcementsController.GetExpiredAnnouncements(ModuleId); + break; + case ViewTypes.Future: + View.Model.Announcements = _announcementsController.GetAnnouncements(ModuleId, DateTime.Now, Null.NullDate); + break; + case ViewTypes.All: + View.Model.Announcements = _announcementsController.GetAnnouncements(ModuleId, Null.NullDate, Null.NullDate); + break; + } + + + } + + } +} \ No newline at end of file diff --git a/MVP/Presenters/TemplateConfigurationPresenter.cs b/MVP/Presenters/TemplateConfigurationPresenter.cs new file mode 100644 index 0000000..cab09eb --- /dev/null +++ b/MVP/Presenters/TemplateConfigurationPresenter.cs @@ -0,0 +1,34 @@ +using System; + +using DotNetNuke.Common; +using DotNetNuke.Modules.Announcements.Components.Settings; +using DotNetNuke.Modules.Announcements.Components.Template; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Presenters +{ + public class TemplateConfigurationPresenter : ModulePresenter + { + public TemplateConfigurationPresenter(ITemplateConfiguration view) : base(view) + { + View.GetSettings += GetSettings; + View.GetTemplate += GetTemplate; + + + } + + private void GetTemplate(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Settings = new SettingsController().GetModuleSettings(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + + private void GetSettings(object sender, EventArgs e) + { + Requires.NotNull("ModuleContext", ModuleContext); + View.Model.Template = new TemplateController().GetTemplate(ModuleContext.ModuleId, ModuleContext.TabModuleId); + } + } +} \ No newline at end of file diff --git a/MVP/Views/IAnnouncementsEdit.cs b/MVP/Views/IAnnouncementsEdit.cs new file mode 100644 index 0000000..edcee4c --- /dev/null +++ b/MVP/Views/IAnnouncementsEdit.cs @@ -0,0 +1,17 @@ +using System; + +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Views +{ + public interface IAnnouncementsEdit : IModuleView + { + event EventHandler GetSettings; + event EventHandler GetItem; + event EventHandler GetAnnouncement; + event EventHandler DeleteAnnouncement; + event EventHandler UpdateAnnouncement; + } +} \ No newline at end of file diff --git a/MVP/Views/IAnnouncementsSettings.cs b/MVP/Views/IAnnouncementsSettings.cs new file mode 100644 index 0000000..7aa51eb --- /dev/null +++ b/MVP/Views/IAnnouncementsSettings.cs @@ -0,0 +1,13 @@ +using System; + +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Views +{ + public interface IAnnouncementsSettings : ISettingsView + { + event EventHandler GetSettings; + + } +} \ No newline at end of file diff --git a/MVP/Views/IAnnouncementsView.cs b/MVP/Views/IAnnouncementsView.cs new file mode 100644 index 0000000..f35b66b --- /dev/null +++ b/MVP/Views/IAnnouncementsView.cs @@ -0,0 +1,17 @@ +using System; + +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Views +{ + public interface IAnnouncementsView : IModuleView + { + event EventHandler GetSettings; + event EventHandler GetAnnouncements; + event EventHandler GetPermissions; + event EventHandler GetTemplate; + event EventHandler GetRenderedTemplate; + + } +} \ No newline at end of file diff --git a/MVP/Views/ITemplateConfiguration.cs b/MVP/Views/ITemplateConfiguration.cs new file mode 100644 index 0000000..4e394b3 --- /dev/null +++ b/MVP/Views/ITemplateConfiguration.cs @@ -0,0 +1,14 @@ +using System; + +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Web.Mvp; + +namespace DotNetNuke.Modules.Announcements.MVP.Views +{ + public interface ITemplateConfiguration : IModuleView + { + event EventHandler GetSettings; + event EventHandler GetTemplate; + + } +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4ab2d15 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,56 @@ +// +// DotNetNuke? - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +// Review the values of the assembly attributes + +[assembly: AssemblyTitle("DotNetNuke.Modules.Annoucements")] +[assembly: AssemblyDescription("This module renders a list of announcements.")] +[assembly: AssemblyCompany("DotNetNuke Corporation")] +[assembly: AssemblyProduct("http://www.dotnetnuke.com")] +[assembly: AssemblyCopyright("DotNetNuke is copyright 2002-2012 by DotNetNuke Corp. All Rights Reserved.")] +[assembly: AssemblyTrademark("DotNetNuke")] +[assembly: CLSCompliant(true)] +[assembly: ComVisibleAttribute(false)] + +//The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("B9083172-2470-43DB-8042-DB0B05614DC0")] +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("07.01.00.00")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Providers/DataProviders/SqlDataProvider/03.01.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.01.00.SqlDataProvider new file mode 100644 index 0000000..f1a72aa --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.01.00.SqlDataProvider @@ -0,0 +1,192 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Create Announcements Table **/ + +if not exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}Announcements]') and OBJECTPROPERTY(id, N'IsTable') = 1) + BEGIN + CREATE TABLE {databaseOwner}[{objectQualifier}Announcements] + ( + [ItemID] [int] NOT NULL IDENTITY(0, 1), + [ModuleID] [int] NOT NULL, + [CreatedByUser] [nvarchar] (100) NULL, + [CreatedDate] [datetime] NULL, + [Title] [nvarchar] (150) NULL, + [URL] [nvarchar] (150) NULL, + [ExpireDate] [datetime] NULL, + [Description] [nvarchar] (2000) NULL, + [ViewOrder] [int] NULL + ) + + ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] ADD CONSTRAINT [PK_{objectQualifier}Announcements] PRIMARY KEY NONCLUSTERED ([ItemID]) + CREATE NONCLUSTERED INDEX [IX_{objectQualifier}Announcements] ON {databaseOwner}[{objectQualifier}Announcements] ([ModuleID]) + + ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] WITH NOCHECK ADD + CONSTRAINT [FK_{objectQualifier}Announcements_{objectQualifier}Modules] FOREIGN KEY ([ModuleID]) REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) ON DELETE CASCADE +GO + + +/** Drop Existing Stored Procedures **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}AddAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}AddAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}DeleteAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}DeleteAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}UpdateAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}UpdateAnnouncement +GO + + +/** Create Stored Procedures **/ + +create procedure {databaseOwner}{objectQualifier}AddAnnouncement + +@ModuleId int, +@UserName nvarchar(100), +@Title nvarchar(150), +@URL nvarchar(150), +@ExpireDate DateTime, +@Description nvarchar(2000), +@ViewOrder int + +as + +insert into {objectQualifier}Announcements ( + ModuleId, + CreatedByUser, + CreatedDate, + Title, + URL, + ExpireDate, + Description, + ViewOrder +) +values ( + @ModuleId, + @UserName, + getdate(), + @Title, + @URL, + @ExpireDate, + @Description, + @ViewOrder +) + +select SCOPE_IDENTITY() + +GO + +create procedure {databaseOwner}{objectQualifier}DeleteAnnouncement + + @ItemId int + +as + +delete +from {objectQualifier}Announcements +where ItemId = @ItemId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncement + + @ItemId int, + @ModuleId int + +as + +select + {objectQualifier}Announcements.ItemID, + {objectQualifier}Announcements.ModuleID, + {objectQualifier}Announcements.Title, + case when {objectQualifier}Files.FileName is null then {objectQualifier}Announcements.URL else {objectQualifier}Files.Folder + {objectQualifier}Files.FileName end AS URL, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}Announcements.Description, + {objectQualifier}Users.FirstName + ' ' + {objectQualifier}Users.LastName AS CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}Users on {objectQualifier}Announcements.CreatedByUser = {objectQualifier}Users.UserId +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID left outer join {objectQualifier}Files on {objectQualifier}Announcements.URL = 'fileid=' + +convert(varchar,{objectQualifier}Files.FileID) +where {objectQualifier}Announcements.ItemId = @ItemId +and {objectQualifier}Announcements.ModuleId = @ModuleId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncements + + @ModuleId int + +as + +select + {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleID, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + case when {objectQualifier}Files.FileName is null then {objectQualifier}Announcements.URL else {objectQualifier}Files.Folder + {objectQualifier}Files.FileName end AS URL, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID left outer join {objectQualifier}Files on {objectQualifier}Announcements.URL = 'fileid=' + +convert(varchar,{objectQualifier}Files.FileID) +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ({objectQualifier}Announcements.ExpireDate > GetDate() or {objectQualifier}Announcements.ExpireDate is null) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.CreatedDate desc + +GO + +create procedure {databaseOwner}{objectQualifier}UpdateAnnouncement + + @ItemId int, + @UserName nvarchar(100), + @Title nvarchar(150), + @URL nvarchar(150), + @ExpireDate datetime, + @Description nvarchar(2000), + @ViewOrder int + +as + +update {objectQualifier}Announcements +set CreatedByUser = @UserName, + CreatedDate = GetDate(), + Title = @Title, + URL = @URL, + ExpireDate = @ExpireDate, + Description = @Description, + ViewOrder = @ViewOrder +where ItemId = @ItemId + +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.03.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.03.00.SqlDataProvider new file mode 100644 index 0000000..0cc9e02 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.03.00.SqlDataProvider @@ -0,0 +1,172 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Change CreatedByUser column to an int for performance **/ + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD + CreatedByUserID int NULL +GO + +update {databaseOwner}{objectQualifier}Announcements +set CreatedByUserID = convert(int,CreatedByUser) +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements + DROP COLUMN CreatedByUser +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD + CreatedByUser int NOT NULL CONSTRAINT DF_{objectQualifier}Announcements_CreatedByUser DEFAULT 0 +GO + +update {databaseOwner}{objectQualifier}Announcements +set CreatedByUser = CreatedByUserID +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements + DROP COLUMN CreatedByUserID +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements + DROP CONSTRAINT DF_{objectQualifier}Announcements_CreatedByUser +GO + + +/** Drop Existing Stored Procedures **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}AddAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}AddAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}UpdateAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}UpdateAnnouncement +GO + +/** Create Optimized Stored Procedures **/ + +create procedure {databaseOwner}{objectQualifier}AddAnnouncement + + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(150), + @Url nvarchar(150), + @Description nvarchar(2000), + @ViewOrder int + +as + +insert into {objectQualifier}Announcements ( + ModuleId, + CreatedByUser, + CreatedDate, + Title, + Url, + Description, + ViewOrder +) +values ( + @ModuleId, + @CreatedByUser, + @CreatedDate, + @Title, + @Url, + @Description, + @ViewOrder +) + +select SCOPE_IDENTITY() + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncement + +@ItemId int, +@ModuleId int + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ItemId = @ItemId +and {objectQualifier}Announcements.ModuleId = @ModuleId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncements + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.Description, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ( (({objectQualifier}Announcements.CreatedDate >= @StartDate) or @StartDate is null) and (({objectQualifier}Announcements.CreatedDate <= @EndDate) or @EndDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.CreatedDate desc + +GO + +create procedure {databaseOwner}{objectQualifier}UpdateAnnouncement + + @ItemId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(100), + @Url nvarchar(250), + @Description nvarchar(2000), + @ViewOrder int + +as + +update {objectQualifier}Announcements +set CreatedByUser = @CreatedByUser, + CreatedDate = @CreatedDate, + Title = @Title, + Url = @Url, + Description = @Description, + ViewOrder = @ViewOrder +where ItemId = @ItemId + +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.03.01.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.03.01.SqlDataProvider new file mode 100644 index 0000000..14ed95a --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.03.01.SqlDataProvider @@ -0,0 +1,14 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.03.02.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.03.02.SqlDataProvider new file mode 100644 index 0000000..a2fff3c --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.03.02.SqlDataProvider @@ -0,0 +1,159 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Add PublishDate field **/ +IF (SELECT COLUMNPROPERTY( OBJECT_ID('{databaseOwner}{objectQualifier}Announcements'),'PublishDate ','AllowsNull')) IS NULL +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD + PublishDate DateTime NULL +GO + +/** Set value for publishDate for existing records to CreatedDate **/ +UPDATE {databaseOwner}{objectQualifier}Announcements + SET PublishDate = CreatedDate +GO + +/** Drop Existing Stored Procedures **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}AddAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}AddAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}UpdateAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}UpdateAnnouncement +GO + + +/** Create Optimized Stored Procedures **/ + +create procedure {databaseOwner}{objectQualifier}AddAnnouncement + + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(150), + @Url nvarchar(150), + @Description nvarchar(2000), + @ViewOrder int, + @PublishDate datetime + +as + +insert into {objectQualifier}Announcements ( + ModuleId, + CreatedByUser, + CreatedDate, + Title, + Url, + Description, + ViewOrder, + PublishDate +) +values ( + @ModuleId, + @CreatedByUser, + @CreatedDate, + @Title, + @Url, + @Description, + @ViewOrder, + @PublishDate +) + +select SCOPE_IDENTITY() + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncement + +@ItemId int, +@ModuleId int + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ItemId = @ItemId +and {objectQualifier}Announcements.ModuleId = @ModuleId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncements + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ( (({objectQualifier}Announcements.CreatedDate >= @StartDate) or @StartDate is null) and (({objectQualifier}Announcements.CreatedDate <= @EndDate) or @EndDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + +create procedure {databaseOwner}{objectQualifier}UpdateAnnouncement + + @ItemId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(100), + @Url nvarchar(250), + @Description nvarchar(2000), + @ViewOrder int, + @PublishDate datetime + +as + +update {objectQualifier}Announcements +set CreatedByUser = @CreatedByUser, + CreatedDate = @CreatedDate, + Title = @Title, + Url = @Url, + Description = @Description, + ViewOrder = @ViewOrder, + PublishDate = @PublishDate +where ItemId = @ItemId + +GO +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.03.04.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.03.04.SqlDataProvider new file mode 100644 index 0000000..7853ffb --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.03.04.SqlDataProvider @@ -0,0 +1,48 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + + +/** Create Stored Procedures **/ + + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncements + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ( (({objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and (({objectQualifier}Announcements.PublishDate <= @EndDate) or @EndDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.03.05.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.03.05.SqlDataProvider new file mode 100644 index 0000000..68d4815 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.03.05.SqlDataProvider @@ -0,0 +1,55 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + +/** ensure expiry date column exists **/ +if not exists (select * from dbo.syscolumns where id = object_id(N'{databaseOwner}{objectQualifier}Announcements') and name=N'ExpireDate') +begin + ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD [ExpireDate] [datetime] NULL +end + +GO +/** Create Stored Procedures **/ + + +CREATE procedure {databaseOwner}{objectQualifier}GetAnnouncements + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ({objectQualifier}Announcements.ExpireDate > GetDate() or {objectQualifier}Announcements.ExpireDate is null) +and ( (({objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and (({objectQualifier}Announcements.PublishDate <= @EndDate) or @EndDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/03.04.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/03.04.00.SqlDataProvider new file mode 100644 index 0000000..51028d4 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/03.04.00.SqlDataProvider @@ -0,0 +1,292 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Alter Table, change description to NTEXT **/ + +if not exists (select * from dbo.syscolumns where id = object_id(N'{databaseOwner}{objectQualifier}Announcements') and xtype=99) +begin + ALTER TABLE {databaseOwner}{objectQualifier}Announcements ALTER COLUMN [Description] [NTEXT] NULL +end + +/** Add ImageSource field **/ +IF (SELECT COLUMNPROPERTY( OBJECT_ID('{databaseOwner}{objectQualifier}Announcements'),'ImageSource','AllowsNull')) IS NULL +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD + ImageSource [nvarchar] (250) NULL +GO + + +/** Drop old Stored Procedures **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}AddAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}AddAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetAnnouncements +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetCurrentAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetCurrentAnnouncements +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}GetExpiredAnnouncements]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}GetExpiredAnnouncements +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}UpdateAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}UpdateAnnouncement +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}DeleteAnnouncement]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}DeleteAnnouncement +GO + + +/** To make sure, also drop new sprocs **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Add +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Get]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Get +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetCurrent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetExpired]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Update +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Delete +GO + + + +/** Create Stored Procedures **/ + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Add + + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(150), + @ImageSource nvarchar(150), + @Url nvarchar(150), + @Description ntext, + @ViewOrder int, + @PublishDate datetime, + @ExpireDate datetime + +as + +insert into {objectQualifier}Announcements ( + ModuleId, + CreatedByUser, + CreatedDate, + Title, + ImageSource, + Url, + Description, + ViewOrder, + PublishDate, + ExpireDate +) +values ( + @ModuleId, + @CreatedByUser, + @CreatedDate, + @Title, + @ImageSource, + @Url, + @Description, + @ViewOrder, + @PublishDate, + @ExpireDate +) + +select SCOPE_IDENTITY() + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Get + +@ItemId int, +@ModuleId int + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.ImageSource, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ItemId = @ItemId +and {objectQualifier}Announcements.ModuleId = @ModuleId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent + +@ModuleId int, +@StartDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.ImageSource, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements + left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId + and ( (({objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and ({objectQualifier}Announcements.PublishDate <= GETDATE()) ) + and ( ({objectQualifier}Announcements.ExpireDate > getDate()) or ({objectQualifier}Announcements.ExpireDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired + +@ModuleId int + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.ImageSource, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements + left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId + and {objectQualifier}Announcements.ExpireDate <= getDate() +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {objectQualifier}Announcements.ItemId, + {objectQualifier}Announcements.ModuleId, + {objectQualifier}Announcements.CreatedByUser, + {objectQualifier}Announcements.CreatedDate, + {objectQualifier}Announcements.Title, + {objectQualifier}Announcements.ImageSource, + {objectQualifier}Announcements.URL, + {objectQualifier}Announcements.Description, + {objectQualifier}Announcements.ViewOrder, + {objectQualifier}Announcements.PublishDate, + {objectQualifier}Announcements.ExpireDate, + {objectQualifier}UrlTracking.TrackClicks, + {objectQualifier}UrlTracking.NewWindow +from {objectQualifier}Announcements +left outer join {objectQualifier}UrlTracking on {objectQualifier}Announcements.URL = {objectQualifier}UrlTracking.Url and {objectQualifier}UrlTracking.ModuleId = @ModuleID +where {objectQualifier}Announcements.ModuleId = @ModuleId +and ( (({objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and (({objectQualifier}Announcements.PublishDate <= @EndDate) or @EndDate is null) ) +order by {objectQualifier}Announcements.ViewOrder asc, {objectQualifier}Announcements.PublishDate desc + +GO + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Update + + @ItemId int, + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(100), + @ImageSource nvarchar(150), + @Url nvarchar(250), + @Description ntext, + @ViewOrder int, + @PublishDate datetime, + @ExpireDate datetime + +as + +update {objectQualifier}Announcements +set CreatedByUser = @CreatedByUser, + CreatedDate = @CreatedDate, + Title = @Title, + ImageSource = @ImageSource, + Url = @Url, + Description = @Description, + ViewOrder = @ViewOrder, + PublishDate = @PublishDate, + ExpireDate = @ExpireDate +where ItemId = @ItemId + and ModuleID = @ModuleID + +GO + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Delete + @ModuleId int, + @ItemId int + +as + +delete +from {objectQualifier}Announcements +where ItemId = @ItemId + and ModuleId = @ModuleID + +GO +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/04.00.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/04.00.00.SqlDataProvider new file mode 100644 index 0000000..85d076b --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/04.00.00.SqlDataProvider @@ -0,0 +1,250 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {databaseOwner}{objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Alter Table, change url to nvarchar 250 **/ + + ALTER TABLE {databaseOwner}{objectQualifier}Announcements ALTER COLUMN [URL] [nvarchar] (250) NULL + + +/** To make sure, also drop new sprocs **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Add +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Get]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Get +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetCurrent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetExpired]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Update +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Delete +GO + +/** Create Stored Procedures **/ + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Add + + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(150), + @ImageSource nvarchar(250), + @Url nvarchar(250), + @Description ntext, + @ViewOrder int, + @PublishDate datetime, + @ExpireDate datetime + +as + +insert into {databaseOwner}{objectQualifier}Announcements ( + ModuleId, + CreatedByUser, + CreatedDate, + Title, + ImageSource, + Url, + Description, + ViewOrder, + PublishDate, + ExpireDate +) +values ( + @ModuleId, + @CreatedByUser, + @CreatedDate, + @Title, + @ImageSource, + @Url, + @Description, + @ViewOrder, + @PublishDate, + @ExpireDate +) + +select SCOPE_IDENTITY() + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Get + +@ItemId int, +@ModuleId int + +as + +select {databaseOwner}{objectQualifier}Announcements.ItemId, + {databaseOwner}{objectQualifier}Announcements.ModuleId, + {databaseOwner}{objectQualifier}Announcements.CreatedByUser, + {databaseOwner}{objectQualifier}Announcements.CreatedDate, + {databaseOwner}{objectQualifier}Announcements.Title, + {databaseOwner}{objectQualifier}Announcements.ImageSource, + {databaseOwner}{objectQualifier}Announcements.URL, + {databaseOwner}{objectQualifier}Announcements.Description, + {databaseOwner}{objectQualifier}Announcements.ViewOrder, + {databaseOwner}{objectQualifier}Announcements.PublishDate, + {databaseOwner}{objectQualifier}Announcements.ExpireDate, + {databaseOwner}{objectQualifier}UrlTracking.TrackClicks, + {databaseOwner}{objectQualifier}UrlTracking.NewWindow +from {databaseOwner}{objectQualifier}Announcements +left outer join {databaseOwner}{objectQualifier}UrlTracking on {databaseOwner}{objectQualifier}Announcements.URL = {databaseOwner}{objectQualifier}UrlTracking.Url and {databaseOwner}{objectQualifier}UrlTracking.ModuleId = @ModuleID +where {databaseOwner}{objectQualifier}Announcements.ItemId = @ItemId +and {databaseOwner}{objectQualifier}Announcements.ModuleId = @ModuleId + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent + +@ModuleId int, +@StartDate datetime + +as + +select {databaseOwner}{objectQualifier}Announcements.ItemId, + {databaseOwner}{objectQualifier}Announcements.ModuleId, + {databaseOwner}{objectQualifier}Announcements.CreatedByUser, + {databaseOwner}{objectQualifier}Announcements.CreatedDate, + {databaseOwner}{objectQualifier}Announcements.Title, + {databaseOwner}{objectQualifier}Announcements.ImageSource, + {databaseOwner}{objectQualifier}Announcements.URL, + {databaseOwner}{objectQualifier}Announcements.Description, + {databaseOwner}{objectQualifier}Announcements.ViewOrder, + {databaseOwner}{objectQualifier}Announcements.PublishDate, + {databaseOwner}{objectQualifier}Announcements.ExpireDate, + {databaseOwner}{objectQualifier}UrlTracking.TrackClicks, + {databaseOwner}{objectQualifier}UrlTracking.NewWindow +from {databaseOwner}{objectQualifier}Announcements + left outer join {databaseOwner}{objectQualifier}UrlTracking on {databaseOwner}{objectQualifier}Announcements.URL = {databaseOwner}{objectQualifier}UrlTracking.Url and {databaseOwner}{objectQualifier}UrlTracking.ModuleId = @ModuleID +where {databaseOwner}{objectQualifier}Announcements.ModuleId = @ModuleId + and ( (({databaseOwner}{objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and ({databaseOwner}{objectQualifier}Announcements.PublishDate <= GETDATE()) ) + and ( ({databaseOwner}{objectQualifier}Announcements.ExpireDate > getDate()) or ({databaseOwner}{objectQualifier}Announcements.ExpireDate is null) ) +order by {databaseOwner}{objectQualifier}Announcements.ViewOrder asc, {databaseOwner}{objectQualifier}Announcements.PublishDate desc + +GO + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired + +@ModuleId int + +as + +select {databaseOwner}{objectQualifier}Announcements.ItemId, + {databaseOwner}{objectQualifier}Announcements.ModuleId, + {databaseOwner}{objectQualifier}Announcements.CreatedByUser, + {databaseOwner}{objectQualifier}Announcements.CreatedDate, + {databaseOwner}{objectQualifier}Announcements.Title, + {databaseOwner}{objectQualifier}Announcements.ImageSource, + {databaseOwner}{objectQualifier}Announcements.URL, + {databaseOwner}{objectQualifier}Announcements.Description, + {databaseOwner}{objectQualifier}Announcements.ViewOrder, + {databaseOwner}{objectQualifier}Announcements.PublishDate, + {databaseOwner}{objectQualifier}Announcements.ExpireDate, + {databaseOwner}{objectQualifier}UrlTracking.TrackClicks, + {databaseOwner}{objectQualifier}UrlTracking.NewWindow +from {databaseOwner}{objectQualifier}Announcements + left outer join {databaseOwner}{objectQualifier}UrlTracking on {databaseOwner}{objectQualifier}Announcements.URL = {databaseOwner}{objectQualifier}UrlTracking.Url and {databaseOwner}{objectQualifier}UrlTracking.ModuleId = @ModuleID +where {databaseOwner}{objectQualifier}Announcements.ModuleId = @ModuleId + and {databaseOwner}{objectQualifier}Announcements.ExpireDate <= getDate() +order by {databaseOwner}{objectQualifier}Announcements.ViewOrder asc, {databaseOwner}{objectQualifier}Announcements.PublishDate desc + +GO + + +CREATE procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll + +@ModuleId int, +@StartDate datetime, +@EndDate datetime + +as + +select {databaseOwner}{objectQualifier}Announcements.ItemId, + {databaseOwner}{objectQualifier}Announcements.ModuleId, + {databaseOwner}{objectQualifier}Announcements.CreatedByUser, + {databaseOwner}{objectQualifier}Announcements.CreatedDate, + {databaseOwner}{objectQualifier}Announcements.Title, + {databaseOwner}{objectQualifier}Announcements.ImageSource, + {databaseOwner}{objectQualifier}Announcements.URL, + {databaseOwner}{objectQualifier}Announcements.Description, + {databaseOwner}{objectQualifier}Announcements.ViewOrder, + {databaseOwner}{objectQualifier}Announcements.PublishDate, + {databaseOwner}{objectQualifier}Announcements.ExpireDate, + {databaseOwner}{objectQualifier}UrlTracking.TrackClicks, + {databaseOwner}{objectQualifier}UrlTracking.NewWindow +from {databaseOwner}{objectQualifier}Announcements +left outer join {databaseOwner}{objectQualifier}UrlTracking on {databaseOwner}{objectQualifier}Announcements.URL = {databaseOwner}{objectQualifier}UrlTracking.Url and {databaseOwner}{objectQualifier}UrlTracking.ModuleId = @ModuleID +where {databaseOwner}{objectQualifier}Announcements.ModuleId = @ModuleId +and ( (({databaseOwner}{objectQualifier}Announcements.PublishDate >= @StartDate) or @StartDate is null) and (({databaseOwner}{objectQualifier}Announcements.PublishDate <= @EndDate) or @EndDate is null) ) +order by {databaseOwner}{objectQualifier}Announcements.ViewOrder asc, {databaseOwner}{objectQualifier}Announcements.PublishDate desc + +GO + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Update + + @ItemId int, + @ModuleId int, + @CreatedByUser int, + @CreatedDate datetime, + @Title nvarchar(150), + @ImageSource nvarchar(250), + @Url nvarchar(250), + @Description ntext, + @ViewOrder int, + @PublishDate datetime, + @ExpireDate datetime + +as + +update {databaseOwner}{objectQualifier}Announcements +set CreatedByUser = @CreatedByUser, + CreatedDate = @CreatedDate, + Title = @Title, + ImageSource = @ImageSource, + Url = @Url, + Description = @Description, + ViewOrder = @ViewOrder, + PublishDate = @PublishDate, + ExpireDate = @ExpireDate +where ItemId = @ItemId + and ModuleID = @ModuleID + +GO + +create procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Delete + @ModuleId int, + @ItemId int + +as + +delete +from {databaseOwner}{objectQualifier}Announcements +where ItemId = @ItemId + and ModuleId = @ModuleID + +GO +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/04.00.01.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/04.00.01.SqlDataProvider new file mode 100644 index 0000000..050b12d --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/04.00.01.SqlDataProvider @@ -0,0 +1 @@ +/* this file is intentionally empty, it is needed for the version cleanup file to work */ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/04.00.02.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/04.00.02.SqlDataProvider new file mode 100644 index 0000000..050b12d --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/04.00.02.SqlDataProvider @@ -0,0 +1 @@ +/* this file is intentionally empty, it is needed for the version cleanup file to work */ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/04.00.03.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/04.00.03.SqlDataProvider new file mode 100644 index 0000000..050b12d --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/04.00.03.SqlDataProvider @@ -0,0 +1 @@ +/* this file is intentionally empty, it is needed for the version cleanup file to work */ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/07.00.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/07.00.00.SqlDataProvider new file mode 100644 index 0000000..51316a8 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/07.00.00.SqlDataProvider @@ -0,0 +1,74 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Drop Stored Procedures, version 7.0.0 of the module does not use these anymore **/ + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Add') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_Add +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Get') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_Get +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetAll') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetCurrent') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetExpired') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Update') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_Update +GO + +IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Delete') AND type in (N'P', N'PC')) + DROP PROCEDURE {databaseOwner}{objectQualifier}dnnAnnouncements_Delete +GO + + +/* update table definition */ +ALTER TABLE dbo.Announcements DROP CONSTRAINT PK_Announcements +GO + +ALTER TABLE dbo.Announcements ADD CONSTRAINT PK_Announcements PRIMARY KEY CLUSTERED ( [ItemID] ASC ) +GO + +sp_RENAME '{databaseOwner}{objectQualifier}Announcements.[CreatedByUser]', 'CreatedByUserID', 'COLUMN' +GO + +sp_RENAME '{databaseOwner}{objectQualifier}Announcements.[CreatedDate]', 'CreatedOnDate', 'COLUMN' +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD LastModifiedByUserID [int] NULL +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD LastModifiedOnDate [datetime] NULL +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ALTER COLUMN [Description] NVARCHAR(MAX) NULL +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD PortalID int NULL +GO + +UPDATE {databaseOwner}{objectQualifier}Announcements + SET {databaseOwner}{objectQualifier}Announcements.PortalID = {databaseOwner}{objectQualifier}Modules.PortalID + FROM {databaseOwner}{objectQualifier}Announcements INNER JOIN {databaseOwner}{objectQualifier}Modules ON {databaseOwner}{objectQualifier}Announcements.ModuleID = {databaseOwner}{objectQualifier}Modules.ModuleID +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/07.00.01.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/07.00.01.SqlDataProvider new file mode 100644 index 0000000..ecacb54 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/07.00.01.SqlDataProvider @@ -0,0 +1,70 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +ALTER TABLE {databaseOwner}{objectQualifier}Announcements ADD ContentItemID int NULL +GO + + +CREATE TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] +( +[AnnouncementsSubscriberID] [int] NOT NULL IDENTITY(1, 1), +[ModuleID] [int] NOT NULL, +[UserID] [int] NOT NULL, +[CreatedByUserID] [int] NULL, +[CreatedOnDate] [datetime] NULL, +[LastModifiedByUserID] [int] NULL, +[LastModifiedOnDate] [datetime] NULL +) + +ALTER TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] ADD CONSTRAINT [PK_{objectQualifier}AnnouncementsSubscribers] PRIMARY KEY CLUSTERED ([AnnouncementsSubscriberID]) +GO +ALTER TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] ADD CONSTRAINT [FK_{objectQualifier}AnnouncementsSubscribers_Modules] FOREIGN KEY ([ModuleID]) REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) ON DELETE CASCADE +GO +ALTER TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] ADD CONSTRAINT [FK_{objectQualifier}AnnouncementsSubscribers_Users] FOREIGN KEY ([UserID]) REFERENCES {databaseOwner}[{objectQualifier}Users] ([UserID]) ON DELETE CASCADE +GO + +/* add journal types */ + +DECLARE @NewJournalTypeId INT +SELECT @NewJournalTypeId = MAX(JournalTypeId) +FROM {databaseOwner}{objectQualifier}Journal_Types + + +IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}Journal_Types WHERE JournalType = 'AnnouncementAdd') + INSERT INTO {databaseOwner}[{objectQualifier}Journal_Types] + ( [JournalTypeId], [JournalType], [icon], [PortalId], [IsEnabled], [AppliesToProfile], [AppliesToGroup], [AppliesToStream], [Options], [SupportsNotify], [EnableComments]) + VALUES ( @NewJournalTypeId + 1, 'AnnouncementAdd', '', -1, 1, 1, 1, 1, NULL, 1, 1) + +IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}Journal_Types WHERE JournalType = 'AnnouncementUpdate') + INSERT INTO {databaseOwner}[{objectQualifier}Journal_Types] + ( [JournalTypeId], [JournalType], [icon], [PortalId], [IsEnabled], [AppliesToProfile], [AppliesToGroup], [AppliesToStream], [Options], [SupportsNotify], [EnableComments]) + VALUES ( @NewJournalTypeId + 2, 'AnnouncementUpdate', '', -1, 1, 1, 1, 1, NULL, 1, 1) + +IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}CoreMessaging_NotificationTypes WHERE Name = 'DNNAnnouncements') + INSERT INTO {databaseOwner}[{objectQualifier}CoreMessaging_NotificationTypes] + ([Name],[Description],[TTL],[DesktopModuleID],[CreatedByUserID],[CreatedOnDate],[LastModifiedByUserID],[LastModifiedOnDate]) + VALUES ( 'DNNAnnouncements', 'Announcement Notification', NULL, NULL, -1, GETDATE(), -1, GETDATE() ) + +GO + + +GO + + + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/Install.07.00.00.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/Install.07.00.00.SqlDataProvider new file mode 100644 index 0000000..81c24fd --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/Install.07.00.00.SqlDataProvider @@ -0,0 +1,47 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE {databaseOwner}[{objectQualifier}Announcements]( + [ItemID] [int] IDENTITY(0,1) NOT NULL, + [ModuleID] [int] NOT NULL, + [CreatedOnDate] [datetime] NULL, + [Title] [nvarchar](150) NULL, + [URL] [nvarchar](250) NULL, + [ExpireDate] [datetime] NULL, + [Description] [nvarchar](max) NULL, + [ViewOrder] [int] NULL, + [CreatedByUserID] [int] NOT NULL, + [PublishDate] [datetime] NULL, + [ImageSource] [nvarchar](250) NULL, + [LastModifiedByUserID] [int] NULL, + [LastModifiedOnDate] [datetime] NULL, + [PortalID] [int] NULL, + CONSTRAINT [PK_{objectQualifier}Announcements] PRIMARY KEY CLUSTERED ( [ItemID] ASC ) +) + +GO + +ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] WITH CHECK ADD CONSTRAINT [FK_{objectQualifier}Announcements_Modules] FOREIGN KEY([ModuleID]) +REFERENCES {databaseOwner}[{objectQualifier}Modules] ([ModuleID]) +ON DELETE CASCADE +GO + +ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] CHECK CONSTRAINT [FK_{objectQualifier}Announcements_Modules] +GO + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Providers/DataProviders/SqlDataProvider/Uninstall.SqlDataProvider b/Providers/DataProviders/SqlDataProvider/Uninstall.SqlDataProvider new file mode 100644 index 0000000..aecf014 --- /dev/null +++ b/Providers/DataProviders/SqlDataProvider/Uninstall.SqlDataProvider @@ -0,0 +1,70 @@ +/************************************************************/ +/***** SqlDataProvider *****/ +/***** *****/ +/***** *****/ +/***** Note: To manually execute this script you must *****/ +/***** perform a search and replace operation *****/ +/***** for {databaseOwner} and {objectQualifier} *****/ +/***** *****/ +/************************************************************/ + +/** Drop Announcements Table **/ + +ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] DROP CONSTRAINT [FK_{objectQualifier}Announcements_{objectQualifier}Modules] +GO + +ALTER TABLE {databaseOwner}[{objectQualifier}Announcements] DROP CONSTRAINT [PK_{objectQualifier}Announcements] +GO + +DROP INDEX {databaseOwner}[{objectQualifier}Announcements].[IX_{objectQualifier}Announcements] +GO + +DROP TABLE {databaseOwner}[{objectQualifier}Announcements] +GO + +/** Drop AnnouncementsSubscribers Table **/ +ALTER TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] DROP CONSTRAINT [FK_{objectQualifier}AnnouncementsSubscribers_Users] +GO + +ALTER TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] DROP CONSTRAINT [FK_{objectQualifier}AnnouncementsSubscribers_Modules] +GO + + +DROP TABLE {databaseOwner}[{objectQualifier}AnnouncementsSubscribers] +GO + + +/** Drop Stored Procedures **/ + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Add]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Add +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Get]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Get +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetAll]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetAll +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetCurrent]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetCurrent +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_GetExpired]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_GetExpired +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Update +GO + +if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}dnnAnnouncements_Delete]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) + drop procedure {databaseOwner}{objectQualifier}dnnAnnouncements_Delete +GO + + +/************************************************************/ +/***** SqlDataProvider *****/ +/************************************************************/ \ No newline at end of file diff --git a/Services/AnnouncementInfo.cs b/Services/AnnouncementInfo.cs new file mode 100644 index 0000000..1eaa3a9 --- /dev/null +++ b/Services/AnnouncementInfo.cs @@ -0,0 +1,110 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Runtime.Serialization; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Services +{ + + [DataContract] + public class AnnouncementInfo + { + +#region Constructors + + /// + /// Constructs a new AnnouncementInfo instance + /// + public AnnouncementInfo(Components.Business.AnnouncementInfo announcement) + { + CreatedByUserID = announcement.CreatedByUserID; + CreatedOnDate = announcement.CreatedOnDate; + Description = announcement.Description; + ExpireDate = announcement.ExpireDate; + ImageSource = announcement.ImageSource; + ItemID = announcement.ItemID; + ModuleID = announcement.ModuleID; + PublishDate = announcement.PublishDate; + Title = announcement.Title; + URL = announcement.URL; + ViewOrder = announcement.ViewOrder; + LastModifiedByUserID = announcement.LastModifiedByUserID; + LastModifiedOnDate = announcement.LastModifiedOnDate; + PortalID = announcement.PortalID; + Permalink = announcement.Permalink(); + } + + + +#endregion + +#region Properties + [DataMember] + public int ItemID { get; set; } + [DataMember] + public int ModuleID { get; set; } + [DataMember] + public DateTime CreatedOnDate { get; set; } + [DataMember] + public string Title { get; set; } + [DataMember] + public string URL { get; set; } + [DataMember] + public DateTime? ExpireDate { get; set; } + [DataMember] + public string Description { get; set; } + [DataMember] + public int ViewOrder { get; set; } + [DataMember] + public int CreatedByUserID { get; set; } + [DataMember] + public DateTime? PublishDate { get; set; } + [DataMember] + public string ImageSource { get; set; } + [DataMember] + public int LastModifiedByUserID { get; set; } + [DataMember] + public DateTime LastModifiedOnDate { get; set; } + [DataMember] + public string Permalink { get; set; } + [DataMember] + public int PortalID { get; set; } + +#endregion + + } + +} + + + + + + + diff --git a/Services/AnnouncementsController.cs b/Services/AnnouncementsController.cs new file mode 100644 index 0000000..6584425 --- /dev/null +++ b/Services/AnnouncementsController.cs @@ -0,0 +1,149 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Instrumentation; +using DotNetNuke.Security; +using DotNetNuke.Security.Permissions; +using DotNetNuke.Web.Api; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Services +{ + public class AnnouncementsController : DnnApiController + { + [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)] + [HttpGet] + [ActionName("Current")] + public HttpResponseMessage GetCurrentAnnouncements(string output) + { + try + { + + IEnumerable baseResults = + new Components.Business.AnnouncementsController().GetCurrentAnnouncements(ActiveModule.ModuleID); + List results = + baseResults.Select(announcementInfo => new AnnouncementInfo(announcementInfo)).ToList(); + return GenerateOutput(results, output); + } + catch (Exception ex) + { + DnnLog.Error(ex); + return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); + } + + } + + [DnnAuthorize] + [HttpGet] + [ActionName("All")] + public HttpResponseMessage GetAllAnnouncements(string output) + { + try + { + var mc = new ModuleController(); + var results = new List(); + // get list of all announcements modules in the site + var annModules = mc.GetModulesByDefinition(PortalSettings.PortalId, "Announcements"); + // loop through all the modules + foreach (ModuleInfo m in annModules ) + { + // make sure to only include modules the user actually has access to + if (ModulePermissionController.HasModuleAccess(SecurityAccessLevel.View, "VIEW", m)) + { + // get the current announcements of the module + IEnumerable baseResults = new Components.Business.AnnouncementsController().GetCurrentAnnouncements(m.ModuleID); + // add to the total results list + results.AddRange(baseResults.Select(announcementInfo => new AnnouncementInfo(announcementInfo)).ToList()); + } + } + + return GenerateOutput(results.OrderByDescending(a => a.PublishDate).ToList(), output); + } + catch (Exception ex) + { + DnnLog.Error(ex); + return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); + } + + } + + [AllowAnonymous] + [HttpGet] + public HttpResponseMessage HelloWorld() + { + return Request.CreateResponse(HttpStatusCode.OK, "Hello World!"); + } + + /// + /// This method returns all the announcements modules in the portal. + /// We don't want to show modules that the user has no access to, + /// so we are asking for DnnAuthorize here. + /// Next, we filter the list of modules on those that the user has at least view permissions to + /// + /// + [DnnAuthorize] + [HttpGet] + public HttpResponseMessage Modules() + { + var mc = new ModuleController(); + var annModules = mc.GetModulesByDefinition(PortalSettings.PortalId, "Announcements"); + var results = (from ModuleInfo m in annModules where ModulePermissionController.HasModuleAccess(SecurityAccessLevel.View, "VIEW", m) select new AnnouncementsModule(m)).ToList(); + + return Request.CreateResponse(HttpStatusCode.OK, results); + } + + private HttpResponseMessage GenerateOutput(List results, string output) + { + + //var output = System.Web.HttpContext.Current.Request.QueryString["OutputType"]; + switch (output) + { + case "xml": + return Request.CreateResponse(HttpStatusCode.OK, results, "application/xml"); + case "json": + return Request.CreateResponse(HttpStatusCode.OK, results, "application/json"); + case "rss": + return Request.CreateResponse(HttpStatusCode.OK, results, + new SyndicationFeedFormatter(PortalSettings, System.Web.HttpContext.Current.Request), "application/rss+xml"); + case "atom": + return Request.CreateResponse(HttpStatusCode.OK, results, + new SyndicationFeedFormatter(PortalSettings, System.Web.HttpContext.Current.Request), "application/atom+xml"); + default: + return Request.CreateResponse(HttpStatusCode.OK, results); + } + + } + + } +} \ No newline at end of file diff --git a/Services/AnnouncementsModule.cs b/Services/AnnouncementsModule.cs new file mode 100644 index 0000000..ac70f21 --- /dev/null +++ b/Services/AnnouncementsModule.cs @@ -0,0 +1,54 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Runtime.Serialization; +using System.Xml.Serialization; +using DotNetNuke.Entities.Modules; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Services +{ + [Serializable, XmlRoot("AnnouncementsModule")] + [DataContract] + public class AnnouncementsModule + { + [DataMember] + public string Title { get; set; } + [DataMember] + public int ModuleID { get; set; } + [DataMember] + public int TabID { get; set; } + + public AnnouncementsModule(ModuleInfo dnnModule) + { + Title = dnnModule.ModuleTitle; + ModuleID = dnnModule.ModuleID; + TabID = dnnModule.TabID; + } + } +} \ No newline at end of file diff --git a/Services/RouteMapper.cs b/Services/RouteMapper.cs new file mode 100644 index 0000000..9334254 --- /dev/null +++ b/Services/RouteMapper.cs @@ -0,0 +1,48 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System.Web.Routing; +using DotNetNuke.Web.Api; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Services +{ + public class RouteMapper : IServiceRouteMapper + { + + public void RegisterRoutes(IMapRoute mapRouteManager) + { + + mapRouteManager.MapHttpRoute("Announcements", + "auto", + "{controller}/{action}/{output}", + new RouteValueDictionary {{ "output", "auto" }}, + new RouteValueDictionary {{ "output", "xml|json|rss|atom|auto" }}, + new[] { "DotNetNuke.Modules.Announcements.Services" }); + } + } +} \ No newline at end of file diff --git a/Services/SyndicationFeedFormatter.cs b/Services/SyndicationFeedFormatter.cs new file mode 100644 index 0000000..2bc1177 --- /dev/null +++ b/Services/SyndicationFeedFormatter.cs @@ -0,0 +1,158 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.ServiceModel.Syndication; +using System.Threading.Tasks; +using System.Web; +using System.Xml; +using DotNetNuke.Entities.Portals; + +#endregion + +namespace DotNetNuke.Modules.Announcements.Services +{ + public class SyndicationFeedFormatter : MediaTypeFormatter + { + private readonly string atom = "application/atom+xml"; + private readonly string rss = "application/rss+xml"; + private PortalSettings portalSettings; + private HttpRequest request; + public SyndicationFeedFormatter(PortalSettings portalSettings, HttpRequest request) + { + this.portalSettings = portalSettings; + this.request = request; + SupportedMediaTypes.Add(new MediaTypeHeaderValue(atom)); + SupportedMediaTypes.Add(new MediaTypeHeaderValue(rss)); + } + + readonly Func _supportedType = type => type == typeof(AnnouncementInfo) || type == typeof(List); + + public override bool CanReadType(Type type) + { + return _supportedType(type); + } + + public override bool CanWriteType(Type type) + { + return _supportedType(type); + } + + public override Task WriteToStreamAsync(Type type, object value, Stream writeStream, HttpContent content, TransportContext transportContext) + { + return Task.Factory.StartNew(() => + { + if (_supportedType(type)) + BuildSyndicationFeed(value, writeStream, content.Headers.ContentType.MediaType); + }); + } + + private void BuildSyndicationFeed(object models, Stream stream, string contenttype) + { + string baseUrl = request.Url.Scheme + "://" + request.Url.Authority; + + var items = new List(); + var feed = new SyndicationFeed + { + Title = new TextSyndicationContent(portalSettings.PortalName), + Description = new TextSyndicationContent(portalSettings.Description), + Copyright = new TextSyndicationContent(portalSettings.FooterText), + Id = new Uri(baseUrl).ToString(), + LastUpdatedTime = new DateTimeOffset(DateTime.Now) + }; + + var link = new SyndicationLink(new Uri(baseUrl + request.RawUrl)) + { + RelationshipType = "self", + Title = portalSettings.PortalName + }; + feed.Links.Add(link); + + link = new SyndicationLink(new Uri(baseUrl)) {MediaType = "text/html", Title = portalSettings.PortalName}; + feed.Links.Add(link); + + var list = models as List; + if (list != null) + { + items.AddRange(from announcementInfo in list select BuildSyndicationItem(announcementInfo)); + } + else + { + items.Add(BuildSyndicationItem((AnnouncementInfo)models)); + } + + feed.Items = items; + + using (var writer = XmlWriter.Create(stream)) + { + if (string.Equals(contenttype, atom)) + { + var atomformatter = new Atom10FeedFormatter(feed); + atomformatter.WriteTo(writer); + } + else + { + var rssformatter = new Rss20FeedFormatter(feed); + rssformatter.WriteTo(writer); + } + } + } + + private SyndicationItem BuildSyndicationItem(AnnouncementInfo ann) + { + var item = new SyndicationItem(); + if (ann.PublishDate != null) + item.PublishDate = DateTime.SpecifyKind(ann.PublishDate.Value,DateTimeKind.Utc); + + item.Content = new TextSyndicationContent(ann.Description, TextSyndicationContentKind.Html); + item.LastUpdatedTime = DateTime.SpecifyKind(ann.LastModifiedOnDate, DateTimeKind.Utc); + item.Title = new TextSyndicationContent(ann.Title); + var p = ann.Permalink; + if (p != null) + { + //item.BaseUri = new Uri(p); + item.AddPermalink(new Uri(p)); + } + + if (ann.URL != "") + { + item.Links.Add(new SyndicationLink(new Uri(ann.URL))); + item.Id = ann.URL; + } + + item.Authors.Add(new SyndicationPerson { Name = ann.LastModifiedByUserID.ToString(CultureInfo.InvariantCulture) }); + return item; + } + } +} \ No newline at end of file diff --git a/TemplateConfiguration.ascx b/TemplateConfiguration.ascx new file mode 100644 index 0000000..c0d3c91 --- /dev/null +++ b/TemplateConfiguration.ascx @@ -0,0 +1,108 @@ +<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="TemplateConfiguration.ascx.cs" Inherits="DotNetNuke.Modules.Announcements.TemplateConfiguration" %> +<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %> +<%@ Register TagPrefix="dnn" TagName="URL" Src="~/controls/URLControl.ascx" %> +<%@ Import Namespace="DotNetNuke.Services.Localization" %> +<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %> +<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.UI.WebControls" Assembly="DotNetNuke.Web" %> + +
+
+
+ + + Load Default +
+
+ + + Load Default +
+
+ + + Load Default +
+
+ + + Load Default +
+
+ + + Load Default + +
+
+

+ + <%=LocalizeString("TemplateHelp.head")%>

+
+
+ + +
+
+
+
    +
  • +
  • +
  • +
  • +
+
+ +
+ + \ No newline at end of file diff --git a/TemplateConfiguration.ascx.cs b/TemplateConfiguration.ascx.cs new file mode 100644 index 0000000..c288b0b --- /dev/null +++ b/TemplateConfiguration.ascx.cs @@ -0,0 +1,182 @@ +#region License + +// +// DotNetNuke® - http://www.dotnetnuke.com +// Copyright (c) 2002-2012 +// by DotNetNuke Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +// to permit persons to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or substantial portions +// of the Software. +// +// 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. +// + +#endregion + +#region Usings + +using System; +using DotNetNuke.Common; +using DotNetNuke.Entities.Modules; +using DotNetNuke.Modules.Announcements.Components.Common; +using DotNetNuke.Modules.Announcements.Components.Template; +using DotNetNuke.Modules.Announcements.MVP.Models; +using DotNetNuke.Modules.Announcements.MVP.Presenters; +using DotNetNuke.Modules.Announcements.MVP.Views; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Services.Localization; +using DotNetNuke.Web.Mvp; +using WebFormsMvp; + +#endregion + +namespace DotNetNuke.Modules.Announcements +{ + + /// + /// The Settings ModuleSettingsBase is used to manage the + /// settings for the Links Module + /// + /// + /// + [PresenterBinding(typeof(TemplateConfigurationPresenter))] + public partial class TemplateConfiguration : ModuleView, ITemplateConfiguration + { + public event EventHandler GetSettings; + public event EventHandler GetTemplate; + + private void ApplySettings() + { + try + { + cmdLoadDefHeader.ToolTip = LocalizeString("LoadDefault.Help"); + cmdLoadDefItemTemplate.ToolTip = LocalizeString("LoadDefault.Help"); + cmdLoadDefAltItemTemplate.ToolTip = LocalizeString("LoadDefault.Help"); + cmdLoadDefSeparator.ToolTip = LocalizeString("LoadDefault.Help"); + cmdLoadDefFooterTemplate.ToolTip = LocalizeString("LoadDefault.Help"); + + litTemplateHelp.Text = Localization.GetString("ModuleHelp.Text", LocalResourceFile); + + if (!Page.IsPostBack) + { + var localTemplate = Model.Template as SimpleTemplate; + + if (localTemplate != null) + { + txtTemplate.Text = localTemplate.ItemTemplate; + txtHeaderTemplate.Text = localTemplate.HeaderTemplate; + txtAltItemTemplate.Text = localTemplate.AltItemTemplate; + txtSeparator.Text = localTemplate.Separator; + txtFooterTemplate.Text = localTemplate.FooterTemplate; + } + } + } + catch (Exception exc) //Module failed to load + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + /// + /// UpdateSettings saves the modified settings to the Database + /// + /// + /// + private void UpdateSettings() + { + try + { + var objModules = new ModuleController(); + + ((SimpleTemplate)Model.Template).ItemTemplate = txtTemplate.Text.Trim(); + ((SimpleTemplate)Model.Template).HeaderTemplate = txtHeaderTemplate.Text; + ((SimpleTemplate)Model.Template).AltItemTemplate = txtAltItemTemplate.Text; + ((SimpleTemplate)Model.Template).Separator = txtSeparator.Text; + ((SimpleTemplate)Model.Template).FooterTemplate = txtFooterTemplate.Text; + + ((SimpleTemplate)Model.Template).UpdateTemplate(); + + //ModuleController.SynchronizeModule(MModuleId); + //DataCache.RemoveCache(ModuleController.CacheKey(TabModuleId) + "_viewType"); + + // redirect back to page + Response.Redirect(Globals.NavigateURL(), true); + + } + catch (Exception exc) //Module failed to load + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + //protected void CmdLoadDefHeaderClick(object sender, System.EventArgs e) + //{ + // Template.HeaderTemplate = Template.ItemTemplate; + // txtHeaderTemplate.Text = Template.HeaderTemplate; + //} + + //protected void CmdLoadDefItemTemplateClick(object sender, System.EventArgs e) + //{ + // Template.ItemTemplate = Template.GetTemplate("Template", true); + // txtTemplate.Text = Template.ItemTemplate; + //} + + //protected void CmdLoadDefAltItemTemplateClick(object sender, System.EventArgs e) + //{ + // Template.AltItemTemplate = Template.GetTemplate("AltItemTemplate", true); + // txtAltItemTemplate.Text = Template.AltItemTemplate; + //} + + //protected void CmdLoadDefSeparatorClick(object sender, System.EventArgs e) + //{ + // Template.Separator = Template.GetTemplate("Separator", true); + // txtSeparator.Text = Template.Separator; + //} + + //protected void CmdLoadDefFooterTemplateClick(object sender, System.EventArgs e) + //{ + // Template.FooterTemplate = Template.GetTemplate("FooterTemplate", true); + // txtFooterTemplate.Text = Template.FooterTemplate; + //} + + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + + //cmdLoadDefHeader.Click += CmdLoadDefHeaderClick; + //cmdLoadDefItemTemplate.Click += CmdLoadDefItemTemplateClick; + //cmdLoadDefAltItemTemplate.Click += CmdLoadDefAltItemTemplateClick; + //cmdLoadDefSeparator.Click += CmdLoadDefSeparatorClick; + //cmdLoadDefFooterTemplate.Click += CmdLoadDefFooterTemplateClick; + cmdUpdate.Click += CmdUpdateClick; + } + + protected override void OnLoad(EventArgs e) + { + GetSettings(this, EventArgs.Empty); + GetTemplate(this, EventArgs.Empty); + ApplySettings(); + + var moduleSecurity = new ModuleSecurity(ModuleContext.Configuration); + if (!moduleSecurity.HasEditTemplatePermission) + Response.Redirect(Globals.NavigateURL("Access Denied")); + cancelHyperLink.NavigateUrl = Globals.NavigateURL(); + } + + protected void CmdUpdateClick(object sender, EventArgs e) + { + UpdateSettings(); + } + + } + +} diff --git a/TemplateConfiguration.ascx.designer.cs b/TemplateConfiguration.ascx.designer.cs new file mode 100644 index 0000000..ac574b7 --- /dev/null +++ b/TemplateConfiguration.ascx.designer.cs @@ -0,0 +1,177 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DotNetNuke.Modules.Announcements { + + + public partial class TemplateConfiguration { + + /// + /// plHeaderTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plHeaderTemplate; + + /// + /// txtHeaderTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtHeaderTemplate; + + /// + /// cmdLoadDefHeader control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdLoadDefHeader; + + /// + /// plTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plTemplate; + + /// + /// txtTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtTemplate; + + /// + /// cmdLoadDefItemTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdLoadDefItemTemplate; + + /// + /// plAltItemTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plAltItemTemplate; + + /// + /// txtAltItemTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtAltItemTemplate; + + /// + /// cmdLoadDefAltItemTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdLoadDefAltItemTemplate; + + /// + /// plSeparator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plSeparator; + + /// + /// txtSeparator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtSeparator; + + /// + /// cmdLoadDefSeparator control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdLoadDefSeparator; + + /// + /// plFooterTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl plFooterTemplate; + + /// + /// txtFooterTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtFooterTemplate; + + /// + /// cmdLoadDefFooterTemplate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdLoadDefFooterTemplate; + + /// + /// litTemplateHelp control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Literal litTemplateHelp; + + /// + /// cmdUpdate control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton cmdUpdate; + + /// + /// cancelHyperLink control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HyperLink cancelHyperLink; + } +} diff --git a/Templates/ModernAnnouncements/alternatingitem.htm b/Templates/ModernAnnouncements/alternatingitem.htm new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Templates/ModernAnnouncements/alternatingitem.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Templates/ModernAnnouncements/detail.htm b/Templates/ModernAnnouncements/detail.htm new file mode 100644 index 0000000..4d6eddd --- /dev/null +++ b/Templates/ModernAnnouncements/detail.htm @@ -0,0 +1 @@ +
[RETURN]
[EDIT][ANNOUNCEMENT:TITLE]
[ANNOUNCEMENT:DESCRIPTION]
\ No newline at end of file diff --git a/Templates/ModernAnnouncements/footer.htm b/Templates/ModernAnnouncements/footer.htm new file mode 100644 index 0000000..ac97603 --- /dev/null +++ b/Templates/ModernAnnouncements/footer.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Templates/ModernAnnouncements/header.htm b/Templates/ModernAnnouncements/header.htm new file mode 100644 index 0000000..020432e --- /dev/null +++ b/Templates/ModernAnnouncements/header.htm @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/Templates/ModernAnnouncements/item.htm b/Templates/ModernAnnouncements/item.htm new file mode 100644 index 0000000..d5d1a82 --- /dev/null +++ b/Templates/ModernAnnouncements/item.htm @@ -0,0 +1,3 @@ +
[IMAGESOURCE]
+

[EDIT][TITLE] - [PUBLISHDATE]

[DESCRIPTION] [READMORE]
+
diff --git a/Templates/ModernAnnouncements/separator.htm b/Templates/ModernAnnouncements/separator.htm new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Templates/ModernAnnouncements/separator.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Templates/ModernAnnouncements/template.xml b/Templates/ModernAnnouncements/template.xml new file mode 100644 index 0000000..4be9c4c --- /dev/null +++ b/Templates/ModernAnnouncements/template.xml @@ -0,0 +1,14 @@ + + + SimpleTemplate + item.htm + + header.htm + footer.htm + + + + + 01.00.00 + 2012-11-28T23:30:00 + \ No newline at end of file diff --git a/Templates/SimpleAnnouncements/alternatingitem.htm b/Templates/SimpleAnnouncements/alternatingitem.htm new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Templates/SimpleAnnouncements/alternatingitem.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Templates/SimpleAnnouncements/detail.htm b/Templates/SimpleAnnouncements/detail.htm new file mode 100644 index 0000000..4d6eddd --- /dev/null +++ b/Templates/SimpleAnnouncements/detail.htm @@ -0,0 +1 @@ +
[RETURN]
[EDIT][ANNOUNCEMENT:TITLE]
[ANNOUNCEMENT:DESCRIPTION]
\ No newline at end of file diff --git a/Templates/SimpleAnnouncements/footer.htm b/Templates/SimpleAnnouncements/footer.htm new file mode 100644 index 0000000..ac97603 --- /dev/null +++ b/Templates/SimpleAnnouncements/footer.htm @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/Templates/SimpleAnnouncements/header.htm b/Templates/SimpleAnnouncements/header.htm new file mode 100644 index 0000000..020432e --- /dev/null +++ b/Templates/SimpleAnnouncements/header.htm @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/Templates/SimpleAnnouncements/item.htm b/Templates/SimpleAnnouncements/item.htm new file mode 100644 index 0000000..6f23b36 --- /dev/null +++ b/Templates/SimpleAnnouncements/item.htm @@ -0,0 +1 @@ +
[IMAGESOURCE]
[EDIT][TITLE] - [PUBLISHDATE]
[DESCRIPTION] [READMORE]
\ No newline at end of file diff --git a/Templates/SimpleAnnouncements/separator.htm b/Templates/SimpleAnnouncements/separator.htm new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Templates/SimpleAnnouncements/separator.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Templates/SimpleAnnouncements/template.xml b/Templates/SimpleAnnouncements/template.xml new file mode 100644 index 0000000..4be9c4c --- /dev/null +++ b/Templates/SimpleAnnouncements/template.xml @@ -0,0 +1,14 @@ + + + SimpleTemplate + item.htm + + header.htm + footer.htm + + + + + 01.00.00 + 2012-11-28T23:30:00 + \ No newline at end of file diff --git a/_Dependencies/ReadMe.txt b/_Dependencies/ReadMe.txt new file mode 100644 index 0000000..bafb06c --- /dev/null +++ b/_Dependencies/ReadMe.txt @@ -0,0 +1,9 @@ +The source install package leaves this folder empty. Please copy the following files from your DotNetNuke 7.1.1 installation to this directory: + +DotNetNuke.dll +DotNetNuke.Instrumentation.dll +DotNetNuke.Web.Client.dll +DotNetNuke.Web.dll +Telerik.Web.UI.dll +WebFormsMvp.dll + diff --git a/module.css b/module.css new file mode 100644 index 0000000..9bb084e --- /dev/null +++ b/module.css @@ -0,0 +1,11 @@ +/* ======================================== + CSS STYLES FOR Module DNN.Announcements + ======================================== +*/ +.DNN_ANN_DesignTable { width: auto; } +.DNN_ANN_Description {} +.DNN_ANN_Description p { margin-top: 0px; } +.DNN_ANN_viewtypeSelector { float: right; } +.DNN_ANN_viewtypeSelectorLabel { float: left; } +.DNN_ANN_viewtypeSelectorDDL { float: left; } +.DNN_ANN_ImageDiv { float: left;margin-right: 5px;} \ No newline at end of file