Example #1
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object> ();

            string error  = "";
            UUID   userID = httpRequest.Query.ContainsKey("userid")
                            ? UUID.Parse(httpRequest.Query ["userid"].ToString())
                            : UUID.Parse(requestParameters ["userid"].ToString());

            IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         account     = null;

            if (userService != null)
            {
                account = userService.GetUserAccount(null, userID);
            }

            var        agentService = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();
            IAgentInfo agent        = agentService.GetAgent(userID);

            if (agent == null)
            {
                error = "No agent information is available";
            }

            // Set user type
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters ["Submit"].ToString() == "SubmitSetUserType")
            {
                string UserType  = requestParameters ["UserType"].ToString();
                int    UserFlags = WebHelpers.UserTypeToUserFlags(UserType);

                // set the user account type
                if (account != null)
                {
                    account.UserFlags = UserFlags;
                    userService.StoreUserAccount(account);
                }
                else
                {
                    response = "User account not found - Unable to update!'";
                    return(null);
                }

                if (agent != null)
                {
                    agent.OtherAgentInformation ["UserFlags"] = UserFlags;
                    agentService.UpdateAgent(agent);
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                    return(null);
                }

                IProfileConnector profileData = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ();

                if (profileData != null)
                {
                    IUserProfileInfo profile = profileData.GetUserProfile(userID);

                    if (profile == null)
                    {
                        profileData.CreateNewProfile(userID);
                        profile = profileData.GetUserProfile(userID);
                    }

                    profile.MembershipGroup = WebHelpers.UserFlagToType(UserFlags, webInterface.EnglishTranslator);     // membership is english
                    profileData.UpdateUserProfile(profile);
                }

                response = "User account has been updated.";
                return(null);
            }

            // Password change
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters ["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password     = requestParameters ["password"].ToString();
                string passwordconf = requestParameters ["passwordconf"].ToString();

                if (password != passwordconf)
                {
                    response = "Passwords do not match";
                }
                else
                {
                    IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService> ();

                    if (authService != null)
                    {
                        response = authService.SetPassword(userID, "UserAccount", password)
                                       ? "Successfully set password"
                                       : "Failed to set your password, try again later";
                    }
                    else
                    {
                        response = "No authentication service was available to change the account passwor!";
                    }
                }

                return(null);
            }

            // Email change
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters ["email"].ToString();

                if (account != null)
                {
                    account.Email = email;
                    userService.StoreUserAccount(account);
                    response = "Successfully updated email";
                }
                else
                {
                    response = "No authentication service was available to change the email details!";
                }

                return(null);
            }

            // Delete user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitDeleteUser")
            {
                string username = requestParameters ["username"].ToString();

                if (account != null)
                {
                    if (username == account.Name)
                    {
                        userService.DeleteUser(account.PrincipalID, account.Name, "", false, false);
                        response = "User has been successfully deleted";
                    }
                    else
                    {
                        response = "The user name did not match!";
                    }
                }
                else
                {
                    response = "No account details to verify user against!";
                }

                return(null);
            }

            // Temp Ban user
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters ["Submit"].ToString() == "SubmitTempBanUser")
            {
                int timeDays    = int.Parse(requestParameters ["TimeDays"].ToString());
                int timeHours   = int.Parse(requestParameters ["TimeHours"].ToString());
                int timeMinutes = int.Parse(requestParameters ["TimeMinutes"].ToString());

                if (agent != null)
                {
                    agent.Flags |= IAgentFlags.TempBan;
                    DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes);
                    agent.OtherAgentInformation ["Temperory BanInfo"] = until;
                    agentService.UpdateAgent(agent);
                    response = "User has been banned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            // Ban user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitBanUser")
            {
                if (agent != null)
                {
                    agent.Flags |= IAgentFlags.PermBan;
                    agentService.UpdateAgent(agent);
                    response = "User has been banned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            //UnBan user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitUnbanUser")
            {
                if (agent != null)
                {
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("Temporary BanInfo");
                    agentService.UpdateAgent(agent);
                    response = "User has been unbanned.";
                }
                else
                {
                    response = "Agent information is not available! Has the user logged in yet?";
                }

                return(null);
            }

            // Login as user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitLoginAsUser")
            {
                Authenticator.ChangeAuthentication(httpRequest, account);
                webInterface.Redirect(httpResponse, "/");
                return(vars);
            }

            // Kick user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitKickUser")
            {
                string message = requestParameters ["KickMessage"].ToString();

                if (account != null)
                {
                    IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule> ();

                    if (messageModule != null)
                    {
                        messageModule.KickUser(account.PrincipalID, message);
                    }

                    response = "User has been kicked.";
                }
                else
                {
                    response = "Unable to determine user to  kick!";
                }
                return(null);
            }

            // Message user
            if (requestParameters.ContainsKey("Submit") && requestParameters ["Submit"].ToString() == "SubmitMessageUser")
            {
                string message = requestParameters ["Message"].ToString();

                if (account != null)
                {
                    IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule> ();

                    if (messageModule != null)
                    {
                        messageModule.MessageUser(account.PrincipalID, message);
                        response = "User has been sent the message.";
                    }
                }
                else
                {
                    response = "User account details are unavailable to send the message!";
                }

                return(null);
            }

            // page variables
            string bannedUntil = "";
            bool   userBanned  = false;

            if (agent != null)
            {
                userBanned = ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan);
            }

            bool TempUserBanned = false;

            if (userBanned)
            {
                if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan &&
                    agent.OtherAgentInformation ["Temporary BanInfo"].AsDate() < DateTime.Now.ToUniversalTime())
                {
                    userBanned   = false;
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("Temporary BanInfo");
                    agentService.UpdateAgent(agent);
                }
                else
                {
                    DateTime bannedTime = agent.OtherAgentInformation ["Temporary BanInfo"].AsDate();
                    TempUserBanned = bannedTime != Util.UnixEpoch;
                    bannedUntil    = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());
                }
            }

            bool userOnline = false;
            IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> ();

            if (agentInfoService != null)
            {
                UserInfo Info = null;

                if (account != null)
                {
                    Info = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                }

                userOnline = Info != null && Info.IsOnline;
            }

            if (account != null)
            {
                vars.Add("EmailValue", account.Email);
                vars.Add("UserID", account.PrincipalID);
                vars.Add("UserName", account.Name);
            }
            else
            {
                vars.Add("EmailValue", "");
                vars.Add("UserID", "");
                vars.Add("UserName", "");
            }

            vars.Add("UserOnline", userOnline);
            vars.Add("NotUserBanned", !userBanned);
            vars.Add("UserBanned", userBanned);
            vars.Add("TempUserBanned", TempUserBanned);
            vars.Add("BannedUntil", bannedUntil);
            vars.Add("ErrorMessage", error);
            vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText"));
            vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText"));
            vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText"));
            vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText"));
            vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText"));
            vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
            vars.Add("PasswordText", translator.GetTranslatedString("PasswordText"));
            vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText"));
            vars.Add("DeleteText", translator.GetTranslatedString("DeleteText"));
            vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("TypeUserNameToConfirm", translator.GetTranslatedString("TypeUserNameToConfirm"));

            vars.Add("AdminUserTypeInfoText", translator.GetTranslatedString("AdminUserTypeInfoText"));
            vars.Add("AdminSetUserTypeText", translator.GetTranslatedString("UserTypeText"));

            vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText"));
            vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText"));
            vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText"));
            vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText"));
            vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText"));
            vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText"));
            vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText"));
            vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText"));
            vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText"));
            vars.Add("BanText", translator.GetTranslatedString("BanText"));
            vars.Add("UnbanText", translator.GetTranslatedString("UnbanText"));
            vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText"));
            vars.Add("EdittingText", translator.GetTranslatedString("EdittingText"));
            vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText"));

            vars.Add("KickAUserInfoText", translator.GetTranslatedString("KickAUserInfoText"));
            vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText"));
            vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText"));
            vars.Add("KickUserText", translator.GetTranslatedString("KickUserText"));

            vars.Add("MessageAUserText", translator.GetTranslatedString("MessageAUserText"));
            vars.Add("MessageAUserInfoText", translator.GetTranslatedString("MessageAUserInfoText"));
            vars.Add("MessageUserText", translator.GetTranslatedString("MessageUserText"));

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> > ();

            for (int i = 0; i <= 100; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > hoursArgs = new List <Dictionary <string, object> > ();

            for (int i = 0; i <= 23; i++)
            {
                hoursArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > minutesArgs = new List <Dictionary <string, object> > ();

            for (int i = 0; i <= 59; i++)
            {
                minutesArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Hours", hoursArgs);
            vars.Add("Minutes", minutesArgs);
            vars.Add("DaysText", translator.GetTranslatedString("DaysText"));
            vars.Add("HoursText", translator.GetTranslatedString("HoursText"));
            vars.Add("MinutesText", translator.GetTranslatedString("MinutesText"));

            vars.Add("UserType", WebHelpers.UserTypeArgs(translator));

            return(vars);
        }
Example #2
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                IAsyncMessagePostService asyncPoster    = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                IFriendsService          friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                ICapsService             capsService    = m_registry.RequestModuleInterface <ICapsService>();
                IGridService             gridService    = m_registry.RequestModuleInterface <IGridService>();
                if (asyncPoster != null && friendsService != null && capsService != null && gridService != null)
                {
                    //Get all friends
                    object[] info     = (object[])parameters;
                    UUID     us       = UUID.Parse(info[0].ToString());
                    bool     isOnline = bool.Parse(info[1].ToString());

                    FriendInfo[]  friends                 = friendsService.GetFriends(us);
                    List <UUID>   OnlineFriends           = new List <UUID>();
                    List <string> previouslyContactedURLs = new List <string>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID   FriendToInform = UUID.Zero;
                        string url, first, last, secret;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            HGUtil.ParseUniversalUserIdentifier(friend.Friend, out FriendToInform, out url, out first,
                                                                out last, out secret);
                        }
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                OnlineFriends.Add(FriendToInform);
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                            }
                            else
                            {
                                //If they don't have a root agent, wtf happened?
                                capsService.RemoveCAPS(clientCaps.AgentID);
                            }
                        }
                        else
                        {
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                            if (agentInfoService != null)
                            {
                                UserInfo friendinfo = agentInfoService.GetUserInfo(FriendToInform.ToString());
                                if (friendinfo != null && friendinfo.IsOnline)
                                {
                                    OnlineFriends.Add(FriendToInform);
                                    //Post!
                                    GridRegion r = gridService.GetRegionByUUID(UUID.Zero, friendinfo.CurrentRegionID);
                                    if (r != null)
                                    {
                                        asyncPoster.Post(r.RegionHandle,
                                                         SyncMessageHelper.AgentStatusChange(us, FriendToInform,
                                                                                             isOnline));
                                    }
                                }
                                else
                                {
                                    IUserAgentService uas = m_registry.RequestModuleInterface <IUserAgentService>();
                                    if (uas != null)
                                    {
                                        bool online = uas.RemoteStatusNotification(friend, us, isOnline);
                                        if (online)
                                        {
                                            OnlineFriends.Add(FriendToInform);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, UUID.Parse(info[2].ToString()));
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(onlineFriend, us, isOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #3
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            UserAccount account = null;

            if (httpRequest.Query.ContainsKey("regionid"))
            {
                var regionService = webInterface.Registry.RequestModuleInterface <IGridService> ();
                var region        = regionService.GetRegionByUUID(null, UUID.Parse(httpRequest.Query ["regionid"].ToString()));

                UUID userid = region.EstateOwner;

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, userid);

                //IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ();
                //EstateSettings estate = estateConnector.GetEstateSettings (region.RegionID);
            }
            if (account == null)
            {
                return(vars);
            }

            // There is no harm in showing the system users here, actually it is required
            //if ( Utilities.IsSytemUser(account.PrincipalID))
            //    return vars;

            vars.Add("UserName", account.Name);
            //  TODO: User Profile inworld shows this as the standard mm/dd/yyyy
            //  Do we want this to be localised into the users Localisation or keep it as standard ?
            //
            // greythane, Oct 2014 - Not sure why we need to keep the US format here?  A lot of us don't live there :)
            //  vars.Add("UserBorn", Culture.LocaleDate(Util.ToDateTime(account.Created)));
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>().
                                       GetUserProfile(account.PrincipalID);

            if (profile != null)
            {
                vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);
                if (profile != null)
                {
                    if (profile.Partner != UUID.Zero)
                    {
                        account = webInterface.Registry.RequestModuleInterface <IUserAccountService> ().
                                  GetUserAccount(null, profile.Partner);
                        vars.Add("UserPartner", account.Name);
                    }
                    else
                    {
                        vars.Add("UserPartner", "No partner");
                    }
                    vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);

                    string url = "../images/icons/no_avatar.jpg";
                    IWebHttpTextureService webhttpService =
                        webInterface.Registry.RequestModuleInterface <IWebHttpTextureService> ();
                    if (webhttpService != null && profile.Image != UUID.Zero)
                    {
                        url = webhttpService.GetTextureURL(profile.Image);
                    }
                    vars.Add("UserPictureURL", url);
                }
            }
            else
            {
                // no profile yet for this user
                vars.Add("UserType", "Unknown");
                vars.Add("UserPartner", "Unknown");
                vars.Add("UserPictureURL", "../images/icons/no_avatar.jpg");
            }


            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);

            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>();
                var             friends        = friendsService.GetFriends(account.PrincipalID);
                UUID            friendID       = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService =
                        webInterface.Registry.RequestModuleInterface <IAgentInfoService>();
                    IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>();
                    UserInfo     ourInfo     = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                    if (ourInfo != null && ourInfo.IsOnline)
                    {
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    }
                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline",
                             ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }


            vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor"));
            vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince"));
            vars.Add("AccountType", translator.GetTranslatedString("AccountType"));
            vars.Add("PartnersName", translator.GetTranslatedString("PartnersName"));
            vars.Add("AboutMe", translator.GetTranslatedString("AboutMe"));
            vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText"));
            vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText"));

            return(vars);
        }
        public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID,
                                          string fromObjectName, int amount, string description, TransactionType transType, UUID transactionID)
        {
            // Groups (legacy) should not receive stipends
            if (transType == TransactionType.StipendPayment)
            {
                return(false);
            }

            GroupBalance gb = new GroupBalance {
                StartingDate = DateTime.UtcNow
            };

            // Not sure if a group will receive a system payment (UUID = Zero) but..
            UserCurrency fromuserCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId);

            if (fromuserCurrency != null)
            {
                // Normal users cannot have a credit balance.. check to see whether they have enough money
                if ((int)fromuserCurrency.Amount - amount < 0)
                {
                    return(false); // Not enough money
                }
            }

            // is this a payment from a user to the group or from the group to the user?
            if (payUser)
            {
                gb.TotalTierDebits += amount;          // not sure if this the correct place yet? Total of group payments
                amount              = -1 * amount;
            }
            else
            {
                gb.TotalTierCredits += amount;        // .. total of group receipts
            }
            uint userBalance = 0;

            if (fromuserCurrency != null)
            {
                // user payment
                fromuserCurrency.Amount -= (uint)amount;
                UserCurrencyUpdate(fromuserCurrency, true);
                userBalance = fromuserCurrency.Amount;
            }

            // track specific group fees
            switch (transType)
            {
            case TransactionType.GroupJoin:
                gb.GroupFee += amount;
                break;

            case TransactionType.LandAuction:
                gb.LandFee += amount;
                break;

            case TransactionType.ParcelDirFee:
                gb.ParcelDirectoryFee += amount;
                break;
            }


            // update the group balance
            gb.Balance += amount;
            GroupCurrencyUpdate(groupID, gb, true);

            // Must send out notifications to the users involved so that they get the updates
            if (m_userInfoService != null)
            {
                UserInfo    agentInfo    = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString());
                UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId);
                var         groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> ();
                var         groupInfo    = groupService.GetGroupRecord(userId, groupID, null);
                var         groupName    = "Unknown";

                if (groupInfo != null)
                {
                    groupName = groupInfo.GroupName;
                }

                // record the group transaction
                if (m_config.SaveTransactionLogs)
                {
                    AddGroupTransactionRecord(
                        (transactionID == UUID.Zero ? UUID.Random() : transactionID),
                        description,
                        groupID,
                        groupName,
                        userId,
                        (agentAccount.Valid ? agentAccount.Name : "System"),
                        amount,
                        transType,
                        gb.TotalTierCredits,       // assume this it the 'total credit for the group but it may be land tier credit??
                        (int)userBalance,          // this will be zero if this isa system <> group transaction
                        toObjectName,
                        fromObjectName,
                        (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID)
                        );
                }

                var paidToMsg   = "";
                var paidFromMsg = "";
                var paidDesc    = (description == "" ? "" : " for " + description);

                if (amount > 0)
                {
                    paidToMsg =
                        (groupInfo == null ? " received " : groupName + " paid you ") + InWorldCurrency + amount + paidDesc;
                    paidFromMsg = "You paid " +
                                  (groupInfo == null ? "" : groupName + " ") + InWorldCurrency + amount + paidDesc;
                }

                if (agentInfo != null)
                {
                    if (payUser)
                    {
                        if (agentInfo.IsOnline)
                        {
                            SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, userBalance, paidToMsg);
                        }
                    }
                    else
                    {
                        if (fromObjectID != UUID.Zero)
                        {
                            SendUpdateMoneyBalanceToClient(fromObjectID, transactionID, agentInfo.CurrentRegionURI, (uint)amount, paidFromMsg);
                        }
                    }
                }
            }

            return(true);
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
            {
                return(null);                        // nothing to do here...
            }
            var method = message ["Method"].AsString();

            ISyncMessagePosterService asyncPost = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();

            // We need to check and see if this is an AgentStatusChange
            if (method == "AgentStatusChange")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                // We got a message, now pass it on to the clients that need it
                UUID AgentID          = innerMessage ["AgentID"].AsUUID();
                UUID FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                // Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                // Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, new [] { AgentID }, NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "AgentStatusChanges")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                // We got a message, now pass it on to the clients that need it
                List <UUID> AgentIDs         = ((OSDArray)innerMessage ["AgentIDs"]).ConvertAll <UUID> ((o) => o);
                UUID        FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool        NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                // Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                // Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, AgentIDs.ToArray(), NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "FriendGrantRights")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Target"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    // Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipOffered")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Friend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    // Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendTerminated")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["ExFriend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    // Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipDenied")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    // Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipApproved")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    // Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            return(null);
        }
