public PortalScopedSettings(int portalId)
     : base(
         name => PortalController.GetPortalSetting(name, portalId, ""),
         (name, value) => PortalController.UpdatePortalSetting(portalId, name, value, true)
         )
 {
 }
        protected OAuthConfigBase(string service, int portalId)
            : base(portalId)
        {
            this.Service = service;

            var portalApiKey = PortalController.GetPortalSetting(this.Service + "_APIKey", portalId, string.Empty);
            var hostApiKey   = string.Empty;

            if (string.IsNullOrEmpty(portalApiKey))
            {
                hostApiKey      = HostController.Instance.GetString(this.Service + "_APIKey", string.Empty);
                this.HostConfig = !string.IsNullOrEmpty(hostApiKey);
            }
            else
            {
                this.HostConfig = false;
            }

            if (this.HostConfig)
            {
                this.APIKey    = hostApiKey;
                this.APISecret = HostController.Instance.GetString(this.Service + "_APISecret", string.Empty);
                this.Enabled   = HostController.Instance.GetBoolean(this.Service + "_Enabled", false);
            }
            else
            {
                this.APIKey    = portalApiKey;
                this.APISecret = PortalController.GetPortalSetting(this.Service + "_APISecret", portalId, string.Empty);
                this.Enabled   = PortalController.GetPortalSettingAsBoolean(this.Service + "_Enabled", portalId, false);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            selectCulture.SelectedIndexChanged += selectCulture_SelectedIndexChanged;
            rptLanguages.ItemDataBound         += rptLanguages_ItemDataBound;

            try
            {
                if (ShowLinks)
                {
                    var locales = new Dictionary <string, Locale>();
                    foreach (Locale loc in LocaleController.Instance.GetLocales(PortalSettings.PortalId).Values)
                    {
                        string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), PortalSettings.PortalId, "Administrators");
                        if (!PortalSettings.ContentLocalizationEnabled ||
                            (LocaleIsAvailable(loc) &&
                             (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                        {
                            locales.Add(loc.Code, loc);
                        }
                    }
                    if (locales.Count > 1)
                    {
                        rptLanguages.DataSource = locales.Values;
                        rptLanguages.DataBind();
                    }
                    else
                    {
                        rptLanguages.Visible = false;
                    }
                }

                if (ShowMenu)
                {
                    if (!String.IsNullOrEmpty(CssClass))
                    {
                        selectCulture.CssClass = CssClass;
                    }
                    if (!IsPostBack)
                    {
                        Localization.LoadCultureDropDownList(selectCulture, CultureDropDownTypes.NativeName, CurrentCulture);
                    }
                    //only show language selector if more than one language
                    if (selectCulture.Items.Count <= 1)
                    {
                        selectCulture.Visible = false;
                    }
                }
                else
                {
                    selectCulture.Visible = false;
                }
                handleCommonTemplates();
            }
            catch (Exception ex)
            {
                Exceptions.ProcessPageLoadException(ex, Request.RawUrl);
            }
        }
Esempio n. 4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    string CacheMode = PortalController.GetPortalSetting("OOC_CacheMode", PortalId, "ServerCache");
                    rblMode.SelectedValue = CacheMode;
                    string DefaultIncludeVaryBy = PortalController.GetPortalSetting("OOC_IncludeVaryBy", PortalId, "");
                    tbDefaultInclude.Text = DefaultIncludeVaryBy;
                    string DefaultExcludeVaryBy = PortalController.GetPortalSetting("OOC_ExcludeVaryBy", PortalId, "returnurl");
                    tbDefaultExclude.Text = DefaultExcludeVaryBy;
                    int DefaultCacheDuration = PortalController.GetPortalSettingAsInteger("OOC_CacheDuration", PortalId, 60);
                    tbDuration.Text = DefaultCacheDuration.ToString();

                    int DefaultMaxVaryByCount = PortalController.GetPortalSettingAsInteger("OOC_MaxVaryByCount", PortalId, 0);
                    tbMaxVaryBy.Text = DefaultMaxVaryByCount.ToString();


                    bool VaryByBrowser = PortalController.GetPortalSettingAsBoolean("OOC_VaryByBrowser", PortalId, false);
                    cbVaryByBrowser.Checked = VaryByBrowser;

                    int ExpireDelay = PortalController.GetPortalSettingAsInteger("OOC_ExpireDelay", PortalId, 60);
                    tbExpire.Text = ExpireDelay.ToString();

                    hlCancel.NavigateUrl = Globals.NavigateURL();
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 5
0
            public static List <string> GetCultureListItems()
            {
                List <string> Languages = new List <string>();

                try
                {
                    IEnumerable <System.Web.UI.WebControls.ListItem> cultureListItems = DotNetNuke.Services.Localization.Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CultureInfo.CurrentCulture.ToString(), "", false);
                    PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;
                    foreach (Locale loc in LocaleController.Instance.GetLocales(ps.PortalId).Values)
                    {
                        string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), ps.PortalId, "Administrators");
                        if (!ps.ContentLocalizationEnabled || (LocaleIsAvailable(loc) && (PortalSecurity.IsInRoles(ps.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                        {
                            foreach (System.Web.UI.WebControls.ListItem cultureItem in cultureListItems)
                            {
                                if (cultureItem.Value == loc.Code)
                                {
                                    Languages.Add(loc.Code);
                                }
                            }
                        }
                    }
                }
                catch
                {
                }

                return(Languages);
            }
        internal static List <IUIData> GetData(PortalSettings PortalSettings, UserInfo UserInfo, Dictionary <string, string> Parameters)
        {
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>();
            string cultureCode = string.Empty;
            int    lid         = -1;

            try
            {
                lid = int.Parse(Parameters["lid"]);
            }
            catch { }
            Locale language      = LocaleController.Instance.GetLocale(lid);
            string SelectedRoles = "";

            if (language != null)
            {
                SelectedRoles = PortalController.GetPortalSetting($"DefaultTranslatorRoles-{language.Code}", PortalSettings.PortalId, "Administrators");
            }
            Settings.Add("SelectedRoles", new UIData {
                Name = "SelectedRoles", Options = new ArrayList(SelectedRoles.Split(';'))
            });
            Settings.Add("LanguageID", new UIData {
                Name = "LanguageID", Options = lid
            });
            Settings.Add("RoleGroups", new UIData {
                Name = "RoleGroups", Options = Vanjaro.Common.Factories.Factory.RoleFactory.GetAllRoleGroups(PortalSettings.PortalId, ""), OptionsValue = "Id", OptionsText = "Name", Value = "-2"
            });
            return(Settings.Values.ToList());
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="portalID"></param>
        /// <param name="visitorGUID"></param>
        /// <returns></returns>
        public object JoinVisitor(int portalID, string visitorGUID)
        {
            Groups.Add(Context.ConnectionId, portalID + "-" + visitorGUID);

            var moduleID = int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", portalID, "-1"));

            Requires.NotNegative("moduleID", moduleID);
            var Settings = new ModuleController().GetModule(moduleID).ModuleSettings;

            var currentLiveChat = LiveChatManager.Instance.GetCurrentLiveChatByVisitor(portalID, visitorGUID);

            LiveChatViewModel livechat = null;

            if (currentLiveChat != null)
            {
                if (currentLiveChat.LastMessageDate != null && (DateTime.Now - currentLiveChat.LastMessageDate).TotalHours < 10) // in ghesmat baraye in ast ke agar az akharin post visitor bish az 10 saat gozashte bashad live chat ra neshan nadahad
                {
                    livechat = GetLiveChatViewModel(currentLiveChat);
                }
                else
                {
                    LiveChatManager.Instance.CloseLiveChat(currentLiveChat.LiveChatID, false);
                }
            }

            return(livechat);
        }
Esempio n. 8
0
        public string[] BuildCacheKeys(int PortalId)
        {
            var allCacheKeys = new List <string>();

            foreach (UrlRuleProvider _provider in Providers)
            {
                bool isProviderEnabled;
                if (PortalId == Null.NullInteger) // host menu
                {
                    isProviderEnabled = false;    //_provider.HostProvider;
                }
                else
                {
                    isProviderEnabled = bool.Parse(PortalController.GetPortalSetting(_provider.Name + "_Enabled", PortalId, "True"));
                }
                if (isProviderEnabled)
                {
                    // Get all urls from provider
                    string[] keys = _provider.GetCacheKeys(PortalId);
                    if (keys != null)
                    {
                        allCacheKeys.AddRange(keys);
                    }
                }
            }
            return(allCacheKeys.ToArray());
        }
Esempio n. 9
0
        public HttpResponseMessage GetSmtpSettings()
        {
            try
            {
                var portalId = PortalSettings.Current.PortalId;

                var smtpSettings = new
                {
                    smtpServerMode = PortalController.GetPortalSetting("SMTPmode", portalId, "h"),
                    host           = new { },
                    site           = new
                    {
                        smtpServer          = PortalController.GetPortalSetting("SMTPServer", portalId, string.Empty),
                        smtpConnectionLimit = PortalController.GetPortalSettingAsInteger("SMTPConnectionLimit", portalId, 2),
                        smtpMaxIdleTime     = PortalController.GetPortalSettingAsInteger("SMTPMaxIdleTime", portalId, 100000),
                        smtpAuthentication  = PortalController.GetPortalSetting("SMTPAuthentication", portalId, "0"),
                        enableSmtpSsl       = PortalController.GetPortalSetting("SMTPEnableSSL", portalId, string.Empty) == "Y",
                        smtpUserName        = PortalController.GetPortalSetting("SMTPUsername", portalId, string.Empty),
                        smtpPassword        = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey()),
                    },
                    portalName       = PortalSettings.Current.PortalName,
                    hideCoreSettings = ProviderConfiguration.GetProviderConfiguration("mail").GetDefaultProvider().Attributes.GetValueOrDefault("hideCoreSettings", false),
                };
                return(this.Request.CreateResponse(HttpStatusCode.OK, smtpSettings));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
            public static List <Library.Entities.Language> GetCultureListItems(bool All)
            {
                List <Library.Entities.Language> Languages = new List <Library.Entities.Language>();
                IEnumerable <System.Web.UI.WebControls.ListItem> cultureListItems = DotNetNuke.Services.Localization.Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CultureInfo.CurrentCulture.ToString(), "", false);
                PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings;

                foreach (Locale loc in LocaleController.Instance.GetLocales(ps.PortalId).Values)
                {
                    string defaultRoles = PortalController.GetPortalSetting(string.Format("DefaultTranslatorRoles-{0}", loc.Code), ps.PortalId, "Administrators");
                    if (!ps.ContentLocalizationEnabled || (LocaleIsAvailable(loc) && (PortalSecurity.IsInRoles(ps.AdministratorRoleName) || loc.IsPublished || PortalSecurity.IsInRoles(defaultRoles))))
                    {
                        if (cultureListItems.Count() > 1 || All)
                        {
                            foreach (System.Web.UI.WebControls.ListItem cultureItem in cultureListItems)
                            {
                                if (cultureItem.Value == loc.Code)
                                {
                                    Library.Entities.Language language = new Library.Entities.Language
                                    {
                                        EnglishName = RemoveBracket(loc.EnglishName),
                                        NativeName  = RemoveBracket(loc.NativeName),
                                        URL         = NewUrl(loc.Code, ps),
                                        FlagPath    = Globals.ResolveUrl("~/images/Flags") + "/" + loc.Code + ".gif",
                                        Code        = loc.Code
                                    };
                                    Languages.Add(language);
                                }
                            }
                        }
                    }
                }
                return(Languages);
            }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// LoadSettings loads the settings from the Database and displays them
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void LoadSettings()
        {
            try
            {
                LocalizeModule();

                if (!Page.IsPostBack)
                {
                    var guidSetting = PortalController.GetPortalSetting(FeatureController.SETTING_PORTALGUID_OVERRIDE,
                                                                        PortalId, Null.NullGuid.ToString());

                    if (guidSetting != null && !string.IsNullOrEmpty(guidSetting) && guidSetting != Null.NullGuid.ToString())
                    {
                        txtPortalGuidOverride.Text = guidSetting;
                    }

                    if (Settings.Contains(FeatureController.SETTING_TABID_OVERRIDE))
                    {
                        txtTabIdOverride.Text = Settings[FeatureController.SETTING_TABID_OVERRIDE].ToString();
                    }

                    if (Settings.Contains(FeatureController.SETTING_TABMODULEID_OVERRIDE))
                    {
                        txtTabModuleIdOverride.Text = Settings[FeatureController.SETTING_TABMODULEID_OVERRIDE].ToString();
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 private void BindSSLSettings(PortalInfo portal)
 {
     chkSSLEnabled.Checked  = PortalController.GetPortalSettingAsBoolean("SSLEnabled", portal.PortalID, false);
     chkSSLEnforced.Checked = PortalController.GetPortalSettingAsBoolean("SSLEnforced", portal.PortalID, false);
     txtSSLURL.Text         = PortalController.GetPortalSetting("SSLURL", portal.PortalID, Null.NullString);
     txtSTDURL.Text         = PortalController.GetPortalSetting("STDURL", portal.PortalID, Null.NullString);
 }
        private void BindSkins(PortalInfo portal)
        {
            var skins = SkinController.GetSkins(portal, SkinController.RootSkin, SkinScope.All)
                        .ToDictionary(skin => skin.Key, skin => skin.Value);
            var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.All)
                             .ToDictionary(skin => skin.Key, skin => skin.Value);

            portalSkinCombo.DataSource = skins;
            portalSkinCombo.DataBind(PortalController.GetPortalSetting("DefaultPortalSkin", portal.PortalID, Host.DefaultPortalSkin));

            portalContainerCombo.DataSource = containers;
            portalContainerCombo.DataBind(PortalController.GetPortalSetting("DefaultPortalContainer", portal.PortalID, Host.DefaultPortalContainer));

            editSkinCombo.DataSource = skins;
            editSkinCombo.DataBind(PortalController.GetPortalSetting("DefaultAdminSkin", portal.PortalID, Host.DefaultAdminSkin));

            editContainerCombo.DataSource = containers;
            editContainerCombo.DataBind(PortalController.GetPortalSetting("DefaultAdminContainer", portal.PortalID, Host.DefaultAdminContainer));

            if (ModuleContext.PortalSettings.UserInfo.IsSuperUser)
            {
                uploadSkinLink.NavigateUrl = Util.InstallURL(ModuleContext.TabId, "");

                if (PortalSettings.EnablePopUps)
                {
                    uploadSkinLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(uploadSkinLink.NavigateUrl, this, PortalSettings, true, false));
                }
            }
            else
            {
                uploadSkinLink.Visible = false;
            }
        }
Esempio n. 14
0
        private void GetCookieConsentMarkup()
        {
            try
            {
                if (string.IsNullOrEmpty(Request.QueryString["mid"]) && string.IsNullOrEmpty(Request.QueryString["icp"]))
                {
                    if (Request.Cookies["cookieconsent_status"] == null)
                    {
                        string d = PortalController.GetPortalSetting("Vanjaro_CookieConsent", PortalSettings.PortalId, "False");
                        if (d == bool.TrueString)
                        {
                            if (FindControlRecursive(this, "CookieConsentPane") == null)
                            {
                                Controls.Add(ParseControl("<div id=\"CookieConsentPane\" runat=\"server\" />"));
                            }

                            if (FindControlRecursive(this, "CookieConsentPane") != null)
                            {
                                IDictionary <string, object> Objects = new ExpandoObject() as IDictionary <string, object>;
                                Objects.Add("CookieConsentUrl", PortalSettings.CookieMoreLink);
                                string Template = RazorEngineManager.RenderTemplate("", BlockPath + "/Cookie Consent/", "Default", Objects);
                                Template = new DNNLocalizationEngine(null, ResouceFilePath, false).Parse(Template);
                                FindControlRecursive(this, "CookieConsentPane").Controls.Add(ParseControl(Template));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
        public HttpResponseMessage UpdateBasicSettings(BasicSettingsDTO postData)
        {
            try
            {
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "MyDnnVisitorsOnlineEnabled", postData.PortalSettings["VisitorsOnlineEnabled"].ToString(), true);
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "MyDnnLiveChatEnabled", postData.PortalSettings["LiveChatEnabled"].ToString(), true);

                var moduleID = int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", PortalSettings.PortalId, "-1"));

                Requires.NotNegative("moduleID", moduleID);

                ModuleController.Instance.UpdateModuleSetting(moduleID, "UpdateBasicSettings", "True");

                ModuleController.Instance.UpdateModuleSetting(moduleID, "PlaySoundWhenNewMsg", postData.ModuleSettings["PlaySoundWhenNewMsg"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "ShowDekstopNotificationForIncoming", postData.ModuleSettings["ShowDekstopNotificationForIncoming"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "ShowDekstopNotificationForNewMsg", postData.ModuleSettings["ShowDekstopNotificationForNewMsg"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "AgentsViewPermission", postData.ModuleSettings["AgentsViewPermission"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "SendEmailForOffline", postData.ModuleSettings["SendEmailForOffline"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "SendEmailAfterChat", postData.ModuleSettings["SendEmailAfterChat"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "TranscriptEmailTemplate", postData.ModuleSettings["TranscriptEmailTemplate"].ToString());
                ModuleController.Instance.UpdateModuleSetting(moduleID, "OfflineEmailTemplate", postData.ModuleSettings["OfflineEmailTemplate"].ToString());

                return(Request.CreateResponse(HttpStatusCode.OK, new { Success = true }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
 protected internal AzureConfig(string service, int portalId) : base(service, portalId)
 {
     AppIdUri              = PortalController.GetPortalSetting(Service + "_AppIdUri", portalId, "");
     TokenEndpoint         = PortalController.GetPortalSetting(Service + "_TokenEndpoint", portalId, "");
     AuthorizationEndpoint = PortalController.GetPortalSetting(Service + "_AuthorizationEndpoint", portalId, "");
     GraphEndpoint         = PortalController.GetPortalSetting(Service + "_GraphEndpoint", portalId, "");
 }
        public HttpResponseMessage GetWidgetSettings()
        {
            try
            {
                string    template = "default";
                Hashtable Settings = new Hashtable();

                var livechatEnabled = bool.Parse(PortalController.GetPortalSetting("MyDnnLiveChatEnabled", PortalSettings.PortalId, "false"));
                if (livechatEnabled)
                {
                    var moduleID = int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", PortalSettings.PortalId, "-1"));
                    if (moduleID > 0)
                    {
                        var moduleInfo = new ModuleController().GetModule(moduleID);
                        Settings = moduleInfo.ModuleSettings;
                        template = (Settings["Template"] != null ? Settings["Template"].ToString() : "default");
                    }
                }

                string liveChatWidget = Common.GetFileContent(HttpContext.Current.Request.MapPath(Globals.ResolveUrl(string.Format("~/DesktopModules/MVC/MyDnnSupport/LiveChat/Templates/{0}/view.html", template))));

                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    Template = template,
                    Settings = Settings,
                    LiveChatWidget = liveChatWidget
                }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        /// Pages that are included:
        /// - are not deleted
        /// - are not disabled
        /// - are normal pages (not links,...)
        /// - are visible (based on date and permissions)
        /// </remarks>

        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            TabController     objTabs = new TabController();
            SitemapUrl        pageUrl = null;
            List <SitemapUrl> urls    = new List <SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority           = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"));
            includeHiddenPages        = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "True"));

            this.ps = ps;

            foreach (TabInfo objTab in objTabs.GetTabsByPortal(portalId).Values)
            {
                if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) && (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions))
                {
                    if (includeHiddenPages | objTab.IsVisible)
                    {
                        foreach (string languageCode in CommonLibrary.Services.Localization.Localization.GetLocales(portalId).Keys)
                        {
                            pageUrl = GetPageUrl(objTab, languageCode);
                            urls.Add(pageUrl);
                        }
                    }
                }
            }

            return(urls);
        }
        /// <summary>
        ///   Includes page urls on the sitemap
        /// </summary>
        /// <remarks>
        ///   Pages that are included:
        ///   - are not deleted
        ///   - are not disabled
        ///   - are normal pages (not links,...)
        ///   - are visible (based on date and permissions)
        /// </remarks>
        public override List <SitemapUrl> GetUrls(int portalId, PortalSettings ps, string version)
        {
            SitemapUrl pageUrl = null;
            var        urls    = new List <SitemapUrl>();

            useLevelBasedPagePriority = bool.Parse(PortalController.GetPortalSetting("SitemapLevelMode", portalId, "False"));
            minPagePriority           = float.Parse(PortalController.GetPortalSetting("SitemapMinPriority", portalId, "0.1"), CultureInfo.InvariantCulture);
            includeHiddenPages        = bool.Parse(PortalController.GetPortalSetting("SitemapIncludeHidden", portalId, "True"));

            this.ps = ps;

            foreach (TabInfo objTab in TabController.Instance.GetTabsByPortal(portalId).Values)
            {
                if (!objTab.IsDeleted && !objTab.DisableLink && objTab.TabType == TabType.Normal && (Null.IsNull(objTab.StartDate) || objTab.StartDate < DateTime.Now) &&
                    (Null.IsNull(objTab.EndDate) || objTab.EndDate > DateTime.Now) && IsTabPublic(objTab.TabPermissions))
                {
                    if (includeHiddenPages || objTab.IsVisible)
                    {
                        pageUrl = GetPageUrl(objTab, (ps.ContentLocalizationEnabled) ? objTab.CultureCode : null);
                        urls.Add(pageUrl);
                    }
                }
            }

            return(urls);
        }
Esempio n. 20
0
        private void AddEditorRole()
        {
            if (ModuleContext.PortalSettings.UserId > 0)
            {
                string OpenContent_EditorsRoleId = PortalController.GetPortalSetting("OpenContent_EditorsRoleId", ModuleContext.PortalId, "");
                if (!string.IsNullOrEmpty(OpenContent_EditorsRoleId))
                {
                    int roleId    = int.Parse(OpenContent_EditorsRoleId);
                    var objModule = ModuleContext.Configuration;
                    //todo: probable DNN bug.  objModule.ModulePermissions doesn't return correct permissions for attached multi-lingual modules
                    //don't alter permissions of modules that are non-default language and that are attached
                    var permExist = objModule.ModulePermissions.Where(tp => tp.RoleID == roleId).Any();
                    if (!permExist)
                    {
                        //todo sacha: add two permissions, read and write; Or better still add all permissions that are available. eg if you installed extra permissions

                        var permissionController = new PermissionController();
                        // view permission
                        var arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");
                        var permission          = (PermissionInfo)arrSystemModuleViewPermissions[0];
                        var objModulePermission = new ModulePermissionInfo
                        {
                            ModuleID = ModuleContext.Configuration.ModuleID,
                            //ModuleDefID = permission.ModuleDefID,
                            //PermissionCode = permission.PermissionCode,
                            PermissionID  = permission.PermissionID,
                            PermissionKey = permission.PermissionKey,
                            RoleID        = roleId,
                            //UserID = userId,
                            AllowAccess = true
                        };
                        objModule.ModulePermissions.Add(objModulePermission);

                        // edit permission
                        arrSystemModuleViewPermissions = permissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "EDIT");
                        permission          = (PermissionInfo)arrSystemModuleViewPermissions[0];
                        objModulePermission = new ModulePermissionInfo
                        {
                            ModuleID = ModuleContext.Configuration.ModuleID,
                            //ModuleDefID = permission.ModuleDefID,
                            //PermissionCode = permission.PermissionCode,
                            PermissionID  = permission.PermissionID,
                            PermissionKey = permission.PermissionKey,
                            RoleID        = roleId,
                            //UserID = userId,
                            AllowAccess = true
                        };
                        objModule.ModulePermissions.Add(objModulePermission);
                        try
                        {
                            ModulePermissionController.SaveModulePermissions(objModule);
                        }
                        catch (Exception ex)
                        {
                            //Log.Logger.ErrorFormat("Failed to automaticly set the permission. It already exists? tab={0}, moduletitle={1} ", objModule.TabID ,objModule.ModuleTitle);
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="livechatID"></param>
        /// <param name="reInitialize"></param>
        /// <returns></returns>
        public async Task InitialLiveChatForAgent(int livechatID, bool reInitialize = false)
        {
            var objLiveChatInfo = LiveChatManager.Instance.GetLiveChatByID(livechatID);

            if (objLiveChatInfo != null)
            {
                var moduleID = int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", objLiveChatInfo.PortalID, "-1"));
                Requires.NotNegative("moduleID", moduleID);
                var Settings = new ModuleController().GetModule(moduleID).ModuleSettings;

                var  agent   = AgentManager.Instance.GetAgentByUserName(objLiveChatInfo.PortalID, this.UserName);
                bool isAdmin = agent.IsAdmin;

                var livechat = GetLiveChatViewModel(objLiveChatInfo);

                //if (reInitialize)
                //agentUserID = agent.UserID;

                if (!livechat.Agents.Any() || Settings["AgentsViewPermission"].ToString() == LiveChatViewPermission.AllAgentsInDepartment.ToString() ||
                    (Settings["AgentsViewPermission"].ToString() == LiveChatViewPermission.OnlyCurrentAgentsAndAdmin.ToString() && isAdmin))
                {
                    await Clients.Group(AgentGroupName + agent.UserID).initialLiveChatForAgent(livechat);
                }
            }
        }
Esempio n. 22
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   GetWorkFlow retrieves the currently active Workflow for the Portal
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "ModuleId">The ID of the Module</param>
        /// <param name="TabId">The Tab ID</param>
        /// <param name = "PortalId">The ID of the Portal</param>
        public KeyValuePair <string, int> GetWorkflow(int ModuleId, int TabId, int PortalId)
        {
            int    workFlowId   = Null.NullInteger;
            string workFlowType = Null.NullString;

            // get module settings
            HtmlModuleSettings settings;

            if (ModuleId > -1)
            {
                var module = ModuleController.Instance.GetModule(ModuleId, TabId, false);
                var repo   = new HtmlModuleSettingsRepository();
                settings = repo.GetSettings(module);
            }
            else
            {
                settings = new HtmlModuleSettings();
            }

            if (settings.WorkFlowID != Null.NullInteger)
            {
                workFlowId   = settings.WorkFlowID;
                workFlowType = "Module";
            }
            if (workFlowId == Null.NullInteger)
            {
                // if undefined at module level, get from tab settings
                var tabSettings = TabController.Instance.GetTabSettings(TabId);
                if (tabSettings["WorkflowID"] != null)
                {
                    workFlowId   = Convert.ToInt32(tabSettings["WorkflowID"]);
                    workFlowType = "Page";
                }
            }

            if (workFlowId == Null.NullInteger)
            {
                // if undefined at tab level, get from portal settings
                workFlowId   = int.Parse(PortalController.GetPortalSetting("WorkflowID", PortalId, "-1"));
                workFlowType = "Site";
            }

            // if undefined at portal level, set portal default
            if (workFlowId == Null.NullInteger)
            {
                var       objWorkflow  = new WorkflowStateController();
                ArrayList arrWorkflows = objWorkflow.GetWorkflows(PortalId);
                foreach (WorkflowStateInfo objState in arrWorkflows)
                {
                    // use direct publish as default
                    if (Null.IsNull(objState.PortalID) && objState.WorkflowName == "Direct Publish")
                    {
                        workFlowId   = objState.WorkflowID;
                        workFlowType = "Module";
                    }
                }
            }

            return(new KeyValuePair <string, int>(workFlowType, workFlowId));
        }
Esempio n. 23
0
        private static List <SitemapUrl> GetAllUrls(PortalSettings ps, DateTime dtLastRun)
        {
            var allUrls = new List <SitemapUrl>();

            // get all urls
            foreach (SitemapProvider _provider in Providers)
            {
                var isProviderEnabled = bool.Parse(PortalController.GetPortalSetting(_provider.Name + "Enabled", ps.PortalId, "True"));

                if (isProviderEnabled)
                {
                    // Get all urls from provider
                    var urls = new List <SitemapUrl>();
                    try
                    {
                        urls = _provider.GetUrls(ps.PortalId, ps, SITEMAP_VERSION);
                    }
                    catch (Exception ex)
                    {
                        Exceptions.LogException(ex);
                    }

                    foreach (SitemapUrl url in urls)
                    {
                        // excluded urls older than the last updated date
                        if (url.LastModified > dtLastRun)
                        {
                            allUrls.Add(url);
                        }
                    }
                }
            }

            return(allUrls);
        }
        protected void grdPortals_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            string defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", intPortalId, "");

            DataGridItem item = e.Item;

            if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.SelectedItem)
            {
                Control imgColumnControl = item.Controls[1].Controls[0];
                if (imgColumnControl is ImageButton)
                {
                    var delImage    = (ImageButton)imgColumnControl;
                    var portalAlias = (PortalAliasInfo)item.DataItem;

                    delImage.Visible = portalAlias.PortalAliasID != PortalAlias.PortalAliasID && portalAlias.HTTPAlias != defaultAlias;
                }
                imgColumnControl = item.Controls[0].Controls[0];
                if (imgColumnControl is ImageButton)
                {
                    var editImage   = (ImageButton)imgColumnControl;
                    var portalAlias = (PortalAliasInfo)item.DataItem;

                    editImage.Visible = portalAlias.PortalAliasID != PortalAlias.PortalAliasID;
                }
            }
            else if (item.ItemType == ListItemType.EditItem)
            {
                var chkChild = item.Cells[1].FindControl("chkChild") as CheckBox;
                chkChild.Visible = AddMode;
            }
        }
        public HttpResponseMessage GetSmtpSettings()
        {
            try
            {
                var portalId = PortalSettings.Current.PortalId;

                var smtpSettings = new
                {
                    smtpServerMode = PortalController.GetPortalSetting("SMTPmode", portalId, "h"),
                    host           = new{},
                    site           = new
                    {
                        smtpServer          = PortalController.GetPortalSetting("SMTPServer", portalId, string.Empty),
                        smtpConnectionLimit = PortalController.GetPortalSettingAsInteger("SMTPConnectionLimit", portalId, 1),
                        smtpMaxIdleTime     = PortalController.GetPortalSettingAsInteger("SMTPMaxIdleTime", portalId, 0),
                        smtpAuthentication  = PortalController.GetPortalSetting("SMTPAuthentication", portalId, "0"),
                        enableSmtpSsl       = PortalController.GetPortalSetting("SMTPEnableSSL", portalId, string.Empty) == "Y",
                        smtpUserName        = PortalController.GetPortalSetting("SMTPUsername", portalId, string.Empty),
                        smtpPassword        = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey())
                    },
                    portalName = PortalSettings.Current.PortalName
                };
                return(Request.CreateResponse(HttpStatusCode.OK, smtpSettings));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        private void GetVarBy(Hashtable tabSettings, out StringCollection includeVaryByKeys, out StringCollection excludeVaryByKeys, int PortalId)
        {
            includeVaryByKeys = new StringCollection();
            excludeVaryByKeys = new StringCollection();
            bool   Exclude = GetTabSettingAsInteger(tabSettings, "CacheIncludeExclude", 0) == 0;
            string DefaultIncludeVaryBy = PortalController.GetPortalSetting("IncludeVaryBy", PortalId, "");
            string DefaultExcludeVaryBy = PortalController.GetPortalSetting("ExcludeVaryBy", PortalId, "returnurl");

            if (!string.IsNullOrEmpty(DefaultIncludeVaryBy))
            {
                includeVaryByKeys.AddRange(DefaultIncludeVaryBy.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }
            if (!string.IsNullOrEmpty(DefaultExcludeVaryBy))
            {
                excludeVaryByKeys.AddRange(DefaultExcludeVaryBy.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }
            string IncludeVaryBy = GetTabSettingAsString(tabSettings, "IncludeVaryBy");
            string ExcludeVaryBy = GetTabSettingAsString(tabSettings, "ExcludeVaryBy");

            if (Exclude)
            {
                if (!string.IsNullOrEmpty(IncludeVaryBy))
                {
                    includeVaryByKeys.AddRange(IncludeVaryBy.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(ExcludeVaryBy))
                {
                    excludeVaryByKeys.AddRange(ExcludeVaryBy.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }
        }
Esempio n. 27
0
        public HttpResponseMessage GetRegistrationSettings()
        {
            try
            {
                List <KeyValuePair <string, int> > userRegistrationOptions     = RegistrationSettingsHelper.GetUserRegistrationOptions();
                List <KeyValuePair <string, int> > registrationFormTypeOptions = RegistrationSettingsHelper.GetRegistrationFormOptions();

                var activeLanguage = LocaleController.Instance.GetDefaultLocale(PortalId).Code;
                var portal         = PortalController.Instance.GetPortal(PortalId, activeLanguage);

                var response = new
                {
                    Success = true,
                    Results = new
                    {
                        Settings = new
                        {
                            portal.UserRegistration,
                            EnableRegisterNotification = PortalController.GetPortalSettingAsBoolean("EnableRegisterNotification", PortalId, true),
                            UseAuthenticationProviders = PortalController.GetPortalSettingAsBoolean("Registration_UseAuthProviders", PortalId, false),
                            ExcludedTerms      = PortalController.GetPortalSetting("Registration_ExcludeTerms", PortalId, string.Empty),
                            UseProfanityFilter = PortalController.GetPortalSettingAsBoolean("Registration_UseProfanityFilter", PortalId, false),
                            PortalSettings.Registration.RegistrationFormType,
                            PortalSettings.Registration.RegistrationFields,
                            UseEmailAsUsername               = PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", PortalId, false),
                            RequireUniqueDisplayName         = PortalController.GetPortalSettingAsBoolean("Registration_RequireUniqueDisplayName", PortalId, false),
                            DisplayNameFormat                = PortalController.GetPortalSetting("Security_DisplayNameFormat", PortalId, string.Empty),
                            UserNameValidation               = PortalController.GetPortalSetting("Security_UserNameValidation", PortalId, Globals.glbUserNameRegEx),
                            EmailAddressValidation           = PortalController.GetPortalSetting("Security_EmailValidation", PortalId, Globals.glbEmailRegEx),
                            UseRandomPassword                = PortalController.GetPortalSettingAsBoolean("Registration_RandomPassword", PortalId, false),
                            RequirePasswordConfirmation      = PortalController.GetPortalSettingAsBoolean("Registration_RequireConfirmPassword", PortalId, true),
                            RequireValidProfile              = PortalController.GetPortalSettingAsBoolean("Security_RequireValidProfile", PortalId, false),
                            UseCaptchaRegister               = PortalController.GetPortalSettingAsBoolean("Security_CaptchaRegister", PortalId, false),
                            RedirectAfterRegistrationTabId   = ValidateTabId(PortalSettings.Registration.RedirectAfterRegistration),
                            RedirectAfterRegistrationTabName = GetTabName(PortalSettings.Registration.RedirectAfterRegistration),
                            RedirectAfterRegistrationTabPath = GetTabPath(PortalSettings.Registration.RedirectAfterRegistration),
                            RequiresUniqueEmail              = MembershipProviderConfig.RequiresUniqueEmail.ToString(CultureInfo.InvariantCulture),
                            PasswordFormat               = MembershipProviderConfig.PasswordFormat.ToString(),
                            PasswordRetrievalEnabled     = MembershipProviderConfig.PasswordRetrievalEnabled.ToString(CultureInfo.InvariantCulture),
                            PasswordResetEnabled         = MembershipProviderConfig.PasswordResetEnabled.ToString(CultureInfo.InvariantCulture),
                            MinPasswordLength            = MembershipProviderConfig.MinPasswordLength.ToString(CultureInfo.InvariantCulture),
                            MinNonAlphanumericCharacters = MembershipProviderConfig.MinNonAlphanumericCharacters.ToString(CultureInfo.InvariantCulture),
                            RequiresQuestionAndAnswer    = MembershipProviderConfig.RequiresQuestionAndAnswer.ToString(CultureInfo.InvariantCulture),
                            MembershipProviderConfig.PasswordStrengthRegularExpression,
                            MaxInvalidPasswordAttempts = MembershipProviderConfig.MaxInvalidPasswordAttempts.ToString(CultureInfo.InvariantCulture),
                            PasswordAttemptWindow      = MembershipProviderConfig.PasswordAttemptWindow.ToString(CultureInfo.InvariantCulture)
                        },
                        UserRegistrationOptions     = userRegistrationOptions,
                        RegistrationFormTypeOptions = registrationFormTypeOptions
                    }
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
        public HttpResponseMessage GetBasicSettings()
        {
            try
            {
                Hashtable moduleSettings = new Hashtable();
                Hashtable portalSettings = new Hashtable();

                var moduleID = int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", PortalSettings.PortalId, "-1"));
                if (moduleID > 0)
                {
                    var moduleInfo = new ModuleController().GetModule(moduleID);
                    moduleSettings = moduleInfo.ModuleSettings;

                    portalSettings.Add("VisitorsOnlineEnabled", PortalController.GetPortalSetting("MyDnnVisitorsOnlineEnabled", PortalSettings.PortalId, "false"));
                    portalSettings.Add("LiveChatEnabled", PortalController.GetPortalSetting("MyDnnLiveChatEnabled", PortalSettings.PortalId, "false"));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, new
                {
                    PortalSettings = portalSettings,
                    ModuleSettings = moduleSettings
                }));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
        public HttpResponseMessage GetSslSettings()
        {
            try
            {
                dynamic settings = new ExpandoObject();
                settings.SSLEnabled  = PortalController.GetPortalSettingAsBoolean("SSLEnabled", PortalId, false);
                settings.SSLEnforced = PortalController.GetPortalSettingAsBoolean("SSLEnforced", PortalId, false);
                settings.SSLURL      = PortalController.GetPortalSetting("SSLURL", PortalId, Null.NullString);
                settings.STDURL      = PortalController.GetPortalSetting("STDURL", PortalId, Null.NullString);

                if (UserInfo.IsSuperUser)
                {
                    settings.SSLOffloadHeader = HostController.Instance.GetString("SSLOffloadHeader", "");
                }

                var response = new
                {
                    Success = true,
                    Results = new
                    {
                        Settings = settings
                    }
                };

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
Esempio n. 30
0
        public ActionResult Index()
        {
            var moduleId =
                int.Parse(PortalController.GetPortalSetting("MyDnnLiveChatModuleID", PortalSettings.PortalId, "-1"));

            if (moduleId == -1)
            {
                moduleId = ActiveModule.ModuleID;
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, "MyDnnLiveChatModuleID",
                                                     moduleId.ToString(), true);

                var role = RoleController.Instance.GetRoleByName(PortalSettings.PortalId, "MyDnnSupportAgent");
                if (role == null)
                {
                    var objRoleInfo = new RoleInfo
                    {
                        PortalID    = PortalSettings.PortalId,
                        Description = "mydnn live chat agent",
                        RoleName    = "MyDnnSupportAgent",
                        IsPublic    = false,
                        Status      = RoleStatus.Approved,
                        RoleGroupID = Null.NullInteger
                    };
                    RoleController.Instance.AddRole(objRoleInfo);

                    var listeners     = VisitorsOnlineApi.Instance.GetListeners(PortalSettings.PortalId);
                    var listenerInfos = listeners as IList <ListenerInfo> ?? listeners.ToList();
                    if (!listenerInfos.Any(l => l.RoleName == "MyDnnSupportAgent" &&
                                           l.LoginState == VisitorsOnline.Components.Enums.LoginState.LoggedIn))
                    {
                        VisitorsOnlineApi.Instance.AddListener(new ListenerInfo()
                        {
                            PortalID     = PortalSettings.PortalId,
                            RoleName     = "MyDnnSupportAgent",
                            LoginState   = VisitorsOnline.Components.Enums.LoginState.LoggedIn,
                            InvokeScript =
                                "$('#mydnnLiveChatMinButton').find('[data-livechat-isonline]').hide();$('#mydnnLiveChatMinButton').find('[data-livechat-isonline=\"online\"]').show();",
                            CreatedByModuleName = "MyDnnSupportLiveChat",
                            CreatedOnDate       = DateTime.Now
                        });
                    }
                    if (!listenerInfos.Any(l => l.RoleName == "MyDnnSupportAgent" &&
                                           l.LoginState == VisitorsOnline.Components.Enums.LoginState.LoggedOff))
                    {
                        VisitorsOnlineApi.Instance.AddListener(new ListenerInfo()
                        {
                            PortalID     = PortalSettings.PortalId,
                            RoleName     = "MyDnnSupportAgent",
                            LoginState   = VisitorsOnline.Components.Enums.LoginState.LoggedOff,
                            InvokeScript =
                                "$('#mydnnLiveChatMinButton').find('[data-livechat-isonline]').hide();$('#mydnnLiveChatMinButton').find('[data-livechat-isonline=\"offline\"]').show();",
                            CreatedByModuleName = "MyDnnSupportLiveChat",
                            CreatedOnDate       = DateTime.Now
                        });
                    }
                }
            }

            return(View());
        }