public static List <ListItem> GetTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir, FileUri otherModuleTemplate) { //bool otherModuleSkinTemplate = otherModuleTemplate != null && otherModuleTemplate.PhysicalFilePath.Contains(HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir))); string basePath = HostingEnvironment.MapPath(GetSiteTemplateFolder(portalSettings, moduleSubDir)); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } var dirs = Directory.GetDirectories(basePath); if (otherModuleTemplate != null) { var selDir = otherModuleTemplate.PhysicalFullDirectory; if (!dirs.Contains(selDir)) { selDir = Path.GetDirectoryName(selDir); } if (dirs.Contains(selDir)) { dirs = new string[] { selDir } } ; else { dirs = new string[] { } }; } List <ListItem> lst = new List <ListItem>(); foreach (var dir in dirs) { string templateCat = "Site"; //string dirName = Path.GetFileNameWithoutExtension(dir); string dirName = dir.Substring(basePath.Length); int modId = -1; if (int.TryParse(dirName, out modId)) { // if numeric directory name --> module template if (modId == moduleId) { // this module -> show templateCat = "Module"; } else { // if it's from an other module -> don't show continue; } } IEnumerable <string> files = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories); IEnumerable <string> manifestfiles = files.Where(s => s.EndsWith("manifest.json")); var manifestTemplateFound = false; if (manifestfiles.Any()) { foreach (string manifestFile in manifestfiles) { FileUri manifestFileUri = FileUri.FromPath(manifestFile); var manifest = ManifestUtils.GetFileManifest(manifestFileUri); if (manifest != null && manifest.HasTemplates) { manifestTemplateFound = true; foreach (var template in manifest.Templates) { FileUri templateUri = new FileUri(manifestFileUri.FolderPath, template.Key); string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!string.IsNullOrEmpty(template.Value.Title)) { templateName = templateName + " - " + template.Value.Title; } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } if (!manifestTemplateFound) { IEnumerable <string> scriptfiles = files.Where(s => s.EndsWith(".cshtml") || s.EndsWith(".vbhtml") || s.EndsWith(".hbs")); foreach (string script in scriptfiles) { FileUri templateUri = FileUri.FromPath(script); string scriptName = script.Remove(script.LastIndexOf(".")).Replace(basePath, ""); if (templateCat == "Module") { if (scriptName.ToLower().EndsWith("template")) { scriptName = ""; } else { scriptName = scriptName.Substring(scriptName.LastIndexOf("\\") + 1); } } else if (scriptName.ToLower().EndsWith("template")) { scriptName = scriptName.Remove(scriptName.LastIndexOf("\\")); } else { scriptName = scriptName.Replace("\\", " - "); } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + scriptName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } // skin basePath = HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir)); if (Directory.Exists(basePath)) { dirs = Directory.GetDirectories(basePath); if (otherModuleTemplate != null /*&& */) { var selDir = otherModuleTemplate.PhysicalFullDirectory; if (!dirs.Contains(selDir)) { selDir = Path.GetDirectoryName(selDir); } if (dirs.Contains(selDir)) { dirs = new string[] { selDir } } ; else { dirs = new string[] { } }; } foreach (var dir in dirs) { string templateCat = "Skin"; IEnumerable <string> files = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories); IEnumerable <string> manifestfiles = files.Where(s => s.EndsWith("manifest.json")); var manifestTemplateFound = false; if (manifestfiles.Any()) { foreach (string manifestFile in manifestfiles) { FileUri manifestFileUri = FileUri.FromPath(manifestFile); var manifest = ManifestUtils.GetFileManifest(manifestFileUri); if (manifest != null && manifest.HasTemplates) { manifestTemplateFound = true; foreach (var template in manifest.Templates) { FileUri templateUri = new FileUri(manifestFileUri.FolderPath, template.Key); string templateName = Path.GetDirectoryName(manifestFile).Substring(basePath.Length).Replace("\\", " / "); if (!string.IsNullOrEmpty(template.Value.Title)) { templateName = templateName + " - " + template.Value.Title; } var item = new ListItem((templateCat == "Site" ? "" : templateCat + " : ") + templateName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } if (!manifestTemplateFound) { var scriptfiles = Directory.EnumerateFiles(dir, "*.*", SearchOption.AllDirectories) .Where(s => s.EndsWith(".cshtml") || s.EndsWith(".vbhtml") || s.EndsWith(".hbs")); foreach (string script in scriptfiles) { string scriptName = script.Remove(script.LastIndexOf(".")).Replace(basePath, ""); if (scriptName.ToLower().EndsWith("template")) { scriptName = scriptName.Remove(scriptName.LastIndexOf("\\")); } else { scriptName = scriptName.Replace("\\", " - "); } FileUri templateUri = FileUri.FromPath(script); var item = new ListItem(templateCat + " : " + scriptName, templateUri.FilePath); if (selectedTemplate != null && templateUri.FilePath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } } } return(lst); }
public static bool HasEditPermissions(PortalSettings portalSettings, ModuleInfo module, string editrole, int createdByUserId) { return(module.HasEditRightsOnModule() || HasEditRole(portalSettings, editrole, createdByUserId)); }
private void UpdateManifest(PortalSettings portalSettings, UpdateThemeInfo updateTheme) { var themePath = SkinController.FormatSkinSrc(updateTheme.Path, portalSettings); if (File.Exists(themePath.Replace(".ascx", ".htm"))) { var strFile = themePath.Replace(".ascx", ".xml"); if (File.Exists(strFile) == false) { strFile = strFile.Replace(Path.GetFileName(strFile), "skin.xml"); } XmlDocument xmlDoc = null; try { xmlDoc = new XmlDocument { XmlResolver = null }; xmlDoc.Load(strFile); } catch { xmlDoc.InnerXml = "<Objects></Objects>"; } var xmlToken = xmlDoc.DocumentElement.SelectSingleNode("descendant::Object[Token='[" + updateTheme.Token + "]']"); if (xmlToken == null) { //add token string strToken = "<Token>[" + updateTheme.Token + "]</Token><Settings></Settings>"; xmlToken = xmlDoc.CreateElement("Object"); xmlToken.InnerXml = strToken; xmlDoc.SelectSingleNode("Objects").AppendChild(xmlToken); xmlToken = xmlDoc.DocumentElement.SelectSingleNode("descendant::Object[Token='[" + updateTheme.Token + "]']"); } var strValue = updateTheme.Value; var blnUpdate = false; foreach (XmlNode xmlSetting in xmlToken.SelectNodes(".//Settings/Setting")) { if (xmlSetting.SelectSingleNode("Name").InnerText == updateTheme.Setting) { xmlSetting.SelectSingleNode("Value").InnerText = strValue; blnUpdate = true; } } if (blnUpdate == false) { var strSetting = "<Name>" + updateTheme.Setting + "</Name><Value>" + strValue + "</Value>"; XmlNode xmlSetting = xmlDoc.CreateElement("Setting"); xmlSetting.InnerXml = strSetting; xmlToken.SelectSingleNode("Settings").AppendChild(xmlSetting); } try { if (File.Exists(strFile)) { File.SetAttributes(strFile, FileAttributes.Normal); } var objStream = File.CreateText(strFile); var strXML = xmlDoc.InnerXml; strXML = strXML.Replace("><", ">" + Environment.NewLine + "<"); objStream.WriteLine(strXML); objStream.Close(); } catch (Exception ex) { Logger.Error(ex); } } }
internal override string FriendlyUrl(TabInfo tab, string path, string pageName) { PortalSettings _portalSettings = PortalController.Instance.GetCurrentPortalSettings(); return(this.FriendlyUrl(tab, path, pageName, _portalSettings)); }
private String GetPhotoExtension(String FileExtension, String FilePath, PortalSettings ps, String ModulePath) { //先判断是否是图片格式的 if (FileExtension == "jpg") { return(GetPhotoPath(FilePath, ps)); } else if (FileExtension == "png") { return(GetPhotoPath(FilePath, ps)); } else if (FileExtension == "jpeg") { return(GetPhotoPath(FilePath, ps)); } else if (FileExtension == "gif") { return(GetPhotoPath(FilePath, ps)); } else if (FileExtension == "bmp") { return(GetPhotoPath(FilePath, ps)); } else if (FileExtension == "mp3") { return(GetFileIcon("audio.png", ModulePath)); } else if (FileExtension == "wma") { return(GetFileIcon("audio.png", ModulePath)); } else if (FileExtension == "zip") { return(GetFileIcon("archive.png", ModulePath)); } else if (FileExtension == "rar") { return(GetFileIcon("archive.png", ModulePath)); } else if (FileExtension == "7z") { return(GetFileIcon("archive.png", ModulePath)); } else if (FileExtension == "xls") { return(GetFileIcon("spreadsheet.png", ModulePath)); } else if (FileExtension == "txt") { return(GetFileIcon("text.png", ModulePath)); } else if (FileExtension == "cs") { return(GetFileIcon("code.png", ModulePath)); } else if (FileExtension == "html") { return(GetFileIcon("code.png", ModulePath)); } else if (FileExtension == "doc") { return(GetFileIcon("document.png", ModulePath)); } else if (FileExtension == "docx") { return(GetFileIcon("document.png", ModulePath)); } else { return(GetFileIcon("default.png", ModulePath)); } }
public Resource_FilesStatus(DNNGo_LayerGallery_Files PhotoItem, int fileLength, PortalSettings ps, String ModulePath) { SetValues(PhotoItem, fileLength, ps, ModulePath); }
/// ----------------------------------------------------------------------------- /// <summary> /// Assigns common properties from passed in tab to newly created DNNNode that is added to the passed in DNNNodeCollection. /// </summary> /// <param name="objTab">Tab to base DNNNode off of.</param> /// <param name="objNodes">Node collection to append new node to.</param> /// <param name="objBreadCrumbs">Hashtable of breadcrumb IDs to efficiently determine node's BreadCrumb property.</param> /// <param name="objPortalSettings">Portal settings object to determine if node is selected.</param> /// <param name="eToolTips"></param> /// <remarks> /// Logic moved to separate sub to make GetNavigationNodes cleaner. /// </remarks> /// ----------------------------------------------------------------------------- private static void AddNode(TabInfo objTab, DNNNodeCollection objNodes, Hashtable objBreadCrumbs, PortalSettings objPortalSettings, ToolTipSource eToolTips, IDictionary <string, DNNNode> nodesLookup) { var objNode = new DNNNode(); if (objTab.Title == "~") // NEW! { // A title (text) of ~ denotes a break objNodes.AddBreak(); } else { // assign breadcrumb and selected properties if (objBreadCrumbs.Contains(objTab.TabID)) { objNode.BreadCrumb = true; if (objTab.TabID == objPortalSettings.ActiveTab.TabID) { objNode.Selected = true; } } if (objTab.DisableLink) { objNode.Enabled = false; } objNode.ID = objTab.TabID.ToString(); objNode.Key = objNode.ID; objNode.Text = objTab.LocalizedTabName; objNode.NavigateURL = objTab.FullUrl; objNode.ClickAction = eClickAction.Navigate; objNode.Image = objTab.IconFile; objNode.LargeImage = objTab.IconFileLarge; switch (eToolTips) { case ToolTipSource.TabName: objNode.ToolTip = objTab.LocalizedTabName; break; case ToolTipSource.Title: objNode.ToolTip = objTab.Title; break; case ToolTipSource.Description: objNode.ToolTip = objTab.Description; break; } bool newWindow = false; if (objTab.TabSettings["LinkNewWindow"] != null && bool.TryParse((string)objTab.TabSettings["LinkNewWindow"], out newWindow) && newWindow) { objNode.Target = "_blank"; } objNodes.Add(objNode); if (!nodesLookup.ContainsKey(objNode.ID)) { nodesLookup.Add(objNode.ID, objNode); } } }
public override void Init(string[] args, PortalSettings portalSettings, UserInfo userInfo, int activeTabId) { TaskId = GetFlagValue(FlagId, "Task Id", -1, true, true, true); Enabled = GetFlagValue(FlagEnabled, "Enabled", true, true); }
/// <summary> /// Get Url for the equivalent full site based on the current page of the mobile site /// </summary> /// <returns>string - Empty if redirection rules are not defined or no match found</returns> /// <param name="portalId">Portal Id from which Redirection Rules should be applied.</param> /// <param name="currentTabId">Current Tab Id that needs to be evaluated.</param> public string GetFullSiteUrl(int portalId, int currentTabId) { string fullSiteUrl = string.Empty; IList <IRedirection> redirections = GetAllRedirections(); //check for redirect only when redirect rules are defined if (redirections == null || redirections.Count == 0) { return(fullSiteUrl); } //try to get content from cache var cacheKey = string.Format(FullSiteUrlCacheKey, portalId, currentTabId); fullSiteUrl = GetUrlFromCache(cacheKey); if (!string.IsNullOrEmpty(fullSiteUrl)) { return(fullSiteUrl); } bool foundRule = false; foreach (var redirection in redirections) { if (redirection.Enabled) { if (redirection.TargetType == TargetType.Tab) //page within same site { int targetTabId = int.Parse(redirection.TargetValue.ToString()); if (targetTabId == currentTabId) //target tab is same as current tab { foundRule = true; } } else if (redirection.TargetType == TargetType.Portal) //home page of another portal { int targetPortalId = int.Parse(redirection.TargetValue.ToString()); if (targetPortalId == portalId) //target portal is same as current portal { foundRule = true; } } //found the rule, let's find the url now if (foundRule) { ////redirection is based on tab //Following are being commented as NavigateURL method does not return correct url for a tab in a different portal //always point to the home page of the other portal //if (redirection.SourceTabId != Null.NullInteger) //{ // fullSiteUrl = Globals.NavigateURL(redirection.SourceTabId); //} //else //redirection is based on portal { var portalSettings = new PortalSettings(redirection.PortalId); if (portalSettings.HomeTabId != Null.NullInteger && portalSettings.HomeTabId != currentTabId) //ensure it's not redirecting to itself { fullSiteUrl = GetPortalHomePageUrl(portalSettings); } } break; } } } //append special query string if (!string.IsNullOrEmpty(fullSiteUrl)) { fullSiteUrl += string.Format("{0}{1}=1", fullSiteUrl.Contains("?") ? "&" : "?", DisableMobileRedirectQueryStringName); } //update cache content SetUrlInCache(cacheKey, fullSiteUrl); return(fullSiteUrl); }
private string GetPortalHomePageUrl(PortalSettings portalSettings) { return(Globals.AddHTTP(portalSettings.DefaultPortalAlias)); }
/// <summary> /// Get search info for each dnn module containing 2sxc data /// </summary> /// <returns></returns> public IList <SearchDocument> GetModifiedSearchDocuments(IContainer container, DateTime beginDate) { var searchDocuments = new List <SearchDocument>(); var dnnModule = (container as Container <ModuleInfo>)?.UnwrappedContents; // always log with method, to ensure errors are caught Log.Add($"start search for mod#{dnnModule?.ModuleID}"); // turn off logging into history by default - the template code can reactivate this if desired Log.Preserve = false; if (dnnModule == null) { return(searchDocuments); } var isContentModule = dnnModule.DesktopModule.ModuleName == "2sxc"; // New Context because PortalSettings.Current is null var zoneId = new DnnEnvironment(Log).ZoneMapper.GetZoneId(dnnModule.OwnerPortalID); var appId = !isContentModule ? new DnnMapAppToInstance(Log).GetAppIdFromInstance(container, zoneId) : new ZoneRuntime(zoneId, Log).DefaultAppId; if (!appId.HasValue) { return(searchDocuments); } // As PortalSettings.Current is null, instantiate with modules' portal id var portalSettings = new PortalSettings(dnnModule.OwnerPortalID); // Ensure cache builds up with correct primary language var cache = State.Cache; cache.Load(new AppIdentity(zoneId, appId.Value), portalSettings.DefaultLanguage.ToLower()); // must find tenant through module, as the PortalSettings.Current is null in search mode var tenant = new DnnTenant(portalSettings); var mcb = new BlockFromModule(container, Log, tenant); var cmsBlock = mcb.BlockBuilder; var language = dnnModule.CultureCode; var view = cmsBlock.View; if (view == null) { return(searchDocuments); } // This list will hold all EAV entities to be indexed var dataSource = cmsBlock.Block.Data; // 2020-03-12 Try to attach DNN Lookup Providers so query-params like [DateTime:Now] or [Portal:PortalId] will work if (dataSource?.Configuration?.LookUps != null) { Log.Add("Will try to attach dnn providers to DataSource LookUps"); try { //var provider = dataSource.Configuration.LookUps; var dnnLookUps = GetDnnEngine.GenerateDnnBasedLookupEngine(portalSettings, dnnModule.ModuleID, Log); ((LookUpEngine)dataSource.Configuration.LookUps).Link(dnnLookUps); // .Sources; //Log.Add($"Environment provided {dnnLookUps.Count} sources"); //foreach (var prov in dnnLookUps) // if (!provider.Sources.ContainsKey(prov.Key)) // provider.Sources.Add(prov.Key, prov.Value); // else // Log.Add($"Couldn't add source '{prov.Key}', as it already existed"); } catch (Exception e) { Log.Add("Ran into an issue with an error: " + e.Message); } } var engine = EngineFactory.CreateEngine(view); engine.Init(cmsBlock, Purpose.IndexingForSearch, Log); // see if data customization inside the cshtml works try { engine.CustomizeData(); } catch (Exception e) // Catch errors here, because of references to Request etc. { Exceptions.LogException(new SearchIndexException(dnnModule, e)); } var searchInfoDictionary = new Dictionary <string, List <ISearchItem> >(); // Get DNN SearchDocuments from 2Sexy SearchInfos foreach (var stream in dataSource.Out.Where(p => p.Key != ViewParts.Presentation && p.Key != ViewParts.ListPresentation)) { var entities = stream.Value.List; var searchInfoList = searchInfoDictionary[stream.Key] = new List <ISearchItem>(); searchInfoList.AddRange(entities.Select(entity => { var searchInfo = new SearchItem { Entity = entity, Url = "", Description = "", Body = GetJoinedAttributes(entity, language), Title = entity.Title?[language]?.ToString() ?? "(no title)", ModifiedTimeUtc = (entity.Modified == DateTime.MinValue ? DateTime.Now.Date.AddHours(DateTime.Now.Hour) : entity.Modified).ToUniversalTime(), UniqueKey = "2sxc-" + dnnModule.ModuleID + "-" + (entity.EntityGuid != new Guid() ? entity.EntityGuid.ToString() : (stream.Key + "-" + entity.EntityId)), IsActive = true, TabId = dnnModule.TabID, PortalId = dnnModule.PortalID }; // CodeChange #2020-03-20#ContentGroupItemModified - Delete if no side-effects till June 2020 // 2020-03-20 2dm: unclear why this happens - the itm.Modified (above) // is identical with the typed.ContentGroupItemModified // because of this I'll turn the code off for now // I also marked 3 other code bits with the code // Take the newest value (from ContentGroupItem and Entity) //if (entity is IHasEditingData typed) //{ // var contentGroupItemModifiedUtc = typed.ContentGroupItemModified.ToUniversalTime(); // searchInfo.ModifiedTimeUtc = searchInfo.ModifiedTimeUtc > contentGroupItemModifiedUtc // ? searchInfo.ModifiedTimeUtc // : contentGroupItemModifiedUtc; //} return(searchInfo); })); } // check if the cshtml has search customizations try { engine.CustomizeSearch(searchInfoDictionary, new DnnContainer(dnnModule), beginDate); } catch (Exception e) { Exceptions.LogException(new SearchIndexException(dnnModule, e)); } // add it to insights / history. It will only be preserved, if the inner code ran a Log.Preserve = true; History.Add("dnn-search", Log); // reduce load by only keeping recently modified ites foreach (var searchInfoList in searchInfoDictionary) { // Filter by Date - take only SearchDocuments that changed since beginDate var searchDocumentsToAdd = searchInfoList.Value.Where(p => p.ModifiedTimeUtc >= beginDate.ToUniversalTime()).Select(p => (SearchDocument)p); searchDocuments.AddRange(searchDocumentsToAdd); } return(searchDocuments); }
/// <summary> /// Authenticates the request. /// </summary> /// <param name="context">The context.</param> /// <param name="allowUnknownExtensions">if set to <c>true</c> to allow unknown extensinons.</param> public static void AuthenticateRequest(HttpContextBase context, bool allowUnknownExtensions) { HttpRequestBase request = context.Request; HttpResponseBase response = context.Response; // First check if we are upgrading/installing if (!Initialize.ProcessHttpModule(context.ApplicationInstance.Request, allowUnknownExtensions, false)) { return; } // Obtain PortalSettings from Current Context PortalSettings portalSettings = PortalController.Instance.GetCurrentPortalSettings(); bool isActiveDirectoryAuthHeaderPresent = false; var auth = request.Headers.Get("Authorization"); if (!string.IsNullOrEmpty(auth)) { if (auth.StartsWith("Negotiate")) { isActiveDirectoryAuthHeaderPresent = true; } } if (request.IsAuthenticated && !isActiveDirectoryAuthHeaderPresent && portalSettings != null) { var user = UserController.GetCachedUser(portalSettings.PortalId, context.User.Identity.Name); // if current login is from windows authentication, the ignore the process if (user == null && context.User is WindowsPrincipal) { return; } // authenticate user and set last login ( this is necessary for users who have a permanent Auth cookie set ) if (RequireLogout(context, user)) { var portalSecurity = PortalSecurity.Instance; portalSecurity.SignOut(); // Remove user from cache if (user != null) { DataCache.ClearUserCache(portalSettings.PortalId, context.User.Identity.Name); } // Redirect browser back to home page response.Redirect(request.RawUrl, true); return; } if (!user.IsSuperUser && user.IsInRole("Unverified Users") && !HttpContext.Current.Items.Contains(DotNetNuke.UI.Skins.Skin.OnInitMessage)) { HttpContext.Current.Items.Add(DotNetNuke.UI.Skins.Skin.OnInitMessage, Localization.GetString("UnverifiedUser", Localization.SharedResourceFile, CurrentCulture)); } if (!user.IsSuperUser && HttpContext.Current.Request.QueryString.AllKeys.Contains("VerificationSuccess") && !HttpContext.Current.Items.Contains(DotNetNuke.UI.Skins.Skin.OnInitMessage)) { HttpContext.Current.Items.Add(DotNetNuke.UI.Skins.Skin.OnInitMessage, Localization.GetString("VerificationSuccess", Localization.SharedResourceFile, CurrentCulture)); HttpContext.Current.Items.Add(DotNetNuke.UI.Skins.Skin.OnInitMessageType, ModuleMessage.ModuleMessageType.GreenSuccess); } // if users LastActivityDate is outside of the UsersOnlineTimeWindow then record user activity if (DateTime.Compare(user.Membership.LastActivityDate.AddMinutes(Host.UsersOnlineTimeWindow), DateTime.Now) < 0) { // update LastActivityDate and IP Address for user user.Membership.LastActivityDate = DateTime.Now; user.LastIPAddress = UserRequestIPAddressController.Instance.GetUserRequestIPAddress(request); UserController.UpdateUser(portalSettings.PortalId, user, false, false); } // check for RSVP code if (request.QueryString["rsvp"] != null && !string.IsNullOrEmpty(request.QueryString["rsvp"])) { foreach (var role in RoleController.Instance.GetRoles(portalSettings.PortalId, r => (r.SecurityMode != SecurityMode.SocialGroup || r.IsPublic) && r.Status == RoleStatus.Approved)) { if (role.RSVPCode == request.QueryString["rsvp"]) { RoleController.Instance.UpdateUserRole(portalSettings.PortalId, user.UserID, role.RoleID, RoleStatus.Approved, false, false); } } } // save userinfo object in context if (context.Items["UserInfo"] != null) { context.Items["UserInfo"] = user; } else { context.Items.Add("UserInfo", user); } // Localization.SetLanguage also updates the user profile, so this needs to go after the profile is loaded if (request.RawUrl != null && !ServicesModule.ServiceApi.IsMatch(request.RawUrl)) { Localization.SetLanguage(user.Profile.PreferredLocale); } } if (context.Items["UserInfo"] == null) { context.Items.Add("UserInfo", new UserInfo()); } }
/// <summary> /// Handles the UpdateControl event of the EditTable control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:Appleseed.Framework.Web.UI.WebControls.SettingsTableEventArgs"/> instance containing the event data.</param> private void EditTable_UpdateControl(object sender, SettingsTableEventArgs e) { SettingsTable edt = (SettingsTable)sender; PortalSettings.UpdatePortalSetting(edt.ObjectID, ((ISettingItem)e.CurrentItem).EditControl.ID, ((ISettingItem)e.CurrentItem).Value.ToString()); }
public static bool CanInjectModule(ModuleInfo module, PortalSettings portalSettings) { return(_filters.All(filter => filter.CanInjectModule(module, portalSettings))); }
private static void ProcessTab(DNNNode objRootNode, TabInfo objTab, Hashtable objTabLookup, Hashtable objBreadCrumbs, int intLastBreadCrumbId, ToolTipSource eToolTips, int intStartTabId, int intDepth, int intNavNodeOptions, IDictionary <string, DNNNode> nodesLookup) { PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings(); bool showHidden = (intNavNodeOptions & (int)NavNodeOptions.IncludeHiddenNodes) == (int)NavNodeOptions.IncludeHiddenNodes; if (CanShowTab(objTab, TabPermissionController.CanAdminPage(), true, showHidden)) // based off of tab properties, is it shown { DNNNodeCollection objParentNodes; DNNNode objParentNode; bool blnParentFound = nodesLookup.TryGetValue(objTab.ParentId.ToString(), out objParentNode); if (!blnParentFound) { objParentNode = objRootNode; } objParentNodes = objParentNode.DNNNodes; if (objTab.TabID == intStartTabId) { // is this the starting tab if ((intNavNodeOptions & (int)NavNodeOptions.IncludeParent) != 0) { // if we are including parent, make sure there is one, then add if (objTabLookup[objTab.ParentId] != null) { AddNode((TabInfo)objTabLookup[objTab.ParentId], objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips, nodesLookup); if (nodesLookup.TryGetValue(objTab.ParentId.ToString(), out objParentNode)) { objParentNodes = objParentNode.DNNNodes; } } } if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) != 0) { // if we are including our self (starting tab) then add AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips, nodesLookup); } } else if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) && IsTabSibling(objTab, intStartTabId, objTabLookup)) { // is this a sibling of the starting node, and we are including siblings, then add it AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips, nodesLookup); } else { if (blnParentFound) // if tabs parent already in hierarchy (as is the case when we are sending down more than 1 level) { // parent will be found for siblings. Check to see if we want them, if we don't make sure tab is not a sibling if (((intNavNodeOptions & (int)NavNodeOptions.IncludeSiblings) != 0) || IsTabSibling(objTab, intStartTabId, objTabLookup) == false) { // determine if tab should be included or marked as pending bool blnPOD = (intNavNodeOptions & (int)NavNodeOptions.MarkPendingNodes) != 0; if (IsTabPending(objTab, objParentNode, objRootNode, intDepth, objBreadCrumbs, intLastBreadCrumbId, blnPOD)) { if (blnPOD) { objParentNode.HasNodes = true; // mark it as a pending node } } else { AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips, nodesLookup); } } } else if ((intNavNodeOptions & (int)NavNodeOptions.IncludeSelf) == 0 && objTab.ParentId == intStartTabId) { // if not including self and parent is the start id then add AddNode(objTab, objParentNodes, objBreadCrumbs, objPortalSettings, eToolTips, nodesLookup); } } } }
/// ----------------------------------------------------------------------------- /// <summary> /// FormatHtmlText formats HtmlText content for display in the browser /// </summary> /// <remarks> /// </remarks> /// <param name="moduleId">The ModuleID</param> /// <param name = "content">The HtmlText Content</param> /// <param name = "settings">Module Settings</param> /// <param name="portalSettings">The Portal Settings.</param> /// <param name="page">The Page Instance.</param> public static string FormatHtmlText(int moduleId, string content, HtmlModuleSettings settings, PortalSettings portalSettings, Page page) { // token replace if (settings.ReplaceTokens) { var tr = new HtmlTokenReplace(page) { AccessingUser = UserController.Instance.GetCurrentUserInfo(), DebugMessages = portalSettings.UserMode != PortalSettings.Mode.View, ModuleId = moduleId, PortalSettings = portalSettings }; content = tr.ReplaceEnvironmentTokens(content); } // Html decode content content = HttpUtility.HtmlDecode(content); // manage relative paths content = ManageRelativePaths(content, portalSettings.HomeDirectory, "src", portalSettings.PortalId); content = ManageRelativePaths(content, portalSettings.HomeDirectory, "background", portalSettings.PortalId); return(content); }
public Guid SaveUserData() { if (!EditMode) { Guid result = Guid.Empty; if (Session["CameFromSocialNetwork"] == null || IsInvite) { MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(tfEmail.Text, tfPwd.Text, tfEmail.Text, "question", "answer", PortalSettings.IsApprovedCreateUser(), Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { PortalSecurity.SignOn(tfEmail.Text, tfPwd.Text, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { if ((Session["TwitterUserName"] != null) || (Session["LinkedInUserName"] != null)) { // Register Twitter or LinkedIn string userName = (Session["TwitterUserName"] != null) ? Session["TwitterUserName"].ToString() : Session["LinkedInUserName"].ToString(); string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, tfEmail.Text, "question", "answer", PortalSettings.IsApprovedCreateUser(), Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { Session.Contents.Remove("CameFromSocialNetwork"); PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else if (Session["FacebookUserName"] != null || Session["GoogleUserEmail"] != null) { // Register Facebook string userName = tfEmail.Text; string password = GeneratePasswordHash(userName); MembershipCreateStatus status = MembershipCreateStatus.Success; MembershipUser user = Membership.Provider.CreateUser(userName, password, userName, "question", "answer", PortalSettings.IsApprovedCreateUser(), Guid.NewGuid(), out status); this.lblError.Text = string.Empty; switch (status) { case MembershipCreateStatus.DuplicateEmail: case MembershipCreateStatus.DuplicateUserName: this.lblError.Text = Resources.Appleseed.USER_ALREADY_EXISTS; break; case MembershipCreateStatus.ProviderError: break; case MembershipCreateStatus.Success: UpdateProfile(); result = (Guid)user.ProviderUserKey; //if the user is registering himself (thus, is not yet authenticated) we will sign him on and send him to the home page. if (!Context.User.Identity.IsAuthenticated) { // Removing names from social networks of sessions if (Session["CameFromGoogleLogin"] != null) { Session.Contents.Remove("CameFromGoogleLogin"); } if (Session["GoogleUserEmail"] != null) { Session.Contents.Remove("GoogleUserEmail"); } if (Session["GoogleUserName"] != null) { Session.Contents.Remove("GoogleUserName"); } if (Session["FacebookUserName"] != null) { Session.Contents.Remove("FacebookUserName"); } if (Session["FacebookName"] != null) { Session.Contents.Remove("FacebookName"); } PortalSecurity.SignOn(userName, password, false, HttpUrlBuilder.BuildUrl()); } break; // for every other error message... default: this.lblError.Text = Resources.Appleseed.USER_SAVING_ERROR; break; } return(result); } else { return(result); } } } else { string Email = tfEmail.Text; string UserName = Membership.GetUserNameByEmail(Email); if (!UserName.Equals(Email)) { // The user Came from twitter Session["CameFromSocialNetwork"] = true; Session["TwitterUserName"] = UserName; Session["LinkedInUserName"] = UserName; Session["deleteCookies"] = true; } UpdateProfile(); return((Guid)Membership.GetUser(UserName, false).ProviderUserKey); } }
/// <summary> /// 获取图片的路径 /// </summary> /// <param name="FilePath">图片路径</param> /// <returns></returns> public String GetPhotoPath(String FilePath, PortalSettings ps) { return(String.Format("{0}{1}", ps.HomeDirectory, FilePath)); }
/// <summary> /// Initializes a new instance of the <see cref="SitemapBuilder"/> class. /// Creates an instance of the sitemap builder class. /// </summary> /// <param name = "ps">Current PortalSettings for the portal being processed.</param> /// <remarks> /// </remarks> public SitemapBuilder(PortalSettings ps) { this.PortalSettings = ps; LoadProviders(); }
public Resource_FilesStatus(DNNGo_LayerGallery_Files PhotoItem, PortalSettings ps, String ModulePath) { SetValues(PhotoItem, PhotoItem.FileSize, ps, ModulePath); }
public void AddLog(string propertyName, string propertyValue, PortalSettings portalSettings, int userID, EventLogType logType) { AddLog(propertyName, propertyValue, portalSettings, userID, logType.ToString()); }
public String ThumbnailUrl(DNNGo_LayerGallery_Files DataItem, PortalSettings ps, String ModulePath) { return(String.Format("{0}Resource_Service.aspx?Token=thumbnail&PortalId={1}&TabId={2}&ID={3}&width=40&height=40&mode=WH", ModulePath, ps.PortalId, ps.ActiveTab.TabID, DataItem.ID)); }
public void AddLog(PortalSettings portalSettings, int userID, EventLogType logType) { AddLog(new LogProperties(), portalSettings, userID, logType.ToString(), false); }
internal override string FriendlyUrl(TabInfo tab, string path) { PortalSettings _portalSettings = PortalController.Instance.GetCurrentPortalSettings(); return(this.FriendlyUrl(tab, path, Globals.glbDefaultPage, _portalSettings)); }
public void AddLog(object businessObject, PortalSettings portalSettings, int userID, string userName, EventLogType logType) { AddLog(businessObject, portalSettings, userID, userName, logType.ToString()); }
/// <summary> /// Gets the templates files. /// </summary> /// <param name="portalSettings">The portal settings.</param> /// <param name="moduleId">The module identifier.</param> /// <param name="selectedTemplate">The selected template.</param> /// <param name="moduleSubDir">The module sub dir.</param> /// <returns></returns> public static List <ListItem> GetTemplatesFiles(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir) { return(GetTemplatesFiles(portalSettings, moduleId, selectedTemplate, moduleSubDir, null)); }
public void AddLog(object businessObject, PortalSettings portalSettings, int userID, string userName, string logType) { var logInfo = new LogInfo { LogUserID = userID, LogTypeKey = logType }; if (portalSettings != null) { logInfo.LogPortalID = portalSettings.PortalId; logInfo.LogPortalName = portalSettings.PortalName; } switch (businessObject.GetType().FullName) { case "DotNetNuke.Entities.Portals.PortalInfo": var portal = (PortalInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("PortalID", portal.PortalID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("PortalName", portal.PortalName)); logInfo.LogProperties.Add(new LogDetailInfo("Description", portal.Description)); logInfo.LogProperties.Add(new LogDetailInfo("KeyWords", portal.KeyWords)); logInfo.LogProperties.Add(new LogDetailInfo("LogoFile", portal.LogoFile)); break; case "DotNetNuke.Entities.Tabs.TabInfo": var tab = (TabInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("TabID", tab.TabID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("PortalID", tab.PortalID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("TabName", tab.TabName)); logInfo.LogProperties.Add(new LogDetailInfo("Title", tab.Title)); logInfo.LogProperties.Add(new LogDetailInfo("Description", tab.Description)); logInfo.LogProperties.Add(new LogDetailInfo("KeyWords", tab.KeyWords)); logInfo.LogProperties.Add(new LogDetailInfo("Url", tab.Url)); logInfo.LogProperties.Add(new LogDetailInfo("ParentId", tab.ParentId.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("IconFile", tab.IconFile)); logInfo.LogProperties.Add(new LogDetailInfo("IsVisible", tab.IsVisible.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("SkinSrc", tab.SkinSrc)); logInfo.LogProperties.Add(new LogDetailInfo("ContainerSrc", tab.ContainerSrc)); break; case "DotNetNuke.Entities.Modules.ModuleInfo": var module = (ModuleInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("ModuleId", module.ModuleID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("ModuleTitle", module.ModuleTitle)); logInfo.LogProperties.Add(new LogDetailInfo("TabModuleID", module.TabModuleID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("TabID", module.TabID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("PortalID", module.PortalID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("ModuleDefId", module.ModuleDefID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", module.DesktopModule.FriendlyName)); logInfo.LogProperties.Add(new LogDetailInfo("IconFile", module.IconFile)); logInfo.LogProperties.Add(new LogDetailInfo("Visibility", module.Visibility.ToString())); logInfo.LogProperties.Add(new LogDetailInfo("ContainerSrc", module.ContainerSrc)); break; case "DotNetNuke.Entities.Users.UserInfo": var user = (UserInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("UserID", user.UserID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("FirstName", user.Profile.FirstName)); logInfo.LogProperties.Add(new LogDetailInfo("LastName", user.Profile.LastName)); logInfo.LogProperties.Add(new LogDetailInfo("UserName", user.Username)); logInfo.LogProperties.Add(new LogDetailInfo("Email", user.Email)); break; case "DotNetNuke.Security.Roles.RoleInfo": var role = (RoleInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("RoleID", role.RoleID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("RoleName", role.RoleName)); logInfo.LogProperties.Add(new LogDetailInfo("PortalID", role.PortalID.ToString(CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("Description", role.Description)); logInfo.LogProperties.Add(new LogDetailInfo("IsPublic", role.IsPublic.ToString(CultureInfo.InvariantCulture))); break; case "DotNetNuke.Entities.Modules.DesktopModuleInfo": var desktopModule = (DesktopModuleInfo)businessObject; logInfo.LogProperties.Add(new LogDetailInfo("DesktopModuleID", desktopModule.DesktopModuleID.ToString( CultureInfo.InvariantCulture))); logInfo.LogProperties.Add(new LogDetailInfo("ModuleName", desktopModule.ModuleName)); logInfo.LogProperties.Add(new LogDetailInfo("FriendlyName", desktopModule.FriendlyName)); logInfo.LogProperties.Add(new LogDetailInfo("FolderName", desktopModule.FolderName)); logInfo.LogProperties.Add(new LogDetailInfo("Description", desktopModule.Description)); break; default: //Serialise using XmlSerializer logInfo.LogProperties.Add(new LogDetailInfo("logdetail", XmlUtils.Serialize(businessObject))); break; } base.AddLog(logInfo); }
public static List <ListItem> GetTemplates(PortalSettings portalSettings, int moduleId, TemplateManifest selectedTemplate, string moduleSubDir) { string basePath = HostingEnvironment.MapPath(GetSiteTemplateFolder(portalSettings, moduleSubDir)); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } List <ListItem> lst = new List <ListItem>(); foreach (var dir in Directory.GetDirectories(basePath)) { string templateCat = "Site"; string dirName = Path.GetFileNameWithoutExtension(dir); int modId = -1; if (int.TryParse(dirName, out modId)) { if (modId == moduleId) { templateCat = "Module"; } else { continue; } } string scriptName = dir; if (templateCat == "Module") { scriptName = templateCat; } else { scriptName = templateCat + ":" + scriptName.Substring(scriptName.LastIndexOf("\\") + 1); } string scriptPath = FolderUri.ReverseMapPath(dir); var item = new ListItem(scriptName, scriptPath); if (selectedTemplate != null && scriptPath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } // skin basePath = HostingEnvironment.MapPath(GetSkinTemplateFolder(portalSettings, moduleSubDir)); if (Directory.Exists(basePath)) { foreach (var dir in Directory.GetDirectories(basePath)) { string templateCat = "Skin"; string scriptName = dir; scriptName = templateCat + ":" + scriptName.Substring(scriptName.LastIndexOf("\\") + 1); string scriptPath = FolderUri.ReverseMapPath(dir); var item = new ListItem(scriptName, scriptPath); if (selectedTemplate != null && scriptPath.ToLowerInvariant() == selectedTemplate.Key.ToString().ToLowerInvariant()) { item.Selected = true; } lst.Add(item); } } return(lst); }
/// ----------------------------------------------------------------------------- /// <summary> /// CreateUserNotifications creates HtmlTextUser records and optionally sends email notifications to participants in a Workflow /// </summary> /// <remarks> /// </remarks> /// <param name="objHtmlText">An HtmlTextInfo object</param> private void CreateUserNotifications(HtmlTextInfo objHtmlText) { var _htmlTextUserController = new HtmlTextUserController(); HtmlTextUserInfo _htmlTextUser = null; UserInfo _user = null; // clean up old user notification records _htmlTextUserController.DeleteHtmlTextUsers(); // ensure we have latest htmltext object loaded objHtmlText = GetHtmlText(objHtmlText.ModuleID, objHtmlText.ItemID); // build collection of users to notify var objWorkflow = new WorkflowStateController(); var arrUsers = new ArrayList(); // if not published if (objHtmlText.IsPublished == false) { arrUsers.Add(objHtmlText.CreatedByUserID); // include content owner } // if not draft and not published if (objHtmlText.StateID != objWorkflow.GetFirstWorkflowStateID(objHtmlText.WorkflowID) && objHtmlText.IsPublished == false) { // get users from permissions for state foreach (WorkflowStatePermissionInfo permission in WorkflowStatePermissionController.GetWorkflowStatePermissions(objHtmlText.StateID)) { if (permission.AllowAccess) { if (Null.IsNull(permission.UserID)) { int roleId = permission.RoleID; RoleInfo objRole = RoleController.Instance.GetRole(objHtmlText.PortalID, r => r.RoleID == roleId); if ((objRole != null)) { foreach (UserRoleInfo objUserRole in RoleController.Instance.GetUserRoles(objHtmlText.PortalID, null, objRole.RoleName)) { if (!arrUsers.Contains(objUserRole.UserID)) { arrUsers.Add(objUserRole.UserID); } } } } else { if (!arrUsers.Contains(permission.UserID)) { arrUsers.Add(permission.UserID); } } } } } // process notifications if (arrUsers.Count > 0 || (objHtmlText.IsPublished && objHtmlText.Notify)) { // get tabid from module ModuleInfo objModule = ModuleController.Instance.GetModule(objHtmlText.ModuleID, Null.NullInteger, true); PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings(); if (objPortalSettings != null) { string strResourceFile = string.Format("{0}/DesktopModules/{1}/{2}/{3}", Globals.ApplicationPath, objModule.DesktopModule.FolderName, Localization.LocalResourceDirectory, Localization.LocalSharedResourceFile); string strSubject = Localization.GetString("NotificationSubject", strResourceFile); string strBody = Localization.GetString("NotificationBody", strResourceFile); strBody = strBody.Replace("[URL]", NavigationManager.NavigateURL(objModule.TabID)); strBody = strBody.Replace("[STATE]", objHtmlText.StateName); // process user notification collection foreach (int intUserID in arrUsers) { // create user notification record _htmlTextUser = new HtmlTextUserInfo(); _htmlTextUser.ItemID = objHtmlText.ItemID; _htmlTextUser.StateID = objHtmlText.StateID; _htmlTextUser.ModuleID = objHtmlText.ModuleID; _htmlTextUser.TabID = objModule.TabID; _htmlTextUser.UserID = intUserID; _htmlTextUserController.AddHtmlTextUser(_htmlTextUser); // send an email notification to a user if the state indicates to do so if (objHtmlText.Notify) { _user = UserController.GetUserById(objHtmlText.PortalID, intUserID); if (_user != null) { AddHtmlNotification(strSubject, strBody, _user); } } } // if published and the published state specifies to notify members of the workflow if (objHtmlText.IsPublished && objHtmlText.Notify) { // send email notification to the author _user = UserController.GetUserById(objHtmlText.PortalID, objHtmlText.CreatedByUserID); if (_user != null) { try { Services.Mail.Mail.SendEmail(objPortalSettings.Email, objPortalSettings.Email, strSubject, strBody); } catch (Exception exc) { Exceptions.LogException(exc); } } } } } }
public virtual void ProcessRequest(HttpContext context) { if ((HttpContext.Current.Items["PortalSettings"] != null)) { portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; portalId = portalSettings.PortalId; } else { PortalAliasInfo objPortalAliasInfo = PortalAliasController.GetPortalAliasInfo(HttpContext.Current.Request.Url.Host); portalId = objPortalAliasInfo.PortalID; portalSettings = PortalController.GetCurrentPortalSettings(); } Localization.SetThreadCultures(Localization.GetPageLocale(portalSettings), portalSettings); userInfo = HttpContext.Current.Request.IsAuthenticated ? Entities.Users.UserController.GetUserByName(PortalId, HttpContext.Current.User.Identity.Name) : new Entities.Users.UserInfo {UserID = -1}; }
public virtual void AuthenticateDnnUser(Auth0UserInfo user, PortalSettings settings, string IPAddress, Action <UserAuthenticatedEventArgs> onAuthenticated) { var loginStatus = UserLoginStatus.LOGIN_FAILURE; var objUserInfo = UserController.ValidateUser( settings.PortalId, user.UserId, "", _Service, "", settings.PortalName, IPAddress, ref loginStatus); //Raise UserAuthenticated Event var eventArgs = new UserAuthenticatedEventArgs(objUserInfo, user.UserId, loginStatus, _Service) { AutoRegister = true }; var profileProperties = new NameValueCollection(); if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.FirstName) && !string.IsNullOrEmpty(user.FirstName))) { profileProperties.Add("FirstName", user.FirstName); } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.LastName) && !string.IsNullOrEmpty(user.LastName))) { profileProperties.Add("LastName", user.LastName); } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.Email) && !string.IsNullOrEmpty(user.Email))) { profileProperties.Add("Email", user.Email); } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.DisplayName) && !string.IsNullOrEmpty(user.FullName))) { profileProperties.Add("DisplayName", user.FullName); } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.Profile.GetPropertyValue("ProfileImage")) && !string.IsNullOrEmpty(user.Picture))) { profileProperties.Add("ProfileImage", user.Picture); } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.Profile.GetPropertyValue("Website")) && !string.IsNullOrEmpty(user.Website))) { profileProperties.Add("Website", user.Website); } if ((objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.Profile.GetPropertyValue("PreferredLocale")))) && !string.IsNullOrEmpty(user.Locale)) { if (IsValidCultureName(user.Locale.Replace('_', '-'))) { profileProperties.Add("PreferredLocale", user.Locale.Replace('_', '-')); } else { profileProperties.Add("PreferredLocale", settings.CultureCode); } } if (objUserInfo == null || (string.IsNullOrEmpty(objUserInfo.Profile.GetPropertyValue("PreferredTimeZone")))) { profileProperties.Add("PreferredTimeZone", user.ZoneInformation); } eventArgs.Profile = profileProperties; //SaveTokenCookie(String.Empty); onAuthenticated(eventArgs); }