示例#1
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="eventItemId">The eventItem identifier.</param>
        public void ShowDetail(int eventItemId)
        {
            pnlEditDetails.Visible = false;

            EventItem eventItem = null;

            var rockContext = new RockContext();

            if (!eventItemId.Equals(0))
            {
                eventItem = GetEventItem(eventItemId, rockContext);
                pdAuditDetails.SetEntity(eventItem, ResolveRockUrl("~"));
            }

            if (eventItem == null)
            {
                eventItem = new EventItem {
                    Id = 0, IsActive = true, Name = ""
                };
                eventItem.IsApproved = _canApprove;
                var calendarItem = new EventCalendarItem {
                    EventCalendarId = (_calendarId ?? 0)
                };
                eventItem.EventCalendarItems.Add(calendarItem);
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            eventItem.LoadAttributes(rockContext);

            FollowingsHelper.SetFollowing(eventItem, pnlFollowing, this.CurrentPerson);

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;

            if (!_canEdit)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(EventItem.FriendlyTypeName);
            }
            else
            {
                if (eventItem.Id != 0 && !eventItem.EventCalendarItems.Any(i => i.EventCalendarId == (_calendarId ?? 0)))
                {
                    readOnly = true;
                }
            }

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(eventItem);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = true;

                if (!eventItemId.Equals(0))
                {
                    ShowReadonlyDetails(eventItem);
                }
                else
                {
                    ShowEditDetails(eventItem);
                }
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupTypeId">The groupType identifier.</param>
        public void ShowDetail(int groupTypeId)
        {
            pnlDetails.Visible = false;

            bool editAllowed = true;

            GroupType groupType = null;

            if (!groupTypeId.Equals(0))
            {
                groupType = new GroupTypeService(new RockContext()).Get(groupTypeId);
                pdAuditDetails.SetEntity(groupType, ResolveRockUrl("~"));
            }

            if (groupType == null)
            {
                groupType = new GroupType {
                    Id = 0
                };
                var templatePurpose = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE.AsGuid());
                if (templatePurpose != null)
                {
                    groupType.GroupTypePurposeValueId = templatePurpose.Id;
                }

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

            if (groupType != null)
            {
                editAllowed = groupType.IsAuthorized(Authorization.EDIT, CurrentPerson);

                pnlDetails.Visible  = true;
                hfGroupTypeId.Value = groupType.Id.ToString();

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

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

                if (readOnly)
                {
                    btnEdit.Visible   = false;
                    btnDelete.Visible = false;
                    ShowReadonlyDetails(groupType);
                }
                else
                {
                    btnEdit.Visible   = true;
                    btnDelete.Visible = true;

                    if (groupType.Id > 0)
                    {
                        ShowReadonlyDetails(groupType);
                    }
                    else
                    {
                        ShowEditDetails(groupType);
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="dataViewId">The data view identifier.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail(int dataViewId, int?parentCategoryId)
        {
            pnlDetails.Visible = false;

            var rockContext = new RockContext();

            var      dataViewService = new DataViewService(rockContext);
            DataView dataView        = null;

            if (!dataViewId.Equals(0))
            {
                dataView = dataViewService.Get(dataViewId);
                pdAuditDetails.SetEntity(dataView, ResolveRockUrl("~"));
            }

            if (dataView == null)
            {
                dataView = new DataView {
                    Id = 0, IsSystem = false, CategoryId = parentCategoryId
                };
                dataView.Name = string.Empty;

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

            if (!dataView.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                return;
            }

            pnlDetails.Visible      = true;
            hfDataViewId.Value      = dataView.Id.ToString();
            hlblEditDataViewId.Text = "Id: " + dataView.Id.ToString();

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

            nbEditModeMessage.Text = string.Empty;

            string authorizationMessage = string.Empty;

            if (!dataView.IsAuthorizedForAllDataViewComponents(Authorization.EDIT, CurrentPerson, rockContext, out authorizationMessage))
            {
                readOnly = true;
                nbEditModeMessage.Text = authorizationMessage;
            }

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

            btnSecurity.Visible  = dataView.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
            btnSecurity.Title    = dataView.Name;
            btnSecurity.EntityId = dataView.Id;

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(dataView);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Enabled = dataViewService.CanDelete(dataView, out errorMessage);
                if (!btnDelete.Enabled)
                {
                    btnDelete.ToolTip = errorMessage;
                    btnDelete.Attributes["onclick"] = null;
                }

                if (dataView.Id > 0)
                {
                    ShowReadonlyDetails(dataView);
                }
                else
                {
                    ShowEditDetails(dataView);
                }
            }
        }
示例#4
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="categoryId">The category identifier.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail(int categoryId, int?parentCategoryId)
        {
            pnlDetails.Visible = false;

            var      categoryService = new CategoryService(new RockContext());
            Category category        = null;

            if (!categoryId.Equals(0))
            {
                category = categoryService.Get(categoryId);
                pdAuditDetails.SetEntity(category, ResolveRockUrl("~"));
            }

            if (category == null)
            {
                category = new Category {
                    Id = 0, IsSystem = false, ParentCategoryId = parentCategoryId
                };

                // fetch the ParentCategory (if there is one) so that security can check it
                category.ParentCategory            = categoryService.Get(parentCategoryId ?? 0);
                category.EntityTypeId              = entityTypeId;
                category.EntityTypeQualifierColumn = entityTypeQualifierProperty;
                category.EntityTypeQualifierValue  = entityTypeQualifierValue;
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            if (category.EntityTypeId != entityTypeId || !category.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                pnlDetails.Visible = false;
                return;
            }

            pnlDetails.Visible = true;
            hfCategoryId.Value = category.Id.ToString();

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

            nbEditModeMessage.Text = string.Empty;

            // if the person is Authorized to EDIT the category, or has EDIT for the block
            var canEdit = category.IsAuthorized(Authorization.EDIT, CurrentPerson) || this.IsUserAuthorized(Authorization.EDIT);

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

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

            btnSecurity.Visible  = category.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
            btnSecurity.Title    = category.Name;
            btnSecurity.EntityId = category.Id;

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(category);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = true;
                btnDelete.Enabled = categoryService.CanDelete(category, out errorMessage);
                btnDelete.ToolTip = btnDelete.Enabled ? string.Empty : errorMessage;

                if (category.Id > 0)
                {
                    ShowReadonlyDetails(category);
                }
                else
                {
                    ShowEditDetails(category);
                }
            }

            if (btnDelete.Visible && btnDelete.Enabled)
            {
                btnDelete.Attributes["onclick"] = string.Format("javascript: return Rock.dialogs.confirmDelete(event, '{0}');", Category.FriendlyTypeName.ToLower());
            }
        }
示例#5
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="metricId">The metric identifier.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail(int metricId, int?parentCategoryId)
        {
            pnlDetails.Visible = false;

            var    rockContext   = new RockContext();
            var    metricService = new MetricService(rockContext);
            Metric metric        = null;

            if (!metricId.Equals(0))
            {
                metric = metricService.Get(metricId);
            }

            if (metric == null)
            {
                metric = new Metric {
                    Id = 0, IsSystem = false
                };
                metric.SourceValueTypeId = DefinedValueCache.Read(Rock.SystemGuid.DefinedValue.METRIC_SOURCE_VALUE_TYPE_MANUAL.AsGuid()).Id;
                metric.MetricCategories  = new List <MetricCategory>();
                if (parentCategoryId.HasValue)
                {
                    var metricCategory = new MetricCategory {
                        CategoryId = parentCategoryId.Value
                    };
                    metricCategory.Category = metricCategory.Category ?? new CategoryService(rockContext).Get(metricCategory.CategoryId);
                    metric.MetricCategories.Add(metricCategory);
                }
            }

            if (!metric.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                return;
            }

            pnlDetails.Visible = true;
            hfMetricId.Value   = metric.Id.ToString();

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

            nbEditModeMessage.Text = string.Empty;

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

            btnSecurity.Visible  = metric.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
            btnSecurity.Title    = metric.Title;
            btnSecurity.EntityId = metric.Id;

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(metric);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = metricService.CanDelete(metric, out errorMessage);
                if (metric.Id > 0)
                {
                    ShowReadonlyDetails(metric);
                }
                else
                {
                    ShowEditDetails(metric);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="jobId">The job id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "serviceJobId")
            {
                return;
            }

            pnlDetails.Visible = true;
            LoadDropDowns();

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

            if (!itemKeyValue.Equals(0))
            {
                job = new ServiceJobService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(ServiceJob.FriendlyTypeName);
            }
            else
            {
                job = new ServiceJob {
                    Id = 0, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(ServiceJob.FriendlyTypeName);
            }

            hfId.Value                = job.Id.ToString();
            tbName.Text               = job.Name;
            tbDescription.Text        = job.Description;
            cbActive.Checked          = job.IsActive.HasValue ? job.IsActive.Value : false;
            tbAssembly.Text           = job.Assembly;
            tbClass.Text              = job.Class;
            tbNotificationEmails.Text = job.NotificationEmails;
            drpNotificationStatus.SetValue((int)job.NotificationStatus);
            tbCronExpression.Text = job.CronExpression;

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

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

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

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

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            cbActive.Enabled              = !readOnly;
            tbAssembly.ReadOnly           = readOnly;
            tbClass.ReadOnly              = readOnly;
            tbNotificationEmails.ReadOnly = readOnly;
            drpNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="signatureDocumentTemplateId">The signature document type identifier.</param>
        public void ShowDetail(int signatureDocumentTemplateId)
        {
            pnlDetails.Visible = true;
            SignatureDocumentTemplate signatureDocumentTemplate = null;

            using (var rockContext = new RockContext())
            {
                if (!signatureDocumentTemplateId.Equals(0))
                {
                    signatureDocumentTemplate = new SignatureDocumentTemplateService(rockContext).Get(signatureDocumentTemplateId);
                }

                if (signatureDocumentTemplate == null)
                {
                    signatureDocumentTemplate = new SignatureDocumentTemplate {
                        Id = 0
                    };
                    var components = DigitalSignatureContainer.Instance.Components;
                    var entityType = components.Where(c => c.Value.Value.IsActive).OrderBy(c => c.Value.Value.Order).Select(c => c.Value.Value.EntityType).FirstOrDefault();
                    if (entityType != null)
                    {
                        signatureDocumentTemplate.ProviderEntityType = new EntityTypeService(rockContext).Get(entityType.Id);
                    }

                    Guid?fileTypeGuid = GetAttributeValue(AttributeKey.DefaultFileType).AsGuidOrNull();
                    if (fileTypeGuid.HasValue)
                    {
                        var binaryFileType = new BinaryFileTypeService(rockContext).Get(fileTypeGuid.Value);
                        if (binaryFileType != null)
                        {
                            signatureDocumentTemplate.BinaryFileType   = binaryFileType;
                            signatureDocumentTemplate.BinaryFileTypeId = binaryFileType.Id;
                        }
                    }

                    Guid?inviteEmailGuid = GetAttributeValue(AttributeKey.DefaultInviteEmail).AsGuidOrNull();
                    if (inviteEmailGuid.HasValue)
                    {
                        var systemEmail = new SystemCommunicationService(rockContext).Get(inviteEmailGuid.Value);
                        if (systemEmail != null)
                        {
                            signatureDocumentTemplate.InviteSystemCommunication   = systemEmail;
                            signatureDocumentTemplate.InviteSystemCommunicationId = systemEmail.Id;
                        }
                    }
                }

                hfSignatureDocumentTemplateId.SetValue(signatureDocumentTemplate.Id);


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

                nbEditModeMessage.Text = string.Empty;
                bool canEdit = UserCanEdit || signatureDocumentTemplate.IsAuthorized(Authorization.EDIT, CurrentPerson);
                bool canView = canEdit || signatureDocumentTemplate.IsAuthorized(Authorization.VIEW, CurrentPerson);

                if (!canView)
                {
                    pnlDetails.Visible = false;
                }
                else
                {
                    pnlDetails.Visible = true;

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

                    if (readOnly)
                    {
                        btnEdit.Visible   = false;
                        btnDelete.Visible = false;
                        ShowReadonlyDetails(signatureDocumentTemplate);
                    }
                    else
                    {
                        btnEdit.Visible   = true;
                        btnDelete.Visible = false;
                        if (signatureDocumentTemplate.Id > 0)
                        {
                            ShowReadonlyDetails(signatureDocumentTemplate);
                        }
                        else
                        {
                            ShowEditDetails(signatureDocumentTemplate);
                        }
                    }
                }
            }
        }
示例#8
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;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="contentChannelId">The marketing campaign ad type identifier.</param>
        public void ShowDetail(int contentChannelId)
        {
            ContentChannel contentChannel = null;

            bool editAllowed = IsUserAuthorized(Authorization.EDIT);

            var rockContext = new RockContext();

            if (!contentChannelId.Equals(0))
            {
                contentChannel = GetContentChannel(contentChannelId);
                if (contentChannel != null)
                {
                    editAllowed = editAllowed || contentChannel.IsAuthorized(Authorization.EDIT, CurrentPerson);
                }
            }

            if (contentChannel == null)
            {
                contentChannel = new ContentChannel {
                    Id = 0
                };
            }

            if (contentChannel != null && contentChannel.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                hfId.Value = contentChannel.Id.ToString();

                bool readOnly = false;
                nbEditModeMessage.Text = string.Empty;

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

                if (readOnly)
                {
                    lbEdit.Visible = false;
                    ShowReadonlyDetails(contentChannel);
                }
                else
                {
                    lbEdit.Visible = true;
                    if (contentChannel.Id > 0)
                    {
                        ShowReadonlyDetails(contentChannel);
                    }
                    else
                    {
                        ShowEditDetails(contentChannel);
                    }
                }

                lbSave.Visible = !readOnly;
            }
            else
            {
                nbEditModeMessage.Text      = EditModeMessage.NotAuthorizedToView(ContentChannel.FriendlyTypeName);
                pnlEditDetails.Visible      = false;
                fieldsetViewSummary.Visible = false;
            }
        }
示例#10
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="parentCategoryId">The parent category id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?parentCategoryId)
        {
            pnlDetails.Visible = false;
            if (!itemKey.Equals("categoryId"))
            {
                return;
            }

            var      categoryService = new CategoryService();
            Category category        = null;

            if (!itemKeyValue.Equals(0))
            {
                category = categoryService.Get(itemKeyValue);
            }
            else
            {
                category = new Category {
                    Id = 0, IsSystem = false, ParentCategoryId = parentCategoryId
                };
                category.EntityTypeId = entityTypeId;
                category.EntityTypeQualifierColumn = entityTypeQualifierProperty;
                category.EntityTypeQualifierValue  = entityTypeQualifierValue;
            }

            if (category == null || !category.IsAuthorized("View", CurrentPerson))
            {
                return;
            }

            pnlDetails.Visible = true;
            hfCategoryId.Value = category.Id.ToString();

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

            nbEditModeMessage.Text = string.Empty;
            if (!category.IsAuthorized("Edit", CurrentPerson))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Category.FriendlyTypeName);
            }

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

            btnSecurity.Visible  = category.IsAuthorized("Administrate", CurrentPerson);
            btnSecurity.Title    = category.Name;
            btnSecurity.EntityId = category.Id;

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(category);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = categoryService.CanDelete(category, out errorMessage);
                if (category.Id > 0)
                {
                    ShowReadonlyDetails(category);
                }
                else
                {
                    ShowEditDetails(category);
                }
            }
        }
示例#11
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();
                tbPort.Text       = "9107";
            }

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

            tbName.Text        = sign.Name;
            tbPIN.Text         = sign.PIN;
            tbDescription.Text = sign.Description;
            tbIPAddress.Text   = sign.IPAddress;
            if (sign.Id != 0)
            {
                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();
        }
示例#12
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="pageId">The page identifier.</param>
        /// <param name="parentPageId">The parent page identifier.</param>
        public void ShowDetail(int pageId, int?parentPageId)
        {
            var rockContext = new RockContext();

            LoadSites(rockContext);

            PageService pageService = new PageService(rockContext);

            Rock.Model.Page page = pageService.Queryable("Layout,PageRoutes")
                                   .Where(p => p.Id == pageId)
                                   .FirstOrDefault();

            if (page == null)
            {
                page = new Rock.Model.Page {
                    Id = 0, IsSystem = false, ParentPageId = parentPageId
                };

                // fetch the ParentCategory (if there is one) so that security can check it
                page.ParentPage = pageService.Get(parentPageId ?? 0);
            }

            hfPageId.Value = page.Id.ToString();

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

            nbEditModeMessage.Text = string.Empty;

            // if the person is Authorized to EDIT the page, or has EDIT for the block
            var canEdit = page.IsAuthorized(Authorization.EDIT, CurrentPerson) || this.IsUserAuthorized(Authorization.EDIT);

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

            btnSecurity.Visible  = page.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
            btnSecurity.Title    = page.InternalName;
            btnSecurity.EntityId = page.Id;

            aChildPages.HRef = string.Format("javascript: Rock.controls.modal.show($(this), '/pages/{0}?t=Child Pages&amp;pb=&amp;sb=Done')", page.Id);

            // this will be true when used in the Page Builder page, and false when used in the System Dialog
            var enableFullEditMode = this.GetAttributeValue("EnableFullEditMode").AsBooleanOrNull() ?? false;

            pnlEditModeActions.Visible     = enableFullEditMode;
            pnlReadOnlyModeActions.Visible = enableFullEditMode;
            pnlHeading.Visible             = enableFullEditMode;
            pnlDetails.CssClass            = enableFullEditMode ? "panel panel-block" : string.Empty;
            pnlBody.CssClass = enableFullEditMode ? "panel-body" : string.Empty;

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(page);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = true;
                btnDelete.Enabled = pageService.CanDelete(page, out errorMessage);
                btnDelete.ToolTip = btnDelete.Enabled ? string.Empty : errorMessage;

                if (page.Id > 0 && enableFullEditMode)
                {
                    ShowReadonlyDetails(page);
                }
                else
                {
                    ShowEditDetails(page);
                }
            }

            if (btnDelete.Visible && btnDelete.Enabled)
            {
                btnDelete.Attributes["onclick"] = string.Format("javascript: return Rock.dialogs.confirmDelete(event, '{0}');", Rock.Model.Page.FriendlyTypeName.ToLower());
            }
        }
        /// <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;

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

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

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

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

                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;
            }
        }
        /// <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)
        {
            var rockContext = new RockContext();

            pnlDetails.Visible = false;

            if (!itemKey.Equals("businessId"))
            {
                return;
            }

            bool editAllowed = true;

            Person business = null;     // A business is a person

            if (!itemKeyValue.Equals(0))
            {
                business    = new PersonService(rockContext).Get(itemKeyValue);
                editAllowed = business.IsAuthorized(Authorization.EDIT, CurrentPerson);
            }
            else
            {
                business = new Person {
                    Id = 0
                };
            }

            if (business == null)
            {
                return;
            }

            pnlDetails.Visible = true;
            hfBusinessId.Value = business.Id.ToString();

            bool readOnly = false;

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

            if (readOnly)
            {
                ShowSummary(business);
            }
            else
            {
                if (business.Id > 0)
                {
                    ShowSummary(business);
                }
                else
                {
                    ShowEditDetails(business);
                }
            }

            BindContactListGrid(business);
        }
