Ejemplo n.º 1
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, OwnerPersonAliasId = CurrentPersonAliasId, OwnerPersonAlias = CurrentPersonAlias };
                if ( entityTypeId.HasValue )
                {
                    tag.EntityTypeId = entityTypeId.Value;
                }
                // hide the panel drawer that show created and last modified dates
                pdAuditDetails.Visible = false;
            }

            pnlDetails.Visible = true;
            hfId.Value = tag.Id.ToString();

            bool readOnly = false;

            if ( !_canConfigure && ( tag.OwnerPersonAlias == null || tag.OwnerPersonAlias.PersonId != CurrentPersonId ) )
            {
                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.º 2
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("definedTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            DefinedType definedType = null;

            if (!itemKeyValue.Equals(0))
            {
                definedType = new DefinedTypeService().Get(itemKeyValue);
            }
            else
            {
                definedType = new DefinedType {
                    Id = 0
                };
            }

            hfDefinedTypeId.SetValue(definedType.Id);

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

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized("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;
                ShowReadonlyDetails(definedType);
            }
            else
            {
                btnEdit.Visible = true;
                if (definedType.Id > 0)
                {
                    ShowReadonlyDetails(definedType);
                }
                else
                {
                    ShowEditDetails(definedType);
                }
            }

            BindDefinedTypeAttributesGrid();
            BindDefinedValuesGrid();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "campusId")
            {
                return;
            }

            pnlDetails.Visible = true;

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

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

            hfCampusId.Value   = campus.Id.ToString();
            tbCampusName.Text  = campus.Name;
            tbCampusCode.Text  = campus.ShortCode;
            tbPhoneNumber.Text = campus.PhoneNumber;
            ppCampusLeader.SetValue(campus.LeaderPersonAlias != null ? campus.LeaderPersonAlias.Person : null);

            // 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="routeId">The route identifier.</param>
        public void ShowDetail(int routeId)
        {
            pnlDetails.Visible = true;

            PageRoute pageRoute = null;

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

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

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

            ShowSite();

            tbRoute.Text = pageRoute.Route;

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

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

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

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

            ppPage.Enabled   = !readOnly;
            tbRoute.ReadOnly = readOnly;
            btnSave.Visible  = !readOnly;
        }
        /// <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("pageRouteId"))
            {
                return;
            }

            pnlDetails.Visible = true;

            PageRoute pageRoute = null;

            if (!itemKeyValue.Equals(0))
            {
                pageRoute         = new PageRouteService().Get(itemKeyValue);
                lActionTitle.Text = ActionTitle.Edit(PageRoute.FriendlyTypeName);
            }
            else
            {
                pageRoute = new PageRoute {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(PageRoute.FriendlyTypeName);
            }

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

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

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

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

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

            ppPage.Enabled   = !readOnly;
            tbRoute.ReadOnly = readOnly;
            btnSave.Visible  = !readOnly;
        }
        public void ShowDetail(GroupRole groupRole)
        {
            if (groupRole.Id > 0)
            {
                lActionTitle.Text = ActionTitle.Edit(GroupRole.FriendlyTypeName);
            }
            else
            {
                lActionTitle.Text = ActionTitle.Add(GroupRole.FriendlyTypeName);
            }

            LoadDropDowns();

            hfGroupRoleId.Value        = groupRole.Id.ToString();
            tbName.Text                = groupRole.Name;
            tbDescription.Text         = groupRole.Description;
            ddlGroupType.SelectedValue = groupRole.GroupTypeId.ToString();
            tbSortOrder.Text           = groupRole.SortOrder != null?groupRole.SortOrder.ToString() : string.Empty;

            tbMaxCount.Text = groupRole.MaxCount != null?groupRole.MaxCount.ToString() : string.Empty;

            tbMinCount.Text = groupRole.MinCount != null?groupRole.MinCount.ToString() : string.Empty;

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

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

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

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

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;
            ddlGroupType.Enabled   = !readOnly;
            tbSortOrder.ReadOnly   = readOnly;
            tbMaxCount.ReadOnly    = readOnly;
            tbMinCount.ReadOnly    = readOnly;
            btnSave.Visible        = !readOnly;
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="lavaShortcodeId">The Lava Shortcode identifier.</param>
        public void ShowDetail(int lavaShortcodeId)
        {
            pnlDetails.Visible = true;

            // Load depending on Add(0) or Edit
            LavaShortcode lavaShortcode = null;

            if (!lavaShortcodeId.Equals(0))
            {
                lavaShortcode     = new LavaShortcodeService(new RockContext()).Get(lavaShortcodeId);
                lActionTitle.Text = ActionTitle.Edit(LavaShortcode.FriendlyTypeName).FormatAsHtmlTitle();
                pdAuditDetails.SetEntity(lavaShortcode, ResolveRockUrl("~"));
            }

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

            hfLavaShortcodeId.Value = lavaShortcode.Id.ToString();

            // 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 (lavaShortcode.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlySystem(Campus.FriendlyTypeName);
            }

            if (readOnly)
            {
                ShowReadonlyDetails(lavaShortcode);
            }
            else
            {
                ShowEditDetails(lavaShortcode);
            }
        }
Ejemplo n.º 8
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);
                }
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="groupId">The group id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?groupId)
        {
            pnlDetails.Visible = false;
            if (!itemKey.Equals("groupMemberId"))
            {
                return;
            }

            GroupMember groupMember = null;

            if (!itemKeyValue.Equals(0))
            {
                groupMember = new GroupMemberService().Get(itemKeyValue);
                groupMember.LoadAttributes();
            }
            else
            {
                // only create a new one if parent was specified
                if (groupId != null)
                {
                    groupMember = new GroupMember {
                        Id = 0
                    };
                    groupMember.GroupId           = groupId.Value;
                    groupMember.Group             = new GroupService().Get(groupMember.GroupId);
                    groupMember.GroupRoleId       = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
                    groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                }
            }

            if (groupMember == null)
            {
                return;
            }

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

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

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

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

            if (readOnly)
            {
                btnEdit.Visible = false;
                ShowReadonlyDetails(groupMember);
            }
            else
            {
                btnEdit.Visible = true;
                if (groupMember.Id > 0)
                {
                    ShowReadonlyDetails(groupMember);
                }
                else
                {
                    ShowEditDetails(groupMember);
                }
            }
        }
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupMemberId">The group member identifier.</param>
        /// <param name="groupId">The group id.</param>
        public void ShowDetail(int groupMemberId, int?groupId)
        {
            // autoexpand the person picker if this is an add
            this.Page.ClientScript.RegisterStartupScript(
                this.GetType(),
                "StartupScript", @"Sys.Application.add_load(function () {

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

            });", true);

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

            if (!groupMemberId.Equals(0))
            {
                groupMember = new GroupMemberService(rockContext).Get(groupMemberId);
            }
            else
            {
                // only create a new one if parent was specified
                if (groupId.HasValue)
                {
                    groupMember = new GroupMember {
                        Id = 0
                    };
                    groupMember.GroupId           = groupId.Value;
                    groupMember.Group             = new GroupService(rockContext).Get(groupMember.GroupId);
                    groupMember.GroupRoleId       = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
                    groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                }
            }

            if (groupMember == null)
            {
                nbErrorMessage.Title   = "Invalid Request";
                nbErrorMessage.Text    = "An incorrect querystring parameter was used.  A valid GroupMemberId or GroupId parameter is required.";
                pnlEditDetails.Visible = false;
                return;
            }

            pnlEditDetails.Visible = true;

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

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

            var group = groupMember.Group;

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

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

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

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

            btnSave.Visible = !readOnly;

            LoadDropDowns();

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

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

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

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

            Rock.Attribute.Helper.AddEditControls(groupMember, phAttributes, true, "", true);
            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(groupMember, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
            }
            else
            {
                phAttributesReadOnly.Visible = false;
                phAttributes.Visible         = true;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="groupMemberId">The group member identifier.</param>
        /// <param name="groupId">The group id.</param>
        public void ShowDetail(int groupMemberId, int?groupId)
        {
            // autoexpand the person picker if this is an add
            var personPickerStartupScript = @"Sys.Application.add_load(function () {

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

            });";

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

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

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

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

                pnlEditDetails.Visible = false;
                return;
            }

            pnlEditDetails.Visible = true;

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

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

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

            var group = groupMember.Group;

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

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

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

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

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

            btnSave.Visible = !readOnly;

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

            LoadDropDowns();

            ShowRequiredDocumentStatus(rockContext, groupMember, group);

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

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

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

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

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

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

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

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

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

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

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

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

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

            var groupHasRequirements = group.GroupRequirements.Any();

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

            ShowGroupRequirementsStatuses();
        }
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("WorkflowTriggerId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            WorkflowTrigger WorkflowTrigger = null;

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

            LoadDropDowns();

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

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

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

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

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

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

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

            if (!UserCanEdit && !metric.IsAuthorized(Authorization.EDIT, CurrentPerson))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.NotAuthorizedToEdit(Metric.FriendlyTypeName);
            }

            bool canAdministrate = UserCanAdministrate || metric.IsAuthorized(Authorization.ADMINISTRATE, CurrentPerson);

            if (canAdministrate)
            {
                btnSecurity.Visible  = true;
                btnSecurity.Title    = metric.Title;
                btnSecurity.EntityId = metric.Id;
            }
            else
            {
                btnSecurity.Visible = false;
            }

            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);
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The group id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?parentGroupId)
        {
            pnlDetails.Visible = false;
            if (!itemKey.Equals("groupId"))
            {
                return;
            }

            Group group = null;

            if (!itemKeyValue.Equals(0))
            {
                group = new GroupService().Get(itemKeyValue);
            }
            else
            {
                group = new Group {
                    Id = 0, IsActive = true, ParentGroupId = parentGroupId
                };
            }

            if (group == null)
            {
                return;
            }

            pnlDetails.Visible = true;
            hfGroupId.Value    = group.Id.ToString();

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

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

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

            bool roleBelowMimumumMembership = false;

            if (bool.TryParse(PageParameter("roleBelowMin"), out roleBelowMimumumMembership))
            {
                int roleId = 0;

                int.TryParse(PageParameter("roleId"), out roleId);

                if (roleBelowMimumumMembership && roleId > 0)
                {
                    GroupRole role = new GroupRoleService().Get(roleId);

                    if (role.MinCount != null)
                    {
                        int groupRoleMemberCount = GetGroupRoleMemberCount(itemKeyValue, roleId);

                        string minumumMemberText = string.Format("The {0} role is currently below it's minimum active membership requirement of {1} {2}.",
                                                                 role.Name,
                                                                 role.MinCount,
                                                                 role.MinCount == 1 ? "member" : "members"
                                                                 );

                        if (nbEditModeMessage.Text.Length > 0)
                        {
                            nbEditModeMessage.Text = nbEditModeMessage.Text + " <br> " + minumumMemberText;
                        }
                        else
                        {
                            nbEditModeMessage.Text = "INFO: " + minumumMemberText;
                        }
                    }
                }
            }

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

            if (job == null)
            {
                job = new ServiceJob {
                    Id = 0, IsActive = true
                };
                lActionTitle.Text = ActionTitle.Add(ServiceJob.FriendlyTypeName).FormatAsHtmlTitle();
            }

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

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

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

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

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

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

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

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


            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            cbActive.Enabled              = !readOnly;
            ddlJobTypes.Enabled           = !readOnly;
            tbNotificationEmails.ReadOnly = readOnly;
            ddlNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            // return if unexpected itemKey
            if (itemKey != "blockTypeId")
            {
                return;
            }

            pnlDetails.Visible = true;

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

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

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

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

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

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

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

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(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;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The group id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?entityTypeId)
        {
            pnlDetails.Visible = false;
            if (!itemKey.Equals("tagId"))
            {
                return;
            }

            Tag tag = null;

            if (!itemKeyValue.Equals(0))
            {
                tag = new TagService().Get(itemKeyValue);
            }
            else
            {
                tag = new Tag {
                    Id = 0, OwnerId = CurrentPersonId
                };
                if (entityTypeId.HasValue)
                {
                    tag.EntityTypeId = entityTypeId.Value;
                }
            }

            if (tag == null)
            {
                return;
            }

            pnlDetails.Visible = true;
            hfId.Value         = tag.Id.ToString();

            bool readOnly = false;

            if (!_canConfigure && tag.OwnerId != CurrentPersonId)
            {
                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);
                }
            }
        }
        /// <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).FormatAsHtmlTitle();
            }
            else
            {
                marketingCampaignAdType = new MarketingCampaignAdType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(MarketingCampaignAdType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            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.º 19
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        public void ShowDetail(string itemKey, int itemKeyValue)
        {
            if (!itemKey.Equals("binaryFileTypeId"))
            {
                return;
            }

            pnlDetails.Visible = true;
            BinaryFileType binaryFileType = null;

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

            BinaryFileAttributesState = new ViewStateList <Attribute>();

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

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

            AttributeService attributeService = new AttributeService();

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

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

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

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

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

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

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            tbIconCssClass.ReadOnly       = readOnly;
            imgIconLarge.Enabled          = !readOnly;
            imgIconSmall.Enabled          = !readOnly;
            gBinaryFileAttributes.Enabled = !readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 20
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());
            }
        }
