Ejemplo n.º 1
0
        /// <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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int DeviceId)
        {
            pnlDetails.Visible = true;
            Device Device = null;

            var rockContext = new RockContext();

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

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

            LoadDropDowns();

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

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

            SetPrinterVisibility();
            SetPrinterSettingsVisibility();

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

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

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

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

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

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

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

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

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

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

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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);
                }
            }
        }
        /// <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);
                }
            }
        }
Ejemplo n.º 6
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();
        }
        /// <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;
            }
        }
        /// <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);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="binaryFileTypeId">The binary file type identifier.</param>
        public void ShowDetail(int binaryFileTypeId)
        {
            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

            var rockContext = new RockContext();

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

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

            BinaryFileAttributesState = new List <Attribute>();

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

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

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

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

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

            cbPreferredRequired.Checked = binaryFileType.PreferredRequired;

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

            AttributeService attributeService = new AttributeService(rockContext);

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

            BinaryFileAttributesState = qryBinaryFileAttributes.ToList();

            BindBinaryFileAttributesGrid();

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

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

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

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

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

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

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

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

            // allow these to be edited in restricted edit mode if not readonly
            tbDescription.ReadOnly         = readOnly;
            tbIconCssClass.ReadOnly        = readOnly;
            cbAllowCaching.Enabled         = !readOnly;
            cbRequiresViewSecurity.Enabled = !readOnly;
            cpStorageType.Enabled          = !readOnly;
            nbMaxWidth.ReadOnly            = readOnly;
            nbMaxHeight.ReadOnly           = readOnly;
            ddlPreferredFormat.Enabled     = !readOnly;
            ddlPreferredResolution.Enabled = !readOnly;
            ddlPreferredColorDepth.Enabled = !readOnly;
            cbPreferredRequired.Enabled    = !readOnly;
            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="definedTypeId">The defined type identifier.</param>
        public void ShowDetail(int definedTypeId)
        {
            pnlDetails.Visible = true;
            DefinedType definedType = null;

            if (!definedTypeId.Equals(0))
            {
                definedType = new DefinedTypeService(new RockContext()).Get(definedTypeId);
            }

            if (definedType == null)
            {
                definedType = new DefinedType {
                    Id = 0
                };
            }

            hfDefinedTypeId.SetValue(definedType.Id);

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

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

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

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(definedType);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = false;
                if (definedType.Id > 0)
                {
                    ShowReadonlyDetails(definedType);
                }
                else
                {
                    ShowEditDetails(definedType);
                }
            }

            BindDefinedTypeAttributesGrid();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="tagId">The tag identifier.</param>
        /// <param name="entityTypeId">The entity type identifier.</param>
        public void ShowDetail(int tagId, int?entityTypeId)
        {
            pnlDetails.Visible = false;

            Tag tag = null;

            if (!tagId.Equals(0))
            {
                tag = new TagService(new RockContext()).Get(tagId);
                pdAuditDetails.SetEntity(tag, ResolveRockUrl("~"));
            }

            if (tag == null)
            {
                tag = new Tag {
                    Id                 = 0,
                    CategoryId         = PageParameter("CategoryId").AsIntegerOrNull(),
                    OwnerPersonAliasId = CurrentPersonAliasId,
                    OwnerPersonAlias   = CurrentPersonAlias,
                    EntityTypeId       = entityTypeId
                };

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

            bool canView = _canConfigure || tag.IsAuthorized(Authorization.VIEW, CurrentPerson);

            if (canView)
            {
                bool canEdit = _canConfigure || tag.IsAuthorized(Authorization.EDIT, CurrentPerson);

                pnlDetails.Visible = true;

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

                bool readOnly = false;

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

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

                if (readOnly)
                {
                    btnEdit.Visible   = false;
                    btnDelete.Visible = false;
                    ShowReadonlyDetails(tag);
                }
                else
                {
                    btnEdit.Visible   = true;
                    btnDelete.Visible = true;
                    if (tag.Id > 0)
                    {
                        ShowReadonlyDetails(tag);
                    }
                    else
                    {
                        ShowEditDetails(tag);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("marketingCampaignAdTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            MarketingCampaignAdType marketingCampaignAdType = null;

            if (!itemKeyValue.Equals(0))
            {
                marketingCampaignAdType = new MarketingCampaignAdTypeService().Get(itemKeyValue);
                lActionTitle.Text       = ActionTitle.Edit(MarketingCampaignAdType.FriendlyTypeName);
            }
            else
            {
                marketingCampaignAdType = new MarketingCampaignAdType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(MarketingCampaignAdType.FriendlyTypeName);
            }

            LoadDropDowns();

            // load data into UI controls
            AttributesState = new ViewStateList <Attribute>();

            hfMarketingCampaignAdTypeId.Value = marketingCampaignAdType.Id.ToString();
            tbName.Text = marketingCampaignAdType.Name;
            ddlDateRangeType.SetValue((int)marketingCampaignAdType.DateRangeType);

            AttributeService attributeService = new AttributeService();

            string qualifierValue = marketingCampaignAdType.Id.ToString();
            var    qry            = attributeService.GetByEntityTypeId(new MarketingCampaignAd().TypeId).AsQueryable()
                                    .Where(a => a.EntityTypeQualifierColumn.Equals("MarketingCampaignAdTypeId", StringComparison.OrdinalIgnoreCase) &&
                                           a.EntityTypeQualifierValue.Equals(qualifierValue));

            AttributesState.AddAll(qry.ToList());
            BindMarketingCampaignAdAttributeTypeGrid();

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

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

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

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

            tbName.ReadOnly          = readOnly;
            ddlDateRangeType.Enabled = !readOnly;
            gMarketingCampaignAdAttributeTypes.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 13
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("DataViewId"))
            {
                return;
            }

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

            if (!itemKeyValue.Equals(0))
            {
                dataView = dataViewService.Get(itemKeyValue);
            }
            else
            {
                dataView = new DataView {
                    Id = 0, IsSystem = false, CategoryId = parentCategoryId
                };
            }

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

            pnlDetails.Visible = true;
            hfDataViewId.Value = dataView.Id.ToString();

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

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

            if (dataView.DataViewFilter != null && !dataView.DataViewFilter.IsAuthorized("View", CurrentPerson))
            {
                readOnly = true;
                nbEditModeMessage.Text = "INFO: This Data View contains a filter that you do not have access to view.";
            }

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

            btnSecurity.Visible  = dataView.IsAuthorized("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.Visible = dataViewService.CanDelete(dataView, out errorMessage);
                if (dataView.Id > 0)
                {
                    ShowReadonlyDetails(dataView);
                }
                else
                {
                    ShowEditDetails(dataView);
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="serviceJobId">The service job identifier.</param>
        public void ShowDetail(int serviceJobId)
        {
            pnlDetails.Visible = true;
            LoadDropDowns();

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

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

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

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

            ddlJobTypes.SetValue(job.Class);

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

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

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

            job.LoadAttributes();
            avcAttributes.AddEditControls(job);

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

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

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

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                avcAttributesReadOnly.AddDisplayControls(job);
                avcAttributesReadOnly.Visible = true;
                avcAttributes.Visible         = false;
                tbCronExpression.Text         = job.CronExpression;
            }

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

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Shows the 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);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        public void ShowDetail(int siteId)
        {
            pnlDetails.Visible = false;

            Site site = null;

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

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

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

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

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

            bool readOnly = false;

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

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

            if (readOnly)
            {
                btnEdit.Visible   = false;
                btnDelete.Visible = false;
                ShowReadonlyDetails(site);
            }
            else
            {
                btnEdit.Visible   = true;
                btnDelete.Visible = !site.IsSystem;
                if (site.Id > 0)
                {
                    ShowReadonlyDetails(site);
                }
                else
                {
                    ShowEditDetails(site);
                }
            }
        }
Ejemplo n.º 17
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);
                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);
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="metricValueId">The metric value identifier.</param>
        /// <param name="metricId">The metric identifier.</param>
        public void ShowDetail(int metricValueId, int?metricId)
        {
            pnlDetails.Visible = true;

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

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

            if (metricValue == null && metricId.HasValue)
            {
                metricValue = new MetricValue {
                    Id = 0, MetricId = metricId.Value
                };
                metricValue.Metric = metricValue.Metric ?? new MetricService(new RockContext()).Get(metricValue.MetricId);
                lActionTitle.Text  = ActionTitle.Add(MetricValue.FriendlyTypeName).FormatAsHtmlTitle();
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

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

            LoadDropDowns();

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

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

            nbEditModeMessage.Text = string.Empty;

            bool canEdit = UserCanEdit;

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

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

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

            CreateDynamicControls(metricValue, true, readOnly);

            ddlMetricValueType.Enabled    = !readOnly;
            tbXValue.ReadOnly             = readOnly;
            tbYValue.ReadOnly             = readOnly;
            tbNote.ReadOnly               = readOnly;
            dpMetricValueDateTime.Enabled = !readOnly;

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

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

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

            LoadDropDowns();

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

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

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

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

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

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

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 20
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;
            }
        }
Ejemplo n.º 21
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);
                }
            }
        }
Ejemplo n.º 22
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);
                }
            }
        }
Ejemplo n.º 23
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);
                    }
                }
            }
        }
Ejemplo n.º 24
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;
            }
        }
Ejemplo n.º 25
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;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            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);
        }
Ejemplo n.º 27
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;
        }
Ejemplo n.º 28
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 detail.
        /// </summary>
        /// <param name="blockTypeId">The block type identifier.</param>
        public void ShowDetail(int blockTypeId)
        {
            pnlDetails.Visible = true;

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

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

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

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

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

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

            StringBuilder sb = new StringBuilder();

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

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

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

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

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

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

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

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

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

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

            BindBlockTypeAttributesGrid();
        }
Ejemplo n.º 30
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());
            }
        }