示例#15
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;
            acAddress.SetValues(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;
        }
示例#16
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="eventCalendarId">The Event Calendar Type identifier.</param>
        public void ShowDetail(int eventCalendarId)
        {
            pnlDetails.Visible = false;

            EventCalendar eventCalendar = null;
            var           rockContext   = new RockContext();

            if (!eventCalendarId.Equals(0))
            {
                eventCalendar = GetEventCalendar(eventCalendarId, rockContext);
            }

            if (eventCalendar == null)
            {
                eventCalendar = new EventCalendar {
                    Id = 0
                };
            }

            // Admin rights are needed to edit a calendar ( Edit rights only allow adding/removing items )
            bool adminAllowed = UserCanAdministrate || eventCalendar.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);

            pnlDetails.Visible      = true;
            hfEventCalendarId.Value = eventCalendar.Id.ToString();

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!adminAllowed)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(EventCalendar.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible     = false;
                btnDelete.Visible   = false;
                btnSecurity.Visible = false;
                ShowReadonlyDetails(eventCalendar);
            }
            else
            {
                btnEdit.Visible     = true;
                btnDelete.Visible   = true;
                btnSecurity.Visible = true;

                btnSecurity.Title    = "Secure " + eventCalendar.Name;
                btnSecurity.EntityId = eventCalendar.Id;

                if (!eventCalendarId.Equals(0))
                {
                    ShowReadonlyDetails(eventCalendar);
                }
                else
                {
                    LoadStateDetails(eventCalendar, rockContext);
                    ShowEditDetails(eventCalendar, rockContext);
                }
            }
        }
