CanApproveDraft() public static method

Determines whether a user can approve/reject a draft of a page.
public static CanApproveDraft ( System.PageInfo page, string username, string groups ) : bool
page System.PageInfo The page.
username string The username.
groups string The groups.
return bool
コード例 #1
0
        /// <summary>
        /// Activates the page editor.
        /// </summary>
        private void ActivatePageEditor()
        {
            lblCurrentPage.Text = txtCurrentPage.Value;
            txtNewName.Text     = NameTools.GetLocalName(txtCurrentPage.Value);

            // Enable/disable page sections
            PageContent   page        = Pages.FindPage(currentWiki, txtCurrentPage.Value);
            NamespaceInfo nspace      = Pages.FindNamespace(currentWiki, NameTools.GetNamespace(page.FullName));
            string        currentUser = SessionFacade.GetCurrentUsername();

            string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki);

            AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki));

            bool canApproveReject    = AdminMaster.CanApproveDraft(page.Provider.CurrentWiki, page.FullName, currentUser, currentGroups);
            bool canDeletePages      = authChecker.CheckActionForNamespace(nspace, Actions.ForNamespaces.DeletePages, currentUser, currentGroups);
            bool canManageAllPages   = authChecker.CheckActionForNamespace(nspace, Actions.ForNamespaces.ManagePages, currentUser, currentGroups);
            bool canManagePage       = authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ManagePage, currentUser, currentGroups);
            bool canManageDiscussion = authChecker.CheckActionForPage(page.FullName, Actions.ForPages.ManageDiscussion, currentUser, currentGroups);
            bool namespaceAvailable  = PopulateTargetNamespaces(page);

            // Approve/reject
            // Rename
            // Migrate
            // Rollback
            // Delete Backups
            // Clear discussion
            // Delete

            pnlApproveRevision.Enabled = canApproveReject;
            pnlRename.Enabled          = canDeletePages;
            pnlMigrate.Enabled         = canManageAllPages && namespaceAvailable;
            pnlRollback.Enabled        = canManagePage;
            pnlDeleteBackups.Enabled   = canManagePage;
            pnlClearDiscussion.Enabled = canManageDiscussion;
            pnlDelete.Enabled          = canDeletePages;

            // Disable rename, migrate, delete for default page
            NamespaceInfo currentNamespace   = Pages.FindNamespace(currentWiki, lstNamespace.SelectedValue);
            string        currentDefaultPage = currentNamespace != null ? currentNamespace.DefaultPageFullName : Settings.GetDefaultPage(currentWiki);

            if (txtCurrentPage.Value == currentDefaultPage)
            {
                btnRename.Enabled     = false;
                btnMigrate.Enabled    = false;
                btnDeletePage.Enabled = false;
            }

            LoadDraft(txtCurrentPage.Value);

            LoadBackups(txtCurrentPage.Value);

            btnRollback.Enabled      = lstRevision.Items.Count > 0;
            btnDeleteBackups.Enabled = lstBackup.Items.Count > 0;

            pnlList.Visible     = false;
            pnlEditPage.Visible = true;

            ClearResultLabels();
        }
コード例 #2
0
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            PageContent page = Pages.FindPage(currentWiki, txtCurrentPage.Value);

            if (!AdminMaster.CanApproveDraft(page.Provider.CurrentWiki, page.FullName, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames(currentWiki)))
            {
                return;
            }

            PageContent draft = Pages.GetDraft(page);

            Log.LogEntry("Page draft approval requested for " + draft.FullName, EntryType.General, SessionFacade.CurrentUsername, currentWiki);

            PageContent newPageContent = Pages.SetPageContent(draft.Provider.CurrentWiki, NameTools.GetNamespace(draft.FullName), NameTools.GetLocalName(draft.FullName), draft.Title, draft.User, draft.LastModified, draft.Comment,
                                                              draft.Content, draft.Keywords, draft.Description, SaveMode.Backup);

            if (newPageContent != null)
            {
                Pages.DeleteDraft(draft.FullName, draft.Provider);

                lblApproveResult.CssClass = "resultok";
                lblApproveResult.Text     = Properties.Messages.DraftApproved;
                lblDraftPreview.Text      = "";

                ReturnToList();
            }
            else
            {
                lblApproveResult.CssClass = "resulterror";
                lblApproveResult.Text     = Properties.Messages.CouldNotApproveDraft;
            }
        }
コード例 #3
0
        protected void btnApprove_Click(object sender, EventArgs e)
        {
            PageInfo page = Pages.FindPage(txtCurrentPage.Value);

            if (!AdminMaster.CanApproveDraft(page, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                return;
            }

            PageContent draft = Pages.GetDraft(page);

            Log.LogEntry("Page draft approval requested for " + draft.PageInfo.FullName, EntryType.General, SessionFacade.CurrentUsername);

            bool done = Pages.ModifyPage(draft.PageInfo, draft.Title, draft.User, draft.LastModified, draft.Comment,
                                         draft.Content, draft.Keywords, draft.Description, SaveMode.Backup);

            if (done)
            {
                Pages.DeleteDraft(draft.PageInfo);

                lblApproveResult.CssClass = "resultok";
                lblApproveResult.Text     = Properties.Messages.DraftApproved;
                lblDraftPreview.Text      = "";

                ReturnToList();
            }
            else
            {
                lblApproveResult.CssClass = "resulterror";
                lblApproveResult.Text     = Properties.Messages.CouldNotApproveDraft;
            }
        }
コード例 #4
0
        protected void btnReject_Click(object sender, EventArgs e)
        {
            PageInfo page = Pages.FindPage(txtCurrentPage.Value);

            if (!AdminMaster.CanApproveDraft(page, SessionFacade.GetCurrentUsername(), SessionFacade.GetCurrentGroupNames()))
            {
                return;
            }

            Log.LogEntry("Page draft reject requested for " + page.FullName, EntryType.General, SessionFacade.CurrentUsername);

            Pages.DeleteDraft(page);

            lblApproveResult.CssClass = "resultok";
            lblApproveResult.Text     = Properties.Messages.DraftRejected;
            lblDraftPreview.Text      = "";

            ReturnToList();
        }