private void AddThankYouPage() { var parent = Content.Load((int)this.Content["ParentId"]); Node landingPage = null; Node landingView = null; // elevation: we do not want to grant Open permission to the user for this technical content using (new SystemAccount()) { if (parent.Fields.ContainsKey("LandingPage") && parent.Fields.ContainsKey("PageContentView")) { landingPage = parent["LandingPage"] as Node; landingView = parent["PageContentView"] as Node; } } if (landingPage == null || landingView == null) { return; } var landingContent = Content.Create(landingPage); var landingCV = ContentView.Create(landingContent, this.Page, ViewMode.Browse, landingView.Path); _wizard.WizardSteps[_wizard.WizardSteps.Count - 1].Controls.Add(landingCV); _wizard.WizardSteps[_wizard.WizardSteps.Count - 2].AllowReturn = false; }
private void BuildAfterSubmitForm_ContentView(SNC.Content formitem) { if (CurrentForm == null) { return; } //FormItem fi = new FormItem(CurrentForm); //_cFormItem = SNC.Content.Create(fi); if (formitem == null && _formItemID != 0) { formitem = Content.Load(_formItemID); } if (formitem != null) { _cFormItem = formitem; _cvFormItem = ContentView.Create(_cFormItem, this.Page, ViewMode.New, AfterSubmitViewPath); _cvFormItem.ID = "cvAfterSubmitFormItem"; //_cvFormItem.Init += new EventHandler(_cvFormItem_Init); _cvFormItem.UserAction += new EventHandler <UserActionEventArgs>(_cvAfterSubmitFormItem_UserAction); this.Controls.Add(_cvFormItem); } else if (!string.IsNullOrEmpty(AfterSubmitViewPath)) { this.Controls.Add(Page.LoadControl(AfterSubmitViewPath)); } }
/// <summary> /// Gets the model. /// </summary> /// <returns></returns> protected override object GetModel() { var managerHead = NodeHead.Get(FirstManager); if (managerHead == null) { throw new NotSupportedException(ResourceManager.Current.GetString("OrganizationChart", "NoSuchManagerError")); } var resultXml = new XmlDocument(); if (!SecurityHandler.HasPermission(managerHead, PermissionType.Open)) { return(resultXml); } var manager = Content.Load(FirstManager); if (manager == null) { throw new NotSupportedException(ResourceManager.Current.GetString("OrganizationChart", "NoSuchManagerError")); } var managerStream = manager.GetXml(true); resultXml.Load(managerStream); _usedNodeId = new List <int> { manager.Id }; try { GetEmployees(manager, resultXml.SelectSingleNode("/Content"), 1); } catch (Exception ex) { Logger.WriteException(ex); throw new NotSupportedException(ex.Message); } return(resultXml); }
//========================================================================================= Event handlers protected void StartWorkflowButton_Click(object sender, EventArgs e) { if (this.ContentView == null) { return; } this.ContentView.NeedToValidate = true; this.ContentView.UpdateContent(); var content = this.ContentView.Content; if (this.ContentView.IsUserInputValid && content.IsValid) { try { if (this.StartOnCurrentContent) { var workflow = content.ContentHandler as WorkflowHandlerBase; if (workflow != null) { content.Fields["RelatedContent"].SetData(this.ContextNode); //workflow.RelatedContent = this.ContextNode; } } ValidateWorkflow(); WorkflowHandlerBase wfContent; //need to create workflow in elevated mode using (new SystemAccount()) { content.Fields["OwnerSiteUrl"].SetData(PortalContext.Current.RequestedUri.GetLeftPart(UriPartial.Authority)); content.Save(); //TODO: review this ... this is a temporary solution wfContent = Node.Load <WorkflowHandlerBase>(content.Id); } //start workflow InstanceManager.Start(wfContent); } catch (Exception ex) { //cleanup: delete the instance if it was saved before the error if (content.Id != 0) { using (new SystemAccount()) { content.ForceDelete(); } } Logger.WriteException(ex); this.ContentView.ContentException = ex; return; } if (!string.IsNullOrEmpty(ConfirmContentPath)) { //if confirm page or content is given, redirect there var confirmContent = Content.Load(ConfirmContentPath); var confirmBrowseAction = Helpers.Actions.BrowseUrl(confirmContent); //If the user does not have enough permissions for the Browse action //in this subtree, but the target content is a page, than use its path. if (string.IsNullOrEmpty(confirmBrowseAction) && confirmContent != null && confirmContent.ContentType.IsInstaceOfOrDerivedFrom("Page")) { confirmBrowseAction = PortalContext.GetSiteRelativePath(confirmContent.Path); } if (!string.IsNullOrEmpty(confirmBrowseAction)) { HttpContext.Current.Response.Redirect(confirmBrowseAction, false); return; } } CallDone(false); } }
/// <summary> /// Sets the callback URL of the ActionMenu. It represents the service url with correct parameters for the actions. /// </summary> private void SetServiceUrl() { var scParams = GetReplacedScenarioParameters(); var context = UITools.FindContextInfo(this, ContextInfoID); var path = !String.IsNullOrEmpty(ContextInfoID) ? context.Path : NodePath; var encodedReturnUrl = Uri.EscapeDataString(PortalContext.Current.RequestedUri.PathAndQuery); var encodedParams = Uri.EscapeDataString(scParams ?? string.Empty); if (String.IsNullOrEmpty(path)) { path = GetPathFromContentView(this); } if (string.IsNullOrEmpty(path)) { this.Visible = false; return; } var head = NodeHead.Get(path); if (head == null || !SecurityHandler.HasPermission(head, PermissionType.See)) { this.Visible = false; return; } this.Content = Content.Load(path); //Pre-check action count. If empty, hide the action menu. if (CheckActionCount) { //var sc = ScenarioManager.GetScenario(Scenario, scParams); var actionCount = 0; if (!string.IsNullOrEmpty(Scenario)) { actionCount = ActionFramework.GetActions(this.Content, Scenario, scParams, null).Count(); } if (actionCount < 2 && string.Equals(Scenario, "new", StringComparison.CurrentCultureIgnoreCase)) { ClickDisabled = true; } else if (actionCount == 0) { this.Visible = false; return; } } //Pre-check required permissions var permissions = ActionFramework.GetRequiredPermissions(RequiredPermissions); if (permissions.Count > 0 && !SecurityHandler.HasPermission(head, permissions.ToArray())) { this.Visible = false; return; } var encodedPath = HttpUtility.UrlEncode(path); ServiceUrl = String.Format("/SmartAppHelper.mvc/GetActions?path={0}&scenario={1}&back={2}¶meters={3}", encodedPath, Scenario, encodedReturnUrl, encodedParams); }
protected override void Render(HtmlTextWriter writer) { //render nothing if the action does not exist if (Action == null) { return; } var actionClickable = true; if (CheckActionCount) { var am = ActionMenu.FindContainerActionMenu(this); List <ActionBase> scActions = null; var scenario = string.Empty; if (am != null) { scenario = am.Scenario; if (!string.IsNullOrEmpty(scenario)) { scActions = ActionFramework.GetActions(Content.Load(ContextPath), scenario, am.GetReplacedScenarioParameters()).ToList(); } } if (scActions != null) { if (scActions.Count > 1) { actionClickable = false; } else if (scActions.Count == 1 && string.Equals(scenario, "new", StringComparison.CurrentCultureIgnoreCase) && string.Equals(this.ActionName, "add", StringComparison.CurrentCultureIgnoreCase)) { //change action to the single "New" action found in the parent menu _action = scActions.First(); _actionChecked = true; this.Text = this.Text + " " + _action.Text; } } } if (actionClickable) { var claction = Action as ClientAction; if (claction != null && claction.Callback != null) { NavigateUrl = "javascript:"; this.Attributes["onclick"] = claction.Callback; } else { NavigateUrl = Action.Uri; } } this.CssClass += (string.IsNullOrEmpty(this.CssClass) ? "" : " ") + "sn-actionlinkbutton"; if (Action.Forbidden) { this.CssClass += " sn-disabled"; this.Enabled = false; this.NavigateUrl = string.Empty; } base.Render(writer); }