Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            RockPage.AddScriptLink("~/Scripts/CheckinClient/ZebraPrint.js");
            RockPage.AddCSSLink("~/Styles/fluidbox.css");
            RockPage.AddScriptLink("~/Scripts/jquery.fluidbox.min.js");

            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlContent);

            gAttendanceHistory.DataKeyNames = new string[] { "Id" };

            var leftBadgeGuids  = GetAttributeValues(AttributeKey.BadgesLeft).AsGuidList();
            var rightBadgeGuids = GetAttributeValues(AttributeKey.BadgesRight).AsGuidList();

            var leftBadges  = leftBadgeGuids.Select(a => BadgeCache.Get(a)).Where(a => a != null).OrderBy(a => a.Order).ToList();
            var rightBadges = rightBadgeGuids.Select(a => BadgeCache.Get(a)).Where(a => a != null).OrderBy(a => a.Order).ToList();

            // Set BadgeEntity using a new RockContext that won't get manually disposed.
            var badgesEntity = new PersonService(new RockContext()).Get(GetPersonGuid());

            blBadgesLeft.Entity  = badgesEntity;
            blBadgesRight.Entity = badgesEntity;

            foreach (var badge in leftBadges)
            {
                blBadgesLeft.BadgeTypes.Add(badge);
            }

            foreach (var badge in rightBadges)
            {
                blBadgesRight.BadgeTypes.Add(badge);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Shows the badges.
        /// </summary>
        /// <param name="businessId">The business identifier.</param>
        private void ShowBadges(int businessId)
        {
            var business = new PersonService(new RockContext()).Get(businessId);

            Entity = business;

            string badgeList = GetAttributeValue(AttributeKey.Badges);

            blStatus.BadgeTypes.Clear();
            if (!string.IsNullOrWhiteSpace(badgeList))
            {
                foreach (string badgeGuid in badgeList.SplitDelimitedValues())
                {
                    Guid guid = badgeGuid.AsGuid();
                    if (guid != Guid.Empty)
                    {
                        var badge = BadgeCache.Get(guid);
                        if (badge != null)
                        {
                            blStatus.BadgeTypes.Add(badge);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the Guid for the Badge that has the specified Id
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public override Guid?GetGuid(int id)
        {
            var cacheItem = BadgeCache.Get(id);

            if (cacheItem != null)
            {
                return(cacheItem.Guid);
            }

            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Restores view-state information from a previous page request that was saved by the <see cref="M:System.Web.UI.Control.SaveViewState" /> method.
        /// </summary>
        /// <param name="savedState">An <see cref="T:System.Object" /> that represents the control state to be restored.</param>
        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);

            var badgeId = ViewState["BadgeId"] as int?;

            if (badgeId.HasValue)
            {
                BadgeCache = BadgeCache.Get(badgeId.Value);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Restores view-state information from a previous request that was saved with the <see cref="M:System.Web.UI.WebControls.WebControl.SaveViewState" /> method.
        /// </summary>
        /// <param name="savedState">An object that represents the control state to restore.</param>
        protected override void LoadViewState(object savedState)
        {
            base.LoadViewState(savedState);
            var delimitedIds = ViewState["BadgeTypeIds"] as string;

            if (!string.IsNullOrWhiteSpace(delimitedIds))
            {
                var badgeTypeIds = delimitedIds.Split(',').Select(s => s.AsIntegerOrNull()).Where(i => i.HasValue);
                BadgeTypes = badgeTypeIds.Select(id => BadgeCache.Get(id.Value)).ToList();
            }
        }
Exemplo n.º 6
0
        //  overrides of the base RockBlock methods (i.e. OnInit, OnLoad)

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            RockPage.AddCSSLink("~/Styles/fluidbox.css");
            RockPage.AddScriptLink("~/Scripts/imagesloaded.min.js");
            RockPage.AddScriptLink("~/Scripts/jquery.fluidbox.min.js");

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(upnlContent);

            gHistory.DataKeyNames = new string[] { "Id" };


            var leftBadgeGuids  = GetAttributeValues(AttributeKey.BadgesLeft).AsGuidList();
            var rightBadgeGuids = GetAttributeValues(AttributeKey.BadgesRight).AsGuidList();

            var leftBadges  = leftBadgeGuids.Select(a => BadgeCache.Get(a)).Where(a => a != null).OrderBy(a => a.Order).ToList();
            var rightBadges = rightBadgeGuids.Select(a => BadgeCache.Get(a)).Where(a => a != null).OrderBy(a => a.Order).ToList();

            // set BadgeEntity using a new RockContext that won't get manually disposed
            var badgesEntity = new PersonService(new RockContext()).Get(GetPersonGuid());

            blBadgesLeft.Entity  = badgesEntity;
            blBadgesRight.Entity = badgesEntity;

            foreach (var badge in leftBadges)
            {
                blBadgesLeft.BadgeTypes.Add(badge);
            }

            foreach (var badge in rightBadges)
            {
                blBadgesRight.BadgeTypes.Add(badge);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!Page.IsPostBack && Entity != null && Entity.Id != 0)
            {
                string badgeList = GetAttributeValue("Badges");
                if (!string.IsNullOrWhiteSpace(badgeList))
                {
                    foreach (string badgeGuid in badgeList.SplitDelimitedValues())
                    {
                        Guid guid = badgeGuid.AsGuid();
                        if (guid != Guid.Empty)
                        {
                            var badge = BadgeCache.Get(guid);
                            if (badge != null)
                            {
                                blBadges.BadgeTypes.Add(badge);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Gets the cache object associated with this Entity
 /// </summary>
 /// <returns></returns>
 public IEntityCache GetCacheObject()
 {
     return(BadgeCache.Get(this.Id));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            RockPage.AddCSSLink("~/Styles/fluidbox.css");
            RockPage.AddScriptLink("~/Scripts/imagesloaded.min.js");
            RockPage.AddScriptLink("~/Scripts/jquery.fluidbox.min.js");

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(pnlContent);

            if (Person == null)
            {
                return;
            }

            // If this is the empty person, check for an old Alias record and if found, redirect permanent to it instead.
            if (Person.Id == 0)
            {
                //referring to aliasPersonId as person might be merged
                var personId = this.PageParameter(PageParameterKey.PersonId).AsIntegerOrNull();

                if (personId.HasValue)
                {
                    var personAlias = new PersonAliasService(new RockContext()).GetByAliasId(personId.Value);
                    if (personAlias != null)
                    {
                        var pageReference = RockPage.PageReference;
                        pageReference.Parameters.AddOrReplace(PageParameterKey.PersonId, personAlias.PersonId.ToString());
                        Response.RedirectPermanent(pageReference.BuildUrl(), false);
                    }
                }
            }

            pnlFollow.Visible = GetAttributeValue(AttributeKey.AllowFollowing).AsBoolean();

            // Record Type - this is always "business". it will never change.
            if (Person.IsBusiness())
            {
                var parms = new Dictionary <string, string>();
                parms.Add(PageParameterKey.BusinessId, Person.Id.ToString());
                NavigateToLinkedPage(AttributeKey.BusinessDetailPage, parms);
            }
            else if (Person.IsNameless())
            {
                var parms = new Dictionary <string, string>();
                parms.Add(PageParameterKey.NamelessPersonId, Person.Id.ToString());
                NavigateToLinkedPage(AttributeKey.NamelessPersonDetailPage, parms);
            }

            if (Person.IsDeceased)
            {
                divBio.AddCssClass("deceased");
            }

            // Set the browser page title to include person's name
            RockPage.BrowserTitle = Person.FullName;

            string badgeList = GetAttributeValue(AttributeKey.Badges);

            if (!string.IsNullOrWhiteSpace(badgeList))
            {
                foreach (string badgeGuid in badgeList.SplitDelimitedValues())
                {
                    Guid guid = badgeGuid.AsGuid();
                    if (guid != Guid.Empty)
                    {
                        var badge = BadgeCache.Get(guid);
                        if (badge != null)
                        {
                            blStatus.BadgeTypes.Add(badge);
                        }
                    }
                }
            }

            if (Person.AccountProtectionProfile > Rock.Utility.Enums.AccountProtectionProfile.Low)
            {
                hlAccountProtectionLevel.Visible = true;
                hlAccountProtectionLevel.Text    = $"Protection Profile: {Person.AccountProtectionProfile.ConvertToString( true )}";
                if (Person.AccountProtectionProfile == Rock.Utility.Enums.AccountProtectionProfile.Extreme)
                {
                    // show 'danger' if AccountProtectionProfile is extreme
                    hlAccountProtectionLevel.LabelType = LabelType.Danger;
                }
                else
                {
                    hlAccountProtectionLevel.LabelType = LabelType.Warning;
                }
            }
            else
            {
                hlAccountProtectionLevel.Visible = false;
            }

            lbEditPerson.Visible = IsUserAuthorized(Rock.Security.Authorization.EDIT);

            // only show if the when all these are true
            //   -- EnableImpersonation is enabled
            //   -- Not the same as the current person
            //   -- The current user is authorized to Administrate the person
            //   -- PersonToken usage is allowed on the person (due to AccountProtectionProfile)

            bool enableImpersonation = this.GetAttributeValue(AttributeKey.EnableImpersonation).AsBoolean();

            lbImpersonate.Visible = false;
            if (enableImpersonation &&
                Person.Id != CurrentPersonId &&
                Person.IsAuthorized(Rock.Security.Authorization.ADMINISTRATE, this.CurrentPerson)
                )
            {
                // We are allowed to impersonate for anybody that has Token Usage Allowed.
                lbImpersonate.Visible = true;

                if (Person.IsPersonTokenUsageAllowed() == false)
                {
                    // Since the logged-in user would normally see an Impersonate button, but this Person doesn't have TokenUsage allowed,
                    // show the button, but have it be disabled.
                    lbImpersonate.Enabled = false;
                }
                else
                {
                    lbImpersonate.Enabled = true;
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            RockPage.AddCSSLink("~/Styles/fluidbox.css");
            RockPage.AddScriptLink("~/Scripts/imagesloaded.min.js");
            RockPage.AddScriptLink("~/Scripts/jquery.fluidbox.min.js");

            // this event gets fired after block settings are updated. it's nice to repaint the screen if these settings would alter it
            this.BlockUpdated += Block_BlockUpdated;
            this.AddConfigurationUpdateTrigger(pnlContent);

            if (Person == null)
            {
                return;
            }

            // If this is the empty person, check for an old Alias record and if found, redirect permanent to it instead.
            if (Person.Id == 0)
            {
                //referring to aliasPersonId as person might be merged
                var personId = this.PageParameter(PageParameterKey.PersonId).AsIntegerOrNull();

                if (personId.HasValue)
                {
                    var personAlias = new PersonAliasService(new RockContext()).GetByAliasId(personId.Value);
                    if (personAlias != null)
                    {
                        var pageReference = RockPage.PageReference;
                        pageReference.Parameters.AddOrReplace(PageParameterKey.PersonId, personAlias.PersonId.ToString());
                        Response.RedirectPermanent(pageReference.BuildUrl(), false);
                    }
                }
            }

            pnlFollow.Visible = GetAttributeValue(AttributeKey.AllowFollowing).AsBoolean();

            // Record Type - this is always "business". it will never change.
            if (Person.IsBusiness())
            {
                var parms = new Dictionary <string, string>();
                parms.Add(PageParameterKey.BusinessId, Person.Id.ToString());
                NavigateToLinkedPage(AttributeKey.BusinessDetailPage, parms);
            }
            else if (Person.IsNameless())
            {
                var parms = new Dictionary <string, string>();
                parms.Add(PageParameterKey.NamelessPersonId, Person.Id.ToString());
                NavigateToLinkedPage(AttributeKey.NamelessPersonDetailPage, parms);
            }

            if (Person.IsDeceased)
            {
                divBio.AddCssClass("deceased");
            }

            // Set the browser page title to include person's name
            RockPage.BrowserTitle = Person.FullName;

            string badgeList = GetAttributeValue(AttributeKey.Badges);

            if (!string.IsNullOrWhiteSpace(badgeList))
            {
                foreach (string badgeGuid in badgeList.SplitDelimitedValues())
                {
                    Guid guid = badgeGuid.AsGuid();
                    if (guid != Guid.Empty)
                    {
                        var badge = BadgeCache.Get(guid);
                        if (badge != null)
                        {
                            blStatus.BadgeTypes.Add(badge);
                        }
                    }
                }
            }

            lbEditPerson.Visible = IsUserAuthorized(Rock.Security.Authorization.EDIT);

            // only show if the Impersonation button if the feature is enabled, and the current user is authorized to Administrate the person
            bool enableImpersonation = this.GetAttributeValue(AttributeKey.EnableImpersonation).AsBoolean();

            lbImpersonate.Visible = false;
            if (enableImpersonation && Person.Id != CurrentPersonId && Person.IsAuthorized(Rock.Security.Authorization.ADMINISTRATE, this.CurrentPerson))
            {
                lbImpersonate.Visible = true;
            }
        }