public UserAccount[] Get(List <UUID> scopeIDs, string[] fields, string[] values)
        {
            Dictionary <string, object> where = new Dictionary <string, object>(values.Length);

            for (uint i = 0; i < values.Length; ++i)
            {
                where[fields[i]] = values[i];
            }

            List <string> query = GD.Query(new[]
            {
                "PrincipalID",
                "ScopeID",
                "FirstName",
                "LastName",
                "Email",
                "Created",
                "UserLevel",
                "UserFlags",
                "IFNULL(Name, " + GD.ConCat(new[] { "FirstName", "' '", "LastName" }) +
                ") as Name"
            }, m_realm, new QueryFilter
            {
                andFilters = where
            }, null, null, null);

            return(ParseQuery(scopeIDs, query).ToArray());
        }
        public UserAccount[] GetUsers(List <UUID> scopeIDs, string query, uint?start, uint?count)
        {
            QueryFilter filter = GetUsersFilter(query);

            Dictionary <string, bool> sort = new Dictionary <string, bool>(2);

            sort["LastName"]  = true;
            sort["FirstName"] = true; // these are in this order so results should be ordered by last name first, then first name

            List <string> retVal = GD.Query(new[] {
                "PrincipalID",
                "ScopeID",
                "FirstName",
                "LastName",
                "Email",
                "ServiceURLs",
                "Created",
                "UserLevel",
                "UserFlags",
                "UserTitle",
                "IFNULL(Name, " + GD.ConCat(new[] { "FirstName", "' '", "LastName" }) + ") as Name",
                "OSD"
            }, m_realm, filter, sort, start, count);

            return(ParseQuery(scopeIDs, retVal).ToArray());
        }
Example #3
0
        public UserAccount[] GetUsers(UUID scopeID, string query)
        {
            List <UserAccount> data = new List <UserAccount>();

            string[] words = query.MySqlEscape().Split(new[] { ' ' });

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i].Length < 3)
                {
                    if (i != words.Length - 1)
                    {
                        Array.Copy(words, i + 1, words, i, words.Length - i - 1);
                    }
                    Array.Resize(ref words, words.Length - 1);
                }
            }

            QueryFilter filter = new QueryFilter();

            filter.orMultiFilters["ScopeID"] = new List <object>(2);
            filter.orMultiFilters["ScopeID"].Add(scopeID);
            filter.orMultiFilters["ScopeID"].Add(UUID.Zero);

            List <string> retVal;

            if (words.Length > 0)
            {
                filter.orLikeFilters["Name"]      = "%" + query + "%";
                filter.orLikeFilters["FirstName"] = "%" + words[0] + "%";
                if (words.Length == 2)
                {
                    filter.orLikeMultiFilters["LastName"] = new List <string>(2);
                    filter.orLikeMultiFilters["LastName"].Add("%" + words[0]);
                    filter.orLikeMultiFilters["LastName"].Add("%" + words[1] + "%");
                }
                else
                {
                    filter.orLikeFilters["LastName"] = "%" + words[0] + "%";
                }
            }

            retVal = GD.Query(new string[] {
                "PrincipalID",
                "ScopeID",
                "FirstName",
                "LastName",
                "Email",
                "ServiceURLs",
                "Created",
                "UserLevel",
                "UserFlags",
                "UserTitle",
                GD.IsNull("Name", GD.ConCat(new[] { "FirstName", "' '", "LastName" })) + " as Name "
            }, m_realm, filter, null, null, null);

            ParseQuery(retVal, ref data);

            return(data.ToArray());
        }
Example #4
0
        public UserAccount[] GetUsers(UUID scopeID, string query)
        {
            List <UserAccount> data = new List <UserAccount>();

            string[] words = query.Split(new char[] { ' ' });

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i].Length < 3)
                {
                    if (i != words.Length - 1)
                    {
                        Array.Copy(words, i + 1, words, i, words.Length - i - 1);
                    }
                    Array.Resize(ref words, words.Length - 1);
                }
            }

            if (words.Length == 0)
            {
                return(new UserAccount[0]);
            }

            if (words.Length > 2)
            {
                return(new UserAccount[0]);
            }

            List <string> retVal = GD.Query("(ScopeID='" + scopeID + "' or ScopeID='00000000-0000-0000-0000-000000000000') " +
                                            "and (Name like '%" + query + "%' or " +
                                            "FirstName like '%" + words[0] + "%' " +
                                            ((words.Length == 1) ?
                                             " or LastName like '%" + words[0]
                    : " and LastName like '%" + words[1])
                                            + "%')", m_realm, " PrincipalID, ScopeID, FirstName, LastName, Email, ServiceURLs, Created, UserLevel, UserFlags, UserTitle, " + GD.IsNull("Name", GD.ConCat(new string[] { "FirstName", "' '", "LastName" })) + " as Name ");

            ParseQuery(retVal, ref data);

            return(data.ToArray());
        }