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

            PageRoute pageRoute = null;

            if (!routeId.Equals(0))
            {
                pageRoute         = new PageRouteService(new RockContext()).Get(routeId);
                lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(pageRoute, ResolveRockUrl("~"));
            }

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

            hfPageRouteId.Value = pageRoute.Id.ToString();
            ppPage.SetValue(pageRoute.Page);

            ShowSite();

            tbRoute.Text       = pageRoute.Route;
            cbIsGlobal.Checked = pageRoute.IsGlobal;

            // render UI based on Authorized and IsSystem. Do IsSystem check first so the IsUserAuthorized check can overwrite the settings.
            nbEditModeMessage.Text = string.Empty;

            if (pageRoute.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(PageRoute.FriendlyTypeName);

                ppPage.Enabled     = false;
                tbRoute.ReadOnly   = true;
                cbIsGlobal.Enabled = true;
                btnSave.Visible    = true;
            }

            if (!IsUserAuthorized(Authorization.EDIT))
            {
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(PageRoute.FriendlyTypeName);

                lActionTitle.Text = ActionTitle.View(PageRoute.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";

                ppPage.Enabled     = false;
                tbRoute.ReadOnly   = true;
                cbIsGlobal.Enabled = false;
                btnSave.Visible    = false;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        public void ShowDetail(int siteId)
        {
            pnlDetails.Visible = false;

            Site site = null;

            if (!siteId.Equals(0))
            {
                site = new SiteService(new RockContext()).Get(siteId);
            }

            if (site == null)
            {
                site = new Site {
                    Id = 0
                };
                site.SiteDomains = new List <SiteDomain>();
                site.Theme       = RockPage.Layout.Site.Theme;
            }

            pnlDetails.Visible = true;
            hfSiteId.Value     = site.Id.ToString();

            bool readOnly = false;

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

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

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(site);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = !site.IsSystem;
                if (site.Id > 0)
                {
                    ShowReadonlyDetails(site);
                }
                else
                {
                    ShowEditDetails(site);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="authClaimId">The authentication claim identifier.</param>
        public void ShowDetail(int authClaimId)
        {
            AuthClaim authClaim = null;
            var       isNew     = authClaimId.Equals(0);

            if (!isNew)
            {
                dlgClaimDetails.Title = ActionTitle.Edit("Claim").FormatAsHtmlTitle();
                using (var rockContext = new RockContext())
                {
                    authClaim = new AuthClaimService(rockContext).Get(authClaimId);
                }
            }
            else
            {
                dlgClaimDetails.Title = ActionTitle.Add("Claim").FormatAsHtmlTitle();
            }

            if (authClaim == null)
            {
                if (!isNew)
                {
                    DisplayErrorMessage("The Auth Claim with the specified Id was found.");
                    return;
                }

                authClaim = new AuthClaim {
                    Id = 0, IsActive = true
                };
            }

            hfAuthClaimId.Value = authClaim.Id.ToString();

            tbClaimName.Text       = authClaim.Name;
            tbClaimPublicName.Text = authClaim.PublicName;
            tbClaimValue.Text      = authClaim.Value;
            cbClaimActive.Checked  = authClaim.IsActive;

            nbEditModeMessage.Text = string.Empty;
            if (authClaim.IsSystem)
            {
                tbClaimName.Enabled    = false;
                tbClaimValue.Visible   = false;
                cbClaimActive.Enabled  = false;
                nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.AuthClaim.FriendlyTypeName);
            }

            dlgClaimDetails.Show();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="authScopeId">The rest user identifier.</param>
        public void ShowDetail(int authScopeId)
        {
            var rockContext = new RockContext();

            AuthScope authScope = null;
            var       isNew     = authScopeId.Equals(0);

            if (!isNew)
            {
                authScope   = new AuthScopeService(rockContext).Get(authScopeId);
                lTitle.Text = ActionTitle.Edit("Scope").FormatAsHtmlTitle();
            }
            else
            {
                lTitle.Text = ActionTitle.Add("Scope").FormatAsHtmlTitle();
            }

            if (authScope == null)
            {
                if (!isNew)
                {
                    DisplayErrorMessage("The Auth Scope with the specified Id was found.");
                    return;
                }

                authScope = new AuthScope {
                    Id = 0, IsActive = true
                };
            }

            hfRestUserId.Value = authScope.Id.ToString();

            tbName.Text       = authScope.Name;
            tbPublicName.Text = authScope.PublicName;
            cbActive.Checked  = authScope.IsActive;

            nbEditModeMessage.Text = string.Empty;
            if (authScope.IsSystem)
            {
                tbName.Enabled         = false;
                cbActive.Enabled       = false;
                nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.AuthScope.FriendlyTypeName);
            }

            var editAllowed = authScope.IsAuthorized(Authorization.EDIT, CurrentPerson);

            lbSave.Visible = editAllowed;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="persistedDatasetId">The persisted dataset identifier.</param>
        public void ShowDetail(int persistedDatasetId)
        {
            if (persistedDatasetId > 0)
            {
                lActionTitle.Text = ActionTitle.Edit(PersistedDataset.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(PersistedDataset.FriendlyTypeName).FormatAsHtmlTitle();
            }

            var rockContext             = new RockContext();
            var persistedDatasetService = new PersistedDatasetService(rockContext);
            PersistedDataset persistedDataset;

            if (persistedDatasetId > 0)
            {
                persistedDataset = persistedDatasetService.Get(persistedDatasetId);
            }
            else
            {
                persistedDataset = new PersistedDataset();
            }

            hfPersistedDatasetId.Value = persistedDatasetId.ToString();

            nbEditModeMessage.Text = string.Empty;

            if (persistedDataset.IsSystem)
            {
                ceBuildScript.ReadOnly = true;
                ceBuildScript.Enabled  = false;
                tbAccessKey.Enabled    = false;
                nbEditModeMessage.Text = EditModeMessage.System(Category.FriendlyTypeName);
            }

            tbName.Text        = persistedDataset.Name;
            cbIsActive.Checked = persistedDataset.IsActive;
            tbAccessKey.Text   = persistedDataset.AccessKey;
            tbDescription.Text = persistedDataset.Description;
            ceBuildScript.Text = persistedDataset.BuildScript;
            lcpEnabledLavacommands.SelectedLavaCommands = persistedDataset.EnabledLavaCommands.SplitDelimitedValues().ToList();
            nbRefreshIntervalHours.Text        = persistedDataset.RefreshIntervalMinutes.HasValue ? TimeSpan.FromMinutes(persistedDataset.RefreshIntervalMinutes.Value).TotalHours.ToString("F") : string.Empty;
            nbMemoryCacheDurationHours.Text    = persistedDataset.MemoryCacheDurationMS.HasValue ? TimeSpan.FromMilliseconds(persistedDataset.MemoryCacheDurationMS.Value).TotalHours.ToString("F") : string.Empty;
            dtpExpireDateTime.SelectedDate     = persistedDataset.ExpireDateTime;
            etpEntityType.SelectedEntityTypeId = persistedDataset.EntityTypeId;
            cbAllowManualRefresh.Checked       = persistedDataset.AllowManualRefresh;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        private void ShowDetail(int templateId)
        {
            CommunicationTemplate communicationTemplate = null;
            var newTemplate = false;

            if (!templateId.Equals(0))
            {
                communicationTemplate = new CommunicationTemplateService(new RockContext()).Get(templateId);
                if (communicationTemplate != null)
                {
                    lTitle.Text = communicationTemplate.Name.FormatAsHtmlTitle();
                    pdAuditDetails.SetEntity(communicationTemplate, ResolveRockUrl("~"));
                }
            }

            if (communicationTemplate == null)
            {
                RockPage.PageTitle    = "New Communication Template";
                lTitle.Text           = "New Communication Template".FormatAsHtmlTitle();
                communicationTemplate = new CommunicationTemplate();
                newTemplate           = true;
            }

            LoadDropDowns();

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

            hfCommunicationTemplateId.Value = templateId.ToString();

            tbName.Text        = communicationTemplate.Name;
            cbIsActive.Checked = communicationTemplate.IsActive;
            tbDescription.Text = communicationTemplate.Description;
            cpCategory.SetValue(communicationTemplate.CategoryId);

            imgTemplatePreview.BinaryFileId = communicationTemplate.ImageFileId;
            imgTemplateLogo.BinaryFileId    = communicationTemplate.LogoBinaryFileId;

            // Email Fields
            tbFromName.Text    = communicationTemplate.FromName;
            tbFromAddress.Text = communicationTemplate.FromEmail;

            tbReplyToAddress.Text        = communicationTemplate.ReplyToEmail;
            tbCCList.Text                = communicationTemplate.CCEmails;
            tbBCCList.Text               = communicationTemplate.BCCEmails;
            cbCssInliningEnabled.Checked = communicationTemplate.CssInliningEnabled;
            kvlMergeFields.Value         = communicationTemplate.LavaFields.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");

            hfShowAdditionalFields.Value = (!string.IsNullOrEmpty(communicationTemplate.ReplyToEmail) || !string.IsNullOrEmpty(communicationTemplate.CCEmails) || !string.IsNullOrEmpty(communicationTemplate.BCCEmails)).ToTrueFalse().ToLower();

            tbEmailSubject.Text = communicationTemplate.Subject;

            nbTemplateHelp.InnerHtml = @"
<p>An email template needs to be an html doc with some special divs to support the communication wizard.</p>
<br/>
<p>The template needs to have at least one div with a 'dropzone' class in the BODY</p> 
<br/>
<pre>
&lt;div class=""dropzone""&gt;
&lt;/div&gt;
</pre>
<br/>

<p>A template also needs to have at least one div with a 'structure-dropzone' class in the BODY to support adding zones</p> 
<br/>
<pre>
&lt;div class=""structure-dropzone""&gt;
    &lt;div class=""dropzone""&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<br/>

<p>To have some starter text, include a 'component component-text' div within the 'dropzone' div</p> 
<br/>
<pre>
&lt;div class=""structure-dropzone""&gt;
    &lt;div class=""dropzone""&gt;
        &lt;div class=""component component-text"" data-content=""&lt;h1&gt;Hello There!&lt;/h1&gt;"" data-state=""component""&gt;
            &lt;h1&gt;Hello There!&lt;/h1&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</pre>
<br/>

<p>To enable the PREHEADER text, a div with an id of 'preheader-text' needs to be the first div in the BODY</p>
<br/>
<pre>
&lt;!-- HIDDEN PREHEADER TEXT --&gt;
&lt;div id=""preheader-text"" style=""display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;""&gt;
    Entice the open with some amazing preheader text. Use a little mystery and get those subscribers to read through...
&lt;/div&gt;
</pre>

<p>To include a logo, an img div with an id of 'template-logo' can be placed anywhere in the template, which will then show the 'Logo' image uploader under the template editor which will be used to set the src of the template-logo</p>
<br/>
<pre>
&lt;!-- LOGO --&gt;
&lt;img id='template-logo' src='/Content/EmailTemplates/placeholder-logo.png' width='200' height='50' data-instructions='Provide a PNG with a transparent background or JPG with the background color of #ee7725.' /&gt;
</pre>

<br/>
";

            ceEmailTemplate.Text = communicationTemplate.Message;

            hfAttachedBinaryFileIds.Value = communicationTemplate.Attachments.Select(a => a.BinaryFileId).ToList().AsDelimited(",");
            UpdateAttachedFiles(false);

            // SMS Fields
            ddlSMSFrom.SetValue(communicationTemplate.SMSFromDefinedValueId);
            tbSMSTextMessage.Text = communicationTemplate.SMSMessage;

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

            if (!newTemplate && !communicationTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson))
            {
                restrictedEdit            = true;
                readOnly                  = true;
                nbEditModeMessage.Text    = EditModeMessage.NotAuthorizedToEdit(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            if (communicationTemplate.IsSystem)
            {
                restrictedEdit            = true;
                nbEditModeMessage.Text    = EditModeMessage.System(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            tbName.ReadOnly    = restrictedEdit;
            cbIsActive.Enabled = !restrictedEdit;

            tbFromName.ReadOnly       = restrictedEdit;
            tbName.ReadOnly           = restrictedEdit;
            tbFromAddress.ReadOnly    = restrictedEdit;
            tbReplyToAddress.ReadOnly = restrictedEdit;
            tbCCList.ReadOnly         = restrictedEdit;
            tbBCCList.ReadOnly        = restrictedEdit;
            tbEmailSubject.ReadOnly   = restrictedEdit;
            fupAttachments.Visible    = !restrictedEdit;

            // Allow these to be Editable if they are IsSystem, but not if they don't have EDIT Auth
            tbDescription.ReadOnly     = readOnly;
            imgTemplatePreview.Enabled = !readOnly;
            ceEmailTemplate.ReadOnly   = readOnly;

            mfpSMSMessage.Visible     = !restrictedEdit;
            ddlSMSFrom.Enabled        = !restrictedEdit;
            tbSMSTextMessage.ReadOnly = restrictedEdit;
            ceEmailTemplate.ReadOnly  = restrictedEdit;

            btnSave.Enabled = !readOnly;

            tglPreviewAdvanced.Checked = true;
            tglPreviewAdvanced_CheckedChanged(null, null);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        public void ShowDetail(int siteId)
        {
            pnlDetails.Visible = false;

            Site site = null;

            if (!siteId.Equals(0))
            {
                site = new SiteService(new RockContext()).Get(siteId);
                pdAuditDetails.SetEntity(site, ResolveRockUrl("~"));
            }

            if (site == null)
            {
                site = new Site {
                    Id = 0
                };
                site.SiteDomains = new List <SiteDomain>();
                site.Theme       = RockPage.Layout.Site.Theme;
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }
            else
            {
                if (site.DefaultPageId.HasValue)
                {
                    lVisitSite.Text = string.Format(@"<a href=""{0}{1}"" target=""_blank""><span class=""label label-info"">Visit Site</span></a>", ResolveRockUrl("~/page/"), site.DefaultPageId);
                }
            }

            Guid fileTypeGuid = GetAttributeValue("DefaultFileType").AsGuid();

            imgSiteIcon.BinaryFileTypeGuid = fileTypeGuid;

            // set theme compile button
            if (!new RockTheme(site.Theme).AllowsCompile)
            {
                btnCompileTheme.Enabled = false;
                btnCompileTheme.Text    = "Theme Doesn't Support Compiling";
            }

            pnlDetails.Visible = true;
            hfSiteId.Value     = site.Id.ToString();

            cePageHeaderContent.Text = site.PageHeaderContent;
            cbAllowIndexing.Checked  = site.AllowIndexing;

            bool readOnly = false;

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

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

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(site);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = !site.IsSystem;
                if (site.Id > 0)
                {
                    ShowReadonlyDetails(site);
                }
                else
                {
                    ShowEditDetails(site);
                }
            }
        }
Ejemplo n.º 8
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();
                pdAuditDetails.SetEntity(binaryFileType, ResolveRockUrl("~"));
            }

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

                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            BinaryFileAttributesState = new List <Attribute>();

            hfBinaryFileTypeId.Value = binaryFileType.Id.ToString();
            tbName.Text         = binaryFileType.Name;
            tbDescription.Text  = binaryFileType.Description;
            tbIconCssClass.Text = binaryFileType.IconCssClass;
            cbCacheToServerFileSystem.Checked = binaryFileType.CacheToServerFileSystem;

            if (binaryFileType.CacheControlHeaderSettings != null)
            {
                cpCacheSettings.CurrentCacheablity = JsonConvert.DeserializeObject <RockCacheability>(binaryFileType.CacheControlHeaderSettings);
            }

            cbRequiresViewSecurity.Checked = binaryFileType.RequiresViewSecurity;

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

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

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

            ddlPreferredColorDepth.BindToEnum <ColorDepth>();
            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, true).AsQueryable()
                                             .Where(a => a.EntityTypeQualifierColumn.Equals("BinaryFileTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                    a.EntityTypeQualifierValue.Equals(qualifierValue));

            BinaryFileAttributesState = 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, BlockValidationGroup);
            }

            // 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;
            cbCacheToServerFileSystem.Enabled = !readOnly;
            cpCacheSettings.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;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="siteId">The group id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?siteId)
        {
            if (!itemKey.Equals("layoutId"))
            {
                return;
            }

            Layout layout = null;

            if (!itemKeyValue.Equals(0))
            {
                layout = new LayoutService(new RockContext()).Get(itemKeyValue);
            }
            else
            {
                // only create a new one if parent was specified
                if (siteId.HasValue)
                {
                    layout = new Layout {
                        Id = 0
                    };
                    layout.SiteId = siteId.Value;
                }
            }

            if (layout == null)
            {
                return;
            }

            hfSiteId.Value   = layout.SiteId.ToString();
            hfLayoutId.Value = layout.Id.ToString();

            bool readOnly = false;

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

            if (layout.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.Layout.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible = false;
                //btnDelete.Visible = false;
                ShowReadonlyDetails(layout);
            }
            else
            {
                btnEdit.Visible = true;
                //btnDelete.Visible = !layout.IsSystem;
                if (layout.Id > 0)
                {
                    ShowReadonlyDetails(layout);
                }
                else
                {
                    ShowEditDetails(layout);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="templateId">The template identifier.</param>
        private void ShowDetail(int templateId)
        {
            CommunicationTemplate communicationTemplate = null;
            var newTemplate       = false;
            var pushCommunication = new CommunicationDetails();

            if (!templateId.Equals(0))
            {
                communicationTemplate = new CommunicationTemplateService(new RockContext()).Get(templateId);
                if (communicationTemplate != null)
                {
                    lTitle.Text = communicationTemplate.Name.FormatAsHtmlTitle();
                    pdAuditDetails.SetEntity(communicationTemplate, ResolveRockUrl("~"));
                }

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

            if (communicationTemplate == null)
            {
                RockPage.PageTitle    = "New Communication Template";
                lTitle.Text           = "New Communication Template".FormatAsHtmlTitle();
                communicationTemplate = new CommunicationTemplate();
                newTemplate           = true;
            }

            LoadDropDowns();

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

            hfCommunicationTemplateId.Value = templateId.ToString();

            tbName.Text        = communicationTemplate.Name;
            cbIsActive.Checked = communicationTemplate.IsActive;
            tbDescription.Text = communicationTemplate.Description;
            cpCategory.SetValue(communicationTemplate.CategoryId);

            imgTemplatePreview.BinaryFileId = communicationTemplate.ImageFileId;
            imgTemplateLogo.BinaryFileId    = communicationTemplate.LogoBinaryFileId;

            // Email Fields
            tbFromName.Text    = communicationTemplate.FromName;
            tbFromAddress.Text = communicationTemplate.FromEmail;

            tbReplyToAddress.Text        = communicationTemplate.ReplyToEmail;
            tbCCList.Text                = communicationTemplate.CCEmails;
            tbBCCList.Text               = communicationTemplate.BCCEmails;
            cbCssInliningEnabled.Checked = communicationTemplate.CssInliningEnabled;
            kvlMergeFields.Value         = communicationTemplate.LavaFields.Select(a => string.Format("{0}^{1}", a.Key, a.Value)).ToList().AsDelimited("|");

            hfShowAdditionalFields.Value = (!string.IsNullOrEmpty(communicationTemplate.ReplyToEmail) || !string.IsNullOrEmpty(communicationTemplate.CCEmails) || !string.IsNullOrEmpty(communicationTemplate.BCCEmails)).ToTrueFalse().ToLower();

            tbEmailSubject.Text = communicationTemplate.Subject;

            nbTemplateHelp.InnerHtml = CommunicationTemplateHelper.GetTemplateHelp(true);
            ceEmailTemplate.Text     = communicationTemplate.Message;

            hfAttachedBinaryFileIds.Value = communicationTemplate.Attachments.Select(a => a.BinaryFileId).ToList().AsDelimited(",");
            UpdateAttachedFiles(false);

            // SMS Fields
            dvpSMSFrom.SetValue(communicationTemplate.SMSFromDefinedValueId);
            tbSMSTextMessage.Text = communicationTemplate.SMSMessage;

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

            if (!newTemplate && !communicationTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson))
            {
                restrictedEdit            = true;
                readOnly                  = true;
                nbEditModeMessage.Text    = EditModeMessage.NotAuthorizedToEdit(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            if (communicationTemplate.IsSystem)
            {
                restrictedEdit            = true;
                nbEditModeMessage.Text    = EditModeMessage.System(CommunicationTemplate.FriendlyTypeName);
                nbEditModeMessage.Visible = true;
            }

            tbName.ReadOnly    = restrictedEdit;
            cbIsActive.Enabled = !restrictedEdit;

            tbFromName.ReadOnly               = restrictedEdit;
            tbName.ReadOnly                   = restrictedEdit;
            tbFromAddress.ReadOnly            = restrictedEdit;
            tbReplyToAddress.ReadOnly         = restrictedEdit;
            tbCCList.ReadOnly                 = restrictedEdit;
            tbBCCList.ReadOnly                = restrictedEdit;
            tbEmailSubject.ReadOnly           = restrictedEdit;
            fupAttachments.Visible            = !restrictedEdit;
            fupAttachments.BinaryFileTypeGuid = this.GetAttributeValue(AttributeKey.AttachmentBinaryFileType).AsGuidOrNull() ?? Rock.SystemGuid.BinaryFiletype.DEFAULT.AsGuid();
            // Allow these to be Editable if they are IsSystem, but not if they don't have EDIT Auth
            tbDescription.ReadOnly     = readOnly;
            imgTemplatePreview.Enabled = !readOnly;
            ceEmailTemplate.ReadOnly   = readOnly;

            mfpSMSMessage.Visible     = !restrictedEdit;
            dvpSMSFrom.Enabled        = !restrictedEdit;
            tbSMSTextMessage.ReadOnly = restrictedEdit;
            ceEmailTemplate.ReadOnly  = restrictedEdit;

            btnSave.Enabled = !readOnly;

            tglPreviewAdvanced.Checked = true;

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

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

            SetEmailMessagePreviewModeEnabled(tglPreviewAdvanced.Checked);
        }
        /// <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;

            var rockContext = new RockContext();

            if (!itemKeyValue.Equals(0))
            {
                binaryFileType    = new BinaryFileTypeService(rockContext).Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
            }
            else
            {
                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;
            cbRequiresSecurity.Checked = binaryFileType.RequiresSecurity;

            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;

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

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

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

            if (readOnly || binaryFileType.IsSystem)
            {
                lActionTitle.Text = ActionTitle.View(BinaryFileType.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(binaryFileType, phAttributes);
            }
            else
            {
                Rock.Attribute.Helper.AddEditControls(binaryFileType, phAttributes, true);
            }

            tbName.ReadOnly               = readOnly || binaryFileType.IsSystem;
            tbDescription.ReadOnly        = readOnly || binaryFileType.IsSystem;
            tbIconCssClass.ReadOnly       = readOnly || binaryFileType.IsSystem;
            cbAllowCaching.Enabled        = !readOnly && !binaryFileType.IsSystem;
            cbRequiresSecurity.Enabled    = !readOnly && !binaryFileType.IsSystem;
            gBinaryFileAttributes.Enabled = !readOnly && !binaryFileType.IsSystem;

            // allow storagetype to be edited if IsSystem
            cpStorageType.Enabled = !readOnly;

            // allow save to be clicked if IsSystem since some things can be edited
            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="layoutId">The layout identifier.</param>
        /// <param name="siteId">The group id.</param>
        public void ShowDetail(int layoutId, int?siteId)
        {
            Layout layout = null;

            if (!layoutId.Equals(0))
            {
                layout = new LayoutService(new RockContext()).Get(layoutId);
            }

            if (layout == null && siteId.HasValue)
            {
                var site = SiteCache.Read(siteId.Value);
                if (site != null)
                {
                    layout = new Layout {
                        Id = 0
                    };
                    layout.SiteId = siteId.Value;
                }
            }

            if (layout == null)
            {
                pnlDetails.Visible = false;
                return;
            }

            hfSiteId.Value   = layout.SiteId.ToString();
            hfLayoutId.Value = layout.Id.ToString();

            bool readOnly = false;

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

            if (layout.IsSystem)
            {
                nbEditModeMessage.Text = EditModeMessage.System(Rock.Model.Layout.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible = false;
                //btnDelete.Visible = false;
                ShowReadonlyDetails(layout);
            }
            else
            {
                btnEdit.Visible = true;
                //btnDelete.Visible = !layout.IsSystem;
                if (layout.Id > 0)
                {
                    ShowReadonlyDetails(layout);
                }
                else
                {
                    ShowEditDetails(layout);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        public void ShowDetail(int siteId)
        {
            pnlDetails.Visible = false;

            Site site = null;

            if (!siteId.Equals(0))
            {
                site = new SiteService(new RockContext()).Get(siteId);
                pdAuditDetails.SetEntity(site, ResolveRockUrl("~"));
            }

            if (site == null)
            {
                site = new Site {
                    Id = 0
                };
                site.SiteDomains = new List <SiteDomain>();
                site.Theme       = RockPage.Layout.Site.Theme;
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            // set theme compile button
            if (!new RockTheme(site.Theme).AllowsCompile)
            {
                btnCompileTheme.Enabled = false;
                btnCompileTheme.Text    = "Theme Doesn't Support Compiling";
            }

            pnlDetails.Visible = true;
            hfSiteId.Value     = site.Id.ToString();

            cePageHeaderContent.Text = site.PageHeaderContent;
            cbAllowIndexing.Checked  = site.AllowIndexing;

            bool readOnly = false;

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

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

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(site);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = !site.IsSystem;
                if (site.Id > 0)
                {
                    ShowReadonlyDetails(site);
                }
                else
                {
                    ShowEditDetails(site);
                }
            }
        }
Ejemplo n.º 14
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.º 15
0
        /// <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;

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

                if (!emailTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson))
                {
                    restrictedEdit            = true;
                    readOnly                  = true;
                    nbEditModeMessage.Text    = EditModeMessage.NotAuthorizedToEdit(CommunicationTemplate.FriendlyTypeName);
                    nbEditModeMessage.Visible = true;
                }

                if (emailTemplate.IsSystem)
                {
                    restrictedEdit            = true;
                    nbEditModeMessage.Text    = EditModeMessage.System(CommunicationTemplate.FriendlyTypeName);
                    nbEditModeMessage.Visible = true;
                }

                tbTitle.ReadOnly    = restrictedEdit;
                cbIsActive.Enabled  = !restrictedEdit;
                cpCategory.Enabled  = !restrictedEdit;
                tbFromName.ReadOnly = restrictedEdit;
                tbTo.ReadOnly       = restrictedEdit;
                tbFrom.ReadOnly     = restrictedEdit;
                tbCc.ReadOnly       = restrictedEdit;
                tbBcc.ReadOnly      = restrictedEdit;
                tbSubject.ReadOnly  = restrictedEdit;

                mfpSMSMessage.Visible     = !restrictedEdit;
                dvpSMSFrom.Enabled        = !restrictedEdit;
                tbSMSTextMessage.ReadOnly = restrictedEdit;
                ceEmailTemplate.ReadOnly  = restrictedEdit;

                (phPushNotification.Controls[0] as PushNotification).Enabled = !restrictedEdit;

                btnSave.Enabled    = !readOnly;
                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;
            }
        }