public int CreateNewEstate(EstateSettings es)
        {
            object remoteValue = DoRemote(es.ToOSD());
            if (remoteValue != null || m_doRemoteOnly)
                return (int) remoteValue;

            int estateID = GetEstate(es.EstateOwner, es.EstateName);
            if (estateID > 0)
            {
                return estateID;
            }

            // check for system or user estates
            if ((es.EstateOwner == (UUID) Constants.GovernorUUID))                  // Mainland?
            {
                es.EstateID = Constants.MainlandEstateID;
            } else if ( (es.EstateOwner == (UUID) Constants.RealEstateOwnerUUID) )  // System Estate?
            {
                es.EstateID = (uint) Constants.SystemEstateID;
            } else                                                                  // must be a new user estate then
                es.EstateID = GetNewEstateID();

            SaveEstateSettings(es, true);
            return (int) es.EstateID;
        }
        public EstateSettings GetEstateSettings(UUID regionID)
        {
            EstateSettings settings = new EstateSettings () { EstateID = 0 };

            if (m_doRemoteOnly) {
                object remoteValue = DoRemote (regionID);
                return remoteValue != null ? (EstateSettings)remoteValue : settings;
            }

            int estateID = GetEstateID(regionID);
            if (estateID == 0)
                return settings;
            settings = GetEstate(estateID);
            return settings;
        }
        public int CreateNewEstate(EstateSettings es)
        {
            object remoteValue = DoRemote(es.ToOSD());
            if (remoteValue != null || m_doRemoteOnly)
                return (int) remoteValue;

            int estateID = GetEstate(es.EstateOwner, es.EstateName);
            if (estateID > 0)
            {
                return estateID;
            }

            es.EstateID = GetNewEstateID();
            SaveEstateSettings(es, true);
            return (int) es.EstateID;
        }
        public int CreateNewEstate(EstateSettings es, UUID RegionID)
        {
            object remoteValue = DoRemote(es.ToOSD(), RegionID);
            if (remoteValue != null || m_doRemoteOnly)
                return (int) remoteValue;

            int estateID = GetEstate(es.EstateOwner, es.EstateName);
            if (estateID > 0)
            {
                if (LinkRegion(RegionID, estateID))
                    return estateID;
                return 0;
            }
            es.EstateID = GetNewEstateID();
            SaveEstateSettings(es, true);
            LinkRegion(RegionID, (int) es.EstateID);
            return (int) es.EstateID;
        }
        public int CreateNewEstate(EstateSettings es)
        {
            object remoteValue = DoRemote(es.ToOSD());
            if (remoteValue != null || m_doRemoteOnly)
                return (int) remoteValue;

            int estateID = GetEstate(es.EstateOwner, es.EstateName);
            if (estateID > 0)
            {
                return estateID;
            }

            // check for system user/estate
            if ( (es.EstateOwner == (UUID) Constants.RealEstateOwnerUUID) )           // probably don't need to check both :)
            //                (es.EstateName == Constants.SystemEstateName) )                     // maybe if the system user can have multiple estates??
            {
                es.EstateID = (uint) Constants.SystemEstateID;                        // Default Mainland estate  #
            } else
                es.EstateID = GetNewEstateID();

            SaveEstateSettings(es, true);
            return (int) es.EstateID;
        }
        public void SaveEstateSettings(EstateSettings es)
        {
            object remoteValue = DoRemote(es.ToOSD());
            if (remoteValue != null || m_doRemoteOnly)
                return;

            SaveEstateSettings(es, false);
        }
        private EstateSettings CreateEstateInfo(IScene scene)
        {
            EstateSettings ES = new EstateSettings();
            while (true)
            {
                IEstateConnector EstateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector>();

                string name = MainConsole.Instance.Prompt("Estate owner name", LastEstateOwner);
                UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name);

                if (account == null)
                {
                    string createNewUser =
                        MainConsole.Instance.Prompt(
                            "Could not find user " + name + ". Would you like to create this user?", "yes");

                    if (createNewUser == "yes")
                    {
                        // Create a new account
                        string password = MainConsole.Instance.PasswordPrompt(name + "'s password");
                        string email = MainConsole.Instance.Prompt(name + "'s email", "");

                        scene.UserAccountService.CreateUser(name, Util.Md5Hash(password), email);
                        account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.AllScopeIDs, name);

                        if (account == null)
                        {
                            MainConsole.Instance.ErrorFormat(
                                "[EstateService]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level.");
                            continue;
                        }
                    }
                    else
                        continue;
                }

                LastEstateOwner = account.Name;

                List<EstateSettings> ownerEstates = EstateConnector.GetEstates(account.PrincipalID);
                string response = (ownerEstates != null && ownerEstates.Count > 0) ? "yes" : "no";
                if (ownerEstates != null && ownerEstates.Count > 0)
                {
                    MainConsole.Instance.WarnFormat("Found user. {0} has {1} estates currently. {2}", account.Name,
                                                    ownerEstates.Count,
                                                    "These estates are the following:");
                    foreach (EstateSettings t in ownerEstates)
                    {
                        MainConsole.Instance.Warn(t.EstateName);
                    }
                    response =
                        MainConsole.Instance.Prompt(
                            "Do you wish to join one of these existing estates? (Options are {yes, no, cancel})",
                            response, new List<string> {"yes", "no", "cancel"});
                }
                else
                {
                    MainConsole.Instance.WarnFormat("Found user. {0} has no estates currently. Creating a new estate.",
                                                    account.Name);
                }
                if (response == "no")
                {
                    // Create a new estate
                    // ES could be null
                    ES.EstateName = MainConsole.Instance.Prompt("New estate name (or cancel to go back)", "My Estate");
                    if (ES.EstateName == "cancel")
                        continue;
                    //Set to auto connect to this region next
                    LastEstateName = ES.EstateName;
                    ES.EstateOwner = account.PrincipalID;

                    ES.EstateID = (uint) EstateConnector.CreateNewEstate(ES, scene.RegionInfo.RegionID);
                    if (ES.EstateID == 0)
                    {
                        MainConsole.Instance.Warn("There was an error in creating this estate: " + ES.EstateName);
                            //EstateName holds the error. See LocalEstateConnector for more info.
                        continue;
                    }
                    break;
                }
                if (response == "yes")
                {
                    if (ownerEstates != null && ownerEstates.Count != 1)
                    {
                        if (LastEstateName == "")
                            LastEstateName = ownerEstates[0].EstateName;

                        List<string> responses = ownerEstates.Select(settings => settings.EstateName).ToList();

                        responses.Add("None");
                        responses.Add("Cancel");
                        response = MainConsole.Instance.Prompt("Estate name to join", LastEstateName, responses);
                        if (response == "None" || response == "Cancel")
                            continue;
                        LastEstateName = response;
                    }
                    else if (ownerEstates != null) LastEstateName = ownerEstates[0].EstateName;

                    int estateID = EstateConnector.GetEstate(account.PrincipalID, LastEstateName);
                    if (estateID == 0)
                    {
                        MainConsole.Instance.Warn("The name you have entered matches no known estate. Please try again");
                        continue;
                    }

                    //We save the Password because we have to reset it after we tell the EstateService about it, as it clears it for security reasons
                    if (EstateConnector.LinkRegion(scene.RegionInfo.RegionID, estateID))
                    {
                        if ((ES = EstateConnector.GetEstateSettings(scene.RegionInfo.RegionID)) == null ||
                            ES.EstateID == 0)
                            //We could do by EstateID now, but we need to completely make sure that it fully is set up
                        {
                            MainConsole.Instance.Warn("The connection to the server was broken, please try again soon.");
                            continue;
                        }
                        MainConsole.Instance.Warn("Successfully joined the estate!");
                        break;
                    }

                    MainConsole.Instance.Warn("Joining the estate failed. Please try again.");
                    continue;
                }
            }
            return ES;
        }
        EstateSettings GetEstate(int estateID)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["EstateID"] = estateID;

            List<string> retVals = GD.Query(new string[1] { "*" }, m_estateSettingsTable, filter, null, null, null);
            EstateSettings settings = new EstateSettings {EstateID = 0};

            if (retVals.Count > 0)
                settings.FromOSD((OSDMap) OSDParser.DeserializeJson(retVals[4]));

            return settings;
        }
        static void UpdateConsoleRegionEstate (string regionName, EstateSettings estateSettings)
        {
            for (int idx = 0; idx < MainConsole.Instance.ConsoleScenes.Count; idx++) {
                if (MainConsole.Instance.ConsoleScenes [idx].RegionInfo.RegionName == regionName)
                    MainConsole.Instance.ConsoleScenes [idx].RegionInfo.EstateSettings = estateSettings;
            }

        }
        protected void CreateEstateCommand (IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ();
            IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            ISystemAccountService sysAccounts = m_registry.RequestModuleInterface<ISystemAccountService> ();

            string estateName = "";
            string estateOwner = sysAccounts.SystemEstateOwnerName;

            // check for passed estate name
            estateName = (cmd.Length < 3)
                ? MainConsole.Instance.Prompt ("Estate name", estateName)
                : cmd [2];
            if (estateName == "")
                return;

            // verify that the estate does not already exist
            if (estateConnector.EstateExists (estateName)) {
                MainConsole.Instance.ErrorFormat ("[EstateService]: The estate '{0}' already exists!", estateName);
                return;
            }

            // owner?
            estateOwner = (cmd.Length > 3)
                ? Util.CombineParams (cmd, 4) // in case of spaces in the name eg Allan Allard
                : MainConsole.Instance.Prompt ("Estate owner: ", estateOwner);
            if (estateOwner == "")
                return;


            // check to make sure the user exists
            UserAccount account = accountService.GetUserAccount (null, estateOwner);
            if (account == null) {
                MainConsole.Instance.WarnFormat ("[User account service]: The user, '{0}' was not found!", estateOwner);

                // temporary fix until remote user creation can be implemented
                if (accountService.IsLocalConnector) {
                    string createUser = MainConsole.Instance.Prompt ("Do you wish to create this user?  (yes/no)", "yes").ToLower ();
                    if (!createUser.StartsWith ("y", StringComparison.Ordinal))
                        return;

                    // Create a new account
                    string password = MainConsole.Instance.PasswordPrompt (estateOwner + "'s password");
                    string email = MainConsole.Instance.Prompt (estateOwner + "'s email", "");

                    accountService.CreateUser (estateOwner, Util.Md5Hash (password), email);
                    // CreateUser will tell us success or problem
                    account = accountService.GetUserAccount (null, estateOwner);

                    if (account == null) {
                        MainConsole.Instance.ErrorFormat (
                            "[EstateService]: Unable to store account details.\n   If this simulator is connected to a grid, create the estate owner account first at the grid level.");
                        return;
                    }
                } else {
                    MainConsole.Instance.WarnFormat ("[User account service]: The user must be created on the Grid before assigning an estate!");
                    MainConsole.Instance.WarnFormat ("[User account service]: Regions should be assigned to the system user estate until this can be corrected");

                    return;
                }
            }

            // check for bogies...
            if (Utilities.IsSystemUser (account.PrincipalID)) {
                MainConsole.Instance.Info ("[EstateService]: Tsk, tsk.  System users should not be used as estate managers!");
                return;
            }

            // we have an estate name and a user
            // Create a new estate
            var ES = new EstateSettings ();
            ES.EstateName = estateName;
            ES.EstateOwner = account.PrincipalID;

            ES.EstateID = (uint)estateConnector.CreateNewEstate (ES);
            if (ES.EstateID == 0) {
                MainConsole.Instance.Warn ("There was an error in creating this estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else
                MainConsole.Instance.InfoFormat ("[EstateService]: The estate '{0}' owned by '{1}' has been created.", estateName, estateOwner);
        }
        /// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates (IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions ((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID) {
                estateConnector.DeleteEstate ((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate (eS);
                MainConsole.Instance.Info ("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions) {
                estateConnector.LinkRegion (regID, newEstateID);
            }
            if (regions.Count > 0)
                MainConsole.Instance.InfoFormat ("Relinked {0} regions", regions.Count);
        }
        /// <summary>
        /// Checks for a valid system estate. Adds or corrects if required
        /// </summary>
        /// <param name="estateID">Estate I.</param>
        /// <param name="estateName">Estate name.</param>
        /// <param name="ownerUUID">Owner UUI.</param>
        void CheckSystemEstateInfo (int estateID, string estateName, UUID ownerUUID)
        {
            // these should have already been checked but just make sure...
            if (m_estateConnector == null)
                return;

            if (m_estateConnector.RemoteCalls ())
                return;

            ISystemAccountService sysAccounts = m_registry.RequestModuleInterface<ISystemAccountService> ();
            EstateSettings ES;

            // check for existing estate name in case of estate ID change
            ES = m_estateConnector.GetEstateSettings (estateName);
            if (ES != null) {
                // ensure correct ID
                if (ES.EstateID != estateID)
                    UpdateSystemEstates (m_estateConnector, ES, estateID);
            }

            ES = m_estateConnector.GetEstateSettings (estateID);
            if ((ES != null) && (ES.EstateID != 0)) {

                // ensure correct owner
                if (ES.EstateOwner != ownerUUID) {
                    ES.EstateOwner = ownerUUID;
                    m_estateConnector.SaveEstateSettings (ES);
                    MainConsole.Instance.Info ("[EstateService]: The system Estate owner has been updated to " +
                        sysAccounts.GetSystemEstateOwnerName (estateID));
                }


                // in case of configuration changes
                if (ES.EstateName != estateName) {
                    ES.EstateName = estateName;
                    m_estateConnector.SaveEstateSettings (ES);
                    MainConsole.Instance.Info ("[EstateService]: The system Estate name has been updated to " + estateName);
                }

                return;
            }

            // Create a new estate

            ES = new EstateSettings ();
            ES.EstateName = estateName;
            ES.EstateOwner = ownerUUID;

            ES.EstateID = (uint)m_estateConnector.CreateNewEstate (ES);
            if (ES.EstateID == 0) {
                MainConsole.Instance.Warn ("There was an error in creating the system estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else {
                MainConsole.Instance.InfoFormat ("[EstateService]: The estate '{0}' owned by '{1}' has been created.",
                    ES.EstateName, sysAccounts.GetSystemEstateOwnerName (estateID));
            }
        }
        /// <summary>
        /// Checks for the grid owner estate on initial startup.
        /// </summary>
        void CheckGridOwnerEstate ()
        {
            // these should have already been checked but just make sure...
            if (m_estateConnector == null)
                return;

            if (m_estateConnector.RemoteCalls ())
                return;

            // check for existing estate name in case of estate ID change
            var estates = m_estateConnector.GetEstateNames();
            if (estates.Count > 2)     // we have 2 system estates, 'System' & 'Mainland'
                return;
            
            // Create an estate for the grid owner
            IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            if (accountService == null) {
                MainConsole.Instance.Warn ("[EstateService]: Unable to determine grid owner for estate creation");
                return;
            }

            var userAccts = accountService.GetUserAccounts(null, "*");
            UUID gridOwnerId = UUID.Zero;
            foreach (var acct in userAccts) {
                if (!Utilities.IsSystemUser (acct.PrincipalID))
                    gridOwnerId = acct.PrincipalID;                 // we should have only one non system user
            }
            var gridOwnerAcct = accountService.GetUserAccount (null, gridOwnerId);
            MainConsole.Instance.InfoFormat("[EstateService]: The estate for '{0}' needs to be created.", gridOwnerAcct.Name);

            // get estate name
            var estateName = MainConsole.Instance.Prompt ("Estate name", "Owner's Estate");
            if (estateName == "")
                estateName = "Owner's Estate";


            var ES = new EstateSettings ();
            ES.EstateName = estateName;
            ES.EstateOwner = gridOwnerId;

            ES.EstateID = (uint)m_estateConnector.CreateNewEstate (ES);
            if (ES.EstateID == 0) {
                MainConsole.Instance.Warn ("There was an error in creating the owner's estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else {
                MainConsole.Instance.InfoFormat ("[EstateService]: The estate '{0}' owned by '{1}' has been created.",
                                                 ES.EstateName, gridOwnerAcct.Name);
            }
        }
 /// <summary>
 /// Loads the estate settings from an archive.
 /// </summary>
 /// <param name="data">Data.</param>
 /// <param name="filePath">File path.</param>
 /// <param name="type">Type.</param>
 /// <param name="scene">Scene.</param>
 public void LoadModuleFromArchive(byte[] data, string filePath, TarArchiveReader.TarEntryType type, IScene scene)
 {
     if (filePath.StartsWith("estatesettings/"))
     {
         EstateSettings settings = new EstateSettings();
         settings.FromOSD((OSDMap) OSDParser.DeserializeLLSDBinary(data));
         scene.RegionInfo.EstateSettings = settings;
     }
     else if (filePath.StartsWith("regioninfo/"))
     {
         string m_merge =
             MainConsole.Instance.Prompt(
                 "Should we load the region information from the archive (region name, region position, etc)?",
                 "false");
         RegionInfo settings = new RegionInfo();
         settings.UnpackRegionInfoData((OSDMap) OSDParser.DeserializeLLSDBinary(data));
         if (m_merge == "false")
         {
             //Still load the region settings though
             scene.RegionInfo.RegionSettings = settings.RegionSettings;
             return;
         }
         settings.RegionSettings = scene.RegionInfo.RegionSettings;
         settings.EstateSettings = scene.RegionInfo.EstateSettings;
         scene.RegionInfo = settings;
     }
 }
Example #15
0
        protected void CreateEstateCommand(IScene scene, string[] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector>();
            IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService>();

            string estateName = "";
            string estateOwner = Constants.RealEstateOwnerName;

            // check for passed estate name
            estateName = (cmd.Length < 3)
                ? MainConsole.Instance.Prompt("Estate name: ")
                : cmd[2];
            if (estateName == "")
                return;

            // verify that the estate does not already exist
            if (estateConnector.EstateExists(estateName))
            {
                MainConsole.Instance.ErrorFormat("EstateService]: The estate '{0}' already exists!",estateName);
                return;
            }

            // owner?
            estateOwner = (cmd.Length > 3)
                ? Util.CombineParams(cmd, 4) // in case of spaces in the name eg Allan Allard
                : MainConsole.Instance.Prompt("Estate owner: ", estateOwner);
            if (estateOwner == "")
                return;

            // check to make sure the user exists
            UserAccount account = accountService.GetUserAccount(null, estateOwner);
             if (account == null)
            {
                MainConsole.Instance.WarnFormat("[USER ACCOUNT SERVICE]: The user, '{0}' was not found!", estateOwner);
                string createUser = MainConsole.Instance.Prompt("Do you wish to create this user?  (yes/no)","yes").ToLower();
                if (!createUser.StartsWith("y"))
                   return;

                // Create a new account
                string password = MainConsole.Instance.PasswordPrompt(estateOwner + "'s password");
                string email = MainConsole.Instance.Prompt(estateOwner + "'s email", "");

                accountService.CreateUser(estateOwner, Util.Md5Hash(password), email);
                // CreateUser will tell us success or problem
                account = accountService.GetUserAccount(null, estateOwner);

                if (account == null)
                {
                    MainConsole.Instance.ErrorFormat(
                        "[EstateService]: Unable to store account details.\n   If this simulator is connected to a grid, create the estate owner account first at the grid level.");
                    return;
                }
            }

            // we have an estate name and a user
            // Create a new estate
            EstateSettings ES = new EstateSettings();
            ES.EstateName = estateName;
            ES.EstateOwner = account.PrincipalID;

            ES.EstateID = (uint) estateConnector.CreateNewEstate(ES);
            if (ES.EstateID == 0)
            {
                MainConsole.Instance.Warn("There was an error in creating this estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.", estateName, estateOwner);
        }
        public void SaveEstateSettings(EstateSettings es)
        {
            if (m_doRemoteOnly) {
                DoRemote (es.ToOSD ());
                return;
            }

            SaveEstateSettings(es, false);
        }
Example #17
0
        private void CheckSystemEstateInfo(IEstateConnector estateConnector)
        {
            // these should have already been checked but just make sure...
            if (estateConnector == null)
                return;

            if (estateConnector.RemoteCalls ())
                return;

            if (estateConnector.EstateExists (Constants.SystemEstateName))
                return;

            // Create a new estate
            EstateSettings ES = new EstateSettings();
            ES.EstateName = Constants.SystemEstateName;
            ES.EstateOwner = (UUID) Constants.RealEstateOwnerUUID;

            ES.EstateID = (uint) estateConnector.CreateNewEstate(ES);
            if (ES.EstateID == 0)
            {
                MainConsole.Instance.Warn("There was an error in creating the system estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.

            } else {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.",
                    Constants.SystemEstateName, Constants.RealEstateOwnerName);
            }
        }
        protected void SaveEstateSettings(EstateSettings es, bool doInsert)
        {
            Dictionary<string, object> values = new Dictionary<string, object>(5);
            values["EstateID"] = es.EstateID;
            values["EstateName"] = es.EstateName;
            values["EstateOwner"] = es.EstateOwner;
            values["ParentEstateID"] = es.ParentEstateID;
            values["Settings"] = OSDParser.SerializeJsonString(es.ToOSD());

            if (!doInsert)
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["EstateID"] = es.EstateID;
                GD.Update(m_estateSettingsTable, values, null, filter, null, null);
            }
            else
            {
                GD.Insert(m_estateSettingsTable, values);
            }
        }
Example #19
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> ();
            var estateConnector = Framework.Utilities.DataManager.RequestPlugin<IEstateConnector> ();

            string estate;

            if (httpRequest.Query.ContainsKey ("EstateID")) {
                estate = httpRequest.Query ["EstateID"].ToString ();
            } else {
                if (requestParameters.ContainsKey ("EstateID")) {
                    estate = requestParameters ["EstateID"].ToString ();
                } else {
                    response = "<h3>Estate details not supplied, redirecting to main page</h3>" +
                        "<script>" +
                        "setTimeout(function() {window.location.href = \"/?page=estate_manager\";}, 1000);" +
                        "</script>";
                    return null;
                }
            }

            var estateid = -1;
            int.TryParse (estate, out estateid);

            if (requestParameters.ContainsKey ("Delete")) {
                //var estateID = httpRequest.Query ["delete"].ToString ();
                //if (estateConnector.DeleteEstate (estateID))
                //    response = "<h3>Estate details have been deleted</h3>" +
                //        "<script>" +
                //        "setTimeout(function() {window.location.href = \"/?page=estate_manager\";}, 1000);" +
                //        "</script>";
                //else
                response = "Estate details would have been deleted (but not yet).";
                return null;
            }

            if (requestParameters.ContainsKey ("Submit")) {
                var estateSettings = new EstateSettings ();
                if (estateid >= 0)
                    estateSettings = estateConnector.GetEstateSettings (estateid);

                var estateOwner = requestParameters ["EstateOwner"].ToString ();

                estateSettings.EstateName = requestParameters ["EstateName"].ToString (); 
                estateSettings.EstateOwner = UUID.Parse (estateOwner);
                estateSettings.PricePerMeter = int.Parse (requestParameters ["PricePerMeter"].ToString ());
                estateSettings.PublicAccess = requestParameters ["PublicAccess"].ToString () == "1";
                estateSettings.TaxFree = requestParameters ["TaxFree"].ToString () == "1";
                estateSettings.AllowVoice = requestParameters ["AllowVoice"].ToString () == "1";
                estateSettings.AllowDirectTeleport = requestParameters ["AllowDirectTeleport"].ToString () == "1";

                estateConnector.SaveEstateSettings (estateSettings);

                response = "Estate details have been updated." +
                            "<script>" +
                           "setTimeout(function() {window.location.href = \"/?page=estate_manager\";}, 1000);" +
                            "</script>";

                return null;
            }

            if (requestParameters.ContainsKey ("NewEstate")) {
                // blank details for new estate
                vars.Add ("EstateID", "-1");
                vars.Add ("EstateName", "");
                vars.Add ("UserList", WebHelpers.UserSelections (webInterface.Registry, UUID.Zero));
                vars.Add ("PricePerMeter", "");
                vars.Add ("PublicAccess", WebHelpers.YesNoSelection (translator, true));
                vars.Add ("AllowVoice", WebHelpers.YesNoSelection (translator, true));
                vars.Add ("TaxFree", WebHelpers.YesNoSelection (translator, true));
                vars.Add ("AllowDirectTeleport", WebHelpers.YesNoSelection (translator, true));

                vars.Add ("Submit", translator.GetTranslatedString ("AddEstateText"));
            } else {
                // get selected estate details
                var estateSettings = estateConnector.GetEstateSettings (estateid);
                if (estateSettings != null) {
                    vars.Add ("EstateID", estateSettings.EstateID.ToString ());
                    vars.Add ("EstateName", estateSettings.EstateName);
                    vars.Add ("UserList", WebHelpers.UserSelections (webInterface.Registry, estateSettings.EstateOwner));
                    vars.Add ("PricePerMeter", estateSettings.PricePerMeter.ToString ());
                    vars.Add ("PublicAccess", WebHelpers.YesNoSelection (translator, estateSettings.PublicAccess));
                    vars.Add ("AllowVoice", WebHelpers.YesNoSelection (translator, estateSettings.AllowVoice));
                    vars.Add ("TaxFree", WebHelpers.YesNoSelection (translator, estateSettings.TaxFree));
                    vars.Add ("AllowDirectTeleport", WebHelpers.YesNoSelection (translator, estateSettings.AllowDirectTeleport));

                    vars.Add ("Submit", translator.GetTranslatedString ("SaveUpdates"));
                }
            }


            // labels
            vars.Add ("EstateManagerText", translator.GetTranslatedString ("MenuEstateManager"));
            vars.Add ("EstateNameText", translator.GetTranslatedString ("EstateText"));
            vars.Add ("EstateOwnerText", translator.GetTranslatedString ("MenuOwnerTitle"));
            vars.Add ("PricePerMeterText", translator.GetTranslatedString ("PricePerMeterText"));
            vars.Add ("PublicAccessText", translator.GetTranslatedString ("PublicAccessText"));
            vars.Add ("AllowVoiceText", translator.GetTranslatedString ("AllowVoiceText"));
            vars.Add ("TaxFreeText", translator.GetTranslatedString ("TaxFreeText"));
            vars.Add ("AllowDirectTeleportText", translator.GetTranslatedString ("AllowDirectTeleportText"));
            vars.Add ("Cancel", translator.GetTranslatedString ("Cancel"));
            vars.Add ("InfoMessage", "");

            return vars;

        }
Example #20
0
 private bool CheckEstateGroups(EstateSettings ES, AgentCircuitData agent)
 {
     IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
     if (gm != null && ES.EstateGroups.Count > 0)
     {
         GroupMembershipData[] gmds = gm.GetMembershipData(agent.AgentID);
         return gmds.Any(gmd => ES.EstateGroups.Contains(gmd.GroupID));
     }
     return false;
 }
        public override void FinishedMigration(IDataConnector genericData)
        {
            if (!genericData.TableExists("estates")) return;
            DataReaderConnection dr = genericData.QueryData("WHERE `Key` = 'EstateID'", "estates",
                                                            "`ID`, `Key`, `Value`");

            if (dr != null)
            {
                try
                {
                    while (dr.DataReader.Read())
                    {
                        try
                        {
                            UUID ID = UUID.Parse(dr.DataReader["ID"].ToString());
                            string value = dr.DataReader["Value"].ToString();
                            QueryFilter filter = new QueryFilter();
                            filter.andFilters["`ID`"] = value;
                            filter.andFilters["`Key`"] = "EstateSettings";
                            List<string> results = genericData.Query(new string[1] {"`Value`"}, "estates", filter, null,
                                                                     null, null);
                            if ((results != null) && (results.Count >= 1))
                            {
                                EstateSettings es = new EstateSettings();
                                es.FromOSD((OSDMap) OSDParser.DeserializeLLSDXml(results[0]));
                                genericData.Insert("estateregions", new object[] {ID, value});

                                filter = new QueryFilter();
                                filter.andFilters["`EstateID`"] = value;

                                List<string> exist = genericData.Query(new string[1] {"`EstateID`"}, "estatesettings",
                                                                       filter, null, null, null);
                                if (exist == null || exist.Count == 0)
                                {
                                    genericData.Insert("estatesettings",
                                                       new object[]
                                                           {
                                                               value, es.EstateName, es.EstateOwner, es.ParentEstateID,
                                                               es.ToOSD()
                                                           });
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch
                {
                }
                finally
                {
                    dr.DataReader.Close();
                    genericData.CloseDatabase(dr);
                    dr.Dispose ();
                }
            }
        }