示例#17
0
        /// <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;
            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;

            btnSave.Visible = !readOnly;
        }
示例#18
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="campusId">The <see cref="Campus"/> identifier.</param>
        public void ShowDetail(int campusId)
        {
            pnlDetails.Visible = false;

            Campus campus = null;

            if (!campusId.Equals(0))
            {
                campus = GetUntrackedCampus(campusId, _readOnlyIncludes);

                pdAuditDetails.SetEntity(campus, ResolveRockUrl("~"));
            }

            if (campus == null)
            {
                campus = new Campus {
                    Id = 0
                };

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

            if (campus.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                pnlDetails.Visible = true;
                hfCampusId.Value   = campus.Id.ToString();

                bool readOnly = false;

                if (!campus.IsAuthorized(Authorization.EDIT, CurrentPerson))
                {
                    readOnly = true;
                    nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Campus.FriendlyTypeName);
                }

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

                if (readOnly)
                {
                    btnEdit.Visible   = false;
                    btnDelete.Visible = false;
                    ShowReadOnlyDetails(campus);
                }
                else
                {
                    btnEdit.Visible   = true;
                    btnDelete.Visible = true;

                    if (campus.Id > 0)
                    {
                        ShowReadOnlyDetails(campus);
                    }
                    else
                    {
                        ShowEditDetails(campus);
                    }
                }
            }
        }
