Example #1
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        bool nextStepIsPublished = false;

        if (Node != null)
        {
            // Check modify permissions
            if (CheckPermissions && (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied))
            {
                return;
            }

            // Raise event
            RaiseOnBeforeApprove(sender, e);

            // Approve the document - Go to next workflow step
            // Get original step
            WorkflowStepInfo originalStep = WorkflowMan.GetStepInfo(Node);

            // Approve the document
            WorkflowStepInfo nextStep = WorkflowMan.MoveToNextStep(Node, "");

            if (nextStep != null)
            {
                nextStepIsPublished = (nextStep.StepName.ToLower() == "published");

                // Send workflow e-mails
                if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSSendWorkflowEmails"))
                {
                    WorkflowMan.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, nextStep, nextStepIsPublished ? WorkflowActionEnum.Published : WorkflowActionEnum.Approved, string.Empty);
                }
            }

            ReloadMenu();

            string siteName = CMSContext.CurrentSiteName;

            // Refresh content tree when step is 'Published' or scope has been removed and icons should be displayed
            if ((nextStepIsPublished || (nextStep == null)) && (UIHelper.DisplayPublishedIcon(siteName) || UIHelper.DisplayVersionNotPublishedIcon(siteName) || UIHelper.DisplayNotPublishedIcon(siteName)))
            {
                RefreshTree(Node.NodeParentID, NodeID);
            }
        }

        if (EnablePassiveRefresh)
        {
            PassiveRefresh(NodeID);
        }
    }
Example #2
0
    protected void btnReject_Click(object sender, EventArgs e)
    {
        // Reject the document - Go to previous workflow step
        if (Node != null)
        {
            // Check modify permissions
            if (CheckPermissions && (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied))
            {
                return;
            }

            // Raise event
            RaiseOnBeforeReject(sender, e);

            // Get original step
            WorkflowStepInfo originalStep = WorkflowMan.GetStepInfo(Node);

            // Reject the document
            WorkflowStepInfo previousStep = WorkflowMan.MoveToPreviousStep(Node, "");

            // Send workflow e-mails
            if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSSendWorkflowEmails"))
            {
                WorkflowMan.SendWorkflowEmails(Node, CMSContext.CurrentUser, originalStep, previousStep, WorkflowActionEnum.Rejected, "");
            }

            ReloadMenu();

            string siteName = CMSContext.CurrentSiteName;

            if (UIHelper.DisplayCheckedOutIcon(siteName) || UIHelper.DisplayNotPublishedIcon(siteName))
            {
                RefreshTree(Node.NodeParentID, NodeID);
            }
        }

        if (EnablePassiveRefresh)
        {
            PassiveRefresh(NodeID);
        }
    }
