diff --git a/Components/ExportController.cs b/Components/ExportController.cs index c1a4f18..3d10c62 100644 --- a/Components/ExportController.cs +++ b/Components/ExportController.cs @@ -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 { @@ -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 lstProfilePropertiesList = new List(); + while (idr.Read()) + { + lstProfilePropertiesList.Add(idr.GetString(0)); + } + //check if IsDeleted column exists bool IsDeletedExists = true; try @@ -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) diff --git a/MainControl.ascx b/MainControl.ascx index 3d7561a..52e20ab 100644 --- a/MainControl.ascx +++ b/MainControl.ascx @@ -70,7 +70,7 @@
- +
diff --git a/MainControl.ascx.cs b/MainControl.ascx.cs index bca3967..40e4ef8 100644 --- a/MainControl.ascx.cs +++ b/MainControl.ascx.cs @@ -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())); }