Example #6
0
        public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable      requestData = (Hashtable)request.Params[0];
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();

            Hashtable membershiplevels = new Hashtable();

            membershiplevels.Add("levels", membershiplevels);

            Hashtable landuse = new Hashtable();

            Hashtable level = new Hashtable
            {
                { "id", "00000000-0000-0000-0000-000000000000" },
                { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" }
            };

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
            {
                UUID agentId;
                UUID.TryParse((string)requestData["agentId"], out agentId);
                UserCurrency     currency = m_connector.GetUserCurrency(agentId);
                IUserProfileInfo profile  =
                    DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId);


                //IClientCapsService client = m_dustCurrencyService.Registry.RequestModuleInterface<ICapsService>().GetClientCapsService(agentId);
                OSDMap   replyData = null;
                bool     response  = false;
                UserInfo user      = m_agentInfoService.GetUserInfo(agentId.ToString());
                if (user == null)
                {
                    landuse.Add("action", false);

                    retparam.Add("success", false);
                    retparam.Add("currency", currency);
                    retparam.Add("membership", level);
                    retparam.Add("landuse", landuse);
                    retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                    ret.Value = retparam;
                }
                else
                {
                    OSDMap map = new OSDMap();
                    map["Method"]  = "GetLandData";
                    map["AgentID"] = agentId;
                    m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) =>
                    {
                        replyData = o;
                        response  = true;
                    });
                    while (!response)
                    {
                        Thread.Sleep(10);
                    }
                    if (replyData == null || replyData["Success"] == false)
                    {
                        landuse.Add("action", false);

                        retparam.Add("success", false);
                        retparam.Add("currency", currency);
                        retparam.Add("membership", level);
                        retparam.Add("landuse", landuse);
                        retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                        ret.Value = retparam;
                    }
                    else
                    {
                        //if (client != null)
                        //    m_dustCurrencyService.SendGridMessage(agentId, String.Format(m_dustCurrencyService.m_options.MessgeBeforeBuyLand, profile.DisplayName, replyData.ContainsKey("SalePrice")), false, UUID.Zero);
                        if (replyData.ContainsKey("SalePrice"))
                        {
                            // I think, this might be usable if they don't have the money
                            // Hashtable currencytable = new Hashtable { { "estimatedCost", replyData["SalePrice"].AsInteger() } };

                            int  landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger());
                            bool needsUpgrade   = false;
                            switch (profile.MembershipGroup)
                            {
                            case "Premium":
                            case "":
                                needsUpgrade = landTierNeeded >= currency.Tier;
                                break;

                            case "Banned":
                                needsUpgrade = true;
                                break;
                            }
                            // landuse.Add("action", m_DustCurrencyService.m_options.upgradeMembershipUri);
                            landuse.Add("action", needsUpgrade);

                            retparam.Add("success", true);
                            retparam.Add("currency", currency);
                            retparam.Add("membership", level);
                            retparam.Add("landuse", landuse);
                            retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                            ret.Value = retparam;
                        }
                    }
                }
            }

            return(ret);
        }