Ejemplo n.º 21
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.º 22
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.º 23
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;
            dvpCampusStatus.SetValue(campus.CampusStatusValueId);
            dvpCampusType.SetValue(campus.CampusTypeValueId);
            tbCampusCode.Text   = campus.ShortCode;
            tbUrl.Text          = campus.Url;
            tbPhoneNumber.Text  = campus.PhoneNumber;
            lpLocation.Location = campus.Location;

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

            campus.LoadAttributes();
            avcAttributes.ExcludedAttributes = campus.Attributes.Where(a => !a.Value.IsAuthorized(Rock.Security.Authorization.EDIT, this.CurrentPerson)).Select(a => a.Value).ToArray();
            avcAttributes.AddEditControls(campus);

            // 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.º 24
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.BinaryFileId  = groupType.IconSmallFileId;
                imgIconLarge.BinaryFileId  = groupType.IconLargeFileId;

                cbTakesAttendance.Checked = groupType.TakesAttendance;
                ddlAttendanceRule.SetValue((int)groupType.AttendanceRule);
                ddlAttendancePrintTo.SetValue((int)groupType.AttendancePrintTo);
                ddlLocationSelectionMode.SetValue((int)groupType.LocationSelectionMode);
                ddlGroupTypePurpose.SetValue(groupType.GroupTypePurposeValueId);
                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;
            ddlGroupTypePurpose.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();
        }
