private string HandleRolesRegex(string RoleRegex, string Mode)
        {
            string sOut = string.Empty;

            ArrayList oRoles = RoleProvider.Instance().GetRoles(PortalSettings.PortalId);

            foreach (RoleInfo oRole in oRoles)
            {
                if (Regex.IsMatch(oRole.RoleName, RoleRegex, RegexOptions.IgnoreCase))
                {
                    switch (Mode)
                    {
                    case "Find":
                    {
                        sOut += GetDeletedLink(oRole.RoleName, false);
                        break;
                    }

                    case "Remove":
                    {
                        if (DeleteRole(oRole.RoleName) == true)
                        {
                            sOut += $"Role {oRole.RoleName}: Removed<br />";
                        }
                        else
                        {
                            sOut += $"Role {oRole.RoleName}: Cannot Remove Role<br />";
                        }
                        break;
                    }

                    default:
                    {
                        sOut += string.Format("No mode Selected");
                        break;
                    }
                    }
                }
            }

            if (sOut == string.Empty)
            {
                sOut = "No Roles Found";
            }

            return(sOut);
        }
Exemplo n.º 2
0
        private bool ExecuteDeleteCommand()
        {
            try
            {
                var ctlRole = new RoleController();
                var role    = ctlRole.GetRole(GroupId, PortalId);

                var result = role.Settings.Remove(SettingKey);

                RoleProvider.Instance().UpdateRoleSettings(role);

                return(result);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                return(false);
            }
        }
Exemplo n.º 3
0
        private void BindData()
        {
            LocalizeModule();

            lnkDelete.Visible = (GroupId != Null.NullInteger);

            if (GroupId > Null.NullInteger && !string.IsNullOrEmpty(SettingKey))
            {
                // this is an edit view
                var setting = from s in RoleProvider.Instance().GetRoleSettings(GroupId)
                              where s.Key == SettingKey
                              select s;

                txtSettingKey.Text   = setting.First().Key;
                txtSettingValue.Text = setting.First().Value;
            }
            else
            {
                // this is a new item view
                txtSettingKey.Focus();
            }
        }
        public void SetUp()
        {
            Globals.SetStatus(Globals.UpgradeStatus.None);

            ComponentFactory.Container = new SimpleContainer();
            ComponentFactory.InstallComponents(new ProviderInstaller("data", typeof(DataProvider), typeof(SqlDataProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("caching", typeof(CachingProvider), typeof(FBCachingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("logging", typeof(LoggingProvider), typeof(DBLoggingProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("members", typeof(MembershipProvider), typeof(AspNetMembershipProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("roles", typeof(RoleProvider), typeof(DNNRoleProvider)));
            ComponentFactory.InstallComponents(new ProviderInstaller("profiles", typeof(ProfileProvider), typeof(DNNProfileProvider)));
            ComponentFactory.RegisterComponent <IPortalSettingsController, PortalSettingsController>();

            PortalController.ClearInstance();
            UserController.ClearInstance();
            RoleController.ClearInstance();

            var roleController    = RoleController.Instance;
            var roleProviderField = roleController.GetType().GetField("provider", BindingFlags.NonPublic | BindingFlags.Static);

            if (roleProviderField != null)
            {
                roleProviderField.SetValue(roleController, RoleProvider.Instance());
            }

            var membershipType = typeof(System.Web.Security.Membership);
            var initializedDefaultProviderField = membershipType.GetField("s_InitializedDefaultProvider", BindingFlags.NonPublic | BindingFlags.Static);
            var defaultProviderField            = membershipType.GetField("s_Provider", BindingFlags.NonPublic | BindingFlags.Static);

            if (initializedDefaultProviderField != null &&
                defaultProviderField != null &&
                (bool)initializedDefaultProviderField.GetValue(null) == false)
            {
                initializedDefaultProviderField.SetValue(null, true);
                defaultProviderField.SetValue(null, System.Web.Security.Membership.Providers["AspNetSqlMembershipProvider"]);
            }
        }
Exemplo n.º 5
0
        public static void SendEmailToModerators(int templateId, int portalId, int forumId, int topicId, int replyId, int moduleID, int tabID, string comments, UserInfo user)
        {
            var portalSettings = (Entities.Portals.PortalSettings)(HttpContext.Current.Items["PortalSettings"]);
            var mainSettings   = DataCache.MainSettings(moduleID);
            var fc             = new ForumController();
            var fi             = fc.Forums_Get(forumId, -1, false, true);

            if (fi == null)
            {
                return;
            }

            var subs       = new List <SubscriptionInfo>();
            var rc         = new Security.Roles.RoleController();
            var rp         = RoleProvider.Instance();
            var uc         = new Entities.Users.UserController();
            var modApprove = fi.Security.ModApprove;
            var modRoles   = modApprove.Split('|')[0].Split(';');

            foreach (var r in modRoles)
            {
                if (string.IsNullOrEmpty(r))
                {
                    continue;
                }
                var rid   = Convert.ToInt32(r);
                var rName = rc.GetRole(rid, portalId).RoleName;
                foreach (UserRoleInfo usr in rp.GetUserRoles(portalId, null, rName))
                {
                    var ui = uc.GetUser(portalId, usr.UserID);
                    var si = new SubscriptionInfo
                    {
                        UserId      = ui.UserID,
                        DisplayName = ui.DisplayName,
                        Email       = ui.Email,
                        FirstName   = ui.FirstName,
                        LastName    = ui.LastName
                    };
                    if (!(subs.Contains(si)))
                    {
                        subs.Add(si);
                    }
                }
            }

            if (subs.Count <= 0)
            {
                return;
            }

            var sTemplate = string.Empty;
            var tc        = new TemplateController();
            var ti        = tc.Template_Get(templateId, portalId, moduleID);
            var subject   = TemplateUtils.ParseEmailTemplate(ti.Subject, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            var bodyText  = TemplateUtils.ParseEmailTemplate(ti.TemplateText, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            var bodyHTML  = TemplateUtils.ParseEmailTemplate(ti.TemplateHTML, string.Empty, portalId, moduleID, tabID, forumId, topicId, replyId, comments, user, -1, Convert.ToInt32(portalSettings.TimeZone.BaseUtcOffset.TotalMinutes));
            var sFrom     = fi.EmailAddress != string.Empty ? fi.EmailAddress : portalSettings.Email;

            var oEmail = new Email
            {
                Recipients = subs,
                Subject    = subject,
                From       = sFrom,
                BodyText   = bodyText,
                BodyHTML   = bodyHTML,
                UseQueue   = mainSettings.MailQueue
            };


            new Thread(oEmail.Send).Start();
        }