Example #7
0
        private bool OnAllowedIncomingAgent(IScene scene, AgentCircuitData agent, bool isRootAgent, out string reason)
        {
            #region Incoming Agent Checks

            UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, agent.AgentID);
            if (account == null)
            {
                reason = "No account exists";
                return(false);
            }
            IScenePresence Sp = scene.GetScenePresence(agent.AgentID);

            if (LoginsDisabled)
            {
                reason = "Logins Disabled";
                return(false);
            }

            //Check how long its been since the last TP
            if (m_enabledBlockTeleportSeconds && Sp != null && !Sp.IsChildAgent)
            {
                if (TimeSinceLastTeleport.ContainsKey(Sp.Scene.RegionInfo.RegionID))
                {
                    if (TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] > Util.UnixTimeSinceEpoch())
                    {
                        reason = "Too many teleports. Please try again soon.";
                        return(false); // Too soon since the last TP
                    }
                }
                TimeSinceLastTeleport[Sp.Scene.RegionInfo.RegionID] = Util.UnixTimeSinceEpoch() +
                                                                      ((int)(SecondsBeforeNextTeleport));
            }

            //Gods tp freely
            if ((Sp != null && Sp.GodLevel != 0) || (account != null && account.UserLevel != 0))
            {
                reason = "";
                return(true);
            }

            //Check whether they fit any ban criteria
            if (Sp != null)
            {
                foreach (string banstr in BanCriteria)
                {
                    if (Sp.Name.Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                    else if (((IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString().Contains(banstr))
                    {
                        reason = "You have been banned from this region.";
                        return(false);
                    }
                }
                //Make sure they exist in the grid right now
                IAgentInfoService presence = scene.RequestModuleInterface <IAgentInfoService>();
                if (presence == null)
                {
                    reason =
                        String.Format(
                            "Failed to verify user presence in the grid for {0} in region {1}. Presence service does not exist.",
                            account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }

                UserInfo pinfo = presence.GetUserInfo(agent.AgentID.ToString());

                if (pinfo == null || (!pinfo.IsOnline && ((agent.TeleportFlags & (uint)TeleportFlags.ViaLogin) == 0)))
                {
                    reason =
                        String.Format(
                            "Failed to verify user presence in the grid for {0}, access denied to region {1}.",
                            account.Name, scene.RegionInfo.RegionName);
                    return(false);
                }
            }

            EstateSettings ES = scene.RegionInfo.EstateSettings;

            IEntityCountModule entityCountModule = scene.RequestModuleInterface <IEntityCountModule>();
            if (entityCountModule != null && scene.RegionInfo.RegionSettings.AgentLimit
                < entityCountModule.RootAgents + 1 &&
                scene.RegionInfo.RegionSettings.AgentLimit > 0)
            {
                reason = "Too many agents at this time. Please come back later.";
                return(false);
            }

            List <EstateBan> EstateBans = new List <EstateBan>(ES.EstateBans);
            int i = 0;
            //Check bans
            foreach (EstateBan ban in EstateBans)
            {
                if (ban.BannedUserID == agent.AgentID)
                {
                    if (Sp != null)
                    {
                        string banIP = ((IPEndPoint)Sp.ControllingClient.GetClientEP()).Address.ToString();

                        if (ban.BannedHostIPMask != banIP) //If it changed, ban them again
                        {
                            //Add the ban with the new hostname
                            ES.AddBan(new EstateBan
                            {
                                BannedHostIPMask   = banIP,
                                BannedUserID       = ban.BannedUserID,
                                EstateID           = ban.EstateID,
                                BannedHostAddress  = ban.BannedHostAddress,
                                BannedHostNameMask = ban.BannedHostNameMask
                            });
                            //Update the database
                            ES.Save();
                        }
                    }

                    reason = "Banned from this region.";
                    return(false);
                }
                if (Sp != null)
                {
                    IPAddress   end  = Sp.ControllingClient.EndPoint;
                    IPHostEntry rDNS = null;
                    try
                    {
                        rDNS = Dns.GetHostEntry(end);
                    }
                    catch (SocketException)
                    {
                        MainConsole.Instance.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end);
                        rDNS = null;
                    }
                    if (ban.BannedHostIPMask == agent.IPAddress ||
                        (rDNS != null && rDNS.HostName.Contains(ban.BannedHostIPMask)) ||
                        end.ToString().StartsWith(ban.BannedHostIPMask))
                    {
                        //Ban the new user
                        ES.AddBan(new EstateBan
                        {
                            EstateID           = ES.EstateID,
                            BannedHostIPMask   = agent.IPAddress,
                            BannedUserID       = agent.AgentID,
                            BannedHostAddress  = agent.IPAddress,
                            BannedHostNameMask = agent.IPAddress
                        });
                        ES.Save();

                        reason = "Banned from this region.";
                        return(false);
                    }
                }
                i++;
            }

            //Estate owners/managers/access list people/access groups tp freely as well
            if (ES.EstateOwner == agent.AgentID ||
                new List <UUID>(ES.EstateManagers).Contains(agent.AgentID) ||
                new List <UUID>(ES.EstateAccess).Contains(agent.AgentID) ||
                CheckEstateGroups(ES, agent))
            {
                reason = "";
                return(true);
            }

            if (ES.DenyAnonymous &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile) ==
                 (int)IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyIdentified &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile) ==
                 (int)IUserProfileInfo.ProfileFlags.PaymentInfoOnFile))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (ES.DenyTransacted &&
                ((account.UserFlags & (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse) ==
                 (int)IUserProfileInfo.ProfileFlags.PaymentInfoInUse))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            const long m_Day = 25 * 60 * 60; //Find out day length in seconds
            if (scene.RegionInfo.RegionSettings.MinimumAge != 0 &&
                (account.Created - Util.UnixTimeSinceEpoch()) < (scene.RegionInfo.RegionSettings.MinimumAge * m_Day))
            {
                reason = "You may not enter this region.";
                return(false);
            }

            if (!ES.PublicAccess)
            {
                reason = "You may not enter this region, Public access has been turned off.";
                return(false);
            }

            IAgentConnector AgentConnector = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector>();
            IAgentInfo      agentInfo      = null;
            if (AgentConnector != null)
            {
                agentInfo = AgentConnector.GetAgent(agent.AgentID);
                if (agentInfo == null)
                {
                    AgentConnector.CreateNewAgent(agent.AgentID);
                    agentInfo = AgentConnector.GetAgent(agent.AgentID);
                }
            }

            if (m_checkMaturityLevel)
            {
                if (agentInfo != null &&
                    scene.RegionInfo.AccessLevel > Util.ConvertMaturityToAccessLevel((uint)agentInfo.MaturityRating))
                {
                    reason = "The region has too high of a maturity level. Blocking teleport.";
                    return(false);
                }

                if (agentInfo != null && ES.DenyMinors && (agentInfo.Flags & IAgentFlags.Minor) == IAgentFlags.Minor)
                {
                    reason = "The region has too high of a maturity level. Blocking teleport.";
                    return(false);
                }
            }

            #endregion

            reason = "";
            return(true);
        }