示例#19
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="eventCalendarId">The Event Calendar Type identifier.</param>
        public void ShowDetail(int eventCalendarId)
        {
            pnlDetails.Visible = false;

            EventCalendar eventCalendar = null;
            var           rockContext   = new RockContext();

            cbIndexCalendar.Visible = IndexContainer.IndexingEnabled;
            var descriptionListLeft = new DescriptionList();



            if (!eventCalendarId.Equals(0))
            {
                eventCalendar = GetEventCalendar(eventCalendarId, rockContext);
                pdAuditDetails.SetEntity(eventCalendar, ResolveRockUrl("~"));
            }

            if (eventCalendar == null)
            {
                eventCalendar = new EventCalendar {
                    Id = 0
                };
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            // Admin rights are needed to edit a calendar ( Edit rights only allow adding/removing items )
            bool adminAllowed = UserCanAdministrate || eventCalendar.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);

            pnlDetails.Visible      = true;
            hfEventCalendarId.Value = eventCalendar.Id.ToString();

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

            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!adminAllowed)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(EventCalendar.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible     = false;
                btnDelete.Visible   = false;
                btnSecurity.Visible = false;
                ShowReadonlyDetails(eventCalendar);
            }
            else
            {
                btnEdit.Visible     = true;
                btnDelete.Visible   = true;
                btnSecurity.Visible = true;

                btnSecurity.Title    = "Secure " + eventCalendar.Name;
                btnSecurity.EntityId = eventCalendar.Id;

                if (!eventCalendarId.Equals(0))
                {
                    ShowReadonlyDetails(eventCalendar);
                }
                else
                {
                    LoadStateDetails(eventCalendar, rockContext);
                    ShowEditDetails(eventCalendar, rockContext);
                }
            }

            if (IndexContainer.IndexingEnabled)
            {
                descriptionListLeft.Add("Is Indexed", eventCalendar.IsIndexEnabled.ToYesNo());
            }

            lDetailsLeft.Text = descriptionListLeft.Html;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="mergeTemplateId">The merge template identifier.</param>
        /// <param name="parentCategoryId">The parent category identifier.</param>
        public void ShowDetail(int mergeTemplateId, int?parentCategoryId)
        {
            pnlDetails.Visible = false;

            var rockContext          = new RockContext();
            var mergeTemplateService = new MergeTemplateService(rockContext);

            MergeTemplate mergeTemplate = null;

            if (!mergeTemplateId.Equals(0))
            {
                mergeTemplate = mergeTemplateService.Get(mergeTemplateId);
            }

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

            if (mergeTemplate == null)
            {
                mergeTemplate            = new MergeTemplate();
                mergeTemplate.CategoryId = parentCategoryId ?? 0;

                if (mergeTemplateOwnership == MergeTemplateOwnership.Personal)
                {
                    mergeTemplate.PersonAliasId = this.CurrentPersonAliasId;
                    mergeTemplate.PersonAlias   = this.CurrentPersonAlias;
                }
            }

            pnlDetails.Visible      = true;
            hfMergeTemplateId.Value = mergeTemplateId.ToString();

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

            nbEditModeMessage.Text = string.Empty;
            if (mergeTemplate.PersonAliasId.HasValue && mergeTemplate.PersonAlias.PersonId == this.CurrentPersonId)
            {
                // Allow Person to edit their own Merge Templates
            }
            else if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(MergeTemplate.FriendlyTypeName);
            }

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(mergeTemplate);
            }
            else
            {
                btnEdit.Visible = true;
                string errorMessage = string.Empty;
                btnDelete.Visible = mergeTemplateService.CanDelete(mergeTemplate, out errorMessage);
                if (mergeTemplate.Id > 0)
                {
                    ShowReadonlyDetails(mergeTemplate);
                }
                else
                {
                    ShowEditDetails(mergeTemplate);
                }
            }
        }
