Example #1
0
        private string GetPackagePolicy(string settingsName, string key)
        {
            // load package
            PackageInfo package = PackagesHelper.GetCachedPackage(PanelSecurity.PackageId);

            if (package != null)
            {
                // load user profile
                int userId = package.UserId;
                _policyUser = UsersHelper.GetCachedUser(package.UserId);

                if (_policyUser != null)
                {
                    // load settings
                    UserSettings settings = UsersHelper.GetCachedUserSettings(userId, settingsName);
                    if (settings != null)
                    {
                        string policyValue = settings[key];
                        if (policyValue != null)
                        {
                            return(policyValue);
                        }
                    }
                }
            }

            return(null);
        }
Example #2
0
        public void ShowResultMessage(string moduleName, int resultCode, bool showcf, params object[] formatArgs)
        {
            MessageBoxType messageType = MessageBoxType.Warning;

            // try to get warning
            string sCode                = Convert.ToString(resultCode * -1);
            string localizedMessage     = GetSharedLocalizedString(moduleName, "Warning." + sCode);
            string localizedDescription = GetSharedLocalizedString(moduleName, "WarningDescription." + sCode);

            if (localizedMessage == null)
            {
                messageType = MessageBoxType.Error;

                // try to get error
                localizedMessage     = GetSharedLocalizedString(moduleName, "Error." + sCode);
                localizedDescription = GetSharedLocalizedString(moduleName, "ErrorDescription." + sCode);

                if (localizedMessage == null)
                {
                    localizedMessage = GetSharedLocalizedString(moduleName, "Message.Generic") + " " + resultCode.ToString();
                }
                else
                {
                    if (formatArgs != null && formatArgs.Length > 0)
                    {
                        localizedMessage = String.Format(localizedMessage, formatArgs);
                    }
                }
            }

            // check if this is a "demo" message and it is overriden
            if (resultCode == BusinessErrorCodes.ERROR_USER_ACCOUNT_DEMO)
            {
                UserSettings wspSettings = UsersHelper.GetCachedUserSettings(
                    PanelSecurity.EffectiveUserId, UserSettings.WEBSITEPANEL_POLICY);
                if (!String.IsNullOrEmpty(wspSettings["DemoMessage"]))
                {
                    localizedDescription = wspSettings["DemoMessage"];
                }
            }

            // render message
            Exception fake_ex = null;

            // Contact form is requested to be shown
            if (showcf)
            {
                fake_ex = new Exception();
            }
            //
            messageBox.RenderMessage(messageType, localizedMessage, localizedDescription, fake_ex);
        }
Example #3
0
        public void SetUserPolicy(int userId, string settingsName, string key)
        {
            // load user profile
            UserInfo user = UsersHelper.GetCachedUser(userId);

            if (user != null)
            {
                PolicyUser = user;

                // load settings
                UserSettings settings = UsersHelper.GetCachedUserSettings(userId, settingsName);
                if (settings != null)
                {
                    string policyValue = settings[key];
                    if (policyValue != null)
                    {
                        PolicyValue = policyValue;
                    }
                }
            }

            // toggle controls
            ToggleControls();
        }