Example #8
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters,
                                                ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            string      username = filename.Split('/').LastOrDefault();
            UserAccount account  = null;

            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name"))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name    = name.Replace('.', ' ');
                name    = name.Replace("%20", " ");
                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                webInterface.Redirect(httpResponse, "/webprofile/?name=" + username);
                return(vars);
            }

            if (account == null)
            {
                return(vars);
            }

            vars.Add("UserName", account.Name);
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>().
                                       GetUserProfile(account.PrincipalID);

            vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);
            if (profile != null)
            {
                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                              GetUserAccount(null, profile.Partner);
                    vars.Add("UserPartner", account.Name);
                }
                else
                {
                    vars.Add("UserPartner", "No partner");
                }
                vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                string url = "../images/icons/no_picture.jpg";
                IWebHttpTextureService webhttpService =
                    webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();
                if (webhttpService != null && profile.Image != UUID.Zero)
                {
                    url = webhttpService.GetTextureURL(profile.Image);
                }
                vars.Add("UserPictureURL", url);
            }
            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);

            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>();
                var             friends        = friendsService.GetFriends(account.PrincipalID);
                UUID            friendID       = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService =
                        webInterface.Registry.RequestModuleInterface <IAgentInfoService>();
                    IGridService gridService = webInterface.Registry.RequestModuleInterface <IGridService>();
                    UserInfo     ourInfo     = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                    if (ourInfo != null && ourInfo.IsOnline)
                    {
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    }
                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline",
                             ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }

            // Menu Profile
            vars.Add("MenuProfileTitle", translator.GetTranslatedString("MenuProfileTitle"));
            vars.Add("MenuGroupTitle", translator.GetTranslatedString("MenuGroupTitle"));
            vars.Add("MenuPicksTitle", translator.GetTranslatedString("MenuPicksTitle"));

            vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor"));
            vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince"));
            vars.Add("AccountType", translator.GetTranslatedString("AccountType"));
            vars.Add("PartnersName", translator.GetTranslatedString("PartnersName"));
            vars.Add("AboutMe", translator.GetTranslatedString("AboutMe"));
            vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText"));
            vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText"));

            // Style Switcher
            vars.Add("styles1", translator.GetTranslatedString("styles1"));
            vars.Add("styles2", translator.GetTranslatedString("styles2"));
            vars.Add("styles3", translator.GetTranslatedString("styles3"));
            vars.Add("styles4", translator.GetTranslatedString("styles4"));
            vars.Add("styles5", translator.GetTranslatedString("styles5"));

            vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText"));
            vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText"));
            vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText"));

            // Language Switcher
            vars.Add("en", translator.GetTranslatedString("en"));
            vars.Add("fr", translator.GetTranslatedString("fr"));
            vars.Add("de", translator.GetTranslatedString("de"));
            vars.Add("it", translator.GetTranslatedString("it"));
            vars.Add("es", translator.GetTranslatedString("es"));

            IGenericsConnector generics = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>();
            var settings = generics.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

            vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar);
            vars.Add("ShowStyleBar", !settings.HideStyleBar);

            return(vars);
        }
