Skip to content

Commit

Permalink
Form and List 6.4.0 - no Telerik - no deprecated System Calls
Browse files Browse the repository at this point in the history
  • Loading branch information
SCullman committed May 11, 2018
1 parent a9495eb commit 885da7b
Show file tree
Hide file tree
Showing 40 changed files with 5,051 additions and 5,126 deletions.
304 changes: 158 additions & 146 deletions App_LocalResources/form.ascx.resx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: ComVisible(false)]


[assembly: AssemblyVersion("06.03.03.00")]
[assembly: AssemblyVersion("06.04.00.00")]
[assembly: CLSCompliant(true)]
[assembly: AssemblyFileVersion("06.03.03.00")]
[assembly: AssemblyFileVersion("06.04.00.00")]

127 changes: 67 additions & 60 deletions BusinessController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Web;
using System.Xml;
Expand All @@ -11,35 +10,34 @@
using DotNetNuke.Modules.UserDefinedTable.Components;
using DotNetNuke.Modules.UserDefinedTable.Interfaces;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;
using DotNetNuke.Services.Search;
using DotNetNuke.Services.Search.Entities;
using Microsoft.VisualBasic;
using Globals = DotNetNuke.Common.Globals;

namespace DotNetNuke.Modules.UserDefinedTable
{
public class BusinessController : ISearchable, IPortable, IPortable2
public class BusinessController : ModuleSearchBase, IPortable, IPortable2
{
public enum SettingsType
{
ModuleSettings,
TabModuleSettings
}

static DataTable GetSettingsTable(int id, SettingsType type)
{
var modules = new ModuleController();
Hashtable settings = null;
static DataTable GetSettingsTable(Hashtable settings, SettingsType type)
{


DataTable returnValue = null;

switch (type)
{
case SettingsType.ModuleSettings:
settings = modules.GetModuleSettings(id);
case SettingsType.ModuleSettings:

returnValue = new DataTable(DataSetTableName.Settings);
break;
case SettingsType.TabModuleSettings:
settings = modules.GetTabModuleSettings(id);
case SettingsType.TabModuleSettings:

returnValue = new DataTable(DataSetTableName.TabSettings);
break;
}
Expand All @@ -52,38 +50,38 @@ static DataTable GetSettingsTable(int id, SettingsType type)
}


var dc = new DataColumn(SettingsTableColumn.Setting, typeof (string))
{ColumnMapping = MappingType.Attribute};
if (returnValue != null) returnValue.Columns.Add(dc);

dc = new DataColumn(SettingsTableColumn.Value, typeof (string)) {ColumnMapping = MappingType.Attribute};
if (returnValue != null)
{
returnValue.Columns.Add(dc);

foreach (var key in sortedSettings.Keys)
{
var row = returnValue.NewRow();
row[SettingsTableColumn.Setting] = key;
row[SettingsTableColumn.Value] = sortedSettings[key];
returnValue.Rows.Add(row);
}
return returnValue;
using (var nameCol = new DataColumn(SettingsTableColumn.Setting, typeof(string)) { ColumnMapping = MappingType.Attribute })
{
if (returnValue != null)
{
returnValue.Columns.Add(nameCol);
using (var valCol = new DataColumn(SettingsTableColumn.Value, typeof(string)) { ColumnMapping = MappingType.Attribute })
{
returnValue.Columns.Add(valCol);
foreach (var key in sortedSettings.Keys)
{
var row = returnValue.NewRow();
row[SettingsTableColumn.Setting] = key;
row[SettingsTableColumn.Value] = sortedSettings[key];
returnValue.Rows.Add(row);
}
}
}
}
return null;
return returnValue;
}

DataTable GetStylesheetTable(Components.Settings settings, int portalId)
{
var returnValue = new DataTable(DataSetTableName.Stylesheets);

returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.NameOfSetting, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.LocalFilePath, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.Stylesheet, typeof (string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.NameOfSetting, typeof(string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.LocalFilePath, typeof(string)));
returnValue.Columns.Add(new DataColumn(StylesheetTableColumn.Stylesheet, typeof(string)));

var renderMethod = string.Format("UDT_{0}", settings.RenderingMethod );
var renderMethod = string.Format("UDT_{0}", settings.RenderingMethod);
var listScript = renderMethod == SettingName.XslUserDefinedStyleSheet
? settings.ScriptByRenderingMethod( renderMethod )
? settings.ScriptByRenderingMethod(renderMethod)
: string.Empty;
if (listScript.Length > 0)
{
Expand All @@ -106,16 +104,16 @@ DataTable GetStylesheetTable(Components.Settings settings, int portalId)
}

return returnValue;
}

}

/// -----------------------------------------------------------------------------
/// <summary>
/// Implements the search interface for DotNetNuke
/// </summary>
/// -----------------------------------------------------------------------------
public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
{
var searchItemCollection = new SearchItemInfoCollection();
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc)
{
var searchDocuments = new List<SearchDocument>();
var udtController = new UserDefinedTableController(modInfo);

try
Expand All @@ -128,8 +126,7 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
var colnameChangedAt = udtController.ColumnNameByDataType(dsUserDefinedRows,
DataTypeNames.UDT_DataType_ChangedAt);

var moduleController = new ModuleController();
var settings = moduleController.GetModuleSettings(modInfo.ModuleID);
var settings = modInfo.ModuleSettings;
var includeInSearch = !(settings[SettingName.ExcludeFromSearch].AsBoolean());

if (includeInSearch)
Expand All @@ -139,11 +136,11 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
var changedDate = DateTime.Today;
var changedByUserId = 0;

if (colnameChangedAt != string.Empty && ! Information.IsDBNull(row[colnameChangedAt]))
if (colnameChangedAt != string.Empty && !Information.IsDBNull(row[colnameChangedAt]))
{
changedDate = Convert.ToDateTime(row[colnameChangedAt]);
}
if (colnameChangedBy != string.Empty && ! Information.IsDBNull(row[colnameChangedBy]))
if (colnameChangedBy != string.Empty && !Information.IsDBNull(row[colnameChangedBy]))
{
changedByUserId = ModuleSecurity.UserId(row[colnameChangedBy].ToString(), modInfo.PortalID);
}
Expand All @@ -163,11 +160,20 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
if (desc.EndsWith("<br/>"))
{
desc = desc.Substring(0, Convert.ToInt32(desc.Length - 5));
}
var searchItem = new SearchItemInfo(modInfo.ModuleTitle, desc, changedByUserId, changedDate,
modInfo.ModuleID, row[DataTableColumn.RowId].ToString(),
desc);
searchItemCollection.Add(searchItem);
}

var searchDoc = new SearchDocument
{
UniqueKey = row[DataTableColumn.RowId].ToString(),
PortalId = modInfo.PortalID,
Title = modInfo.ModuleTitle,
Description = desc,
Body = desc,
ModifiedTimeUtc = changedDate
};

searchDocuments.Add(searchDoc);

}
}
}
Expand All @@ -176,7 +182,7 @@ public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
Exceptions.LogException(ex);
}