Ejemplo n.º 25
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)
        {
            if (!itemKey.Equals("workflowTypeId"))
            {
                pnlDetails.Visible = false;
                return;
            }

            WorkflowType workflowType = null;

            if (!itemKeyValue.Equals(0))
            {
                workflowType = new WorkflowTypeService().Get(itemKeyValue);
            }
            else
            {
                workflowType = new WorkflowType {
                    Id = 0, IsActive = true, IsPersisted = true, IsSystem = false, CategoryId = parentCategoryId
                };
            }

            if (workflowType == null)
            {
                return;
            }

            pnlDetails.Visible     = true;
            hfWorkflowTypeId.Value = workflowType.Id.ToString();

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

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

            if (workflowType.IsSystem)
            {
                readOnly = true;
                nbEditModeMessage.Heading = "Information";
                nbEditModeMessage.Text    = EditModeMessage.ReadOnlySystem(WorkflowType.FriendlyTypeName);
            }

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

            BindWorkflowTypeAttributesGrid();
        }
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)
        {
            // return if unexpected itemKey
            if (itemKey != "serviceJobId")
            {
                return;
            }

            pnlDetails.Visible = true;
            LoadDropDowns();

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

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

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

            if (job.Id == 0)
            {
                job.Class = ddlJobTypes.SelectedValue;
            }

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

            // 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).FormatAsHtmlTitle();
                btnCancel.Text    = "Close";
                Rock.Attribute.Helper.AddDisplayControls(job, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
                tbCronExpression.Text        = ExpressionDescriptor.GetDescription(job.CronExpression);
            }

            tbName.ReadOnly               = readOnly;
            tbDescription.ReadOnly        = readOnly;
            cbActive.Enabled              = !readOnly;
            ddlJobTypes.Enabled           = !readOnly;
            tbNotificationEmails.ReadOnly = readOnly;
            ddlNotificationStatus.Enabled = !readOnly;
            tbCronExpression.ReadOnly     = readOnly;

            btnSave.Visible = !readOnly;
        }