示例#21
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="businessId">The business identifier.</param>
        public void ShowDetail(int businessId)
        {
            var rockContext = new RockContext();

            // Load the Campus drop down
            ddlCampus.Items.Clear();
            ddlCampus.Items.Add(new ListItem(string.Empty, string.Empty));
            foreach (var campus in CampusCache.All())
            {
                ListItem li = new ListItem(campus.Name, campus.Id.ToString());
                ddlCampus.Items.Add(li);
            }

            Person business = null;     // A business is a person

            if (!businessId.Equals(0))
            {
                business = new PersonService(rockContext).Get(businessId);
                pdAuditDetails.SetEntity(business, ResolveRockUrl("~"));
            }

            if (business == null)
            {
                business = new Person {
                    Id = 0, Guid = Guid.NewGuid()
                };
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            bool editAllowed = business.IsAuthorized(Authorization.EDIT, CurrentPerson);

            hfBusinessId.Value = business.Id.ToString();

            bool readOnly = false;

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

            if (readOnly)
            {
                ShowSummary(businessId);
            }
            else
            {
                if (business.Id > 0)
                {
                    ShowSummary(business.Id);
                }
                else
                {
                    ShowEditDetails(business);
                }
            }

            BindContactListGrid(business);
        }
示例#22
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int kioskTypeId)
        {
            pnlDetails.Visible = true;
            KioskType kioskType = null;

            var checkinContext = new RockContext();

            if (!kioskTypeId.Equals(0))
            {
                kioskType         = new KioskTypeService(checkinContext).Get(kioskTypeId);
                lActionTitle.Text = ActionTitle.Edit(KioskType.FriendlyTypeName).FormatAsHtmlTitle();
            }

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

            hfKioskTypeId.Value = kioskType.Id.ToString();

            tbName.Text         = kioskType.Name;
            tbDescription.Text  = kioskType.Description;
            tbMessage.Text      = kioskType.Message;
            cbIsMobile.Checked  = kioskType.IsMobile;
            tbGraceMinutes.Text = kioskType.GraceMinutes.ToString();
            tbMinutesValid.Text = kioskType.MinutesValid.ToString();

            ddlTheme.SelectedValue = kioskType.Theme;

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

            Schedules = new Dictionary <int, string>();
            foreach (var schedule in kioskType.Schedules)
            {
                Schedules.Add(schedule.Id, schedule.Name);
            }

            BindDropDownList(kioskType);
            BindLocations();
            BindSchedules();

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

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

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

            ddlCampus.SelectedCampusId = kioskType.CampusId;

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

            btnSave.Visible = !readOnly;
        }
