/// <summary> /// Sets the following on postback. /// </summary> /// <param name="eventItemId">The event item identifier.</param> private void SetFollowingOnPostback(int eventItemId) { var rockContext = new RockContext(); if (!eventItemId.Equals(0)) { var eventItem = GetEventItem(eventItemId, rockContext); if (eventItem != null) { FollowingsHelper.SetFollowing(eventItem, pnlFollowing, this.CurrentPerson); } } }
/// <summary> /// Sets the following on postback. /// </summary> private void SetFollowingOnPostback() { int?registrationInstanceId = PageParameter(PageParameterKey.RegistrationInstanceId).AsIntegerOrNull(); if (registrationInstanceId.HasValue) { using (var rockContext = new RockContext()) { RegistrationInstance registrationInstance = GetRegistrationInstance(registrationInstanceId.Value, rockContext); if (registrationInstance != null) { FollowingsHelper.SetFollowing(registrationInstance, pnlFollowing, this.CurrentPerson); } } } }
/// <summary> /// Shows the detail. /// </summary> /// <param name="eventItemId">The eventItem identifier.</param> public void ShowDetail(int eventItemId) { pnlEditDetails.Visible = false; EventItem eventItem = null; var rockContext = new RockContext(); if (!eventItemId.Equals(0)) { eventItem = GetEventItem(eventItemId, rockContext); } if (eventItem == null) { eventItem = new EventItem { Id = 0, IsActive = true, Name = "" }; eventItem.IsApproved = _canApprove; var calendarItem = new EventCalendarItem { EventCalendarId = (_calendarId ?? 0) }; eventItem.EventCalendarItems.Add(calendarItem); } eventItem.LoadAttributes(rockContext); FollowingsHelper.SetFollowing(eventItem, pnlFollowing, this.CurrentPerson); bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!_canEdit) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(EventItem.FriendlyTypeName); } else { if (eventItem.Id != 0 && !eventItem.EventCalendarItems.Any(i => i.EventCalendarId == (_calendarId ?? 0))) { readOnly = true; } } if (readOnly) { btnEdit.Visible = false; btnDelete.Visible = false; ShowReadonlyDetails(eventItem); } else { btnEdit.Visible = true; btnDelete.Visible = true; if (!eventItemId.Equals(0)) { ShowReadonlyDetails(eventItem); } else { ShowEditDetails(eventItem); } } }
/// <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) { if (Person != null && Person.Id != 0) { SetPersonName(); // Setup Image string imgTag = Rock.Model.Person.GetPersonPhotoImageTag(Person, 200, 200); if (Person.PhotoId.HasValue) { lImage.Text = string.Format("<a href='{0}'>{1}</a>", Person.PhotoUrl, imgTag); } else { lImage.Text = imgTag; } if (GetAttributeValue("AllowFollowing").AsBoolean()) { FollowingsHelper.SetFollowing(Person.PrimaryAlias, pnlFollow, this.CurrentPerson); } hlVCard.NavigateUrl = ResolveRockUrl(string.Format("~/GetVCard.ashx?Person={0}", Person.Id)); var socialCategoryGuid = GetAttributeValue("SocialMediaCategory").AsGuidOrNull(); if (socialCategoryGuid.HasValue) { var attributes = Person.Attributes.Where(p => p.Value.Categories.Select(c => c.Guid).Contains(socialCategoryGuid.Value)); var result = attributes.Join(Person.AttributeValues, a => a.Key, v => v.Key, (a, v) => new { Attribute = a.Value, Value = v.Value, QualifierValues = a.Value.QualifierValues }); rptSocial.DataSource = result .Where(r => r.Value != null && r.Value.Value != string.Empty && r.QualifierValues != null && r.QualifierValues.ContainsKey(NAME_KEY) && r.QualifierValues.ContainsKey(ICONCSSCLASS_KEY) && r.QualifierValues.ContainsKey(COLOR_KEY)) .OrderBy(r => r.Attribute.Order) .Select(r => new { url = r.Value.Value, name = r.QualifierValues[NAME_KEY].Value, icon = r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value.Contains("fa-fw") ? r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value : r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value + " fa-fw", color = r.Attribute.QualifierValues[COLOR_KEY].Value, }) .ToList(); rptSocial.DataBind(); } if (Person.BirthDate.HasValue) { var formattedAge = Person.FormatAge(); if (formattedAge.IsNotNullOrWhiteSpace()) { formattedAge += " old"; } lAge.Text = string.Format("<dd>{0} <small>({1})</small></dd>", formattedAge, (Person.BirthYear.HasValue && Person.BirthYear != DateTime.MinValue.Year) ? Person.BirthDate.Value.ToShortDateString() : Person.BirthDate.Value.ToMonthDayString()); } lGender.Text = string.Format("<dd>{0}</dd>", Person.Gender.ToString()); if (GetAttributeValue("DisplayGraduation").AsBoolean()) { if (Person.GraduationYear.HasValue && Person.HasGraduated.HasValue) { lGraduation.Text = string.Format( "<dd><small>{0} {1}</small></dd>", Person.HasGraduated.Value ? "Graduated " : "Graduates ", Person.GraduationYear.Value); } lGrade.Text = Person.GradeFormatted; } if (Person.AnniversaryDate.HasValue && GetAttributeValue("DisplayAnniversaryDate").AsBoolean()) { lMaritalStatus.Text = string.Format("<dd>{0}", Person.MaritalStatusValueId.DefinedValue()); lAnniversary.Text = string.Format("{0} yrs <small>({1})</small></dd>", Person.AnniversaryDate.Value.Age(), Person.AnniversaryDate.Value.ToMonthDayString()); } else { if (Person.MaritalStatusValueId.HasValue) { lMaritalStatus.Text = string.Format("<dd>{0}</dd>", Person.MaritalStatusValueId.DefinedValue()); } } if (Person.PhoneNumbers != null) { rptPhones.DataSource = Person.PhoneNumbers.ToList(); rptPhones.DataBind(); } var communicationLinkedPageValue = this.GetAttributeValue("CommunicationPage"); Rock.Web.PageReference communicationPageReference; if (communicationLinkedPageValue.IsNotNullOrWhiteSpace()) { communicationPageReference = new Rock.Web.PageReference(communicationLinkedPageValue); } else { communicationPageReference = null; } lEmail.Text = Person.GetEmailTag(ResolveRockUrl("/"), communicationPageReference); if (GetAttributeValue("DisplayTags").AsBoolean(true)) { taglPersonTags.Visible = true; taglPersonTags.EntityTypeId = Person.TypeId; taglPersonTags.EntityGuid = Person.Guid; taglPersonTags.CategoryGuid = GetAttributeValue("TagCategory").AsGuidOrNull(); taglPersonTags.GetTagValues(CurrentPersonId); } else { taglPersonTags.Visible = false; } CreateActionMenu(); string customContent = GetAttributeValue("CustomContent"); if (!string.IsNullOrWhiteSpace(customContent)) { var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(RockPage, CurrentPerson); string resolvedContent = customContent.ResolveMergeFields(mergeFields); phCustomContent.Controls.Add(new LiteralControl(resolvedContent)); } } else { nbInvalidPerson.Visible = true; pnlContent.Visible = false; } } }
/// <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) { if (Person != null && Person.Id != 0) { SetPersonName(); // Setup Image string imgTag = Rock.Model.Person.GetPersonPhotoImageTag(Person, 200, 200); if (Person.PhotoId.HasValue) { lImage.Text = string.Format("<a href='{0}'>{1}</a>", Person.PhotoUrl, imgTag); } else { lImage.Text = imgTag; } FollowingsHelper.SetFollowing(Person.PrimaryAlias, pnlFollow, this.CurrentPerson); var socialCategoryGuid = Rock.SystemGuid.Category.PERSON_ATTRIBUTES_SOCIAL.AsGuid(); if (!socialCategoryGuid.IsEmpty()) { var attributes = Person.Attributes.Where(p => p.Value.Categories.Select(c => c.Guid).Contains(socialCategoryGuid)); var result = attributes.Join(Person.AttributeValues, a => a.Key, v => v.Key, (a, v) => new { Attribute = a.Value, Value = v.Value }); rptSocial.DataSource = result .Where(r => r.Value != null && r.Value.Value != string.Empty) .OrderBy(r => r.Attribute.Order) .Select(r => new { url = r.Value.Value, name = r.Attribute.Name, icon = r.Attribute.IconCssClass }) .ToList(); rptSocial.DataBind(); } if (Person.BirthDate.HasValue) { lAge.Text = string.Format("{0}<small>({1})</small><br/>", Person.FormatAge(), (Person.BirthYear.HasValue && Person.BirthYear != DateTime.MinValue.Year) ? Person.BirthDate.Value.ToShortDateString() : Person.BirthDate.Value.ToMonthDayString()); } lGender.Text = Person.Gender.ToString(); if (Person.GraduationYear.HasValue && Person.HasGraduated.HasValue) { lGraduation.Text = string.Format( "<small>({0} {1})</small>", Person.HasGraduated.Value ? "Graduated " : "Graduates ", Person.GraduationYear.Value); } lGrade.Text = Person.GradeFormatted; lMaritalStatus.Text = Person.MaritalStatusValueId.DefinedValue(); if (Person.AnniversaryDate.HasValue) { lAnniversary.Text = string.Format("{0} yrs <small>({1})</small>", Person.AnniversaryDate.Value.Age(), Person.AnniversaryDate.Value.ToMonthDayString()); } if (Person.PhoneNumbers != null) { rptPhones.DataSource = Person.PhoneNumbers.ToList(); rptPhones.DataBind(); } lEmail.Text = Person.GetEmailTag(ResolveRockUrl("/")); taglPersonTags.EntityTypeId = Person.TypeId; taglPersonTags.EntityGuid = Person.Guid; taglPersonTags.GetTagValues(CurrentPersonId); StringBuilder sbActions = new StringBuilder(); var workflowActions = GetAttributeValue("WorkflowActions"); if (!string.IsNullOrWhiteSpace(workflowActions)) { using (var rockContext = new RockContext()) { var workflowTypeService = new WorkflowTypeService(rockContext); foreach (string guidValue in workflowActions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { Guid?guid = guidValue.AsGuidOrNull(); if (guid.HasValue) { var workflowType = workflowTypeService.Get(guid.Value); if (workflowType != null && workflowType.IsAuthorized(Authorization.VIEW, CurrentPerson)) { string url = string.Format("~/WorkflowEntry/{0}?PersonId={1}", workflowType.Id, Person.Id); sbActions.AppendFormat( "<li><a href='{0}'><i class='icon-fw {1}'></i> {2}</a></li>", ResolveRockUrl(url), workflowType.IconCssClass, workflowType.Name); sbActions.AppendLine(); } } } } } var actions = GetAttributeValue("Actions"); if (!string.IsNullOrWhiteSpace(actions)) { string appRoot = ResolveRockUrl("~/"); string themeRoot = ResolveRockUrl("~~/"); actions = actions.Replace("~~/", themeRoot).Replace("~/", appRoot); if (actions.Contains("{0}")) { actions = string.Format(actions, Person.Id); } sbActions.Append(actions); } lActions.Text = sbActions.ToString(); ulActions.Visible = !string.IsNullOrWhiteSpace(lActions.Text); } else { nbInvalidPerson.Visible = true; pnlContent.Visible = false; } } }
/// <summary> /// Shows the detail. /// </summary> private void ShowDetail() { int?registrationInstanceId = PageParameter(PageParameterKey.RegistrationInstanceId).AsIntegerOrNull(); int?parentTemplateId = PageParameter(PageParameterKey.RegistrationTemplateId).AsIntegerOrNull(); if (!registrationInstanceId.HasValue) { pnlDetails.Visible = false; return; } using (var rockContext = new RockContext()) { RegistrationInstance registrationInstance = null; if (registrationInstanceId.HasValue) { registrationInstance = GetRegistrationInstance(registrationInstanceId.Value, rockContext); } if (registrationInstance == null) { registrationInstance = new RegistrationInstance(); registrationInstance.Id = 0; registrationInstance.IsActive = true; registrationInstance.RegistrationTemplateId = parentTemplateId ?? 0; Guid?accountGuid = GetAttributeValue(AttributeKey.DefaultAccount).AsGuidOrNull(); if (accountGuid.HasValue) { var account = new FinancialAccountService(rockContext).Get(accountGuid.Value); registrationInstance.AccountId = account != null ? account.Id : 0; } } if (registrationInstance.RegistrationTemplate == null && registrationInstance.RegistrationTemplateId > 0) { registrationInstance.RegistrationTemplate = new RegistrationTemplateService(rockContext) .Get(registrationInstance.RegistrationTemplateId); } hlType.Visible = registrationInstance.RegistrationTemplate != null; hlType.Text = registrationInstance.RegistrationTemplate != null ? registrationInstance.RegistrationTemplate.Name : string.Empty; lWizardTemplateName.Text = hlType.Text; pnlDetails.Visible = true; hfRegistrationInstanceId.Value = registrationInstance.Id.ToString(); hfRegistrationTemplateId.Value = registrationInstance.RegistrationTemplateId.ToString(); FollowingsHelper.SetFollowing(registrationInstance, pnlFollowing, this.CurrentPerson); // render UI based on Authorized bool readOnly = false; bool canEdit = UserCanEdit || registrationInstance.IsAuthorized(Authorization.EDIT, CurrentPerson) || registrationInstance.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson); nbEditModeMessage.Text = string.Empty; // User must have 'Edit' rights to block, or 'Edit' or 'Administrate' rights to instance if (!canEdit) { readOnly = true; nbEditModeMessage.Heading = "Information"; nbEditModeMessage.Text = EditModeMessage.NotAuthorizedToEdit(RegistrationInstance.FriendlyTypeName); } if (readOnly) { btnEdit.Visible = false; btnDelete.Visible = false; ShowReadonlyDetails(registrationInstance, false); } else { btnEdit.Visible = true; btnDelete.Visible = true; if (registrationInstance.Id > 0) { ShowReadonlyDetails(registrationInstance, false); } else { ShowEditDetails(registrationInstance, rockContext); } } // show send payment reminder link if (!string.IsNullOrWhiteSpace(GetAttributeValue(AttributeKey.PaymentReminderPage)) && ((registrationInstance.RegistrationTemplate.SetCostOnInstance.HasValue && registrationInstance.RegistrationTemplate.SetCostOnInstance == true && registrationInstance.Cost.HasValue && registrationInstance.Cost.Value > 0) || registrationInstance.RegistrationTemplate.Cost > 0 || registrationInstance.RegistrationTemplate.Fees.Count > 0)) { btnSendPaymentReminder.Visible = true; } else { btnSendPaymentReminder.Visible = false; } } }
/// <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) { // dont' show if there isn't a person, or if it is a 'Nameless" person record type if (Person == null || Person.Id == 0 || Person.RecordTypeValueId == DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.PERSON_RECORD_TYPE_NAMELESS.AsGuid())) { nbInvalidPerson.Visible = true; pnlContent.Visible = false; return; } string quickReturnLava = "{{ Person.FullName | AddQuickReturn:'People', 10 }}"; var quickReturnMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, this.CurrentPerson, new Rock.Lava.CommonMergeFieldsOptions { GetLegacyGlobalMergeFields = false }); quickReturnMergeFields.Add("Person", Person); quickReturnLava.ResolveMergeFields(quickReturnMergeFields); SetPersonName(); // Setup Image string imgTag = Rock.Model.Person.GetPersonPhotoImageTag(Person, 200, 200); if (Person.PhotoId.HasValue) { lImage.Text = string.Format("<a href='{0}'>{1}</a>", Person.PhotoUrl, imgTag); } else { lImage.Text = imgTag; } if (GetAttributeValue(AttributeKey.AllowFollowing).AsBoolean()) { FollowingsHelper.SetFollowing(Person.PrimaryAlias, pnlFollow, this.CurrentPerson); } hlVCard.NavigateUrl = ResolveUrl(string.Format("~/api/People/VCard/{0}", Person.Guid)); var socialCategoryGuid = GetAttributeValue(AttributeKey.SocialMediaCategory).AsGuidOrNull(); if (socialCategoryGuid.HasValue) { var attributes = Person.Attributes.Where(p => p.Value.Categories.Select(c => c.Guid).Contains(socialCategoryGuid.Value)); var result = attributes.Join(Person.AttributeValues, a => a.Key, v => v.Key, (a, v) => new { Attribute = a.Value, Value = v.Value, QualifierValues = a.Value.QualifierValues }); rptSocial.DataSource = result .Where(r => r.Value != null && r.Value.Value != string.Empty && r.QualifierValues != null && r.QualifierValues.ContainsKey(NAME_KEY) && r.QualifierValues.ContainsKey(ICONCSSCLASS_KEY) && r.QualifierValues.ContainsKey(COLOR_KEY)) .OrderBy(r => r.Attribute.Order) .Select(r => new { url = r.Value.Value, name = r.QualifierValues[NAME_KEY].Value, icon = r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value.Contains("fa-fw") ? r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value : r.Attribute.QualifierValues[ICONCSSCLASS_KEY].Value + " fa-fw", color = r.Attribute.QualifierValues[COLOR_KEY].Value, }) .ToList(); rptSocial.DataBind(); } if (Person.BirthDate.HasValue) { var formattedAge = Person.FormatAge(); if (formattedAge.IsNotNullOrWhiteSpace()) { formattedAge += " old"; } lAge.Text = string.Format("<dd>{0} <small>({1})</small></dd>", formattedAge, (Person.BirthYear.HasValue && Person.BirthYear != DateTime.MinValue.Year) ? Person.BirthDate.Value.ToShortDateString() : Person.BirthDate.Value.ToMonthDayString()); } lGender.Text = string.Format("<dd>{0}</dd>", Person.Gender.ToString()); if (GetAttributeValue(AttributeKey.DisplayGraduation).AsBoolean()) { if (Person.GraduationYear.HasValue && Person.HasGraduated.HasValue) { lGraduation.Text = string.Format( "<dd><small>{0} {1}</small></dd>", Person.HasGraduated.Value ? "Graduated " : "Graduates ", Person.GraduationYear.Value); } lGrade.Text = Person.GradeFormatted; } if (Person.AnniversaryDate.HasValue && GetAttributeValue(AttributeKey.DisplayAnniversaryDate).AsBoolean()) { lMaritalStatus.Text = string.Format("<dd>{0}", Person.MaritalStatusValueId.DefinedValue()); lAnniversary.Text = string.Format("{0} yrs <small>({1})</small></dd>", Person.AnniversaryDate.Value.Age(), Person.AnniversaryDate.Value.ToMonthDayString()); } else { if (Person.MaritalStatusValueId.HasValue) { lMaritalStatus.Text = string.Format("<dd>{0}</dd>", Person.MaritalStatusValueId.DefinedValue()); } } if (Person.PhoneNumbers != null) { var phoneNumbers = Person.PhoneNumbers.AsEnumerable(); var phoneNumberTypes = DefinedTypeCache.Get(new Guid(Rock.SystemGuid.DefinedType.PERSON_PHONE_TYPE)); if (phoneNumberTypes.DefinedValues.Any()) { var phoneNumberTypeIds = phoneNumberTypes.DefinedValues.Select(a => a.Id).ToList(); phoneNumbers = phoneNumbers.OrderBy(a => phoneNumberTypeIds.IndexOf(a.NumberTypeValueId.Value)); } rptPhones.DataSource = phoneNumbers; rptPhones.DataBind(); } var communicationLinkedPageValue = this.GetAttributeValue(AttributeKey.CommunicationPage); Rock.Web.PageReference communicationPageReference; if (communicationLinkedPageValue.IsNotNullOrWhiteSpace()) { communicationPageReference = new Rock.Web.PageReference(communicationLinkedPageValue); } else { communicationPageReference = null; } lEmail.Text = Person.GetEmailTag(ResolveRockUrl("/"), communicationPageReference); if (GetAttributeValue(AttributeKey.DisplayTags).AsBoolean(true)) { taglPersonTags.Visible = true; taglPersonTags.EntityTypeId = Person.TypeId; taglPersonTags.EntityGuid = Person.Guid; taglPersonTags.CategoryGuid = GetAttributeValue(AttributeKey.TagCategory).AsGuidOrNull(); taglPersonTags.GetTagValues(CurrentPersonId); } else { taglPersonTags.Visible = false; } CreateActionMenu(); string customContent = GetAttributeValue(AttributeKey.CustomContent); if (!string.IsNullOrWhiteSpace(customContent)) { var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(RockPage, CurrentPerson); string resolvedContent = customContent.ResolveMergeFields(mergeFields); phCustomContent.Controls.Add(new LiteralControl(resolvedContent)); } } }