protected void btnCheckout_Click(object sender, EventArgs e) { try { VersionManager.EnsureVersion(Node, Node.IsPublished); // Check out the document VersionManager.CheckOut(Node); // Refresh tree if icon checked out should be displayed if (UIHelper.DisplayCheckedOutIcon(CMSContext.CurrentSiteName)) { AddRefreshTreeScript(); } ReloadData(); versionsElem.ReloadData(); } catch (WorkflowException) { lblError.Text += GetString("EditContent.DocumentCannotCheckOut"); } catch (Exception ex) { // Log exception EventLogProvider ep = new EventLogProvider(); ep.LogEvent("Content", "CHECKOUT", ex); lblError.Text += ex.Message; } }
/// <summary> /// Refresh button click event handler. /// </summary> protected void btnRefresh_Click(object sender, EventArgs e) { if (Node != null) { // Check permission to modify document if (!CheckPermissions || (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(Node, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed)) { // Ensure version for later detection whether node is published VersionManager.EnsureVersion(Node, Node.IsPublished); // Move to edit step WorkflowManager.MoveToFirstStep(Node, null); // Reload form ReloadForm(); if (DocumentManager.SaveChanges) { ScriptHelper.RegisterStartupScript(this, typeof(string), "moveToEditStepChange", ScriptHelper.GetScript("Changed();")); } } } }
protected void btnCheckout_Click(object sender, EventArgs e) { try { // Check permissions if (!WorkflowManager.CheckStepPermissions(Node, WorkflowActionEnum.Approve)) { DisableForm(); return; } VersionManager.EnsureVersion(Node, Node.IsPublished); // Check out the document VersionManager.CheckOut(Node); // Refresh tree if icon checked out should be displayed if (UIHelper.DisplayCheckedOutIcon(CMSContext.CurrentSiteName)) { AddAfterActionScript(); } ReloadData(); versionsElem.ReloadData(); } catch (WorkflowException) { ShowError(GetString("EditContent.DocumentCannotCheckOut")); } catch (Exception ex) { // Log exception EventLogProvider ep = new EventLogProvider(); ep.LogEvent("Content", "CHECKOUT", ex); ShowError(ex.Message); } }
/// <summary> /// Handles attachment action. /// </summary> /// <param name="argument">Argument coming from upload control</param> private void HandleAttachmentAction(string argument, bool isUpdate) { // Get attachment URL first Guid attachmentGuid = ValidationHelper.GetGuid(argument, Guid.Empty); if (attachmentGuid != Guid.Empty) { // Get attachment info TreeProvider tree = new TreeProvider(CMSContext.CurrentUser); // Ensure site information SiteInfo si = CMSContext.CurrentSite; if ((TreeNodeObj != null) && (si.SiteID != TreeNodeObj.NodeSiteID)) { si = SiteInfoProvider.GetSiteInfo(TreeNodeObj.NodeSiteID); } AttachmentInfo ai = DocumentHelper.GetAttachment(attachmentGuid, tree, si.SiteName, false); if (ai != null) { string nodeAliasPath = (TreeNodeObj != null) ? TreeNodeObj.NodeAliasPath : null; if (CMSDialogHelper.IsItemSelectable(SelectableContent, ai.AttachmentExtension)) { // Get attachment URL string url = mediaView.GetAttachmentItemUrl(ai.AttachmentGUID, ai.AttachmentName, nodeAliasPath, 0, 0, 0); // Remember last selected attachment GUID if (SourceType == MediaSourceEnum.DocumentAttachments) { LastAttachmentGuid = ai.AttachmentGUID; } // Get the node workflow int versionHistoryId = 0; if (TreeNodeObj != null) { WorkflowManager wm = new WorkflowManager(TreeNodeObj.TreeProvider); WorkflowInfo wi = wm.GetNodeWorkflow(TreeNodeObj); if (wi != null) { // Ensure the document version VersionManager vm = new VersionManager(TreeNodeObj.TreeProvider); versionHistoryId = vm.EnsureVersion(TreeNodeObj, TreeNodeObj.IsPublished); } } MediaItem item = InitializeMediaItem(ai.AttachmentName, ai.AttachmentExtension, ai.AttachmentImageWidth, ai.AttachmentImageHeight, ai.AttachmentSize, url, null, versionHistoryId, 0, ""); SelectMediaItem(item); ItemToColorize = attachmentGuid; ColorizeRow(ItemToColorize.ToString()); } else { // Unselect old attachment and clear properties ColorizeRow(""); Properties.ClearProperties(true); pnlUpdateProperties.Update(); } mediaView.InfoText = (isUpdate ? GetString("dialogs.attachment.updated") : GetString("dialogs.attachment.created")); pnlUpdateView.Update(); } } ClearActionElems(); }
public void RaisePostBackEvent(string eventArgument) { try { // Parse action to perform Action action = (Action)Enum.Parse(typeof(Action), eventArgument); // Parse action parameter string[] parameters = ValidationHelper.GetString(hdnParameter.Value, string.Empty).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); // Check whether all parameters are present for parameterized pop-ups if (parameters.Length == 2) { // Initialize document manager int nodeId = ValidationHelper.GetInteger(parameters[0], 0); string cultureCode = ValidationHelper.GetString(parameters[1], string.Empty); DocumentManager.Mode = FormModeEnum.Update; DocumentManager.ClearNode(); DocumentManager.DocumentID = 0; DocumentManager.NodeID = nodeId; DocumentManager.CultureCode = cultureCode; TreeNode currentNode = DocumentManager.Node; switch (action) { case Action.Localize: // Initialize localization dialog localizeElem.Action = "newculture"; localizeElem.NodeID = nodeId; localizeElem.AlternativeFormName = DocumentForm; localizeElem.CopyDefaultDataFromDocumentID = currentNode.DocumentID; localizeElem.CheckPermissions = true; pnlLocalizePopup.Visible = true; localizeElem.ReloadData(true); ShowPopup(pnlLocalizePopup, mdlLocalize); break; case Action.Copy: // Initialize copy dialog copyElem.CopiedNodeID = nodeId; copyElem.CopiedDocumentCulture = cultureCode; copyElem.TargetNodeID = LibraryNode.NodeID; copyElem.ReloadData(true); copyElem.CancelButton.OnClientClick = Action.HidePopup + "_" + ClientID + "();return false;"; ShowPopup(pnlCopyPopup, mdlCopy); break; case Action.Delete: // Initialize delete dialog deleteElem.DeletedNodeID = nodeId; deleteElem.DeletedDocumentCulture = cultureCode; deleteElem.ReloadData(true); deleteElem.CancelButton.OnClientClick = Action.HidePopup + "_" + ClientID + "();return false;"; ShowPopup(pnlDeletePopup, mdlDelete); break; case Action.Properties: // Initialize properties dialog propertiesElem.NodeID = nodeId; propertiesElem.CultureCode = cultureCode; propertiesElem.AlternativeFormName = DocumentForm; propertiesElem.CheckPermissions = true; pnlPropertiesPopup.Visible = true; propertiesElem.ReloadData(true); ShowPopup(pnlPropertiesPopup, mdlProperties); break; case Action.VersionHistory: // Initialize version history dialog versionsElem.Heading.Visible = false; versionsElem.NodeID = nodeId; versionsElem.DocumentCulture = cultureCode; versionsElem.SetupControl(); versionsElem.ReloadData(); ShowPopup(pnlVersionsPopup, mdlVersions); break; case Action.Permissions: // Initialize permissions dialog permissionsElem.Node = currentNode; permissionsElem.DisplayButtons = false; permissionsElem.ReloadData(true); ReloadPermissions(); ShowPopup(pnlPermissionsPopup, mdlPermissions); break; case Action.CheckOut: // Perform document checkout DocumentManager.CheckOutDocument(); break; case Action.CheckIn: // Perform document check-in DocumentManager.CheckInDocument(null); break; case Action.UndoCheckout: // Perform undo checkout on document DocumentManager.UndoCheckOutDocument(); break; case Action.SubmitToApproval: // Approve document DocumentManager.ApproveDocument(0, null); break; case Action.Reject: // Reject document DocumentManager.RejectDocument(0, null); break; case Action.Archive: // Archive document DocumentManager.ArchiveDocument(0, null); break; case Action.ExternalRefresh: WorkflowInfo wi = DocumentManager.Workflow; // Check if document uses workflow and check-out/check-in is disabled if ((wi != null) && !wi.UseCheckInCheckOut(currentNode.NodeSiteName) && !wi.WorkflowAutoPublishChanges) { // Check permission to modify document if (MembershipContext.AuthenticatedUser.IsAuthorizedPerDocument(currentNode, NodePermissionsEnum.Modify) == AuthorizationResultEnum.Allowed) { // Get current step WorkflowStepInfo currentStep = DocumentManager.Step; // Check if document uses workflow and step is 'published' or 'archived' if ((currentStep != null) && (currentStep.StepIsPublished || currentStep.StepIsArchived)) { // Ensure version for later detection whether node is published VersionManager.EnsureVersion(currentNode, currentNode.IsPublished); // Move to first step WorkflowManager.MoveToFirstStep(currentNode, null); // Refresh grid RefreshGrid(); } } } break; } } // General actions switch (action) { case Action.RefreshGrid: // Refresh unigrid RefreshGrid(); break; case Action.HidePopup: // Find and hide current popup HideCurrentPopup(); break; } } catch (Exception ex) { AddAlert(GetString("general.erroroccurred") + " " + ex.Message); } }