/// <summary> /// Handles the Click event of the btnCopy control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnCopy_Click(object sender, EventArgs e) { if (Page.IsValid && CommunicationId.HasValue) { var rockContext = new RockContext(); var service = new CommunicationService(rockContext); var communication = service.Get(CommunicationId.Value); if (communication != null) { var newCommunication = communication.Clone(false); newCommunication.CreatedByPersonAlias = null; newCommunication.CreatedByPersonAliasId = null; newCommunication.CreatedDateTime = RockDateTime.Now; newCommunication.ModifiedByPersonAlias = null; newCommunication.ModifiedByPersonAliasId = null; newCommunication.ModifiedDateTime = RockDateTime.Now; newCommunication.Id = 0; newCommunication.Guid = Guid.Empty; newCommunication.SenderPersonAliasId = CurrentPersonAliasId; newCommunication.Status = CommunicationStatus.Draft; newCommunication.ReviewerPersonAliasId = null; newCommunication.ReviewedDateTime = null; newCommunication.ReviewerNote = string.Empty; communication.Recipients.ToList().ForEach(r => newCommunication.Recipients.Add(new CommunicationRecipient() { PersonAliasId = r.PersonAliasId, Status = CommunicationRecipientStatus.Pending, StatusNote = string.Empty, AdditionalMergeValuesJson = r.AdditionalMergeValuesJson })); foreach (var attachment in communication.Attachments.ToList()) { var newAttachment = new CommunicationAttachment(); newAttachment.BinaryFileId = attachment.BinaryFileId; newAttachment.CommunicationType = attachment.CommunicationType; newCommunication.Attachments.Add(newAttachment); } service.Add(newCommunication); rockContext.SaveChanges(); // Redirect to new communication if (CurrentPageReference.Parameters.ContainsKey("CommunicationId")) { CurrentPageReference.Parameters["CommunicationId"] = newCommunication.Id.ToString(); } else { CurrentPageReference.Parameters.Add("CommunicationId", newCommunication.Id.ToString()); } Response.Redirect(CurrentPageReference.BuildUrl()); Context.ApplicationInstance.CompleteRequest(); } } }
/// <summary> /// Handles the Click event of the lbLoginLogout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbLoginLogout_Click(object sender, EventArgs e) { if (action == "Login") { var site = RockPage.Layout.Site; if (site.LoginPageId.HasValue) { site.RedirectToLoginPage(true); } else { FormsAuthentication.RedirectToLoginPage(); } } else { FormsAuthentication.SignOut(); // After logging out check to see if an anonymous user is allowed to view the current page. If so // redirect back to the current page, otherwise redirect to the site's default page if (RockPage.IsAuthorized("View", null)) { Response.Redirect(CurrentPageReference.BuildUrl()); Context.ApplicationInstance.CompleteRequest(); } else { RockPage.Layout.Site.RedirectToDefaultPage(); } } }
/// <summary> /// Handles the Click event of the lbLoginLogout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbLoginLogout_Click(object sender, EventArgs e) { string action = hfActionType.Value; if (action == LOG_IN) { var site = RockPage.Layout.Site; if (site.LoginPageId.HasValue) { site.RedirectToLoginPage(true); } else { FormsAuthentication.RedirectToLoginPage(); } } else { var logoutPage = GetAttributeValue("LogoutPage"); if (logoutPage.IsNotNullOrWhiteSpace()) { NavigateToLinkedPage("LogoutPage"); return; } if (CurrentUser != null) { var transaction = new Rock.Transactions.UserLastActivityTransaction(); transaction.UserId = CurrentUser.Id; transaction.LastActivityDate = RockDateTime.Now; transaction.IsOnLine = false; Rock.Transactions.RockQueue.TransactionQueue.Enqueue(transaction); } Authorization.SignOut(); // After logging out check to see if an anonymous user is allowed to view the current page. If so // redirect back to the current page, otherwise redirect to the site's default page var currentPage = Rock.Web.Cache.PageCache.Get(RockPage.PageId); if (currentPage != null && currentPage.IsAuthorized(Authorization.VIEW, null)) { string url = CurrentPageReference.BuildUrl(true); Response.Redirect(url); Context.ApplicationInstance.CompleteRequest(); } else { RockPage.Layout.Site.RedirectToDefaultPage(); } } }
/// <summary> /// Shows the result. /// </summary> /// <param name="message">The message.</param> /// <param name="communication">The communication.</param> private void ShowResult(string message, Rock.Model.Communication communication) { ShowStatus(communication); pnlEdit.Visible = false; nbResult.Text = message; CurrentPageReference.Parameters.AddOrReplace("CommunicationId", communication.Id.ToString()); hlViewCommunication.NavigateUrl = CurrentPageReference.BuildUrl(); hlViewCommunication.Visible = this.Page.ControlsOfTypeRecursive <RockWeb.Blocks.Communication.CommunicationDetail>().Any(); pnlResult.Visible = true; }
/// <summary> /// Handles the Click event of the lbLoginLogout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbLoginLogout_Click(object sender, EventArgs e) { string action = hfActionType.Value; if (action == LOG_IN) { var site = RockPage.Layout.Site; if (site.LoginPageId.HasValue) { site.RedirectToLoginPage(true); } else { FormsAuthentication.RedirectToLoginPage(); } } else { if (CurrentUser != null) { var updateUserLastActivityMsg = new UpdateUserLastActivity.Message { UserId = CurrentUser.Id, LastActivityDate = RockDateTime.Now, IsOnline = false }; updateUserLastActivityMsg.Send(); } Authorization.SignOut(); // After logging out check to see if an anonymous user is allowed to view the current page. If so // redirect back to the current page, otherwise redirect to the site's default page var currentPage = Rock.Web.Cache.PageCache.Get(RockPage.PageId); if (currentPage != null && currentPage.IsAuthorized(Authorization.VIEW, null)) { string url = CurrentPageReference.BuildUrl(true); Response.Redirect(url); Context.ApplicationInstance.CompleteRequest(); } else { RockPage.Layout.Site.RedirectToDefaultPage(); } } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page.IsPostBack) { using (var rockContext = new RockContext()) { var definedValueService = new DefinedValueService(rockContext); foreach (RepeaterItem item in rptrValues.Items) { var hfValue = item.FindControl("hfValue") as HiddenField; var cbValue = item.FindControl("cbValue") as CheckBox; if (hfValue != null && cbValue != null) { var value = definedValueService.Get(hfValue.ValueAsInt()); if (value != null) { Helper.LoadAttributes(value); if (value.GetAttributeValue(attributeKey) != cbValue.Checked.ToString()) { value.SetAttributeValue(attributeKey, cbValue.Checked.ToString()); value.SaveAttributeValues(rockContext); DefinedValueCache.Flush(value.Id); } } } } } } bool wasVisible = this.Visible; ShowList(); if (Page.IsPostBack && wasVisible && this.Visible == false) { // If last item was just checked do a redirect back to the same page. // This is needed to hide the control since content is inside an update // panel Response.Redirect(CurrentPageReference.BuildUrl(), false); } }
/// <summary> /// Shows the result. /// </summary> /// <param name="message">The message.</param> /// <param name="communication">The communication.</param> private void ShowResult(string message, Rock.Model.Communication communication) { pnlEdit.Visible = false; nbResult.Text = message; if (CurrentPageReference.Parameters.ContainsKey("CommunicationId")) { CurrentPageReference.Parameters["CommunicationId"] = communication.Id.ToString(); } else { CurrentPageReference.Parameters.Add("CommunicationId", communication.Id.ToString()); } hlViewCommunication.NavigateUrl = CurrentPageReference.BuildUrl(); pnlResult.Visible = true; }
/// <summary> /// Handles the Click event of the btnCopy control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected void btnCopy_Click(object sender, EventArgs e) { using (new UnitOfWorkScope()) { var service = new CommunicationService(); var communication = UpdateCommunication(service); if (communication != null) { var newCommunication = communication.Clone(false); newCommunication.Id = 0; newCommunication.Guid = Guid.Empty; newCommunication.SenderPersonId = CurrentPersonId; newCommunication.Status = CommunicationStatus.Transient; newCommunication.ReviewerPersonId = null; newCommunication.ReviewedDateTime = null; newCommunication.ReviewerNote = string.Empty; communication.Recipients.ToList().ForEach(r => newCommunication.Recipients.Add(new CommunicationRecipient() { PersonId = r.PersonId, Status = CommunicationRecipientStatus.Pending, StatusNote = string.Empty })); service.Add(newCommunication, CurrentPersonId); service.Save(newCommunication, CurrentPersonId); // Redirect to new communication if (CurrentPageReference.Parameters.ContainsKey("CommunicationId")) { CurrentPageReference.Parameters["CommunicationId"] = newCommunication.Id.ToString(); } else { CurrentPageReference.Parameters.Add("CommunicationId", newCommunication.Id.ToString()); } Response.Redirect(CurrentPageReference.BuildUrl()); Context.ApplicationInstance.CompleteRequest(); } } }
/// <summary> /// Handles the Click event of the lbLoginLogout control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void lbLoginLogout_Click( object sender, EventArgs e ) { string action = LoginLogout.Text; if ( action == LOGIN_TEXT ) { var site = RockPage.Layout.Site; if ( site.LoginPageId.HasValue ) { site.RedirectToLoginPage( true ); } else { FormsAuthentication.RedirectToLoginPage(); } } else { if ( CurrentUser != null ) { var transaction = new Rock.Transactions.UserLastActivityTransaction(); transaction.UserId = CurrentUser.Id; transaction.LastActivityDate = RockDateTime.Now; transaction.IsOnLine = false; Rock.Transactions.RockQueue.TransactionQueue.Enqueue( transaction ); } FormsAuthentication.SignOut(); // After logging out check to see if an anonymous user is allowed to view the current page. If so // redirect back to the current page, otherwise redirect to the site's default page var currentPage = Rock.Web.Cache.PageCache.Read( RockPage.PageId ); if ( currentPage != null && currentPage.IsAuthorized(Authorization.VIEW, null)) { Response.Redirect( CurrentPageReference.BuildUrl() ); Context.ApplicationInstance.CompleteRequest(); } else { RockPage.Layout.Site.RedirectToDefaultPage(); } } }
/// <summary> /// Shows the result. /// </summary> /// <param name="message">The message.</param> /// <param name="communication">The communication.</param> private void ShowResult(string message, Rock.Model.Communication communication, NotificationBoxType notificationType) { ShowStatus(communication); pnlDetails.Visible = false; nbResult.Text = message; nbResult.NotificationBoxType = notificationType; if (CurrentPageReference.Parameters.ContainsKey("CommunicationId")) { CurrentPageReference.Parameters["CommunicationId"] = communication.Id.ToString(); } else { CurrentPageReference.Parameters.Add("CommunicationId", communication.Id.ToString()); } hlViewCommunication.NavigateUrl = CurrentPageReference.BuildUrl(); pnlResult.Visible = true; }
protected void lbLoginLogout_Click(object sender, EventArgs e) { if (action == "Login") { if (!string.IsNullOrWhiteSpace(CurrentPage.Site.LoginPageReference)) { // if the QueryString already has a returnUrl, use that, otherwise redirect to RawUrl string returnUrl = Request.QueryString["returnUrl"] ?? Server.UrlEncode(Request.RawUrl); Response.Redirect(CurrentPage.Site.LoginPageReference + "?returnurl=" + returnUrl); } else { FormsAuthentication.RedirectToLoginPage(); } } else { FormsAuthentication.SignOut(); Response.Redirect(CurrentPageReference.BuildUrl()); Context.ApplicationInstance.CompleteRequest(); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Page.IsPostBack) { var definedValueService = new DefinedValueService(); foreach (RepeaterItem item in rptrValues.Items) { var hfValue = item.FindControl("hfValue") as HiddenField; var cbValue = item.FindControl("cbValue") as CheckBox; if (hfValue != null && cbValue != null) { var value = definedValueService.Get(hfValue.ValueAsInt()); if (value != null) { Helper.LoadAttributes(value); value.SetAttributeValue(attributeKey, cbValue.Checked.ToString()); Helper.SaveAttributeValues(value, CurrentPersonId); DefinedValueCache.Flush(value.Id); } } } } ShowList(); if (Page.IsPostBack && pnlContent.Visible == false) { // If last item was just checked (postback and visible == false), // do a redirect back to the same page. This is needed to hide // the pre/post content which is outside of this controls update panel. Response.Redirect(CurrentPageReference.BuildUrl(), false); } }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event. /// </summary> /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnInit(EventArgs e) { base.OnInit(e); if (this.GetAttributeValue("ShowClipboardIcon").AsBoolean()) { // Setup for being able to copy text to clipboard RockPage.AddScriptLink(this.Page, "~/Scripts/clipboard.js/clipboard.min.js"); string script = string.Format(@" new Clipboard('#{0}'); $('#{0}').tooltip(); ", btnCopyToClipboard.ClientID); ScriptManager.RegisterStartupScript(btnCopyToClipboard, btnCopyToClipboard.GetType(), "share-copy", script, true); Uri uri = new Uri(Request.Url.ToString()); btnCopyToClipboard.Attributes["data-clipboard-text"] = uri.Scheme + "://" + uri.GetComponents(UriComponents.HostAndPort, UriFormat.UriEscaped) + CurrentPageReference.BuildUrl(); btnCopyToClipboard.Visible = true; } else { btnCopyToClipboard.Visible = false; } // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it this.BlockUpdated += Block_BlockUpdated; this.AddConfigurationUpdateTrigger(upnlContent); }