return searchItemCollection;
return searchDocuments;
}


Expand Down Expand Up @@ -223,15 +229,16 @@ public DataSet ExportModuleDataSet(int moduleId, int tabId)
{
var udtController = new UserDefinedTableController(moduleId);
ds = udtController.GetDataSet(false);
ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
var moduleInfo = new ModuleController().GetModule(moduleId);
ds.Tables.Add(GetSettingsTable(moduleInfo.ModuleSettings, SettingsType.ModuleSettings));
}
else
{
var moduleInfo = new ModuleController().GetModule(moduleId, tabId);
var udtController = new UserDefinedTableController(moduleInfo);
ds = udtController.GetDataSet(false);
ds.Tables.Add(GetSettingsTable(moduleId, SettingsType.ModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleID, SettingsType.TabModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.ModuleSettings, SettingsType.ModuleSettings));
ds.Tables.Add(GetSettingsTable(moduleInfo.TabModuleSettings, SettingsType.TabModuleSettings));
ds.Tables.Add(GetStylesheetTable(udtController.Settings, moduleInfo.PortalID));
}
return (ds);
Expand Down Expand Up @@ -277,7 +284,7 @@ public void ImportModule(int moduleId, int tabId, string content, string version
{
AddTabModuleSettings(modules, tabModuleId, ds);
}
if (! isInstance)
if (!isInstance)
{
AddModuleSettings(moduleId, modules, ds);
//Fields - first delete old Fields
Expand Down Expand Up @@ -348,7 +355,7 @@ static void ImportStyleSheet(int moduleId, bool isInstance, int tabModuleId, Mod
}
else
{
if (! isInstance)
if (!isInstance)
{
modules.UpdateModuleSetting(moduleId, settingName,
string.Format("{0}/{1}", Definition.XSLFolderName, fileName));
Expand All @@ -375,10 +382,10 @@ static void AddFields(int moduleId, DataSet ds)
var fieldSettings = ds.Tables[DataSetTableName.FieldSettings];
foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows)
{
var oldFieldId = row[FieldsTableColumn.Id].AsInt( );
var newFieldId=
var oldFieldId = row[FieldsTableColumn.Id].AsInt();
var newFieldId =
FieldController.AddField(moduleId, row[FieldsTableColumn.Title].ToString(),
row.AsString(FieldsTableColumn.Order).AsInt(fieldIndex ),
row.AsString(FieldsTableColumn.Order).AsInt(fieldIndex),
row.AsString((FieldsTableColumn.HelpText)),
row.AsString(FieldsTableColumn.Required).AsBoolean(),
row.AsString((FieldsTableColumn.Type)),
Expand All @@ -400,8 +407,8 @@ static void AddFields(int moduleId, DataSet ds)
foreach (DataRowView setting in fieldSettings.WithFieldId(oldFieldId))
{
FieldSettingsController.UpdateFieldSetting(
(string) setting["SettingName"],
(string) setting["SettingValue"],
(string)setting["SettingName"],
(string)setting["SettingValue"],
newFieldId);
}
}
Expand Down
5 changes: 3 additions & 2 deletions Components/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ public Components.Settings Settings
if (_moduleSettings == null)
{
var mc = new ModuleController();
_moduleSettings = new Hashtable(mc.GetModuleSettings(ModuleId));
_configuration = mc.GetModule(ModuleId, TabModuleId);
_moduleSettings = new Hashtable(_configuration.ModuleSettings);
if (TabModuleId != Null.NullInteger)
{
var tabModuleSettings = mc.GetTabModuleSettings(TabModuleId);
var tabModuleSettings = _configuration.TabModuleSettings;
foreach (string strKey in tabModuleSettings.Keys)
{
_moduleSettings[strKey] = tabModuleSettings[strKey];
Expand Down
4 changes: 2 additions & 2 deletions Components/ModuleSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class ModuleSecurity
public ModuleSecurity(int moduleId, int tabId, Components.Settings settings)
{
var moduleController = new ModuleController();
Settings = settings ?? new Settings(moduleController.GetModuleSettings(moduleId));
var moduleInfo = moduleController.GetModule(moduleId, tabId);
var moduleInfo = moduleController.GetModule(moduleId, tabId);
Settings = settings ?? new Settings(moduleInfo.ModuleSettings);
if (moduleInfo == null) return;
var mp = moduleInfo.ModulePermissions;
_hasEditRowPermission = ModulePermissionController.HasModulePermission(mp, PermissionName.HasEditRowPermission);
Expand Down
2 changes: 1 addition & 1 deletion Components/UserDefinedTableController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public DataTable Context(ModuleInfo moduleInfo, UserInfo userInfo, string search
row["LocalizedString_Previous"] = Localization.GetString("PagingPrevious.Text", Definition.SharedRessources);
row["LocalizedString_Next"] = Localization.GetString("PagingNext.Text", Definition.SharedRessources);
row["LocalizedString_Last"] = Localization.GetString("PagingLast.Text", Definition.SharedRessources);
var d = SystemDateTime.GetCurrentTimeUtc();
var d = DateUtils.GetDatabaseTime();
var timeZone = userInfo.Username != null
? userInfo.Profile.PreferredTimeZone
: portalSettings.TimeZone;
Expand Down
10 changes: 7 additions & 3 deletions Components/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public static int AsInt(this object value, int @default)
return @default;
}
if (value is int) return (int) value;
int i;
return Int32.TryParse(value.ToString(), out i) ? i : Null.NullInteger;

return Int32.TryParse(value.ToString(), out int i) ? i : Null.NullInteger;
}

public static bool ValidateRegEx(this string value, string pattern)
Expand All @@ -134,7 +134,11 @@ public static bool SaveScript(string fileContent, string fileName, IFolderInfo f
if (forceOverWrite || !FileManager.Instance.FileExists(folder,fileName ))
{
var utf8 = new UTF8Encoding();
FileManager.Instance.AddFile(folder, fileName, new MemoryStream(utf8.GetBytes(fileContent)),forceOverWrite);
using (var stream = new MemoryStream(utf8.GetBytes(fileContent)))
{
FileManager.Instance.AddFile(folder, fileName, stream, forceOverWrite);
}

return true;
}
return false;
Expand Down
12 changes: 8 additions & 4 deletions Configuration.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void SaveSettings()
//tracking
var strTrackingEmailSkript = "";

if (rblBodyType.SelectedValue == "XslScript" && XslTracking.Url != string.Empty)
if (rblBodyType.SelectedValue == "XslScript" && !string.IsNullOrWhiteSpace( XslTracking.Url))
{
var file = FileManager.Instance.GetFile(int.Parse(XslTracking.Url.Substring(7)));
if (file != null)
Expand Down Expand Up @@ -460,7 +460,7 @@ protected override void OnInit(EventArgs e)
Fields.LocalizeString = LocalizeString;
Fields.LocalResourceFile = LocalResourceFile;
Fields.ModuleContext = ModuleContext;
jQuery.RequestDnnPluginsRegistration();
Framework.JavaScriptLibraries.JavaScript.RequestRegistration(Framework.JavaScriptLibraries.CommonJs.DnnPlugins);
ClientAPI.RegisterClientReference(Page, ClientAPI.ClientNamespaceReferences.dnn);
}

Expand Down Expand Up @@ -634,11 +634,15 @@ public void RaisePostBackEvent(string eventArgument)
switch (eventArgument)
{
case "ResetModuleTabSettings":
ModulesController.DeleteTabModuleSettings(ModuleContext.TabModuleId);
foreach (string key in ModuleContext.Configuration.TabModuleSettings.Keys)
{
ModulesController.DeleteTabModuleSetting(ModuleContext.TabModuleId, key);
}

break;
case "SaveSettingsAsDefault":
SaveSettings();
var tabModuleSettings = ModulesController.GetTabModuleSettings(ModuleContext.TabModuleId);
var tabModuleSettings = ModuleContext.Configuration.TabModuleSettings;

foreach (string key in tabModuleSettings.Keys)
{
Expand Down
6 changes: 3 additions & 3 deletions Controls/Field.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void cmdUpdate_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
UpdateField();
if (HideField != null) HideField();
UpdateField();
HideField?.Invoke();
}
}

Expand All @@ -90,7 +90,7 @@ void ShowWarning(string message)

void cmdCancel_Click(object sender, EventArgs e)
{
if (HideField != null) HideField();
HideField?.Invoke();
}

public event Action HideField;
Expand Down
Loading

0 comments on commit 885da7b

Please sign in to comment.