Example #3
0
    public void ReloadMenu()
    {
        newLink     = (Action == "newlink");
        newDocument = ((Action == "new") || newLink || Action == "newvariant");
        newCulture  = (Action == "newculture");

        if (Action == "newvariant")
        {
            ShowSpellCheck = false;
        }

        MenuItem newItem = null;

        // Create the edit menu
        menuElem.Items.Clear();

        mMenuItems = 0;

        // Save button
        MenuItem saveItem = null;

        if (mShowSave)
        {
            saveItem                   = new MenuItem();
            saveItem.ToolTip           = GetString("EditMenu.Save");
            saveItem.JavascriptCommand = FunctionsPrefix + "SaveDocument(" + NodeID + ");";
            saveItem.ImageAltText      = saveItem.ToolTip;
            saveItem.Text              = GetString("general.save");
            saveItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
            saveItem.MouseOverImage    = saveItem.Image;
            saveItem.MouseOverCssClass = "MenuItemEdit";
            saveItem.CssClass          = "MenuItemEdit";
            menuElem.Items.Add(saveItem);
            mMenuItems += 1;
        }

        mWorkflowInfo = "";

        mAllowEdit = true;
        mAllowSave = true;
        bool showDelete = false;

        if (!newDocument)
        {
            if (Node != null && !newCulture)
            {
                bool authorized = true;

                // If the perrmisions should be checked
                if (CheckPermissions)
                {
                    // Check read permissions
                    if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Read) == AuthorizationResultEnum.Denied)
                    {
                        RedirectToAccessDenied(String.Format(GetString("cmsdesk.notauthorizedtoreaddocument"), Node.NodeAliasPath));
                    }
                    // Check modify permissions
                    else if (CMSContext.CurrentUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Denied)
                    {
                        mAllowSave    = false;
                        mWorkflowInfo = String.Format(GetString("cmsdesk.notauthorizedtoeditdocument"), Node.NodeAliasPath);
                        authorized    = false;
                    }
                }

                // If authorized
                if (authorized)
                {
                    WorkflowInfo wi = WorkflowMan.GetNodeWorkflow(Node);
                    // If workflow not null, process the workflow information to display the items
                    if (wi != null)
                    {
                        // Get current step info, do not update document
                        WorkflowStepInfo si = null;
                        if (Node.IsPublished && (Node.DocumentCheckedOutVersionHistoryID <= 0))
                        {
                            si = WorkflowStepInfoProvider.GetWorkflowStepInfo("published", wi.WorkflowID);
                        }
                        else
                        {
                            si = WorkflowMan.GetStepInfo(Node, false) ??
                                 WorkflowMan.GetFirstWorkflowStep(Node, wi);
                        }

                        bool allowApproval      = true;
                        bool canApprove         = true;
                        bool autoPublishChanges = wi.WorkflowAutoPublishChanges;

                        // If license does not allow custom steps, can approve check is useless
                        if (WorkflowInfoProvider.IsCustomStepAllowed())
                        {
                            canApprove = WorkflowMan.CanUserApprove(Node, CMSContext.CurrentUser);
                        }

                        string stepName = si.StepName.ToLower();
                        if (!(canApprove || (stepName == "edit") || (stepName == "published") || (stepName == "archived")))
                        {
                            mAllowSave = false;
                        }

                        bool useCheckInCheckOut = wi.UseCheckInCheckOut(CMSContext.CurrentSiteName);

                        // Check-in, Check-out
                        if (useCheckInCheckOut)
                        {
                            if (!Node.IsCheckedOut)
                            {
                                mAllowSave = false;
                                mAllowEdit = false;

                                // If not checked out, add the check-out button
                                if (mShowCheckOut && (canApprove || (stepName == "edit") || (stepName == "published") || (stepName == "archived")))
                                {
                                    newItem                   = new MenuItem();
                                    newItem.ToolTip           = GetString("EditMenu.CheckOut");
                                    newItem.JavascriptCommand = FunctionsPrefix + "CheckOut(" + NodeID + ");";
                                    newItem.ImageAltText      = newItem.ToolTip;
                                    newItem.Text              = GetString("EditMenu.IconCheckOut");
                                    newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkout.png");
                                    newItem.MouseOverImage    = newItem.Image;
                                    newItem.MouseOverCssClass = "MenuItemEdit";
                                    newItem.CssClass          = "MenuItemEdit";
                                    menuElem.Items.Add(newItem);
                                    mMenuItems += 1;
                                }
                                // Set workflow info
                                // If not checked out, add the check-out information
                                if (canApprove || (stepName == "edit") || (stepName == "published") || (stepName == "archived"))
                                {
                                    mWorkflowInfo += GetString("EditContent.DocumentCheckedIn");
                                }
                            }
                        }
                        if (Node.IsCheckedOut)
                        {
                            // If checked out by current user, add the check-in button
                            int checkedOutBy = Node.DocumentCheckedOutByUserID;
                            if (checkedOutBy == CMSContext.CurrentUser.UserID)
                            {
                                if (mShowUndoCheckOut)
                                {
                                    newItem                   = new MenuItem();
                                    newItem.ToolTip           = GetString("EditMenu.UndoCheckout");
                                    newItem.JavascriptCommand = FunctionsPrefix + "UndoCheckOut(" + NodeID + ");";
                                    newItem.ImageAltText      = newItem.ToolTip;
                                    newItem.Text              = GetString("EditMenu.IconUndoCheckout");
                                    newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/undocheckout.png");
                                    newItem.MouseOverImage    = newItem.Image;
                                    newItem.MouseOverCssClass = "MenuItemEdit";
                                    newItem.CssClass          = "MenuItemEdit";
                                    menuElem.Items.Add(newItem);
                                    mMenuItems += 1;
                                }

                                if (mShowCheckIn)
                                {
                                    newItem                   = new MenuItem();
                                    newItem.ToolTip           = GetString("EditMenu.CheckIn");
                                    newItem.JavascriptCommand = FunctionsPrefix + "CheckIn(" + NodeID + ");";
                                    newItem.ImageAltText      = newItem.ToolTip;
                                    newItem.Text              = GetString("EditMenu.IconCheckIn");
                                    newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/checkin.png");
                                    newItem.MouseOverImage    = newItem.Image;
                                    newItem.MouseOverCssClass = "MenuItemEdit";
                                    newItem.CssClass          = "MenuItemEdit";
                                    menuElem.Items.Add(newItem);
                                    mMenuItems += 1;
                                }

                                // Set workflow info
                                mWorkflowInfo += GetString("EditContent.DocumentCheckedOut");
                            }
                            else
                            {
                                mAllowSave = false;
                                mAllowEdit = false;

                                string userName = UserInfoProvider.GetUserNameById(checkedOutBy);
                                // Set workflow info
                                mWorkflowInfo += String.Format(GetString("EditContent.DocumentCheckedOutByAnother"), userName);
                            }
                            allowApproval = false;
                        }

                        // Document approval
                        if (allowApproval)
                        {
                            MenuItem approveItem = null;

                            switch (stepName)
                            {
                            case "edit":
                                // When edit step and not allowed 'auto publish changes', display submit to approval
                                if (mShowSubmitToApproval && !autoPublishChanges)
                                {
                                    approveItem                   = new MenuItem();
                                    approveItem.ToolTip           = GetString("EditMenu.SubmitToApproval");
                                    approveItem.JavascriptCommand = FunctionsPrefix + "Approve(" + NodeID + ");";
                                    approveItem.ImageAltText      = approveItem.ToolTip;
                                    approveItem.Text              = GetString("EditMenu.IconSubmitToApproval");
                                    approveItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/approve.png");
                                    approveItem.MouseOverImage    = approveItem.Image;
                                    approveItem.MouseOverCssClass = "MenuItemEdit";
                                    approveItem.CssClass          = "MenuItemEdit";
                                    menuElem.Items.Add(approveItem);
                                    mMenuItems += 1;
                                }
                                break;

                            case "published":
                            case "archived":
                                // No workflow options in these steps
                                break;

                            default:
                                // If the user is authorized to perform the step, display the approve and reject buttons
                                if (canApprove)
                                {
                                    if (mShowApprove && !autoPublishChanges)
                                    {
                                        approveItem                   = new MenuItem();
                                        approveItem.ToolTip           = GetString("EditMenu.Approve");
                                        approveItem.JavascriptCommand = FunctionsPrefix + "Approve(" + NodeID + ");";
                                        approveItem.ImageAltText      = approveItem.ToolTip;
                                        approveItem.Text              = GetString("general.approve");
                                        approveItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/approve.png");
                                        approveItem.MouseOverImage    = approveItem.Image;
                                        approveItem.MouseOverCssClass = "MenuItemEdit";
                                        approveItem.CssClass          = "MenuItemEdit";
                                        menuElem.Items.Add(approveItem);
                                        mMenuItems += 1;
                                    }

                                    if (mShowReject && !autoPublishChanges)
                                    {
                                        newItem                   = new MenuItem();
                                        newItem.ToolTip           = GetString("EditMenu.Reject");
                                        newItem.JavascriptCommand = FunctionsPrefix + "Reject(" + NodeID + ");";
                                        newItem.ImageAltText      = newItem.ToolTip;
                                        newItem.Text              = GetString("general.reject");
                                        newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/reject.png");
                                        newItem.MouseOverImage    = newItem.Image;
                                        newItem.MouseOverCssClass = "MenuItemEdit";
                                        newItem.CssClass          = "MenuItemEdit";
                                        menuElem.Items.Add(newItem);
                                        mMenuItems += 1;
                                    }
                                }
                                break;
                            }

                            if (approveItem != null)
                            {
                                // Get next step info
                                WorkflowStepInfo nsi = WorkflowMan.GetNextStepInfo(Node);
                                if (nsi.StepName.ToLower() == "published")
                                {
                                    approveItem.ToolTip = GetString("EditMenu.Publish");
                                    approveItem.Text    = GetString("EditMenu.IconPublish");
                                }
                            }

                            // Set workflow info
                            if (!(canApprove || (stepName == "edit") || (stepName == "published") || (stepName == "archived")))
                            {
                                if (!string.IsNullOrEmpty(mWorkflowInfo))
                                {
                                    mWorkflowInfo += "<br />";
                                }
                                mWorkflowInfo += GetString("EditContent.NotAuthorizedToApprove");
                            }
                            if (!string.IsNullOrEmpty(mWorkflowInfo))
                            {
                                mWorkflowInfo += "<br />";
                            }
                            // If workflow isn't auto publish or step name isn't 'published' or 'check-in/check-out' is allowed then show current step name
                            if (!wi.WorkflowAutoPublishChanges || (stepName != "published") || useCheckInCheckOut)
                            {
                                mWorkflowInfo += String.Format(GetString("EditContent.CurrentStepInfo"), HTMLHelper.HTMLEncode(ResHelper.LocalizeString(si.StepDisplayName)));
                            }
                        }
                    }
                }

                if (mShowProperties)
                {
                    newItem                   = new MenuItem();
                    newItem.ToolTip           = GetString("EditMenu.Properties");
                    newItem.JavascriptCommand = FunctionsPrefix + "Properties(" + NodeID + ");";
                    newItem.ImageAltText      = newItem.ToolTip;
                    newItem.Text              = GetString("EditMenu.IconProperties");
                    newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/properties.png");
                    newItem.MouseOverImage    = newItem.Image;
                    newItem.MouseOverCssClass = "MenuItemEdit";
                    newItem.CssClass          = "MenuItemEdit";
                    menuElem.Items.Add(newItem);
                    mMenuItems += 1;
                }

                if (mShowDelete)
                {
                    showDelete = true;
                }
            }

            // If not allowed to save, disable the save item
            if (!mAllowSave && mShowSave && (saveItem != null))
            {
                saveItem.JavascriptCommand = "";
                saveItem.MouseOverCssClass = "MenuItemEditDisabled";
                saveItem.CssClass          = "MenuItemEditDisabled";
                saveItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/savedisabled.png");
                saveItem.MouseOverImage    = saveItem.Image;
            }
        }
        else if (mAllowSave && mShowCreateAnother)
        {
            newItem                   = new MenuItem();
            newItem.ToolTip           = GetString("EditMenu.SaveAndAnother");
            newItem.JavascriptCommand = FunctionsPrefix + "SaveDocument(" + NodeID + ", true);";
            newItem.ImageAltText      = newItem.ToolTip;
            newItem.Text              = GetString("editmenu.iconsaveandanother");
            newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/saveandanother.png");
            newItem.MouseOverImage    = newItem.Image;
            newItem.MouseOverCssClass = "MenuItemEdit";
            newItem.CssClass          = "MenuItemEdit";
            menuElem.Items.Add(newItem);
            mMenuItems += 1;
        }

        if (mAllowSave && mShowSave && mShowSpellCheck && !newLink)
        {
            newItem                   = new MenuItem();
            newItem.ToolTip           = GetString("EditMenu.SpellCheck");
            newItem.JavascriptCommand = FunctionsPrefix + "SpellCheck(spellURL);";
            newItem.ImageAltText      = newItem.ToolTip;
            newItem.Text              = GetString("EditMenu.IconSpellCheck");
            newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/spellcheck.png");
            newItem.MouseOverImage    = newItem.Image;
            newItem.MouseOverCssClass = "MenuItemEdit";
            newItem.CssClass          = "MenuItemEdit";
            menuElem.Items.Add(newItem);
            mMenuItems += 1;
        }

        if (showDelete)
        {
            newItem                   = new MenuItem();
            newItem.ToolTip           = GetString("EditMenu.Delete");
            newItem.JavascriptCommand = FunctionsPrefix + "Delete(" + NodeID + ");";
            newItem.ImageAltText      = newItem.ToolTip;
            newItem.Text              = GetString("general.delete");
            newItem.Image             = GetImageUrl("CMSModules/CMS_Content/EditMenu/delete.png");
            newItem.MouseOverImage    = newItem.Image;
            newItem.MouseOverCssClass = "MenuItemEdit";
            newItem.CssClass          = "MenuItemEdit";
            menuElem.Items.Add(newItem);
            mMenuItems += 1;
        }
    }