示例#23
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);
                pdAuditDetails.SetEntity(layout, ResolveRockUrl("~"));
            }

            if (layout == null && siteId.HasValue)
            {
                var site = SiteCache.Get(siteId.Value);
                if (site != null)
                {
                    layout = new Layout {
                        Id = 0
                    };
                    layout.SiteId = siteId.Value;
                }
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            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);
                }
            }
        }
示例#24
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;
        }
示例#25
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="projectPointOfAssessmentId">The project point of assessment id.</param>
        /// <param name="competencyPersonProjectAssessmentId">The competency person project assessment id.</param>
        public void ShowDetail(int projectPointOfAssessmentId, int competencyPersonProjectAssessmentId)
        {
            pnlDetails.Visible = true;

            var qry = new ResidencyService <CompetencyPersonProjectAssessmentPointOfAssessment>().Queryable();
            CompetencyPersonProjectAssessmentPointOfAssessment competencyPersonProjectAssessmentPointOfAssessment = null;

            competencyPersonProjectAssessmentPointOfAssessment = qry
                                                                 .Where(a => a.ProjectPointOfAssessmentId.Equals(projectPointOfAssessmentId) && a.CompetencyPersonProjectAssessmentId.Equals(competencyPersonProjectAssessmentId)).FirstOrDefault();

            if (competencyPersonProjectAssessmentPointOfAssessment == null)
            {
                competencyPersonProjectAssessmentPointOfAssessment = new CompetencyPersonProjectAssessmentPointOfAssessment {
                    Id = 0
                };
                competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId = projectPointOfAssessmentId;
                competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment
                    = new ResidencyService <ProjectPointOfAssessment>().Get(projectPointOfAssessmentId);
                competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId = competencyPersonProjectAssessmentId;
                competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment
                    = new ResidencyService <CompetencyPersonProjectAssessment>().Get(competencyPersonProjectAssessmentId);
            }

            hfProjectPointOfAssessmentId.Value          = competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessmentId.ToString();
            hfCompetencyPersonProjectAssessmentId.Value = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessmentId.ToString();

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

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("Edit"))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed("Project Assessment- Point of Assessment");
            }

            if (competencyPersonProjectAssessmentPointOfAssessment.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit("Project Assessment- Point of Assessment");
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add("Project Assessment- Point of Assessment");
            }

            var personProject     = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment.CompetencyPersonProject;
            var projectAssessment = competencyPersonProjectAssessmentPointOfAssessment.CompetencyPersonProjectAssessment;

            lblMainDetails.Text = new DescriptionList()
                                  .Add("Resident", personProject.CompetencyPerson.Person)
                                  .Add("Project", string.Format("{0} - {1}", personProject.Project.Name, personProject.Project.Description))
                                  .Add("Competency", personProject.CompetencyPerson.Competency.Name)
                                  .StartSecondColumn()
                                  .Add("Assessment #", competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment.AssessmentOrder)
                                  .Add("Assessment Text", competencyPersonProjectAssessmentPointOfAssessment.ProjectPointOfAssessment.AssessmentText)
                                  .Add("Assessor", projectAssessment.AssessorPerson)
                                  .Html;

            tbRating.Text      = competencyPersonProjectAssessmentPointOfAssessment.Rating.ToString();
            tbRatingNotes.Text = competencyPersonProjectAssessmentPointOfAssessment.RatingNotes;

            tbRating.ReadOnly      = readOnly;
            tbRatingNotes.ReadOnly = readOnly;

            btnCancel.Visible = !readOnly;
            btnSave.Text      = readOnly ? "Close" : "Save";
        }
