Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminMaster.RedirectToLoginIfNeeded();

            currentWiki = DetectWiki();

            if (!AdminMaster.CanManageConfiguration(SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki)))
            {
                UrlTools.Redirect("AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                rptPages.DataBind();
                rptIndex.DataBind();

                DisplayOrphansCount();

                string anon = Settings.GetAnonymousGroup(currentWiki);
                foreach (UserGroup group in Users.GetUserGroups(currentWiki))
                {
                    if (group.Name != anon)
                    {
                        ListItem item = new ListItem(group.Name, group.Name);
                        item.Selected = true;
                        lstGroups.Items.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void btnNormal_Click(object sender, EventArgs e)
        {
            string currentWiki = DetectWiki();

            NamespaceInfo nspace = Pages.FindNamespace(currentWiki, txtCurrentNamespace.Value);

            RemoveAllPermissions(nspace);

            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            // Set permissions
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.FullControl,
                                                 Users.FindUserGroup(currentWiki, Settings.GetAdministratorsGroup(currentWiki)));

            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.CreatePages,
                                                 Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)));
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.ManageCategories,
                                                 Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)));
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.PostDiscussion,
                                                 Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)));
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.DownloadAttachments,
                                                 Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)));

            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.ReadPages,
                                                 Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)));
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.ReadDiscussion,
                                                 Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)));
            authWriter.SetPermissionForNamespace(AuthStatus.Grant, nspace, Actions.ForNamespaces.DownloadAttachments,
                                                 Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)));

            RefreshPermissionsManager();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes all the permissions for a page.
        /// </summary>
        /// <param name="pageFullName">The page full name.</param>
        private void RemoveAllPermissions(string pageFullName)
        {
            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            authWriter.RemoveEntriesForPage(Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)), pageFullName);
            authWriter.RemoveEntriesForPage(Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)), pageFullName);
            authWriter.RemoveEntriesForPage(Users.FindUserGroup(currentWiki, Settings.GetAdministratorsGroup(currentWiki)), pageFullName);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes all the permissions for a namespace.
        /// </summary>
        /// <param name="nspace">The namespace (<c>null</c> for the root).</param>
        private void RemoveAllPermissions(NamespaceInfo nspace)
        {
            string currentWiki = DetectWiki();

            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            authWriter.RemoveEntriesForNamespace(Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)), nspace);
            authWriter.RemoveEntriesForNamespace(Users.FindUserGroup(currentWiki, Settings.GetUsersGroup(currentWiki)), nspace);
            authWriter.RemoveEntriesForNamespace(Users.FindUserGroup(currentWiki, Settings.GetAdministratorsGroup(currentWiki)), nspace);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads the security configuration.
        /// </summary>
        /// <param name="wiki">The wiki.</param>
        private void LoadSecurityConfig(string currentWiki)
        {
            chkAllowUsersToRegister.Checked = Settings.UsersCanRegister(currentWiki);
            PopulateAccountActivationMode(Settings.GetAccountActivationMode(currentWiki));
            PopulateDefaultGroups(Settings.GetUsersGroup(currentWiki),
                                  Settings.GetAdministratorsGroup(currentWiki),
                                  Settings.GetAnonymousGroup(currentWiki));
            chkEnableCaptchaControl.Checked     = !Settings.GetDisableCaptchaControl(currentWiki);
            chkPreventConcurrentEditing.Checked = Settings.GetDisableConcurrentEditing(currentWiki);

            switch (Settings.GetModerationMode(currentWiki))
            {
            case ChangeModerationMode.None:
                rdoNoModeration.Checked = true;
                break;

            case ChangeModerationMode.RequirePageViewingPermissions:
                rdoRequirePageViewingPermissions.Checked = true;
                break;

            case ChangeModerationMode.RequirePageEditingPermissions:
                rdoRequirePageEditingPermissions.Checked = true;
                break;
            }

            txtExtensionsAllowed.Text = string.Join(", ", Settings.GetAllowedFileTypes(currentWiki));

            lstFileDownloadCountFilterMode.SelectedIndex = -1;
            switch (Settings.GetFileDownloadCountFilterMode(currentWiki))
            {
            case FileDownloadCountFilterMode.CountAll:
                lstFileDownloadCountFilterMode.SelectedIndex = 0;
                txtFileDownloadCountFilter.Enabled           = false;
                break;

            case FileDownloadCountFilterMode.CountSpecifiedExtensions:
                lstFileDownloadCountFilterMode.SelectedIndex = 1;
                txtFileDownloadCountFilter.Enabled           = true;
                txtFileDownloadCountFilter.Text = string.Join(", ", Settings.GetFileDownloadCountFilter(currentWiki));
                break;

            case FileDownloadCountFilterMode.ExcludeSpecifiedExtensions:
                txtFileDownloadCountFilter.Text              = string.Join(", ", Settings.GetFileDownloadCountFilter(currentWiki));
                txtFileDownloadCountFilter.Enabled           = true;
                lstFileDownloadCountFilterMode.SelectedIndex = 2;
                break;

            default:
                throw new NotSupportedException();
            }

            chkAllowScriptTags.Checked = Settings.GetScriptTagsAllowed(currentWiki);
            txtIpHostFilter.Text       = Settings.GetIpHostFilter(currentWiki);
        }
Ejemplo n.º 6
0
        protected void btnPublic_Click(object sender, EventArgs e)
        {
            string page = txtCurrentPage.Value;

            AuthWriter authWriter = new AuthWriter(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            // Set permissions
            authWriter.SetPermissionForPage(AuthStatus.Grant, page, Actions.ForPages.ModifyPage,
                                            Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)));
            authWriter.SetPermissionForPage(AuthStatus.Grant, page, Actions.ForPages.PostDiscussion,
                                            Users.FindUserGroup(currentWiki, Settings.GetAnonymousGroup(currentWiki)));

            RefreshPermissionsManager();
        }
Ejemplo n.º 7
0
        protected void rptGroups_ItemCommand(object sender, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                txtCurrentName.Value = e.CommandArgument as string;
                //rptGroups.DataBind(); Not needed because the list is hidden on select

                UserGroup group = Users.FindUserGroup(currentWiki, txtCurrentName.Value);

                txtName.Text        = group.Name;
                txtName.Enabled     = false;
                txtDescription.Text = group.Description;
                providerSelector.SelectedProvider = group.Provider.GetType().FullName;
                providerSelector.Enabled          = false;

                // Select group's global permissions
                AuthReader authReader = new AuthReader(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));
                aclActionsSelector.GrantedActions = authReader.RetrieveGrantsForGlobals(group);
                aclActionsSelector.DeniedActions  = authReader.RetrieveDenialsForGlobals(group);

                btnCreate.Visible = false;
                btnSave.Visible   = true;
                btnDelete.Visible = true;
                bool isDefaultGroup =
                    group.Name == Settings.GetAdministratorsGroup(currentWiki) ||
                    group.Name == Settings.GetUsersGroup(currentWiki) ||
                    group.Name == Settings.GetAnonymousGroup(currentWiki);

                pnlEditGroup.Visible = true;
                pnlList.Visible      = false;

                // Enable/disable interface sections based on provider read-only settings
                pnlGroupDetails.Enabled = !group.Provider.UserGroupsReadOnly;
                btnDelete.Enabled       = !group.Provider.UserGroupsReadOnly && !isDefaultGroup;

                lblResult.CssClass = "";
                lblResult.Text     = "";
            }
        }