Ejemplo n.º 1
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="campusId">The campus identifier.</param>
        public void ShowDetail(int campusId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            Campus campus = null;

            if (!campusId.Equals(0))
            {
                campus            = new CampusService(new RockContext()).Get(campusId);
                lActionTitle.Text = ActionTitle.Edit(Campus.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (campus == null)
            {
                campus = new Campus {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Campus.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfCampusId.Value   = campus.Id.ToString();
            tbCampusName.Text  = campus.Name;
            cbIsActive.Checked = !campus.IsActive.HasValue || campus.IsActive.Value;
            tbDescription.Text = campus.Description;
            tbUrl.Text         = campus.Url;
            tbPhoneNumber.Text = campus.PhoneNumber;
            acAddress.SetValues(campus.Location);

            tbCampusCode.Text = campus.ShortCode;
            ppCampusLeader.SetValue(campus.LeaderPersonAlias != null ? campus.LeaderPersonAlias.Person : null);
            kvlServiceTimes.Value = campus.ServiceTimes;

            campus.LoadAttributes();
            phAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(campus, phAttributes, true);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Campus.FriendlyTypeName);
            }

            if (campus.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Campus.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Campus.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbCampusName.ReadOnly = readOnly;
            btnSave.Visible       = !readOnly;
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="mergeTemplate">The merge template.</param>
        public void ShowEditDetails(MergeTemplate mergeTemplate)
        {
            if (mergeTemplate.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit(mergeTemplate.ToString()).FormatAsHtmlTitle();
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(MergeTemplate.FriendlyTypeName).FormatAsHtmlTitle();
            }

            SetEditMode(true);

            var mergeTemplateOwnership = this.GetAttributeValue(AttributeKey.MergeTemplatesOwnership).ConvertToEnum <MergeTemplateOwnership>(MergeTemplateOwnership.Global);

            if (this.IsUserAuthorized(Authorization.EDIT))
            {
                // If Authorized to EDIT, owner should be able to be changed, or converted to Global
                ppPerson.Visible               = true;
                ppPerson.Required              = false;
                cpCategory.Visible             = true;
                cpCategory.ExcludedCategoryIds = string.Empty;
            }
            else if (mergeTemplateOwnership == MergeTemplateOwnership.Global)
            {
                ppPerson.Visible               = false;
                ppPerson.Required              = false;
                cpCategory.Visible             = true;
                cpCategory.ExcludedCategoryIds = CategoryCache.Get(Rock.SystemGuid.Category.PERSONAL_MERGE_TEMPLATE.AsGuid()).Id.ToString();
            }
            else if (mergeTemplateOwnership == MergeTemplateOwnership.Personal)
            {
                // if ONLY personal merge templates are permitted, hide the category since it'll always be saved in the personal category
                cpCategory.Visible = false;

                // merge template should be only for the current person, so hide the person picker
                ppPerson.Visible = false;

                // it is required, but not shown..
                ppPerson.Required = false;
            }
            else if (mergeTemplateOwnership == MergeTemplateOwnership.PersonalAndGlobal)
            {
                ppPerson.Visible               = true;
                ppPerson.Required              = false;
                cpCategory.Visible             = true;
                cpCategory.ExcludedCategoryIds = string.Empty;
            }

            tbName.Text        = mergeTemplate.Name;
            tbDescription.Text = mergeTemplate.Description;

            LoadDropDowns();

            ddlMergeTemplateType.SetValue(mergeTemplate.MergeTemplateTypeEntityTypeId);

            fuTemplateBinaryFile.BinaryFileTypeGuid = Rock.SystemGuid.BinaryFiletype.MERGE_TEMPLATE.AsGuid();
            fuTemplateBinaryFile.BinaryFileId       = mergeTemplate.TemplateBinaryFileId;

            cpCategory.AllowMultiSelect = false;
            cpCategory.SetValue(mergeTemplate.CategoryId);
            if (mergeTemplate.PersonAliasId.HasValue)
            {
                ppPerson.SetValue(mergeTemplate.PersonAlias.Person);
            }
            else
            {
                ppPerson.SetValue(null);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("binaryFileTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            BinaryFileType binaryFileType;

            if (!itemKeyValue.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName);
            }
            else
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName);
            }

            BinaryFileAttributesState = new ViewStateList <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text               = binaryFileType.Name;
            tbDescription.Text        = binaryFileType.Description;
            tbIconCssClass.Text       = binaryFileType.IconCssClass;
            imgIconSmall.BinaryFileId = binaryFileType.IconSmallFileId;
            imgIconLarge.BinaryFileId = binaryFileType.IconLargeFileId;
            cbAllowCaching.Checked    = binaryFileType.AllowCaching;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString();
            }

            AttributeService attributeService = new AttributeService();

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState.AddAll(qryBinaryFileAttributes.ToList());
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(BinaryFileType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            tbIconCssClass.ReadOnly       = readOnly;
            imgIconLarge.Enabled          = !readOnly;
            imgIconSmall.Enabled          = !readOnly;
            gBinaryFileAttributes.Enabled = !readOnly;
            cbAllowCaching.Enabled        = !readOnly;
            cpStorageType.Enabled         = !readOnly;
            btnSave.Visible               = !readOnly;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="campusId">The campus identifier.</param>
        public void ShowDetail(int campusId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            Campus campus = null;

            if (!campusId.Equals(0))
            {
                campus            = new CampusService(new RockContext()).Get(campusId);
                lActionTitle.Text = ActionTitle.Edit(Campus.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(campus, ResolveRockUrl("~"));
            }

            if (campus == null)
            {
                campus = new Campus {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Campus.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfCampusId.Value    = campus.Id.ToString();
            tbCampusName.Text   = campus.Name;
            cbIsActive.Checked  = !campus.IsActive.HasValue || campus.IsActive.Value;
            tbDescription.Text  = campus.Description;
            tbUrl.Text          = campus.Url;
            tbPhoneNumber.Text  = campus.PhoneNumber;
            lpLocation.Location = campus.Location;

            tbCampusCode.Text = campus.ShortCode;
            ddlTimeZone.SetValue(campus.TimeZoneId);
            ppCampusLeader.SetValue(campus.LeaderPersonAlias != null ? campus.LeaderPersonAlias.Person : null);
            kvlServiceTimes.Value = campus.ServiceTimes;

            campus.LoadAttributes();
            phAttributes.Controls.Clear();
            var excludeForEdit = campus.Attributes.Where(a => !a.Value.IsAuthorized(Rock.Security.Authorization.EDIT, this.CurrentPerson)).Select(a => a.Key).ToList();

            Rock.Attribute.Helper.AddEditControls(campus, phAttributes, true, BlockValidationGroup, excludeForEdit);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Campus.FriendlyTypeName);
            }

            if (campus.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Campus.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Campus.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbCampusName.ReadOnly = readOnly;
            btnSave.Visible       = !readOnly;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowEditDetails(Rock.Model.Site site)
        {
            if (site.Id == 0)
            {
                nbDefaultPageNotice.Visible = true;
                lReadOnlyTitle.Text         = ActionTitle.Add(Rock.Model.Site.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                nbDefaultPageNotice.Visible = false;
                lReadOnlyTitle.Text         = site.Name.FormatAsHtmlTitle();
            }

            SetEditMode(true);

            LoadDropDowns();

            tbSiteName.ReadOnly = site.IsSystem;
            tbSiteName.Text     = site.Name;

            tbDescription.ReadOnly = site.IsSystem;
            tbDescription.Text     = site.Description;

            ddlTheme.Enabled = !site.IsSystem;
            ddlTheme.SetValue(site.Theme);

            if (site.DefaultPageRoute != null)
            {
                ppDefaultPage.SetValue(site.DefaultPageRoute);
            }
            else
            {
                ppDefaultPage.SetValue(site.DefaultPage);
            }

            if (site.LoginPageRoute != null)
            {
                ppLoginPage.SetValue(site.LoginPageRoute);
            }
            else
            {
                ppLoginPage.SetValue(site.LoginPage);
            }

            if (site.ChangePasswordPageRoute != null)
            {
                ppChangePasswordPage.SetValue(site.ChangePasswordPageRoute);
            }
            else
            {
                ppChangePasswordPage.SetValue(site.ChangePasswordPage);
            }

            if (site.CommunicationPageRoute != null)
            {
                ppCommunicationPage.SetValue(site.CommunicationPageRoute);
            }
            else
            {
                ppCommunicationPage.SetValue(site.CommunicationPage);
            }

            if (site.RegistrationPageRoute != null)
            {
                ppRegistrationPage.SetValue(site.RegistrationPageRoute);
            }
            else
            {
                ppRegistrationPage.SetValue(site.RegistrationPage);
            }

            if (site.PageNotFoundPageRoute != null)
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPageRoute);
            }
            else
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPage);
            }

            tbErrorPage.Text = site.ErrorPage;

            tbSiteDomains.Text          = string.Join("\n", site.SiteDomains.Select(dom => dom.Domain).ToArray());
            tbGoogleAnalytics.Text      = site.GoogleAnalyticsCode;
            cbRequireEncryption.Checked = site.RequiresEncryption;

            cbEnableMobileRedirect.Checked = site.EnableMobileRedirect;
            ppMobilePage.SetValue(site.MobilePage);
            tbExternalURL.Text                 = site.ExternalUrl;
            tbAllowedFrameDomains.Text         = site.AllowedFrameDomains;
            cbRedirectTablets.Checked          = site.RedirectTablets;
            cbEnablePageViews.Checked          = site.EnablePageViews;
            nbPageViewRetentionPeriodDays.Text = site.PageViewRetentionPeriodDays.ToString();
            SetControlsVisiblity();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="site">The site.</param>
        private void ShowEditDetails(Rock.Model.Site site)
        {
            if (site.Id == 0)
            {
                nbDefaultPageNotice.Visible = true;
                lReadOnlyTitle.Text         = ActionTitle.Add(Rock.Model.Site.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                nbDefaultPageNotice.Visible = false;
                lReadOnlyTitle.Text         = site.Name.FormatAsHtmlTitle();
            }

            SetEditMode(true);

            LoadDropDowns();

            tbSiteName.ReadOnly = site.IsSystem;
            tbSiteName.Text     = site.Name;

            tbDescription.ReadOnly = site.IsSystem;
            tbDescription.Text     = site.Description;

            ddlTheme.Enabled = !site.IsSystem;
            ddlTheme.SetValue(site.Theme);

            imgSiteIcon.BinaryFileId = site.FavIconBinaryFileId;
            imgSiteLogo.BinaryFileId = site.SiteLogoBinaryFileId;

            cbIsActive.Checked = site.IsActive;

            if (site.DefaultPageRoute != null)
            {
                ppDefaultPage.SetValue(site.DefaultPageRoute);
            }
            else
            {
                ppDefaultPage.SetValue(site.DefaultPage);
            }

            if (site.LoginPageRoute != null)
            {
                ppLoginPage.SetValue(site.LoginPageRoute);
            }
            else
            {
                ppLoginPage.SetValue(site.LoginPage);
            }

            if (site.ChangePasswordPageRoute != null)
            {
                ppChangePasswordPage.SetValue(site.ChangePasswordPageRoute);
            }
            else
            {
                ppChangePasswordPage.SetValue(site.ChangePasswordPage);
            }

            if (site.CommunicationPageRoute != null)
            {
                ppCommunicationPage.SetValue(site.CommunicationPageRoute);
            }
            else
            {
                ppCommunicationPage.SetValue(site.CommunicationPage);
            }

            if (site.RegistrationPageRoute != null)
            {
                ppRegistrationPage.SetValue(site.RegistrationPageRoute);
            }
            else
            {
                ppRegistrationPage.SetValue(site.RegistrationPage);
            }

            if (site.PageNotFoundPageRoute != null)
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPageRoute);
            }
            else
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPage);
            }

            tbErrorPage.Text = site.ErrorPage;

            tbSiteDomains.Text            = string.Join("\n", site.SiteDomains.OrderBy(d => d.Order).Select(d => d.Domain).ToArray());
            tbGoogleAnalytics.Text        = site.GoogleAnalyticsCode;
            cbRequireEncryption.Checked   = site.RequiresEncryption;
            cbEnableForShortening.Checked = site.EnabledForShortening;

            cbEnableMobileRedirect.Checked = site.EnableMobileRedirect;
            ppMobilePage.SetValue(site.MobilePage);
            tbExternalURL.Text         = site.ExternalUrl;
            tbAllowedFrameDomains.Text = site.AllowedFrameDomains;
            cbRedirectTablets.Checked  = site.RedirectTablets;
            cbEnablePageViews.Checked  = site.EnablePageViews;

            int channelMediumWebsiteValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.INTERACTIONCHANNELTYPE_WEBSITE.AsGuid()).Id;
            var interactionChannelForSite   = new InteractionChannelService(new RockContext()).Queryable()
                                              .Where(a => a.ChannelTypeMediumValueId == channelMediumWebsiteValueId && a.ChannelEntityId == site.Id).FirstOrDefault();

            if (interactionChannelForSite != null)
            {
                nbPageViewRetentionPeriodDays.Text = interactionChannelForSite.RetentionDuration.ToString();
            }

            cbEnableIndexing.Checked        = site.IsIndexEnabled;
            tbIndexStartingLocation.Text    = site.IndexStartingLocation;
            cbEnableExclusiveRoutes.Checked = site.EnableExclusiveRoutes;

            // disable the indexing features if indexing on site is disabled
            var siteEntityType = EntityTypeCache.Get("Rock.Model.Site");

            if (siteEntityType != null && !siteEntityType.IsIndexingEnabled)
            {
                cbEnableIndexing.Visible        = false;
                tbIndexStartingLocation.Visible = false;
            }

            var attributeService     = new AttributeService(new RockContext());
            var siteIdQualifierValue = site.Id.ToString();

            PageAttributesState = attributeService.GetByEntityTypeId(new Page().TypeId, true).AsQueryable()
                                  .Where(a =>
                                         a.EntityTypeQualifierColumn.Equals("SiteId", StringComparison.OrdinalIgnoreCase) &&
                                         a.EntityTypeQualifierValue.Equals(siteIdQualifierValue))
                                  .OrderBy(a => a.Order)
                                  .ThenBy(a => a.Name)
                                  .ToList();
            BindPageAttributesGrid();

            SetControlsVisiblity();
        }
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="page">The page.</param>
        private void ShowEditDetails(Rock.Model.Page page)
        {
            pdAuditDetails.Visible = false;
            if (page.Id > 0)
            {
                lTitle.Text = ActionTitle.Edit(Rock.Model.Page.FriendlyTypeName).FormatAsHtmlTitle();
                lIcon.Text  = "<i class='fa fa-square-o'></i>";
            }
            else
            {
                lTitle.Text = ActionTitle.Add(Rock.Model.Page.FriendlyTypeName).FormatAsHtmlTitle();

                if (!string.IsNullOrEmpty(page.IconCssClass))
                {
                    lIcon.Text = string.Format("<i class='{0}'></i>", page.IconCssClass);
                }
                else
                {
                    lIcon.Text = "<i class='fa fa-file-text-o'></i>";
                }
            }

            SetEditMode(true);

            var         rockContext = new RockContext();
            PageService pageService = new PageService(rockContext);

            if (page.Layout != null)
            {
                ddlSite.SetValue(page.Layout.SiteId);
            }
            else if (page.ParentPageId.HasValue)
            {
                var parentPageCache = PageCache.Get(page.ParentPageId.Value);
                if (parentPageCache != null && parentPageCache.Layout != null)
                {
                    ddlSite.SetValue(parentPageCache.Layout.SiteId);
                }
            }

            LoadLayouts(rockContext, SiteCache.Get(ddlSite.SelectedValue.AsInteger()));
            if (page.LayoutId == 0)
            {
                // default a new page's layout to whatever the parent page's layout is
                if (page.ParentPage != null)
                {
                    page.LayoutId = page.ParentPage.LayoutId;
                }
            }

            ddlLayout.SetValue(page.LayoutId);

            phPageAttributes.Controls.Clear();
            page.LoadAttributes();

            if (page.Attributes != null && page.Attributes.Any())
            {
                wpPageAttributes.Visible = true;
                Rock.Attribute.Helper.AddEditControls(page, phPageAttributes, true, BlockValidationGroup);
            }
            else
            {
                wpPageAttributes.Visible = false;
            }

            rptProperties.DataSource = _tabs;
            rptProperties.DataBind();

            tbPageName.Text     = page.InternalName;
            tbPageTitle.Text    = page.PageTitle;
            tbBrowserTitle.Text = page.BrowserTitle;
            tbBodyCssClass.Text = page.BodyCssClass;
            ppParentPage.SetValue(pageService.Get(page.ParentPageId ?? 0));
            tbIconCssClass.Text = page.IconCssClass;

            cbPageTitle.Checked       = page.PageDisplayTitle;
            cbPageBreadCrumb.Checked  = page.PageDisplayBreadCrumb;
            cbPageIcon.Checked        = page.PageDisplayIcon;
            cbPageDescription.Checked = page.PageDisplayDescription;

            ddlMenuWhen.SelectedValue = ((int)page.DisplayInNavWhen).ToString();
            cbMenuDescription.Checked = page.MenuDisplayDescription;
            cbMenuIcon.Checked        = page.MenuDisplayIcon;
            cbMenuChildPages.Checked  = page.MenuDisplayChildPages;

            cbBreadCrumbIcon.Checked = page.BreadCrumbDisplayIcon;
            cbBreadCrumbName.Checked = page.BreadCrumbDisplayName;

            cbRequiresEncryption.Checked = page.RequiresEncryption;
            cbEnableViewState.Checked    = page.EnableViewState;
            cbIncludeAdminFooter.Checked = page.IncludeAdminFooter;
            cbAllowIndexing.Checked      = page.AllowIndexing;
            tbCacheDuration.Text         = page.OutputCacheDuration.ToString();
            tbDescription.Text           = page.Description;
            ceHeaderContent.Text         = page.HeaderContent;
            tbPageRoute.Text             = string.Join(",", page.PageRoutes.Select(route => route.Route).ToArray());

            // Add enctype attribute to page's <form> tag to allow file upload control to function
            Page.Form.Attributes.Add("enctype", "multipart/form-data");
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupMemberId">The group member identifier.</param>
        /// <param name="groupId">The group id.</param>
        public void ShowDetail(int groupMemberId, int?groupId)
        {
            // autoexpand the person picker if this is an add
            var personPickerStartupScript = @"Sys.Application.add_load(function () {

                // if the person picker is empty then open it for quick entry
                var personPicker = $('.js-authorizedperson');
                var currentPerson = personPicker.find('.picker-selectedperson').html();
                if (currentPerson != null && currentPerson.length == 0) {
                    $(personPicker).find('a.picker-label').trigger('click');
                }

            });";

            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "StartupScript", personPickerStartupScript, true);

            var         rockContext = new RockContext();
            GroupMember groupMember = null;

            if (!groupMemberId.Equals(0))
            {
                groupMember = new GroupMemberService(rockContext).Get(groupMemberId);
                pdAuditDetails.SetEntity(groupMember, ResolveRockUrl("~"));
            }
            else
            {
                // only create a new one if parent was specified
                if (groupId.HasValue)
                {
                    groupMember = new GroupMember {
                        Id = 0
                    };
                    groupMember.GroupId           = groupId.Value;
                    groupMember.Group             = new GroupService(rockContext).Get(groupMember.GroupId);
                    groupMember.GroupRoleId       = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
                    groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                    groupMember.DateTimeAdded     = RockDateTime.Now;
                    // hide the panel drawer that show created and last modified dates
                    pdAuditDetails.Visible = false;
                }
            }

            if (groupMember == null)
            {
                if (groupMemberId > 0)
                {
                    nbErrorMessage.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Warning;
                    nbErrorMessage.Title = "Warning";
                    nbErrorMessage.Text  = "Group Member not found. Group Member may have been moved to another group or deleted.";
                }
                else
                {
                    nbErrorMessage.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Danger;
                    nbErrorMessage.Title = "Invalid Request";
                    nbErrorMessage.Text  = "An incorrect querystring parameter was used.  A valid GroupMemberId or GroupId parameter is required.";
                }

                pnlEditDetails.Visible = false;
                return;
            }

            pnlEditDetails.Visible = true;

            hfGroupId.Value       = groupMember.GroupId.ToString();
            hfGroupMemberId.Value = groupMember.Id.ToString();

            if (IsUserAuthorized(Authorization.ADMINISTRATE))
            {
                cbIsNotified.Checked = groupMember.IsNotified;
                cbIsNotified.Visible = true;
                cbIsNotified.Help    = "If this box is unchecked and a <a href=\"http://www.rockrms.com/Rock/BookContent/7/#servicejobsrelatingtogroups\">group leader notification job</a> is enabled then a notification will be sent to the group's leaders when this group member is saved.";
            }
            else
            {
                cbIsNotified.Visible = false;
            }

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            var group = groupMember.Group;

            if (!string.IsNullOrWhiteSpace(group.GroupType.IconCssClass))
            {
                lGroupIconHtml.Text = string.Format("<i class='{0}' ></i>", group.GroupType.IconCssClass);
            }
            else
            {
                lGroupIconHtml.Text = "<i class='fa fa-user' ></i>";
            }

            if (groupMember.Id.Equals(0))
            {
                lReadOnlyTitle.Text    = ActionTitle.Add(groupMember.Group.GroupType.GroupTerm + " " + groupMember.Group.GroupType.GroupMemberTerm).FormatAsHtmlTitle();
                btnSaveThenAdd.Visible = true;
            }
            else
            {
                lReadOnlyTitle.Text    = groupMember.Person.FullName.FormatAsHtmlTitle();
                btnSaveThenAdd.Visible = false;
            }

            if (groupMember.DateTimeAdded.HasValue)
            {
                hfDateAdded.Text    = string.Format("Added: {0}", groupMember.DateTimeAdded.Value.ToShortDateString());
                hfDateAdded.Visible = true;
            }
            else
            {
                hfDateAdded.Text    = string.Empty;
                hfDateAdded.Visible = false;
            }

            // user has to have EDIT Auth to the Block OR the group
            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT) && !group.IsAuthorized(Authorization.EDIT, this.CurrentPerson))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Group.FriendlyTypeName);
            }

            if (groupMember.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Group.FriendlyTypeName);
            }

            btnSave.Visible = !readOnly;

            if (readOnly || groupMember.Id == 0)
            {
                // hide the ShowMoveDialog if this is readOnly or if this is a new group member (can't move a group member that doesn't exist yet)
                btnShowMoveDialog.Visible = false;
            }

            LoadDropDowns();

            ShowRequiredDocumentStatus(rockContext, groupMember, group);

            ppGroupMemberPerson.SetValue(groupMember.Person);
            ppGroupMemberPerson.Enabled = !readOnly;

            if (groupMember.Id != 0)
            {
                // once a group member record is saved, don't let them change the person
                ppGroupMemberPerson.Enabled = false;
            }

            ddlGroupRole.SetValue(groupMember.GroupRoleId);
            ddlGroupRole.Enabled = !readOnly;

            tbNote.Text     = groupMember.Note;
            tbNote.ReadOnly = readOnly;

            rblStatus.SetValue((int)groupMember.GroupMemberStatus);
            rblStatus.Enabled = !readOnly;
            rblStatus.Label   = string.Format("{0} Status", group.GroupType.GroupMemberTerm);

            var registrations = new RegistrationRegistrantService(rockContext)
                                .Queryable().AsNoTracking()
                                .Where(r =>
                                       r.Registration != null &&
                                       r.Registration.RegistrationInstance != null &&
                                       r.GroupMemberId.HasValue &&
                                       r.GroupMemberId.Value == groupMember.Id)
                                .Select(r => new
            {
                Id   = r.Registration.Id,
                Name = r.Registration.RegistrationInstance.Name
            })
                                .ToList();

            if (registrations.Any())
            {
                rcwLinkedRegistrations.Visible    = true;
                rptLinkedRegistrations.DataSource = registrations;
                rptLinkedRegistrations.DataBind();
            }
            else
            {
                rcwLinkedRegistrations.Visible = false;
            }

            if (groupMember.Group.RequiredSignatureDocumentTemplate != null)
            {
                fuSignedDocument.Label = groupMember.Group.RequiredSignatureDocumentTemplate.Name;
                if (groupMember.Group.RequiredSignatureDocumentTemplate.BinaryFileType != null)
                {
                    fuSignedDocument.BinaryFileTypeGuid = groupMember.Group.RequiredSignatureDocumentTemplate.BinaryFileType.Guid;
                }

                var signatureDocument = new SignatureDocumentService(rockContext)
                                        .Queryable().AsNoTracking()
                                        .Where(d =>
                                               d.SignatureDocumentTemplateId == groupMember.Group.RequiredSignatureDocumentTemplateId.Value &&
                                               d.AppliesToPersonAlias != null &&
                                               d.AppliesToPersonAlias.PersonId == groupMember.PersonId &&
                                               d.LastStatusDate.HasValue &&
                                               d.Status == SignatureDocumentStatus.Signed &&
                                               d.BinaryFile != null)
                                        .OrderByDescending(d => d.LastStatusDate.Value)
                                        .FirstOrDefault();

                if (signatureDocument != null)
                {
                    hfSignedDocumentId.Value      = signatureDocument.Id.ToString();
                    fuSignedDocument.BinaryFileId = signatureDocument.BinaryFileId;
                }

                fuSignedDocument.Visible = true;
            }
            else
            {
                fuSignedDocument.Visible = false;
            }

            groupMember.LoadAttributes();
            phAttributes.Controls.Clear();

            Rock.Attribute.Helper.AddEditControls(groupMember, phAttributes, true, string.Empty, true);
            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(groupMember, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
            }
            else
            {
                phAttributesReadOnly.Visible = false;
                phAttributes.Visible         = true;
            }

            var groupHasRequirements = group.GroupRequirements.Any();

            pnlRequirements.Visible        = groupHasRequirements;
            btnReCheckRequirements.Visible = groupHasRequirements;

            ShowGroupRequirementsStatuses();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="category">The category.</param>
        private void ShowEditDetails(Category category)
        {
            if (category.Id > 0)
            {
                lTitle.Text = ActionTitle.Edit(Category.FriendlyTypeName).FormatAsHtmlTitle();
                lIcon.Text  = "<i class='fa fa-square-o'></i>";
            }
            else
            {
                lTitle.Text = ActionTitle.Add(Category.FriendlyTypeName).FormatAsHtmlTitle();

                if (!string.IsNullOrEmpty(category.IconCssClass))
                {
                    lIcon.Text = String.Format("<i class='{0}'></i>", category.IconCssClass);
                }
                else
                {
                    lIcon.Text = "<i class='fa fa-square-o'></i>";
                }
            }

            SetEditMode(true);

            tbName.Text = category.Name;

            if (category.EntityTypeId != 0)
            {
                var entityType = EntityTypeCache.Read(category.EntityTypeId);
                lblEntityTypeName.Text = entityType.Name;
            }
            else
            {
                lblEntityTypeName.Text = string.Empty;
            }

            var        excludeCategoriesGuids = this.GetAttributeValue("ExcludeCategories").SplitDelimitedValues().AsGuidList();
            List <int> excludedCategoriesIds  = new List <int>();

            if (excludeCategoriesGuids != null && excludeCategoriesGuids.Any())
            {
                foreach (var excludeCategoryGuid in excludeCategoriesGuids)
                {
                    var excludedCategory = CategoryCache.Read(excludeCategoryGuid);
                    if (excludedCategory != null)
                    {
                        excludedCategoriesIds.Add(excludedCategory.Id);
                    }
                }
            }

            cpParentCategory.EntityTypeId = category.EntityTypeId;
            cpParentCategory.EntityTypeQualifierColumn = category.EntityTypeQualifierColumn;
            cpParentCategory.EntityTypeQualifierValue  = category.EntityTypeQualifierValue;
            cpParentCategory.ExcludedCategoryIds       = excludedCategoriesIds.AsDelimited(",");
            var rootCategory = CategoryCache.Read(this.GetAttributeValue("RootCategory").AsGuid());

            cpParentCategory.RootCategoryId = rootCategory != null ? rootCategory.Id : (int?)null;
            cpParentCategory.SetValue(category.ParentCategoryId);

            lblEntityTypeQualifierColumn.Visible = !string.IsNullOrWhiteSpace(category.EntityTypeQualifierColumn);
            lblEntityTypeQualifierColumn.Text    = category.EntityTypeQualifierColumn;
            lblEntityTypeQualifierValue.Visible  = !string.IsNullOrWhiteSpace(category.EntityTypeQualifierValue);
            lblEntityTypeQualifierValue.Text     = category.EntityTypeQualifierValue;
            tbIconCssClass.Text   = category.IconCssClass;
            tbHighlightColor.Text = category.HighlightColor;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="batch">The financial batch.</param>
        protected void ShowEditDetails(FinancialBatch batch)
        {
            if (batch == null || batch.Id == 0)
            {
                // if the "BatchNames" configuration setting is set, and this is a new batch present a DropDown of BatchNames instead of a text box
                var batchNamesDefinedTypeGuid = this.GetAttributeValue("BatchNames").AsGuidOrNull();
                dvpBatchName.Visible = false;
                tbName.Visible       = true;

                if (batchNamesDefinedTypeGuid.HasValue)
                {
                    var batchNamesDefinedType = DefinedTypeCache.Get(batchNamesDefinedTypeGuid.Value);
                    if (batchNamesDefinedType != null)
                    {
                        dvpBatchName.DefinedTypeId = batchNamesDefinedType.Id;
                        if (batchNamesDefinedType.DefinedValues.Any(a => !string.IsNullOrWhiteSpace(a.Value)))
                        {
                            dvpBatchName.Visible = true;
                            tbName.Visible       = false;
                        }
                    }
                }
            }

            if (batch != null)
            {
                hfBatchId.Value = batch.Id.ToString();
                string title = batch.Id > 0 ?
                               ActionTitle.Edit(FinancialBatch.FriendlyTypeName) :
                               ActionTitle.Add(FinancialBatch.FriendlyTypeName);

                SetHeadingInfo(batch, title);

                SetEditMode(true);

                tbName.Text = batch.Name;

                ddlStatus.BindToEnum <BatchStatus>();
                ddlStatus.SelectedIndex = (int)(BatchStatus)batch.Status;
                ddlStatus.Enabled       = true;
                if (batch.Status == BatchStatus.Closed)
                {
                    if (!batch.IsAuthorized("ReopenBatch", this.CurrentPerson))
                    {
                        ddlStatus.Enabled = false;
                    }
                }

                if (batch.IsAutomated == true && batch.Status == BatchStatus.Pending)
                {
                    ddlStatus.Enabled = false;
                }

                campCampus.Campuses = CampusCache.All();
                if (batch.CampusId.HasValue)
                {
                    campCampus.SetValue(batch.CampusId.Value);
                }

                tbControlAmount.Value   = batch.ControlAmount;
                nbControlItemCount.Text = batch.ControlItemCount.ToString();

                dtpStart.SelectedDateTime = batch.BatchStartDateTime;
                dtpEnd.SelectedDateTime   = batch.BatchEndDateTime;

                tbAccountingCode.Text = batch.AccountingSystemCode;
                tbNote.Text           = batch.Note;

                SetEditableForBatchStatus(ddlStatus.SelectedValueAsEnum <BatchStatus>());
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("siteId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            Site site = null;

            if (!itemKeyValue.Equals(0))
            {
                site = new SiteService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(Rock.Model.Site.FriendlyTypeName);
            }
            else
            {
                site = new Site {
                    Id = 0
                };
                site.SiteDomains  = new List <SiteDomain>();
                site.Theme        = CurrentPage.Site.Theme;
                lActionTitle.Text = ActionTitle.Add(Rock.Model.Site.FriendlyTypeName);
            }

            LoadDropDowns();

            hfSiteId.Value = site.Id.ToString();

            tbSiteName.Text    = site.Name;
            tbDescription.Text = site.Description;
            ddlTheme.SetValue(site.Theme);
            ppDefaultPage.SetValue(site.DefaultPage);
            tbLoginPageReference.Text = site.LoginPageReference;

            tbSiteDomains.Text               = string.Join("\n", site.SiteDomains.Select(dom => dom.Domain).ToArray());
            tbFaviconUrl.Text                = site.FaviconUrl;
            tbAppleTouchIconUrl.Text         = site.AppleTouchIconUrl;
            tbFacebookAppId.Text             = site.FacebookAppId;
            tbFacebookAppSecret.Text         = site.FacebookAppSecret;
            tbRegistrationPageReference.Text = site.RegistrationPageReference;
            tbErrorPage.Text = site.ErrorPage;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Rock.Model.Site.FriendlyTypeName);
            }

            if (site.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Rock.Model.Site.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Rock.Model.Site.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbSiteName.ReadOnly                  = readOnly;
            tbDescription.ReadOnly               = readOnly;
            ddlTheme.Enabled                     = !readOnly;
            tbLoginPageReference.ReadOnly        = readOnly;
            ppDefaultPage.Enabled                = !readOnly;
            tbSiteDomains.ReadOnly               = readOnly;
            tbFaviconUrl.ReadOnly                = readOnly;
            tbAppleTouchIconUrl.ReadOnly         = readOnly;
            tbFacebookAppId.ReadOnly             = readOnly;
            tbFacebookAppSecret.ReadOnly         = readOnly;
            tbRegistrationPageReference.ReadOnly = readOnly;
            tbErrorPage.ReadOnly                 = readOnly;

            btnSave.Visible = !readOnly;
        }
        private void ShowDetail()
        {
            pnlDetails.Visible = true;

            int?referralAgencyId  = PageParameter("referralAgencyId").AsInteger(false);
            int?campusId          = PageParameter("campusId").AsInteger(false);
            int?agencyTypeValueId = PageParameter("agencyTypeId").AsInteger(false);

            ReferralAgency referralAgency = null;

            if (referralAgencyId.HasValue)
            {
                referralAgency = _referralAgency ?? new ReferralAgencyService(new SampleProjectContext()).Get(referralAgencyId.Value);
            }

            if (referralAgency != null)
            {
                RockPage.PageTitle = referralAgency.Name;
                lActionTitle.Text  = ActionTitle.Edit(referralAgency.Name).FormatAsHtmlTitle();
            }
            else
            {
                referralAgency = new ReferralAgency {
                    Id = 0, CampusId = campusId, AgencyTypeValueId = agencyTypeValueId
                };
                RockPage.PageTitle = ActionTitle.Add(ReferralAgency.FriendlyTypeName);
                lActionTitle.Text  = ActionTitle.Add(ReferralAgency.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfReferralAgencyId.Value = referralAgency.Id.ToString();
            tbName.Text               = referralAgency.Name;
            tbDescription.Text        = referralAgency.Description;
            cpCampus.SelectedCampusId = referralAgency.CampusId;
            ddlAgencyType.SetValue(referralAgency.AgencyTypeValueId);
            tbContactName.Text = referralAgency.ContactName;
            tbPhoneNumber.Text = referralAgency.PhoneNumber;
            tbWebsite.Text     = referralAgency.Website;

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Rock.Security.Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(ReferralAgency.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(ReferralAgency.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            tbContactName.ReadOnly = readOnly;
            tbPhoneNumber.ReadOnly = readOnly;
            tbWebsite.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int DeviceId)
        {
            pnlDetails.Visible = true;
            Device Device = null;

            var rockContext = new RockContext();

            if (!DeviceId.Equals(0))
            {
                Device            = new DeviceService(rockContext).Get(DeviceId);
                lActionTitle.Text = ActionTitle.Edit(Device.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (Device == null)
            {
                Device = new Device {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Device.FriendlyTypeName).FormatAsHtmlTitle();
            }

            LoadDropDowns();

            hfDeviceId.Value = Device.Id.ToString();

            tbName.Text        = Device.Name;
            tbDescription.Text = Device.Description;
            tbIpAddress.Text   = Device.IPAddress;
            ddlDeviceType.SetValue(Device.DeviceTypeValueId);
            ddlPrintTo.SetValue(Device.PrintToOverride.ConvertToInt().ToString());
            ddlPrinter.SetValue(Device.PrinterDeviceId);
            ddlPrintFrom.SetValue(Device.PrintFrom.ConvertToInt().ToString());

            SetPrinterVisibility();
            SetPrinterSettingsVisibility();

            string orgLocGuid = GlobalAttributesCache.Read().GetValue("OrganizationAddress");

            if (!string.IsNullOrWhiteSpace(orgLocGuid))
            {
                Guid locGuid = Guid.Empty;
                if (Guid.TryParse(orgLocGuid, out locGuid))
                {
                    var location = new LocationService(rockContext).Get(locGuid);
                    if (location != null)
                    {
                        geopPoint.CenterPoint = location.GeoPoint;
                        geopFence.CenterPoint = location.GeoPoint;
                    }
                }
            }

            if (Device.Location != null)
            {
                geopPoint.SetValue(Device.Location.GeoPoint);
                geopFence.SetValue(Device.Location.GeoFence);
            }

            Locations = new Dictionary <int, string>();
            foreach (var location in Device.Locations)
            {
                string path           = location.Name;
                var    parentLocation = location.ParentLocation;
                while (parentLocation != null)
                {
                    path           = parentLocation.Name + " > " + path;
                    parentLocation = parentLocation.ParentLocation;
                }
                Locations.Add(location.Id, path);
            }
            BindLocations();

            Guid mapStyleValueGuid = GetAttributeValue("MapStyle").AsGuid();

            geopPoint.MapStyleValueGuid = mapStyleValueGuid;
            geopFence.MapStyleValueGuid = mapStyleValueGuid;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Device.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Device.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            tbIpAddress.ReadOnly   = readOnly;
            ddlDeviceType.Enabled  = !readOnly;
            ddlPrintTo.Enabled     = !readOnly;
            ddlPrinter.Enabled     = !readOnly;
            ddlPrintFrom.Enabled   = !readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="group">The group.</param>
        private void ShowEditDetails(Rock.Model.Site site)
        {
            if (site.Id == 0)
            {
                nbDefaultPageNotice.Visible = true;
                lReadOnlyTitle.Text         = ActionTitle.Add(Rock.Model.Site.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                nbDefaultPageNotice.Visible = false;
                lReadOnlyTitle.Text         = site.Name.FormatAsHtmlTitle();
            }

            SetEditMode(true);

            LoadDropDowns();

            tbSiteName.ReadOnly = site.IsSystem;
            tbSiteName.Text     = site.Name;

            tbDescription.ReadOnly = site.IsSystem;
            tbDescription.Text     = site.Description;

            ddlTheme.Enabled = !site.IsSystem;
            ddlTheme.SetValue(site.Theme);

            if (site.DefaultPageRoute != null)
            {
                ppDefaultPage.SetValue(site.DefaultPageRoute);
            }
            else
            {
                ppDefaultPage.SetValue(site.DefaultPage);
            }

            if (site.LoginPageRoute != null)
            {
                ppLoginPage.SetValue(site.LoginPageRoute);
            }
            else
            {
                ppLoginPage.SetValue(site.LoginPage);
            }

            if (site.RegistrationPageRoute != null)
            {
                ppRegistrationPage.SetValue(site.RegistrationPageRoute);
            }
            else
            {
                ppRegistrationPage.SetValue(site.RegistrationPage);
            }

            if (site.PageNotFoundPageRoute != null)
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPageRoute);
            }
            else
            {
                ppPageNotFoundPage.SetValue(site.PageNotFoundPage);
            }

            tbErrorPage.Text = site.ErrorPage;

            tbSiteDomains.Text       = string.Join("\n", site.SiteDomains.Select(dom => dom.Domain).ToArray());
            tbGoogleAnalytics.Text   = site.GoogleAnalyticsCode;
            tbFacebookAppId.Text     = site.FacebookAppId;
            tbFacebookAppSecret.Text = site.FacebookAppSecret;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "blockTypeId")
            {
                return;
            }

            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            BlockType blockType = null;

            if (!itemKeyValue.Equals(0))
            {
                blockType         = new BlockTypeService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                lstPages.Visible  = true;
                lblStatus.Visible = true;
            }
            else
            {
                blockType = new BlockType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                lstPages.Visible  = false;
                lblStatus.Visible = false;
            }

            hfBlockTypeId.Value = blockType.Id.ToString();
            tbName.Text         = blockType.Name;
            tbPath.Text         = blockType.Path;
            tbDescription.Text  = blockType.Description;
            foreach (var fullPageName in blockType.Blocks.ToList().Where(a => a.Page != null).Select(a => GetFullyQualifiedPageName(a.Page)).OrderBy(a => a))
            {
                lstPages.Items.Add(fullPageName);
            }

            if (lstPages.Items.Count == 0)
            {
                lstPages.Items.Add("No pages are currently using this block");
            }

            string blockPath = Request.MapPath(blockType.Path);

            if (!System.IO.File.Exists(blockPath))
            {
                lblStatus.Text = string.Format("<span class='label label-danger'>The file '{0}' [{1}] does not exist.</span>", blockType.Path, blockType.Guid);
            }
            else
            {
                lblStatus.Text = "<span class='label label-success'>Block exists on the file system.</span>";
            }

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BlockType.FriendlyTypeName);
            }

            if (blockType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(BlockType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbPath.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="binaryFileTypeId">The binary file type identifier.</param>
        public void ShowDetail(int binaryFileTypeId)
        {
            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            var rockContext = new RockContext();

            if (!binaryFileTypeId.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService(rockContext).Get(binaryFileTypeId);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (binaryFileType == null)
            {
                binaryFileType = new BinaryFileType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            BinaryFileAttributesState = new ViewStateList <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text                    = binaryFileType.Name;
            tbDescription.Text             = binaryFileType.Description;
            tbIconCssClass.Text            = binaryFileType.IconCssClass;
            cbAllowCaching.Checked         = binaryFileType.AllowCaching;
            cbRequiresViewSecurity.Checked = binaryFileType.RequiresViewSecurity;

            nbMaxWidth.Text  = binaryFileType.MaxWidth.ToString();
            nbMaxHeight.Text = binaryFileType.MaxHeight.ToString();

            ddlPreferredFormat.BindToEnum <PreferredFormat>();
            ddlPreferredFormat.SetValue((int)binaryFileType.PreferredFormat);

            ddlPreferredResolution.BindToEnum <PreferredResolution>();
            ddlPreferredResolution.SetValue((int)binaryFileType.PreferredResolution);

            ddlPreferredColorDepth.BindToEnum <PreferredColorDepth>();
            ddlPreferredColorDepth.SetValue((int)binaryFileType.PreferredColorDepth);

            cbPreferredRequired.Checked = binaryFileType.PreferredRequired;

            if (binaryFileType.StorageEntityType != null)
            {
                cpStorageType.SelectedValue = binaryFileType.StorageEntityType.Guid.ToString().ToUpper();
            }

            AttributeService attributeService = new AttributeService(rockContext);

            string qualifierValue          = binaryFileType.Id.ToString();
            var    qryBinaryFileAttributes = attributeService.GetByEntityTypeId(new BinaryFile().TypeId).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState.AddAll(qryBinaryFileAttributes.ToList());
            BindBinaryFileAttributesGrid();

            // render UI based on Authorized and IsSystem
            bool readOnly       = false;
            bool restrictedEdit = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BinaryFileType.FriendlyTypeName);
            }

            if (binaryFileType.IsSystem)
            {
                restrictedEdit         = true;
                nbEditModeMessage.Text = EditModeMessage.System(BinaryFileType.FriendlyTypeName);
            }

            phAttributes.Controls.Clear();
            binaryFileType.LoadAttributes();

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(binaryFileType, phAttributes);
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFileType, phAttributes, true);
            }

            // the only thing we'll restrict for restrictedEdit is the Name (plus they won't be able to remove Attributes that are marked as IsSystem
            tbName.ReadOnly = readOnly || restrictedEdit;

            gBinaryFileAttributes.Enabled = !readOnly;
            gBinaryFileAttributes.Columns.OfType <EditField>().First().Visible = !readOnly;
            gBinaryFileAttributes.Actions.ShowAdd = !readOnly;

            // allow these to be edited in restricted edit mode if not readonly
            tbDescription.ReadOnly         = readOnly;
            tbIconCssClass.ReadOnly        = readOnly;
            cbAllowCaching.Enabled         = !readOnly;
            cbRequiresViewSecurity.Enabled = !readOnly;
            cpStorageType.Enabled          = !readOnly;
            nbMaxWidth.ReadOnly            = readOnly;
            nbMaxHeight.ReadOnly           = readOnly;
            ddlPreferredFormat.Enabled     = !readOnly;
            ddlPreferredResolution.Enabled = !readOnly;
            ddlPreferredColorDepth.Enabled = !readOnly;
            cbPreferredRequired.Enabled    = !readOnly;
            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="pledgeId">The pledge identifier.</param>
        public void ShowDetail(int pledgeId)
        {
            pnlDetails.Visible = true;
            var frequencyTypeGuid = new Guid(Rock.SystemGuid.DefinedType.FINANCIAL_FREQUENCY);

            dvpFrequencyType.DefinedTypeId = DefinedTypeCache.Get(frequencyTypeGuid).Id;

            using (var rockContext = new RockContext())
            {
                FinancialPledge pledge = null;

                if (pledgeId > 0)
                {
                    pledge            = new FinancialPledgeService(rockContext).Get(pledgeId);
                    lActionTitle.Text = ActionTitle.Edit(FinancialPledge.FriendlyTypeName).FormatAsHtmlTitle();
                    pdAuditDetails.SetEntity(pledge, ResolveRockUrl("~"));
                }

                if (pledge == null)
                {
                    pledge            = new FinancialPledge();
                    lActionTitle.Text = ActionTitle.Add(FinancialPledge.FriendlyTypeName).FormatAsHtmlTitle();
                    // hide the panel drawer that show created and last modified dates
                    pdAuditDetails.Visible = false;
                }

                var isReadOnly  = !IsUserAuthorized(Authorization.EDIT);
                var isNewPledge = pledge.Id == 0;

                hfPledgeId.Value = pledge.Id.ToString();
                if (pledge.PersonAlias != null)
                {
                    ppPerson.SetValue(pledge.PersonAlias.Person);
                }
                else
                {
                    ppPerson.SetValue(null);
                }
                ppPerson.Enabled = !isReadOnly;

                GroupType groupType     = null;
                Guid?     groupTypeGuid = GetAttributeValue("SelectGroupType").AsGuidOrNull();
                if (groupTypeGuid.HasValue)
                {
                    groupType = new GroupTypeService(rockContext).Get(groupTypeGuid.Value);
                }

                if (groupType != null)
                {
                    ddlGroup.Label   = groupType.Name;
                    ddlGroup.Visible = true;
                    LoadGroups(pledge.GroupId);
                    ddlGroup.Enabled = !isReadOnly;
                }
                else
                {
                    ddlGroup.Visible = false;
                }

                apAccount.SetValue(pledge.Account);
                apAccount.Enabled = !isReadOnly;
                tbAmount.Text     = !isNewPledge?pledge.TotalAmount.ToString() : string.Empty;

                tbAmount.ReadOnly = isReadOnly;

                dpDateRange.LowerValue = pledge.StartDate;
                dpDateRange.UpperValue = pledge.EndDate;
                dpDateRange.ReadOnly   = isReadOnly;

                dvpFrequencyType.SelectedValue = !isNewPledge?pledge.PledgeFrequencyValueId.ToString() : string.Empty;

                dvpFrequencyType.Enabled = !isReadOnly;

                if (isReadOnly)
                {
                    nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(FinancialPledge.FriendlyTypeName);
                    lActionTitle.Text      = ActionTitle.View(BlockType.FriendlyTypeName);
                    btnCancel.Text         = "Close";
                }

                btnSave.Visible = !isReadOnly;
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("WorkflowTriggerId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            WorkflowTrigger WorkflowTrigger = null;

            if (!itemKeyValue.Equals(0))
            {
                WorkflowTrigger   = new WorkflowTriggerService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(WorkflowTrigger.FriendlyTypeName);
            }
            else
            {
                WorkflowTrigger = new WorkflowTrigger {
                    Id = 0, WorkflowTriggerType = WorkflowTriggerType.PostSave
                };
                lActionTitle.Text = ActionTitle.Add(WorkflowTrigger.FriendlyTypeName);
            }

            LoadDropDowns();

            hfWorkflowTriggerId.Value = WorkflowTrigger.Id.ToString();
            ddlEntityType.SetValue(WorkflowTrigger.EntityTypeId);
            LoadColumnNames();
            tbQualifierValue.Text = WorkflowTrigger.EntityTypeQualifierValue;
            ddlWorkflowType.SetValue(WorkflowTrigger.WorkflowTypeId);
            rblTriggerType.SelectedValue = WorkflowTrigger.WorkflowTriggerType.ConvertToInt().ToString();
            tbWorkflowName.Text          = WorkflowTrigger.WorkflowName ?? string.Empty;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(WorkflowTrigger.FriendlyTypeName);
            }

            if (WorkflowTrigger.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(WorkflowTrigger.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(WorkflowTrigger.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            ddlEntityType.Enabled      = !readOnly;
            ddlQualifierColumn.Enabled = !readOnly;
            tbQualifierValue.ReadOnly  = readOnly;
            ddlWorkflowType.Enabled    = !readOnly;
            rblTriggerType.Enabled     = !readOnly;
            tbWorkflowName.ReadOnly    = readOnly;

            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="blockTypeId">The block type identifier.</param>
        public void ShowDetail(int blockTypeId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            BlockType blockType = null;

            if (!blockTypeId.Equals(0))
            {
                blockType         = new BlockTypeService(new RockContext()).Get(blockTypeId);
                lActionTitle.Text = ActionTitle.Edit(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                lPages.Visible    = true;
                lblStatus.Visible = true;
                pdAuditDetails.SetEntity(blockType, ResolveRockUrl("~"));
            }

            if (blockType == null)
            {
                blockType = new BlockType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                lPages.Visible    = false;
                lblStatus.Visible = false;
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfBlockTypeId.Value = blockType.Id.ToString();
            tbName.Text         = blockType.Name;
            tbPath.Text         = blockType.Path;
            tbDescription.Text  = blockType.Description;

            try
            {
                var  blockControlType       = System.Web.Compilation.BuildManager.GetCompiledType(blockType.Path);
                bool dynamicAttributesBlock = typeof(Rock.Web.UI.IDynamicAttributesBlock).IsAssignableFrom(blockControlType);
                hfIsDynamicAttributesBlock.Value = dynamicAttributesBlock.ToTrueFalse();
            }
            catch
            {
                // if the block can't compile, ignore
            }

            lReadonlySummary.Text = new DescriptionList().Add("Name", blockType.Name).Add("Path", blockType.Path).Add("Description", blockType.Description).Html;

            StringBuilder sb = new StringBuilder();

            foreach (var fullPageName in blockType.Blocks.ToList().Where(a => a.Page != null).Select(a => GetFullyQualifiedPageName(a.Page)).OrderBy(a => a))
            {
                sb.Append(fullPageName);
            }

            if (sb.Length == 0)
            {
                lPages.Text = "<span class='text-muted'><em>No pages are currently using this block</em></muted>";
            }
            else
            {
                lPages.Text = string.Format("<ul>{0}</ul>", sb.ToString());
            }

            string blockPath = Request.MapPath(blockType.Path);

            if (!System.IO.File.Exists(blockPath))
            {
                lblStatus.Text = string.Format("<span class='label label-danger'>The file '{0}' [{1}] does not exist.</span>", blockType.Path, blockType.Guid);
            }
            else
            {
                lblStatus.Text = "<span class='label label-success'>Block exists on the file system.</span>";
            }

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(BlockType.FriendlyTypeName);
            }

            if (blockType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(BlockType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(BlockType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbPath.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnEdit.Visible     = !readOnly;
            pnlEdit.Visible     = false;
            pnlReadOnly.Visible = true;
            btnSave.Visible     = false;
            btnCancel.Visible   = false;

            BindBlockTypeAttributesGrid();
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="marketingCampaignId">The marketing campaign id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?marketingCampaignId)
        {
            pnlDetails.Visible = false;
            if (!itemKey.Equals("marketingCampaignAdId"))
            {
                return;
            }

            MarketingCampaignAd marketingCampaignAd = null;

            btnApproveAd.Visible = IsUserAuthorized("Approve");
            btnDenyAd.Visible    = IsUserAuthorized("Approve");

            if (!itemKeyValue.Equals(0))
            {
                marketingCampaignAd = new MarketingCampaignAdService().Get(itemKeyValue);
                marketingCampaignAd.LoadAttributes();
            }
            else
            {
                // only create a new marketing Campaign Ad if the marketingCampaignId was specified
                if (marketingCampaignId != null)
                {
                    marketingCampaignAd = new MarketingCampaignAd {
                        Id = 0, MarketingCampaignAdStatus = MarketingCampaignAdStatus.PendingApproval
                    };
                    marketingCampaignAd.MarketingCampaignId = marketingCampaignId.Value;
                    marketingCampaignAd.MarketingCampaign   = new MarketingCampaignService().Get(marketingCampaignAd.MarketingCampaignId);
                }
            }

            if (marketingCampaignAd == null)
            {
                return;
            }

            pnlDetails.Visible            = true;
            hfMarketingCampaignAdId.Value = marketingCampaignAd.Id.ToString();
            hfMarketingCampaignId.Value   = marketingCampaignAd.MarketingCampaignId.ToString();

            if (marketingCampaignAd.Id.Equals(0))
            {
                lActionTitleAd.Text = ActionTitle.Add("Marketing Ad for " + marketingCampaignAd.MarketingCampaign.Title);
            }
            else
            {
                lActionTitleAd.Text = ActionTitle.Edit("Marketing Ad for " + marketingCampaignAd.MarketingCampaign.Title);
            }

            LoadDropDowns();
            ddlMarketingCampaignAdType.SetValue(marketingCampaignAd.MarketingCampaignAdTypeId);
            tbPriority.Text = marketingCampaignAd.Priority.ToString();

            SetApprovalValues(marketingCampaignAd.MarketingCampaignAdStatus, new PersonService().Get(marketingCampaignAd.MarketingCampaignStatusPersonId ?? 0));

            if (itemKeyValue.Equals(0))
            {
                tbAdDateRangeStartDate.SelectedDate = null;
                tbAdDateRangeEndDate.SelectedDate   = null;
            }
            else
            {
                tbAdDateRangeStartDate.SelectedDate = marketingCampaignAd.StartDate;
                tbAdDateRangeEndDate.SelectedDate   = marketingCampaignAd.EndDate;
            }

            tbUrl.Text = marketingCampaignAd.Url;

            LoadAdAttributes(marketingCampaignAd, true, true);

            pnlDetails.Visible = true;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="serviceJobId">The service job identifier.</param>
        public void ShowDetail(int serviceJobId)
        {
            pnlDetails.Visible = true;
            LoadDropDowns();

            // Load depending on Add(0) or Edit
            ServiceJob job = null;

            if (!serviceJobId.Equals(0))
            {
                job = new ServiceJobService(new RockContext()).Get(serviceJobId);
                lActionTitle.Text = ActionTitle.Edit(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(job, ResolveRockUrl("~"));
            }

            if (job == null)
            {
                job = new ServiceJob {
                    Id = 0, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            hfId.Value         = job.Id.ToString();
            tbName.Text        = job.Name;
            tbDescription.Text = job.Description;
            cbActive.Checked   = job.IsActive.HasValue ? job.IsActive.Value : false;
            if (job.Class.IsNotNullOrWhitespace())
            {
                if (ddlJobTypes.Items.FindByValue(job.Class) == null)
                {
                    nbJobTypeError.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Danger;
                    nbJobTypeError.Text    = "Unable to find Job Type: " + job.Class;
                    nbJobTypeError.Visible = true;
                }
            }

            ddlJobTypes.SetValue(job.Class);

            tbNotificationEmails.Text = job.NotificationEmails;
            ddlNotificationStatus.SetValue((int)job.NotificationStatus);
            tbCronExpression.Text = job.CronExpression;

            if (job.Id == 0)
            {
                job.Class = ddlJobTypes.SelectedValue;
                lCronExpressionDesc.Visible = false;
                lLastStatusMessage.Visible  = false;
            }
            else
            {
                lCronExpressionDesc.Text = ExpressionDescriptor.GetDescription(job.CronExpression, new Options {
                    ThrowExceptionOnParseError = false
                });
                lCronExpressionDesc.Visible = true;

                lLastStatusMessage.Text    = job.LastStatusMessage.ConvertCrLfToHtmlBr();
                lLastStatusMessage.Visible = true;
            }

            job.LoadAttributes();
            phAttributes.Controls.Clear();
            Rock.Attribute.Helper.AddEditControls(job, phAttributes, true, BlockValidationGroup);

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(ServiceJob.FriendlyTypeName);
            }

            if (job.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(ServiceJob.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(job, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
                tbCronExpression.Text        = job.CronExpression;
            }

            tbName.ReadOnly               = readOnly || job.IsSystem;
            tbDescription.ReadOnly        = readOnly || job.IsSystem;
            cbActive.Enabled              = !(readOnly || job.IsSystem);
            ddlJobTypes.Enabled           = !(readOnly || job.IsSystem);
            tbNotificationEmails.ReadOnly = readOnly;
            ddlNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly || job.IsSystem;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="contentTypeId">The content type identifier.</param>
        public void ShowDetail(int contentTypeId)
        {
            var rockContext = new RockContext();
            ContentChannelType contentType = null;

            if (!contentTypeId.Equals(0))
            {
                contentType = GetContentChannelType(contentTypeId);
                pdAuditDetails.SetEntity(contentType, ResolveRockUrl("~"));
            }
            if (contentType == null)
            {
                contentType = new ContentChannelType {
                    Id = 0
                };
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            string title = contentType.Id > 0 ?
                           ActionTitle.Edit(ContentChannelType.FriendlyTypeName) :
                           ActionTitle.Add(ContentChannelType.FriendlyTypeName);

            lTitle.Text = title.FormatAsHtmlTitle();

            hfId.Value = contentType.Id.ToString();

            tbName.Text = contentType.Name;
            ddlDateRangeType.BindToEnum <ContentChannelDateType>();
            ddlDateRangeType.SetValue((int)contentType.DateRangeType);
            ddlDateRangeType_SelectedIndexChanged(null, null);

            cbIncludeTime.Checked         = contentType.IncludeTime;
            cbDisablePriority.Checked     = contentType.DisablePriority;
            cbDisableContentField.Checked = contentType.DisableContentField;
            cbDisableStatus.Checked       = contentType.DisableStatus;
            cbShowInChannelList.Checked   = contentType.ShowInChannelList;
            // load attribute data
            ChannelAttributesState = new List <Attribute>();
            ItemAttributesState    = new List <Attribute>();

            AttributeService attributeService = new AttributeService(new RockContext());

            string qualifierValue = contentType.Id.ToString();

            attributeService.GetByEntityTypeId(new ContentChannel().TypeId, true).AsQueryable()
            .Where(a =>
                   a.EntityTypeQualifierColumn.Equals("ContentChannelTypeId", StringComparison.OrdinalIgnoreCase) &&
                   a.EntityTypeQualifierValue.Equals(qualifierValue))
            .ToList()
            .ForEach(a => ChannelAttributesState.Add(a));

            // Set order
            int newOrder = 0;

            ChannelAttributesState.ForEach(a => a.Order = newOrder++);

            BindChannelAttributesGrid();

            attributeService.GetByEntityTypeId(new ContentChannelItem().TypeId, true).AsQueryable()
            .Where(a =>
                   a.EntityTypeQualifierColumn.Equals("ContentChannelTypeId", StringComparison.OrdinalIgnoreCase) &&
                   a.EntityTypeQualifierValue.Equals(qualifierValue))
            .ToList()
            .ForEach(a => ItemAttributesState.Add(a));

            // Set order
            newOrder = 0;
            ItemAttributesState.ForEach(a => a.Order = newOrder++);

            BindItemAttributesGrid();
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="workflowTriggerId">The workflow trigger identifier.</param>
        public void ShowDetail(int workflowTriggerId)
        {
            pnlDetails.Visible = true;
            WorkflowTrigger workflowTrigger = null;

            if (!workflowTriggerId.Equals(0))
            {
                workflowTrigger   = new WorkflowTriggerService(new RockContext()).Get(workflowTriggerId);
                lActionTitle.Text = ActionTitle.Edit(WorkflowTrigger.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (workflowTrigger == null)
            {
                workflowTrigger = new WorkflowTrigger {
                    Id = 0, WorkflowTriggerType = WorkflowTriggerType.PostSave, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(WorkflowTrigger.FriendlyTypeName).FormatAsHtmlTitle();
            }

            LoadDropDowns();

            hfWorkflowTriggerId.Value = workflowTrigger.Id.ToString();
            ddlEntityType.SetValue(workflowTrigger.EntityTypeId);
            LoadColumnNames();
            ddlQualifierColumn.SetValue(workflowTrigger.EntityTypeQualifierColumn);
            ShowQualifierValues(workflowTrigger);
            ddlWorkflowType.SetValue(workflowTrigger.WorkflowTypeId);
            rblTriggerType.SelectedValue = workflowTrigger.WorkflowTriggerType.ConvertToInt().ToString();
            tbWorkflowName.Text          = workflowTrigger.WorkflowName ?? string.Empty;
            cbIsActive.Checked           = workflowTrigger.IsActive ?? false;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(WorkflowTrigger.FriendlyTypeName);
            }

            if (workflowTrigger.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(WorkflowTrigger.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(WorkflowTrigger.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            ddlEntityType.Enabled      = !readOnly;
            ddlQualifierColumn.Enabled = !readOnly;
            tbQualifierValue.ReadOnly  = readOnly;
            ddlWorkflowType.Enabled    = !readOnly;
            rblTriggerType.Enabled     = !readOnly;
            tbWorkflowName.ReadOnly    = readOnly;
            cbIsActive.Enabled         = !readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int signId)
        {
            pnlDetails.Visible = true;
            Sign sign = null;

            var rockContext = new RockContext();

            if (!signId.Equals(0))
            {
                sign = new SignService(rockContext).Get(signId);
                lActionTitle.Text = ActionTitle.Edit(Sign.FriendlyTypeName).FormatAsHtmlTitle();
                SignCategories    = new Dictionary <int, string>();
                foreach (var signCategory in sign.SignCategories)
                {
                    SignCategories.Add(signCategory.Id, signCategory.Name);
                }
            }

            if (sign == null)
            {
                sign = new Sign {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(Sign.FriendlyTypeName).FormatAsHtmlTitle();
                sign.Port         = "9107";
            }

            hfSignId.Value = sign.Id.ToString();

            tbName.Text        = sign.Name;
            tbPIN.Text         = sign.PIN;
            tbDescription.Text = sign.Description;
            tbIPAddress.Text   = sign.IPAddress;

            if (sign.Port.IsNullOrWhiteSpace())
            {
                sign.Port = "9107";
            }
            tbPort.Text = sign.Port;

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Sign.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(Sign.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbPIN.ReadOnly         = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;

            BindSignCategories();
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="emailTemplateId">The email template id.</param>
        protected void ShowEdit(int emailTemplateId)
        {
            var globalAttributes = GlobalAttributesCache.Get();

            string globalFromName = globalAttributes.GetValue("OrganizationName");

            tbFromName.Help = string.Format("If a From Name value is not entered the 'Organization Name' Global Attribute value of '{0}' will be used when this template is sent. <small><span class='tip tip-lava'></span></small>", globalFromName);

            string globalFrom = globalAttributes.GetValue("OrganizationEmail");

            tbFrom.Help = string.Format("If a From Address value is not entered the 'Organization Email' Global Attribute value of '{0}' will be used when this template is sent. <small><span class='tip tip-lava'></span></small>", globalFrom);

            tbTo.Help = "You can specify multiple email addresses by separating them with a comma.";

            SystemCommunicationService emailTemplateService = new SystemCommunicationService(new RockContext());
            SystemCommunication        emailTemplate        = emailTemplateService.Get(emailTemplateId);

            bool showMessagePreview = false;

            var pushCommunication = new CommunicationDetails();

            if (emailTemplate != null)
            {
                pdAuditDetails.Visible = true;
                pdAuditDetails.SetEntity(emailTemplate, ResolveRockUrl("~"));

                lActionTitle.Text       = ActionTitle.Edit(SystemCommunication.FriendlyTypeName).FormatAsHtmlTitle();
                hfEmailTemplateId.Value = emailTemplate.Id.ToString();

                cbIsActive.Checked = emailTemplate.IsActive.GetValueOrDefault();
                cpCategory.SetValue(emailTemplate.CategoryId);
                tbTitle.Text         = emailTemplate.Title;
                tbFromName.Text      = emailTemplate.FromName;
                tbFrom.Text          = emailTemplate.From;
                tbTo.Text            = emailTemplate.To;
                tbCc.Text            = emailTemplate.Cc;
                tbBcc.Text           = emailTemplate.Bcc;
                tbSubject.Text       = emailTemplate.Subject;
                ceEmailTemplate.Text = emailTemplate.Body;

                pushCommunication = new CommunicationDetails
                {
                    PushData = emailTemplate.PushData,
                    PushImageBinaryFileId = emailTemplate.PushImageBinaryFileId,
                    PushMessage           = emailTemplate.PushMessage,
                    PushTitle             = emailTemplate.PushTitle,
                    PushOpenMessage       = emailTemplate.PushOpenMessage,
                    PushOpenAction        = emailTemplate.PushOpenAction
                };

                nbTemplateHelp.InnerHtml = CommunicationTemplateHelper.GetTemplateHelp(false);

                kvlMergeFields.Value = emailTemplate.LavaFields.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");

                hfShowAdditionalFields.Value = (!string.IsNullOrEmpty(emailTemplate.Cc) || !string.IsNullOrEmpty(emailTemplate.Bcc)).ToTrueFalse().ToLower();

                cbCssInliningEnabled.Checked = emailTemplate.CssInliningEnabled;

                showMessagePreview = true;
            }
            else
            {
                pdAuditDetails.Visible  = false;
                lActionTitle.Text       = ActionTitle.Add(SystemCommunication.FriendlyTypeName).FormatAsHtmlTitle();
                hfEmailTemplateId.Value = 0.ToString();

                cbIsActive.Checked = true;
                cpCategory.SetValue(( int? )null);
                tbTitle.Text         = string.Empty;
                tbFromName.Text      = string.Empty;
                tbFrom.Text          = string.Empty;
                tbTo.Text            = string.Empty;
                tbCc.Text            = string.Empty;
                tbBcc.Text           = string.Empty;
                tbSubject.Text       = string.Empty;
                ceEmailTemplate.Text = string.Empty;
            }

            var pushNotificationControl = phPushNotification.Controls[0] as PushNotification;

            if (pushNotificationControl != null)
            {
                pushNotificationControl.SetFromCommunication(pushCommunication);
            }

            SetEmailMessagePreviewModeEnabled(showMessagePreview);

            LoadDropDowns();

            // SMS Fields
            mfpSMSMessage.MergeFields.Clear();
            mfpSMSMessage.MergeFields.Add("GlobalAttribute");
            mfpSMSMessage.MergeFields.Add("Rock.Model.Person");

            if (emailTemplate != null)
            {
                dvpSMSFrom.SetValue(emailTemplate.SMSFromDefinedValueId);
                tbSMSTextMessage.Text = emailTemplate.SMSMessage;
            }
        }
Ejemplo n.º 26
0
        public void ShowDetail(int contentItemId, int?contentChannelId)
        {
            bool canEdit = IsUserAuthorized(Authorization.EDIT);

            hfId.Value        = contentItemId.ToString();
            hfChannelId.Value = contentChannelId.HasValue ? contentChannelId.Value.ToString() : string.Empty;

            ContentChannelItem contentItem = GetContentItem();

            if (contentItem == null)
            {
                // this block requires a valid ContentChannel in order to know which channel the ContentChannelItem belongs to, so if ContentChannel wasn't specified, don't show this block
                this.Visible = false;
                return;
            }

            if (contentItem.ContentChannel.IsTaggingEnabled)
            {
                taglTags.EntityTypeId = EntityTypeCache.Read(typeof(ContentChannelItem)).Id;
                taglTags.CategoryGuid = (contentItem.ContentChannel != null && contentItem.ContentChannel.ItemTagCategory != null) ?
                                        contentItem.ContentChannel.ItemTagCategory.Guid : (Guid?)null;
                taglTags.EntityGuid = contentItem.Guid;
                taglTags.DelaySave  = true;
                taglTags.GetTagValues(CurrentPersonId);
                rcwTags.Visible = true;
            }
            else
            {
                rcwTags.Visible = false;
            }

            pdAuditDetails.SetEntity(contentItem, ResolveRockUrl("~"));

            if (contentItem != null &&
                contentItem.ContentChannelType != null &&
                contentItem.ContentChannel != null &&
                (canEdit || contentItem.IsAuthorized(Authorization.EDIT, CurrentPerson)))
            {
                hfIsDirty.Value = "false";

                ShowApproval(contentItem);

                pnlEditDetails.Visible = true;

                // show/hide the delete button
                lbDelete.Visible = (GetAttributeValue("ShowDeleteButton").AsBoolean() && contentItem.Id != 0);

                hfId.Value        = contentItem.Id.ToString();
                hfChannelId.Value = contentItem.ContentChannelId.ToString();

                string cssIcon = contentItem.ContentChannel.IconCssClass;
                if (string.IsNullOrWhiteSpace(cssIcon))
                {
                    cssIcon = "fa fa-certificate";
                }
                lIcon.Text = string.Format("<i class='{0}'></i>", cssIcon);

                string title = contentItem.Id > 0 ?
                               ActionTitle.Edit(ContentChannelItem.FriendlyTypeName) :
                               ActionTitle.Add(ContentChannelItem.FriendlyTypeName);
                lTitle.Text = title.FormatAsHtmlTitle();

                hlContentChannel.Text = contentItem.ContentChannel.Name;

                hlStatus.Visible = contentItem.ContentChannel.RequiresApproval && !contentItem.ContentChannelType.DisableStatus;

                hlStatus.Text = contentItem.Status.ConvertToString();

                hlStatus.LabelType = LabelType.Default;
                switch (contentItem.Status)
                {
                case ContentChannelItemStatus.Approved: hlStatus.LabelType = LabelType.Success; break;

                case ContentChannelItemStatus.Denied: hlStatus.LabelType = LabelType.Danger; break;

                case ContentChannelItemStatus.PendingApproval: hlStatus.LabelType = LabelType.Warning; break;

                default: hlStatus.LabelType = LabelType.Default; break;
                }

                var statusDetail = new System.Text.StringBuilder();
                if (contentItem.ApprovedByPersonAlias != null && contentItem.ApprovedByPersonAlias.Person != null)
                {
                    statusDetail.AppendFormat("by {0} ", contentItem.ApprovedByPersonAlias.Person.FullName);
                }
                if (contentItem.ApprovedDateTime.HasValue)
                {
                    statusDetail.AppendFormat("on {0} at {1}", contentItem.ApprovedDateTime.Value.ToShortDateString(),
                                              contentItem.ApprovedDateTime.Value.ToShortTimeString());
                }
                hlStatus.ToolTip = statusDetail.ToString();

                tbTitle.Text = contentItem.Title;

                htmlContent.Visible = !contentItem.ContentChannelType.DisableContentField;
                htmlContent.Text    = contentItem.Content;
                htmlContent.MergeFields.Clear();
                htmlContent.MergeFields.Add("GlobalAttribute");
                htmlContent.MergeFields.Add("Rock.Model.ContentChannelItem|Current Item");
                htmlContent.MergeFields.Add("Rock.Model.Person|Current Person");
                htmlContent.MergeFields.Add("Campuses");
                htmlContent.MergeFields.Add("RockVersion");

                if (!string.IsNullOrWhiteSpace(contentItem.ContentChannel.RootImageDirectory))
                {
                    htmlContent.DocumentFolderRoot = contentItem.ContentChannel.RootImageDirectory;
                    htmlContent.ImageFolderRoot    = contentItem.ContentChannel.RootImageDirectory;
                }

                htmlContent.StartInCodeEditorMode = contentItem.ContentChannel.ContentControlType == ContentControlType.CodeEditor;

                if (contentItem.ContentChannelType.IncludeTime)
                {
                    dpStart.Visible   = false;
                    dpExpire.Visible  = false;
                    dtpStart.Visible  = contentItem.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                    dtpExpire.Visible = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;

                    dtpStart.SelectedDateTime  = contentItem.StartDateTime;
                    dtpStart.Label             = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dtpExpire.SelectedDateTime = contentItem.ExpireDateTime;
                }
                else
                {
                    dpStart.Visible   = contentItem.ContentChannelType.DateRangeType != ContentChannelDateType.NoDates;
                    dpExpire.Visible  = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange;
                    dtpStart.Visible  = false;
                    dtpExpire.Visible = false;

                    dpStart.SelectedDate  = contentItem.StartDateTime.Date;
                    dpStart.Label         = contentItem.ContentChannelType.DateRangeType == ContentChannelDateType.DateRange ? "Start" : "Active";
                    dpExpire.SelectedDate = contentItem.ExpireDateTime.HasValue ? contentItem.ExpireDateTime.Value.Date : (DateTime?)null;
                }

                nbPriority.Text    = contentItem.Priority.ToString();
                nbPriority.Visible = !contentItem.ContentChannelType.DisablePriority;

                contentItem.LoadAttributes();
                phAttributes.Controls.Clear();
                Rock.Attribute.Helper.AddEditControls(contentItem, phAttributes, true, BlockValidationGroup, 2);

                phOccurrences.Controls.Clear();
                foreach (var occurrence in contentItem.EventItemOccurrences
                         .Where(o => o.EventItemOccurrence != null)
                         .Select(o => o.EventItemOccurrence))
                {
                    var qryParams = new Dictionary <string, string> {
                        { "EventItemOccurrenceId", occurrence.Id.ToString() }
                    };
                    string url          = LinkedPageUrl("EventOccurrencePage", qryParams);
                    var    hlOccurrence = new HighlightLabel();
                    hlOccurrence.LabelType = LabelType.Info;
                    hlOccurrence.ID        = string.Format("hlOccurrence_{0}", occurrence.Id);
                    hlOccurrence.Text      = string.Format("<a href='{0}'><i class='fa fa-calendar-o'></i> {1}</a>", url, occurrence.ToString());
                    phOccurrences.Controls.Add(hlOccurrence);
                }

                bool canHaveChildren = contentItem.Id > 0 && contentItem.ContentChannel.ChildContentChannels.Any();
                bool canHaveParents  = contentItem.Id > 0 && contentItem.ContentChannel.ParentContentChannels.Any();

                pnlChildrenParents.Visible = canHaveChildren || canHaveParents;
                phPills.Visible            = canHaveChildren && canHaveParents;
                if (canHaveChildren && !canHaveParents)
                {
                    lChildrenParentsTitle.Text = "<i class='fa fa-arrow-circle-down'></i> Child Items";
                }

                if (!canHaveChildren && canHaveParents)
                {
                    lChildrenParentsTitle.Text = "<i class='fa fa-arrow-circle-up'></i> Parent Items";
                    divParentItems.AddCssClass("active");
                }

                if (canHaveChildren)
                {
                    BindChildItemsGrid(contentItem);
                }

                if (canHaveParents)
                {
                    BindParentItemsGrid(contentItem);
                }
            }
            else
            {
                nbEditModeMessage.Text = EditModeMessage.NotAuthorizedToEdit(ContentChannelItem.FriendlyTypeName);
                pnlEditDetails.Visible = false;
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("DeviceId"))
            {
                return;
            }

            using (new Rock.Data.UnitOfWorkScope())
            {
                pnlDetails.Visible = true;
                Device Device = null;

                if (!itemKeyValue.Equals(0))
                {
                    Device            = new DeviceService().Get(itemKeyValue);
                    lActionTitle.Text = ActionTitle.Edit(Device.FriendlyTypeName).FormatAsHtmlTitle();
                }
                else
                {
                    Device = new Device {
                        Id = 0
                    };
                    lActionTitle.Text = ActionTitle.Add(Device.FriendlyTypeName).FormatAsHtmlTitle();
                }

                LoadDropDowns();

                hfDeviceId.Value = Device.Id.ToString();

                tbName.Text        = Device.Name;
                tbDescription.Text = Device.Description;
                tbIpAddress.Text   = Device.IPAddress;
                ddlDeviceType.SetValue(Device.DeviceTypeValueId);
                ddlPrintTo.SetValue(Device.PrintToOverride.ConvertToInt().ToString());
                ddlPrinter.SetValue(Device.PrinterDeviceId);
                ddlPrintFrom.SetValue(Device.PrintFrom.ConvertToInt().ToString());

                string orgLocGuid = GlobalAttributesCache.Read().GetValue("OrganizationAddress");
                if (!string.IsNullOrWhiteSpace(orgLocGuid))
                {
                    Guid locGuid = Guid.Empty;
                    if (Guid.TryParse(orgLocGuid, out locGuid))
                    {
                        var location = new LocationService().Get(locGuid);
                        if (location != null)
                        {
                            gpGeoPoint.CenterPoint = location.GeoPoint;
                            gpGeoFence.CenterPoint = location.GeoPoint;
                        }
                    }
                }

                if (Device.Location != null)
                {
                    gpGeoPoint.SetValue(Device.Location.GeoPoint);
                    gpGeoFence.SetValue(Device.Location.GeoFence);
                }

                // render UI based on Authorized and IsSystem
                bool readOnly = false;

                nbEditModeMessage.Text = string.Empty;
                if (!IsUserAuthorized("Edit"))
                {
                    readOnly = true;
                    nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Device.FriendlyTypeName);
                }

                if (readOnly)
                {
                    lActionTitle.Text = ActionTitle.View(Device.FriendlyTypeName);
                    btnCancel.Text    = "Close";
                }

                tbName.ReadOnly        = readOnly;
                tbDescription.ReadOnly = readOnly;
                tbIpAddress.ReadOnly   = readOnly;
                ddlDeviceType.Enabled  = !readOnly;
                ddlPrintTo.Enabled     = !readOnly;
                ddlPrinter.Enabled     = !readOnly;
                ddlPrintFrom.Enabled   = !readOnly;

                btnSave.Visible = !readOnly;
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="noteWatchId">The note watch identifier.</param>
        public void ShowDetail(int noteWatchId)
        {
            pnlView.Visible = true;
            var rockContext = new RockContext();

            // Load depending on Add(0) or Edit
            NoteWatch noteWatch = null;

            if (noteWatchId > 0)
            {
                noteWatch         = new NoteWatchService(rockContext).Get(noteWatchId);
                lActionTitle.Text = ActionTitle.Edit(NoteWatch.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(noteWatch, ResolveRockUrl("~"));
            }

            pdAuditDetails.Visible = noteWatch != null;

            var contextPerson = ContextEntity <Person>();
            var contextGroup  = ContextEntity <Group>();

            if (noteWatch == null)
            {
                noteWatch = new NoteWatch {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(NoteWatch.FriendlyTypeName).FormatAsHtmlTitle();

                if (contextPerson != null)
                {
                    noteWatch.WatcherPersonAliasId = contextPerson.PrimaryAliasId;
                    noteWatch.WatcherPersonAlias   = contextPerson.PrimaryAlias;
                }
                else if (contextGroup != null)
                {
                    noteWatch.WatcherGroupId = contextGroup.Id;
                    noteWatch.WatcherGroup   = contextGroup;
                }
            }

            if (contextPerson != null)
            {
                ppWatcherPerson.Enabled = false;
                gpWatcherGroup.Visible  = false;

                // make sure we are seeing details for a NoteWatch that the current person is watching
                if (!noteWatch.WatcherPersonAliasId.HasValue || !contextPerson.Aliases.Any(a => a.Id == noteWatch.WatcherPersonAliasId.Value))
                {
                    // The NoteWatchId in the url isn't a NoteWatch for the PersonContext, so just hide the block
                    pnlView.Visible = false;
                }
            }
            else if (contextGroup != null)
            {
                ppWatcherPerson.Visible = false;
                gpWatcherGroup.Enabled  = false;

                // make sure we are seeing details for a NoteWatch that the current group context is watching
                if (!noteWatch.WatcherGroupId.HasValue || !(contextGroup.Id != noteWatch.WatcherGroupId))
                {
                    // The NoteWatchId in the url isn't a NoteWatch for the GroupContext, so just hide the block
                    pnlView.Visible = false;
                }
            }

            hfNoteWatchId.Value = noteWatchId.ToString();

            etpEntityType.SetValue(noteWatch.EntityTypeId);
            LoadNoteTypeDropDown(noteWatch.EntityTypeId);

            ddlNoteType.SetValue(noteWatch.NoteTypeId);

            if (noteWatch.WatcherPersonAlias != null)
            {
                ppWatcherPerson.SetValue(noteWatch.WatcherPersonAlias.Person);
            }
            else
            {
                ppWatcherPerson.SetValue(( Person )null);
            }

            gpWatcherGroup.SetValue(noteWatch.WatcherGroup);

            cbIsWatching.Checked = noteWatch.IsWatching;
            cbIsWatching_CheckedChanged(null, null);

            cbAllowOverride.Checked = noteWatch.AllowOverride;

            ShowEntityPicker(etpEntityType.SelectedEntityTypeId);

            etpEntityType.Enabled = true;
            if (noteWatch.EntityTypeId.HasValue && noteWatch.EntityId.HasValue)
            {
                var     watchedEntityTypeId = noteWatch.EntityTypeId;
                IEntity watchedEntity       = new EntityTypeService(rockContext).GetEntity(noteWatch.EntityTypeId.Value, noteWatch.EntityId.Value);

                if (watchedEntity != null)
                {
                    if (watchedEntity is Rock.Model.Person)
                    {
                        ppWatchedPerson.SetValue(watchedEntity as Rock.Model.Person);
                    }
                    else if (watchedEntity is Rock.Model.Group)
                    {
                        gpWatchedGroup.SetValue(watchedEntity as Rock.Model.Group);
                    }
                    else
                    {
                        lWatchedEntityName.Text = watchedEntity.ToString();
                        nbWatchedEntityId.Text  = watchedEntity.Id.ToString();
                    }

                    // Don't let the EntityType get changed if there is a specific Entity getting watched
                    etpEntityType.Enabled = false;
                }
            }

            lWatchedNote.Visible = false;
            if (noteWatch.Note != null)
            {
                var mergefields = Rock.Lava.LavaHelper.GetCommonMergeFields(this.RockPage, null, new Rock.Lava.CommonMergeFieldsOptions {
                    GetLegacyGlobalMergeFields = false
                });
                mergefields.Add("Note", noteWatch.Note);
                var lavaTemplate = this.GetAttributeValue("WatchedNoteLavaTemplate");

                lWatchedNote.Text = lavaTemplate.ResolveMergeFields(mergefields);
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="metricValueId">The metric value identifier.</param>
        /// <param name="metricId">The metric identifier.</param>
        public void ShowDetail(int metricValueId, int?metricId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            MetricValue metricValue = null;

            if (!metricValueId.Equals(0))
            {
                metricValue       = new MetricValueService(new RockContext()).Get(metricValueId);
                lActionTitle.Text = ActionTitle.Edit(MetricValue.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (metricValue == null && metricId.HasValue)
            {
                metricValue = new MetricValue {
                    Id = 0, MetricId = metricId.Value
                };
                metricValue.Metric = metricValue.Metric ?? new MetricService(new RockContext()).Get(metricValue.MetricId);
                lActionTitle.Text  = ActionTitle.Add(MetricValue.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfMetricValueId.Value = metricValue.Id.ToString();

            LoadDropDowns();

            ddlMetricValueType.SelectedValue = metricValue.MetricValueType.ConvertToInt().ToString();
            tbXValue.Text    = metricValue.XValue;
            tbYValue.Text    = metricValue.YValue.ToString();
            hfMetricId.Value = metricValue.MetricId.ToString();
            tbNote.Text      = metricValue.Note;
            dpMetricValueDateTime.SelectedDate = metricValue.MetricValueDateTime;

            var metricEntityType = EntityTypeCache.Read(metricValue.Metric.EntityTypeId ?? 0);

            // Setup EntityType UI controls
            Control entityTypeEditControl = null;

            if (metricEntityType != null && metricEntityType.SingleValueFieldType != null)
            {
                hfSingleValueFieldTypeId.Value = metricEntityType.SingleValueFieldType.Id.ToString();
                FieldTypeCache fieldType = FieldTypeCache.Read(hfSingleValueFieldTypeId.Value.AsInteger());
                entityTypeEditControl = fieldType.Field.EditControl(new Dictionary <string, Rock.Field.ConfigurationValue>(), "entityTypeEditControl");

                if (entityTypeEditControl is IRockControl)
                {
                    (entityTypeEditControl as IRockControl).Label = fieldType.Name;
                }

                phEntityTypeEntityIdValue.Controls.Add(entityTypeEditControl);
                IEntityFieldType entityFieldType = metricEntityType.SingleValueFieldType.Field as IEntityFieldType;
                if (entityFieldType != null)
                {
                    entityFieldType.SetEditValueFromEntityId(entityTypeEditControl, new Dictionary <string, ConfigurationValue>(), metricValue.EntityId);
                }
            }

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;

            bool canEdit = UserCanEdit;

            if (!canEdit && metricId.HasValue && metricId.Value > 0)
            {
                var metric = new MetricService(new RockContext()).Get(metricId.Value);
                if (metric != null && metric.IsAuthorized(Authorization.EDIT, CurrentPerson))
                {
                    canEdit = true;
                }
            }

            if (!canEdit)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(MetricValue.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(MetricValue.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            ddlMetricValueType.Enabled    = !readOnly;
            tbXValue.ReadOnly             = readOnly;
            tbYValue.ReadOnly             = readOnly;
            tbNote.ReadOnly               = readOnly;
            dpMetricValueDateTime.Enabled = !readOnly;
            if (entityTypeEditControl is WebControl)
            {
                (entityTypeEditControl as WebControl).Enabled = !readOnly;
            }

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Shows the edit details.
        /// </summary>
        /// <param name="prayerRequest">The prayer request.</param>
        private void ShowEditDetails(PrayerRequest prayerRequest)
        {
            SetEditMode(true);

            if (prayerRequest.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit(PrayerRequest.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(PrayerRequest.FriendlyTypeName).FormatAsHtmlTitle();
                if (CurrentPersonAlias != null && CurrentPerson != null && GetAttributeValue("SetCurrentPersonToRequester").AsBoolean())
                {
                    prayerRequest.RequestedByPersonAlias = CurrentPersonAlias;
                    prayerRequest.FirstName = CurrentPerson.NickName;
                    prayerRequest.LastName  = CurrentPerson.LastName;
                }
            }

            cpCampus.Items.Clear();
            cpCampus.SelectedCampusId = prayerRequest.CampusId;

            pnlDetails.Visible = true;

            var prayRequestCategory = prayerRequest.Category;

            if (prayRequestCategory == null)
            {
                var defaultCategoryGuid = GetAttributeValue("DefaultCategory").AsGuidOrNull();
                if (defaultCategoryGuid.HasValue)
                {
                    prayRequestCategory = new CategoryService(new RockContext()).Get(defaultCategoryGuid.Value);
                }
            }
            catpCategory.SetValue(prayRequestCategory);

            tbFirstName.Text = prayerRequest.FirstName;
            tbLastName.Text  = prayerRequest.LastName;
            tbEmail.Text     = prayerRequest.Email;
            dtbText.Text     = prayerRequest.Text;
            dtbAnswer.Text   = prayerRequest.Answer;

            if (prayerRequest.RequestedByPersonAlias != null)
            {
                ppRequestor.SetValue(prayerRequest.RequestedByPersonAlias.Person);
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(PageParameter("PersonId")))
                {
                    var requestor = new PersonService(new RockContext()).Get(PageParameter("PersonId").AsInteger());
                    ppRequestor.SetValue(requestor);
                    tbFirstName.Text = requestor.NickName;
                    tbLastName.Text  = requestor.LastName;
                    tbEmail.Text     = requestor.Email;
                }
                else
                {
                    ppRequestor.SetValue(null);
                }
            }

            // If no expiration date is set, then use the default setting.
            if (!prayerRequest.ExpirationDate.HasValue)
            {
                var expireDays = Convert.ToDouble(GetAttributeValue("ExpireDays"));
                dpExpirationDate.SelectedDate = RockDateTime.Now.AddDays(expireDays);
            }
            else
            {
                dpExpirationDate.SelectedDate = prayerRequest.ExpirationDate;
            }

            ShowStatus(prayerRequest, this.CurrentPerson, hlblFlaggedMessage);

            cbIsPublic.Checked      = prayerRequest.IsPublic ?? false;
            cbIsUrgent.Checked      = prayerRequest.IsUrgent ?? false;
            cbIsActive.Checked      = prayerRequest.IsActive ?? false;
            cbAllowComments.Checked = prayerRequest.AllowComments ?? false;

            prayerRequest.LoadAttributes();
            phAttributes.Controls.Clear();
            // Filter to only include attribute / attribute values that the person is authorized to edit.
            var excludeForEdit = prayerRequest.Attributes.Where(a => !a.Value.IsAuthorized(Authorization.EDIT, this.CurrentPerson)).Select(a => a.Key).ToList();

            Rock.Attribute.Helper.AddEditControls(prayerRequest, phAttributes, true, BlockValidationGroup, excludeForEdit);
        }