Example #9
0
        public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID,
                                          string fromObjectName, int amount, string description, TransactionType type, UUID transactionID)
        {
            GroupBalance gb = new GroupBalance {
                StartingDate = DateTime.UtcNow
            };

            // Not sure if a group will receive a system payment but..
            UserCurrency fromCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId);

            // Groups (legacy) should not receive stipends
            if (type == TransactionType.StipendPayment)
            {
                return(false);
            }

            if (fromCurrency != null)
            {
                // Normal users cannot have a credit balance.. check to see whether they have enough money
                if ((int)fromCurrency.Amount - amount < 0)
                {
                    return(false); // Not enough money
                }
            }

            // is thiis a payment to the group or to the user?
            if (payUser)
            {
                amount = -1 * amount;
            }

            uint fromBalance = 0;

            if (fromCurrency != null)
            {
                // user payment
                fromCurrency.Amount -= (uint)amount;
                UserCurrencyUpdate(fromCurrency, true);
                fromBalance = fromCurrency.Amount;
            }

            // track specific group fees
            switch (type)
            {
            case TransactionType.GroupJoin:
                gb.GroupFee += amount;
                break;

            case TransactionType.LandAuction:
                gb.LandFee += amount;
                break;

            case TransactionType.ParcelDirFee:
                gb.ParcelDirectoryFee += amount;
                break;
            }

            if (payUser)
            {
                gb.TotalTierDebit -= amount;          // not sure if this the correct place yet? Are these currency or land credits?
            }
            else
            {
                gb.TotalTierCredits += amount;        // .. or this?
            }
            // update the group balance
            gb.Balance += amount;
            GroupCurrencyUpdate(groupID, gb, true);

            //Must send out notifications to the users involved so that they get the updates
            if (m_userInfoService == null)
            {
                m_userInfoService    = m_registry.RequestModuleInterface <IAgentInfoService>();
                m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            }
            if (m_userInfoService != null)
            {
                UserInfo    agentInfo    = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString());
                UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId);
                var         groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> ();
                var         groupInfo    = groupService.GetGroupRecord(userId, groupID, null);
                var         groupName    = "Unknown";

                if (groupInfo != null)
                {
                    groupName = groupInfo.GroupName;
                }

                if (m_config.SaveTransactionLogs)
                {
                    AddGroupTransactionRecord(
                        (transactionID == UUID.Zero ? UUID.Random() : transactionID),
                        description,
                        groupID,
                        groupName,
                        userId,
                        (agentAccount == null ? "System" : agentAccount.Name),
                        amount,
                        type,
                        gb.TotalTierCredits,        // assume this it the 'total credit for the group but it may be land tier credit??
                        (int)fromBalance,           // this will be zero if this isa system <> group transaction
                        toObjectName,
                        fromObjectName,
                        (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID)
                        );
                }

                if (agentInfo != null && agentInfo.IsOnline)
                {
                    SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, fromBalance,
                                                   "You paid " + groupName + " " + InWorldCurrency + amount);
                }
            }
            return(true);
        }
