Skip to content

Commit

Permalink
Version 1.2.7:
Browse files Browse the repository at this point in the history
Export text values for Profile Properties with type "List" instead of numeric values (for example "Country", "Region")
Fixed an issue with order of the Profile Properties columns for export
Accepted pull request #13: include "CreatedOnDate" column into export
  • Loading branch information
fordnn committed Dec 9, 2021
1 parent 66358c4 commit 0a51f36
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
34 changes: 33 additions & 1 deletion Components/ExportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
using System.Web.Configuration;
using DotNetNuke.Entities.Users;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Entities.Profile;
using System.Collections.Generic;

namespace forDNN.Modules.UsersExportImport.Controller
{
Expand All @@ -23,6 +25,21 @@ public static string DoExport(int PortalId, Models.ExportInfo objExportInfo)
{
IDataReader idr = null;

//get ProfileProperties with type List
string sqlProfilePropertiesList = @"
SELECT DISTINCT [Value]
FROM {databaseOwner}{objectQualifier}ProfilePropertyDefinition ppd
LEFT JOIN {databaseOwner}{objectQualifier}Lists l ON (ppd.DataType=l.EntryID) AND (l.ListName='DataType')
WHERE ppd.PortalID=0
AND (l.Value in (SELECT DISTINCT ListName FROM {databaseOwner}{objectQualifier}Lists WHERE (ListName<>'DataType')))
";
idr = DotNetNuke.Data.DataProvider.Instance().ExecuteSQL(sqlProfilePropertiesList);
List<string> lstProfilePropertiesList = new List<string>();
while (idr.Read())
{
lstProfilePropertiesList.Add(idr.GetString(0));
}

//check if IsDeleted column exists
bool IsDeletedExists = true;
try
Expand Down Expand Up @@ -123,9 +140,24 @@ FOR XML PATH('')) Roles
.Replace("{1}", objParam[0])
);


sbFrom.Append(" LEFT JOIN {databaseOwner}{objectQualifier}UserProfile up{0} ON ((u.UserID=up{0}.UserID) AND (up{0}.PropertyDefinitionID={0})) "
.Replace("{0}", objParam[1]));

ProfilePropertyDefinition objProperty =
ProfileController.GetPropertyDefinitionByName(PortalId, objParam[0]);
if (lstProfilePropertiesList.Contains(objParam[0]))
{
//have to add column with "_Text" for "Lists"
sbSelect.Append(", l{0}.Text [{1}_Text]"
.Replace("{0}", objParam[1])
.Replace("{1}", objParam[0])
);

sbFrom.Append(" LEFT JOIN {databaseOwner}{objectQualifier}Lists l{0} ON (l{0}.ListName='{1}') AND (CAST(l{0}.EntryID AS nvarchar)=CAST(up{0}.PropertyValue AS nvarchar)) "
.Replace("{0}", objParam[1])
.Replace("{1}", objParam[0])
);
}
}

if (objExportInfo.ExportByRole != -1)
Expand Down
2 changes: 1 addition & 1 deletion MainControl.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<asp:CheckBox runat="server" ID="cbPropertiesToExport" CssClass="SubHead normalCheckBox" />
</div>
<div id="divPropertiesToExport">
<asp:CheckBoxList runat="server" ID="cblPropertiesToExport" RepeatDirection="Vertical" RepeatColumns="3" CssClass="normalCheckBox"></asp:CheckBoxList>
<asp:CheckBoxList runat="server" ID="cblPropertiesToExport" RepeatDirection="Horizontal" RepeatColumns="3" CssClass="normalCheckBox"></asp:CheckBoxList>
</div>
</fieldset>
<asp:HyperLink ID="btnExportUsers" runat="server" CssClass="dnnPrimaryAction" resourcekey="ExportUsers"></asp:HyperLink>
Expand Down
2 changes: 1 addition & 1 deletion MainControl.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void ExtraPageLoad()
ddlExportByRole.Items.Clear();
ddlExportByRole.Items.Add(new ListItem(Localization.GetString("AllRoles", this.LocalResourceFile), "-1"));
RoleController objRoleController = new RoleController();
foreach (RoleInfo objRole in objRoleController.GetPortalRoles(this.PortalId))
foreach (RoleInfo objRole in objRoleController.GetRoles(this.PortalId))
{
ddlExportByRole.Items.Add(new ListItem(objRole.RoleName, objRole.RoleID.ToString()));
}
Expand Down

0 comments on commit 0a51f36

Please sign in to comment.