示例#26
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();
                pdAuditDetails.SetEntity(device, ResolveRockUrl("~"));
            }

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

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

            LoadDropDowns();

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

            tbName.Text        = device.Name;
            tbDescription.Text = device.Description;
            tbIpAddress.Text   = device.IPAddress;
            cbIsActive.Checked = device.IsActive;
            dvpDeviceType.SetValue(device.DeviceTypeValueId);
            ddlPrintTo.SetValue(device.PrintToOverride.ConvertToInt().ToString());
            ddlPrinter.SetValue(device.PrinterDeviceId);
            ddlPrintFrom.SetValue(device.PrintFrom.ConvertToInt().ToString());
            cbHasCamera.Checked = device.HasCamera;
            if (device.KioskType.HasValue)
            {
                rblKioskType.SetValue(device.KioskType.ConvertToInt());
            }
            ddlIPadCameraBarcodeConfigurationType.SetValue(device.CameraBarcodeConfigurationType.HasValue ? device.CameraBarcodeConfigurationType.ConvertToInt().ToString() : null);

            SetDeviceTypeControlsVisibility();

            Guid?orgLocGuid = GlobalAttributesCache.Get().GetValue("OrganizationAddress").AsGuidOrNull();

            if (orgLocGuid.HasValue)
            {
                var locationGeoPoint = new LocationService(rockContext).GetSelect(orgLocGuid.Value, a => a.GeoPoint);
                if (locationGeoPoint != null)
                {
                    geopPoint.CenterPoint = locationGeoPoint;
                    geopFence.CenterPoint = locationGeoPoint;
                }
            }

            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(AttributeKey.MapStyle).AsGuid();

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

            UpdateAttributeControlsForDeviceType(device);

            // 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;
            cbIsActive.Enabled     = !readOnly;
            dvpDeviceType.Enabled  = !readOnly;
            ddlPrintTo.Enabled     = !readOnly;
            ddlPrinter.Enabled     = !readOnly;
            ddlPrintFrom.Enabled   = !readOnly;
            SetHighlightLabelVisibility(device, readOnly);

            btnSave.Visible = !readOnly;
        }
示例#27
0
        /// <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);

            ddlFrequencyType.BindToDefinedType(DefinedTypeCache.Read(frequencyTypeGuid), true);

            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;

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

                ddlFrequencyType.Enabled = !isReadOnly;

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

                btnSave.Visible = !isReadOnly;
            }
        }
示例#28
0
        /// <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();
                }
            }

            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);
        }