Example #10
0
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an GroupSessionAgentUpdate
            if (message.ContainsKey("Method") && message["Method"] == "GroupSessionAgentUpdate")
            {
                //Comes in on the Universe.Server side
                //Send it on to whomever it concerns
                OSDMap innerMessage = (OSDMap)message["Message"];
                if (innerMessage["message"] == "ChatterBoxSessionAgentListUpdates")
                //ONLY forward on this type of message
                {
                    UUID agentID                 = message["AgentID"];
                    IEventQueueService eqs       = m_registry.RequestModuleInterface <IEventQueueService>();
                    IAgentInfoService  agentInfo = m_registry.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfo != null)
                    {
                        UserInfo user = agentInfo.GetUserInfo(agentID.ToString());
                        if (user != null && user.IsOnline)
                        {
                            eqs.Enqueue(innerMessage, agentID, user.CurrentRegionID);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FixGroupRoleTitles")
            {
                //Comes in on the Universe.Server side from region
                UUID groupID = message["GroupID"].AsUUID();
                UUID agentID = message["AgentID"].AsUUID();
                UUID roleID  = message["RoleID"].AsUUID();
                byte type    = (byte)message["Type"].AsInteger();
                IGroupsServiceConnector     con     = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector>();
                List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID);
                List <GroupRolesData>       roles   = con.GetGroupRoles(agentID, groupID);
                GroupRolesData everyone             = null;

                foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone"))
                {
                    everyone = role;
                }

                List <UserInfo> regionsToBeUpdated = new List <UserInfo>();
                foreach (GroupRoleMembersData data in members)
                {
                    if (data.RoleID == roleID)
                    {
                        //They were affected by the change
                        switch ((GroupRoleUpdate)type)
                        {
                        case GroupRoleUpdate.Create:
                        case GroupRoleUpdate.NoUpdate:
                            //No changes...
                            break;

                        case GroupRoleUpdate.UpdatePowers:     //Possible we don't need to send this?
                        case GroupRoleUpdate.UpdateAll:
                        case GroupRoleUpdate.UpdateData:
                        case GroupRoleUpdate.Delete:
                            if (type == (byte)GroupRoleUpdate.Delete)
                            {
                                //Set them to the most limited role since their role is gone
                                con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID);
                            }
                            //Need to update their title inworld

                            IAgentInfoService agentInfoService =
                                m_registry.RequestModuleInterface <IAgentInfoService>();
                            UserInfo info;
                            if (agentInfoService != null &&
                                (info = agentInfoService.GetUserInfo(agentID.ToString())) != null && info.IsOnline)
                            {
                                //Forward the message
                                regionsToBeUpdated.Add(info);
                            }
                            break;
                        }
                    }
                }
                if (regionsToBeUpdated.Count != 0)
                {
                    ISyncMessagePosterService messagePost =
                        m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                    if (messagePost != null)
                    {
                        foreach (UserInfo userInfo in regionsToBeUpdated)
                        {
                            OSDMap outgoingMessage = new OSDMap();
                            outgoingMessage["Method"]   = "ForceUpdateGroupTitles";
                            outgoingMessage["GroupID"]  = groupID;
                            outgoingMessage["RoleID"]   = roleID;
                            outgoingMessage["RegionID"] = userInfo.CurrentRegionID;
                            messagePost.Post(userInfo.CurrentRegionURI, outgoingMessage);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "ForceUpdateGroupTitles")
            {
                //Comes in on the region side from the Universe.Server
                UUID          groupID  = message["GroupID"].AsUUID();
                UUID          roleID   = message["RoleID"].AsUUID();
                UUID          regionID = message["RegionID"].AsUUID();
                IGroupsModule gm       = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID);
                }
            }
            return(null);
        }
Example #11
0
        public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, uint amount,
                                         string description, TransactionType type, UUID transactionID)
        {
            object remoteValue = DoRemoteByURL("CurrencyServerURI", toID, fromID, toObjectID, fromObjectID, amount,
                                               description, type, transactionID);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return((bool)remoteValue);
            }

            UserCurrency toCurrency   = GetUserCurrency(toID);
            UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID);

            if (toCurrency == null)
            {
                return(false);
            }
            if (fromCurrency != null)
            {
                //Check to see whether they have enough money
                if ((int)fromCurrency.Amount - (int)amount < 0)
                {
                    return(false); //Not enough money
                }
                fromCurrency.Amount -= amount;

                UserCurrencyUpdate(fromCurrency, true);
            }
            if (fromID == toID)
            {
                toCurrency = GetUserCurrency(toID);
            }

            //Update the user whose getting paid
            toCurrency.Amount += amount;
            UserCurrencyUpdate(toCurrency, true);

            //Must send out noficiations to the users involved so that they get the updates
            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                m_userInfoService   = m_registry.RequestModuleInterface <IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo    toUserInfo   = m_userInfoService.GetUserInfo(toID.ToString());
                UserInfo    fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString());
                UserAccount toAccount    = m_registry.RequestModuleInterface <IUserAccountService>()
                                           .GetUserAccount(null, toID);
                UserAccount fromAccount = m_registry.RequestModuleInterface <IUserAccountService>()
                                          .GetUserAccount(null, fromID);
                if (fromID == toID)
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
                                                       toAccount == null ? "" : (toAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description)));
                    }
                }
                else
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
                                                       fromAccount == null ? "" : (fromAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description)));
                    }
                    if (fromUserInfo != null && fromUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient(fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount,
                                                       "You paid " + (toAccount == null ? "" : toAccount.Name) + " $" + amount);
                    }
                }
            }
            return(true);
        }