Ejemplo n.º 27
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);
                }
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Shows the detail.
        /// </summary>
        /// <param name="itemKey">The item key.</param>
        /// <param name="itemKeyValue">The item key value.</param>
        /// <param name="groupId">The group id.</param>
        public void ShowDetail(string itemKey, int itemKeyValue, int?groupId)
        {
            if (!itemKey.Equals("GroupMemberId"))
            {
                return;
            }

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

            if (!itemKeyValue.Equals(0))
            {
                groupMember = new GroupMemberService(rockContext).Get(itemKeyValue);
                groupMember.LoadAttributes();
            }
            else
            {
                // only create a new one if parent was specified
                if (groupId.HasValue)
                {
                    groupMember = new GroupMember {
                        Id = 0
                    };
                    groupMember.GroupId           = groupId.Value;
                    groupMember.Group             = new GroupService(rockContext).Get(groupMember.GroupId);
                    groupMember.GroupRoleId       = groupMember.Group.GroupType.DefaultGroupRoleId ?? 0;
                    groupMember.GroupMemberStatus = GroupMemberStatus.Active;
                }
            }

            if (groupMember == null)
            {
                return;
            }

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

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

            var group = groupMember.Group;

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

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

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

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

            btnSave.Visible = !readOnly;

            LoadDropDowns();

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

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

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

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

            Rock.Attribute.Helper.AddEditControls(groupMember, phAttributes, true, "", true);
            if (readOnly)
            {
                Rock.Attribute.Helper.AddDisplayControls(groupMember, phAttributesReadOnly);
                phAttributesReadOnly.Visible = true;
                phAttributes.Visible         = false;
            }
            else
            {
                phAttributesReadOnly.Visible = false;
                phAttributes.Visible         = true;
            }
        }
Ejemplo n.º 29
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);
                pdAuditDetails.SetEntity(definedType, ResolveRockUrl("~"));
            }

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

            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.º 30
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("MetricId"))
            {
                return;
            }

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

            if (!itemKeyValue.Equals(0))
            {
                metric = metricService.Get(itemKeyValue);
            }
            else
            {
                metric = new Metric {
                    Id = 0, IsSystem = false
                };
                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 == null || !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);
                }
            }
        }