示例#29
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("groupTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            GroupType groupType = null;

            using (new UnitOfWorkScope())
            {
                var groupTypeService = new GroupTypeService();
                var attributeService = new AttributeService();

                if (!itemKeyValue.Equals(0))
                {
                    groupType         = groupTypeService.Get(itemKeyValue);
                    lActionTitle.Text = ActionTitle.Edit(GroupType.FriendlyTypeName);
                }
                else
                {
                    groupType = new GroupType {
                        Id = 0, ShowInGroupList = true
                    };
                    groupType.ChildGroupTypes = new List <GroupType>();
                    groupType.LocationTypes   = new List <GroupTypeLocationType>();
                    lActionTitle.Text         = ActionTitle.Add(GroupType.FriendlyTypeName);
                }

                LoadDropDowns(groupType.Id);

                ChildGroupTypesDictionary = new Dictionary <int, string>();
                LocationTypesDictionary   = new Dictionary <int, string>();
                GroupTypeAttributesState  = new ViewStateList <Attribute>();
                GroupAttributesState      = new ViewStateList <Attribute>();

                hfGroupTypeId.Value    = groupType.Id.ToString();
                tbName.Text            = groupType.Name;
                tbDescription.Text     = groupType.Description;
                tbGroupTerm.Text       = groupType.GroupTerm;
                tbGroupMemberTerm.Text = groupType.GroupMemberTerm;
                ddlDefaultGroupRole.SetValue(groupType.DefaultGroupRoleId);
                cbShowInGroupList.Checked  = groupType.ShowInGroupList;
                cbShowInNavigation.Checked = groupType.ShowInNavigation;
                tbIconCssClass.Text        = groupType.IconCssClass;
                imgIconSmall.ImageId       = groupType.IconSmallFileId;
                imgIconLarge.ImageId       = groupType.IconLargeFileId;

                cbTakesAttendance.Checked = groupType.TakesAttendance;
                ddlAttendanceRule.SetValue((int)groupType.AttendanceRule);
                ddlAttendancePrintTo.SetValue((int)groupType.AttendancePrintTo);
                ddlLocationSelectionMode.SetValue((int)groupType.LocationSelectionMode);
                cbAllowMultipleLocations.Checked          = groupType.AllowMultipleLocations;
                gtpInheritedGroupType.SelectedGroupTypeId = groupType.InheritedGroupTypeId;
                groupType.ChildGroupTypes.ToList().ForEach(a => ChildGroupTypesDictionary.Add(a.Id, a.Name));
                groupType.LocationTypes.ToList().ForEach(a => LocationTypesDictionary.Add(a.LocationTypeValueId, a.LocationTypeValue.Name));

                string qualifierValue         = groupType.Id.ToString();
                var    qryGroupTypeAttributes = attributeService.GetByEntityTypeId(new GroupType().TypeId).AsQueryable()
                                                .Where(a =>
                                                       a.EntityTypeQualifierColumn.Equals("Id", StringComparison.OrdinalIgnoreCase) &&
                                                       a.EntityTypeQualifierValue.Equals(qualifierValue));

                var qryGroupAttributes = attributeService.GetByEntityTypeId(new Group().TypeId).AsQueryable()
                                         .Where(a =>
                                                a.EntityTypeQualifierColumn.Equals("GroupTypeId", StringComparison.OrdinalIgnoreCase) &&
                                                a.EntityTypeQualifierValue.Equals(qualifierValue));

                GroupTypeAttributesState.AddAll(qryGroupTypeAttributes
                                                .OrderBy(a => a.Order)
                                                .ThenBy(a => a.Name)
                                                .ToList());

                GroupAttributesState.AddAll(qryGroupAttributes
                                            .OrderBy(a => a.Order)
                                            .ThenBy(a => a.Name)
                                            .ToList());

                if (groupType.InheritedGroupTypeId.HasValue)
                {
                    RebuildAttributeLists(groupType.InheritedGroupTypeId, groupTypeService, attributeService, false);
                }
            }

            BindGroupTypeAttributesGrid();
            BindGroupAttributesGrid();

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

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

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

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

            ddlDefaultGroupRole.Enabled      = !readOnly;
            tbName.ReadOnly                  = readOnly;
            tbDescription.ReadOnly           = readOnly;
            tbGroupTerm.ReadOnly             = readOnly;
            tbGroupMemberTerm.ReadOnly       = readOnly;
            cbShowInGroupList.Enabled        = !readOnly;
            cbShowInNavigation.Enabled       = !readOnly;
            tbIconCssClass.ReadOnly          = readOnly;
            imgIconLarge.Enabled             = !readOnly;
            imgIconSmall.Enabled             = !readOnly;
            cbTakesAttendance.Enabled        = !readOnly;
            ddlAttendanceRule.Enabled        = !readOnly;
            ddlAttendancePrintTo.Enabled     = !readOnly;
            ddlLocationSelectionMode.Enabled = !readOnly;
            cbAllowMultipleLocations.Enabled = !readOnly;
            gtpInheritedGroupType.Enabled    = !readOnly;
            gGroupTypeAttributes.Enabled     = !readOnly;
            gGroupAttributes.Enabled         = !readOnly;

            gChildGroupTypes.Enabled = !readOnly;
            gLocationTypes.Enabled   = !readOnly;
            btnSave.Visible          = !readOnly;

            BindChildGroupTypesGrid();
            BindLocationTypesGrid();
        }
示例#30
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="contentChannelId">The marketing campaign ad type identifier.</param>
        public void ShowDetail(int contentChannelId)
        {
            ContentChannel contentChannel = null;

            cbIndexChannel.Visible = IndexContainer.IndexingEnabled;

            bool editAllowed = IsUserAuthorized(Authorization.EDIT);

            var rockContext = new RockContext();

            if (!contentChannelId.Equals(0))
            {
                contentChannel = GetContentChannel(contentChannelId);
                if (contentChannel != null)
                {
                    editAllowed = editAllowed || contentChannel.IsAuthorized(Authorization.EDIT, CurrentPerson);
                }
                pdAuditDetails.SetEntity(contentChannel, ResolveRockUrl("~"));
            }

            if (contentChannel == null)
            {
                contentChannel = new ContentChannel {
                    Id = 0
                };
                contentChannel.ChildContentChannels = new List <ContentChannel>();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            if (contentChannel != null && contentChannel.IsAuthorized(Authorization.VIEW, CurrentPerson))
            {
                hfId.Value = contentChannel.Id.ToString();

                bool readOnly = false;
                nbEditModeMessage.Text = string.Empty;

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

                if (readOnly)
                {
                    lbEdit.Visible = false;
                    ShowReadonlyDetails(contentChannel);
                }
                else
                {
                    lbEdit.Visible = true;
                    if (contentChannel.Id > 0)
                    {
                        ShowReadonlyDetails(contentChannel);
                    }
                    else
                    {
                        ShowEditDetails(contentChannel);
                    }
                }

                btnSecurity.Visible  = contentChannel.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);
                btnSecurity.Title    = contentChannel.Name;
                btnSecurity.EntityId = contentChannel.Id;

                lbSave.Visible = !readOnly;
            }
            else
            {
                nbEditModeMessage.Text      = EditModeMessage.NotAuthorizedToView(ContentChannel.FriendlyTypeName);
                pnlEditDetails.Visible      = false;
                fieldsetViewSummary.Visible = false;
            }
        }