Example #12
0
        public bool DistanceCulling(IScenePresence client, IEntity entity)
        {
            IScene scene = client.Scene;
            float  DD    = client.DrawDistance;

            if (DD < 32) //Limit to a small distance
            {
                DD = 32;
            }
            if (DD > scene.RegionInfo.RegionSizeX)
            {
                return(true); //Its larger than the region, no culling check even necessary
            }
            Vector3 posToCheckFrom = client.AbsolutePosition;

            if (client.IsChildAgent)
            {
                if (m_cachedXOffset == 0 && m_cachedYOffset == 0) //Not found yet
                {
                    IAgentInfoService agentInfoService = scene.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfoService != null)
                    {
                        UserInfo info = agentInfoService.GetUserInfo(client.UUID.ToString());
                        if (info != null)
                        {
                            GridRegion r = scene.GridService.GetRegionByUUID(scene.RegionInfo.ScopeID,
                                                                             info.CurrentRegionID);
                            if (r != null)
                            {
                                m_cachedXOffset = scene.RegionInfo.RegionLocX - r.RegionLocX;
                                m_cachedYOffset = scene.RegionInfo.RegionLocY - r.RegionLocY;
                            }
                        }
                    }
                }
                //We need to add the offset so that we can check from the right place in child regions
                if (m_cachedXOffset < 0)
                {
                    posToCheckFrom.X = scene.RegionInfo.RegionSizeX - (scene.RegionInfo.RegionSizeX + client.AbsolutePosition.X + m_cachedXOffset);
                }
                if (m_cachedYOffset < 0)
                {
                    posToCheckFrom.Y = scene.RegionInfo.RegionSizeY - (scene.RegionInfo.RegionSizeY + client.AbsolutePosition.Y + m_cachedYOffset);
                }
                if (m_cachedXOffset > scene.RegionInfo.RegionSizeX)
                {
                    posToCheckFrom.X = scene.RegionInfo.RegionSizeX - (scene.RegionInfo.RegionSizeX - (client.AbsolutePosition.X + m_cachedXOffset));
                }
                if (m_cachedYOffset > scene.RegionInfo.RegionSizeY)
                {
                    posToCheckFrom.Y = scene.RegionInfo.RegionSizeY - (scene.RegionInfo.RegionSizeY - (client.AbsolutePosition.Y + m_cachedYOffset));
                }
            }
            //If the distance is greater than the clients draw distance, its out of range
            if (Vector3.DistanceSquared(posToCheckFrom, entity.AbsolutePosition) >
                DD * DD) //Use squares to make it faster than having to do the sqrt
            {
                return(false);
            }

            return(true);
        }