public Account Get(string username)
        {
            Account            model    = new Account();
            SettingsController settings = new SettingsController();

            if (!string.IsNullOrEmpty(username))
            {
                model.User = Sitecore.Security.Accounts.User.FromName(username, false);

                if (model.User != null)
                {
                    model.Valid = true;
                    model.Admin = model.User.IsAdministrator;
                    model.Name  = model.User.Profile != null ? model.User.Profile.Name : username;

                    MembershipUser mu = Membership.GetUser(username);

                    if (model.User.Profile != null)
                    {
                        Sitecore.Diagnostics.Log.Warn("Found user (" + username + ") online through last activity date (" + model.User.Profile.LastActivityDate.ToShortDateString() + " " + model.User.Profile.LastActivityDate.ToShortTimeString() + ")", this);
                        model.LoggedIn = model.User.Profile.LastActivityDate.AddMinutes(settings.GetIdleTimeout()) <= DateTime.Now;
                    }
                    else if (mu != null && mu.IsOnline)
                    {
                        Sitecore.Diagnostics.Log.Warn("Found user (" + username + ") online through Membership User", this);
                        model.LoggedIn = true;
                    }
                    else
                    {
                        DomainAccessGuard.Session userSession = DomainAccessGuard.Sessions.Find(session => session.UserName == username);
                        if (userSession == null)
                        {
                            Sitecore.Diagnostics.Log.Warn("Found user (" + username + ") logged out through no DomainAccessGuard session", this);
                            model.LoggedIn = false;
                        }
                        else
                        {
                            Sitecore.Diagnostics.Log.Warn("Found user (" + username + ") online through DomainAccessGuard last request " + userSession.LastRequest.ToString(), this);
                            model.LoggedIn = userSession.LastRequest.AddMinutes(settings.GetIdleTimeout()) <= DateTime.Now;
                        }
                    }
                }
            }

            return(model);
        }
        public List <Notification> Get(Item item, bool checkDatasources = true)
        {
            SettingsController  content            = new SettingsController();
            string              command            = content.GetCommand();
            string              commandDisplayName = content.GetCommandDisplayName();
            string              message;
            AccountController   accounts = new AccountController();
            SecurityController  security = new SecurityController();
            List <Notification> model    = new List <Notification>();
            List <Item>         items    = new List <Item>()
            {
                item
            };

            if (checkDatasources)
            {
                items.AddRange(item.GetDataSources());
            }

            if (items != null && items.Count > 0)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (security.IsUnlockable(items[i]))
                    {
                        Account owner = accounts.Get(items[i].Locking.GetOwner());

                        if (i == 0)
                        {
                            message = content.GetUnlockItemMessage(owner.Name, items[i].DisplayName);
                        }
                        else
                        {
                            message = content.GetUnlockDatasourceMessage(owner.Name, items[i].DisplayName);
                        }

                        model.Add(new Notification(items[i], owner, message, command, commandDisplayName));
                    }
                }
            }

            return(model);
        }