Beispiel #1
0
        void ApplyExternalData()
        {
            for (int i = 0; i < _dialoguesSettings.Count; i++)
            {
                int dialogueSettingsID            = _dialoguesSettings[i].ID;
                DialogueSettings externalSettings = _database.GetDialogueSettings(dialogueSettingsID);
                _dialoguesSettings[i].Text = externalSettings.Text;

                for (int j = 0; j < externalSettings.Answers.Count; j++)
                {
                    _dialoguesSettings[i].Answers[j].Text = externalSettings.Answers[j].Text;
                }
            }
        }
Beispiel #2
0
        List <DialogueSettings> TranslateItems(List <XML_DialogueSettings> dialoguesSettings)
        {
            List <DialogueSettings> translatedDialogueSettings = new List <DialogueSettings>();

            for (int i = 0; i < dialoguesSettings.Count; i++)
            {
                string           text     = dialoguesSettings[i].Text;
                int              id       = dialoguesSettings[i].ID;
                DialogueSettings settings = new DialogueSettings(id, text);

                translatedDialogueSettings.Add(settings);

                translatedDialogueSettings[i].Answers.AddRange(TranslateAnswers(dialoguesSettings[i].Answers));
            }
            return(translatedDialogueSettings);
        }
Beispiel #3
0
        Dialogue CreateDialogue(DialogueSettings settings)
        {
            Dialogue dialogue;

            if (settings.DialoguePrefab != null)
            {
                dialogue = Instantiate(settings.DialoguePrefab, _dialogueSpawnPoint, false);
            }
            else
            {
                dialogue = Instantiate(_dialogueMainPrefab, _dialogueSpawnPoint, false);
            }
            dialogue.InitDialogue(settings);

            return(dialogue);
        }
        /// <summary>
        /// Send the email confirmations
        /// </summary>
        /// <param name="userToSave"></param>
        /// <param name="settings"></param>
        public void SendEmailConfirmationEmail(IMember userToSave, DialogueSettings settings)
        {
            // Ensure we have an umbraco context
            ContextHelper.EnsureUmbracoContext();

            // Make sure correct culture on Ajax Call
            ContextHelper.EnsureCorrectCulture();

            var manuallyAuthoriseMembers       = settings.ManuallyAuthoriseNewMembers;
            var memberEmailAuthorisationNeeded = settings.NewMembersMustConfirmAccountsViaEmail;

            if (manuallyAuthoriseMembers == false && memberEmailAuthorisationNeeded)
            {
                if (!string.IsNullOrEmpty(userToSave.Email))
                {
                    // SEND AUTHORISATION EMAIL
                    var sb = new StringBuilder();
                    var confirmationLink = string.Concat(AppHelpers.ReturnCurrentDomain(), Urls.GenerateUrl(Urls.UrlType.EmailConfirmation), "?id=", userToSave.Id);
                    sb.AppendFormat("<p>{0}</p>", string.Format(AppHelpers.Lang("Members.MemberEmailAuthorisation.EmailBody"),
                                                                settings.ForumName,
                                                                string.Format("<p><a href=\"{0}\">{0}</a></p>", confirmationLink)));
                    var email = new Email
                    {
                        EmailFrom = settings.NotificationReplyEmailAddress,
                        EmailTo   = userToSave.Email,
                        NameTo    = userToSave.Username,
                        Subject   = AppHelpers.Lang("Members.MemberEmailAuthorisation.Subject")
                    };

                    email.Body = EmailTemplate(email.NameTo, sb.ToString());
                    SendMail(email);

                    // ADD COOKIE
                    // We add a cookie for 7 days, which will display the resend email confirmation button
                    // This cookie is removed when they click the confirmation link and they are logged in
                    var myCookie = new HttpCookie(AppConstants.MemberEmailConfirmationCookieName)
                    {
                        Value   = $"{userToSave.Id}#{userToSave.Username}",
                        Expires = DateTime.Now.AddDays(7)
                    };
                    // Add the cookie.
                    HttpContext.Current.Response.Cookies.Add(myCookie);
                }
            }
        }
Beispiel #5
0
        private static DialogueSettings Settings(IPublishedContent forumRootNode)
        {
            if (forumRootNode != null)
            {
                var settings = new DialogueSettings();

                // Content
                settings.ForumId                = forumRootNode.Id;
                settings.ForumRootUrl           = forumRootNode.Url;
                settings.ForumName              = forumRootNode.GetPropertyValue <string>("forumName");
                settings.ForumDescription       = forumRootNode.GetPropertyValue <string>("forumDescription");
                settings.ForumRootUrlWithDomain = string.Concat(AppHelpers.ReturnCurrentDomain(), settings.ForumRootUrl);

                // Urls
                settings.TopicUrlName    = forumRootNode.GetPropertyValue <string>(AppConstants.PropTopicUrlName);
                settings.MemberUrlName   = forumRootNode.GetPropertyValue <string>(AppConstants.PropMemberUrlName);
                settings.DialogueUrlName = forumRootNode.GetPropertyValue <string>(AppConstants.PropDialogueUrlName);

                var loginPage = forumRootNode.Descendant(AppConstants.DocTypeLogin) ?? forumRootNode.Ancestor(AppConstants.DocTypeLogin);
                settings.LoginUrl = loginPage != null ? loginPage.Url : "/Unable-to-find-login-page";

                var registerPage = forumRootNode.Descendant(AppConstants.DocTypeRegister) ?? forumRootNode.Ancestor(AppConstants.DocTypeRegister);
                settings.RegisterUrl = registerPage != null ? registerPage.Url : "/Unable-to-find-Register-page";

                settings.BannedEmails = forumRootNode.GetPropertyValue <string[]>("bannedEmail").ToList();
                settings.BannedLinks  = forumRootNode.GetPropertyValue <string[]>("bannedLinks").ToList();
                settings.BannedWords  = forumRootNode.GetPropertyValue <string[]>("bannedWords").ToList();

                // General

                var extensions = forumRootNode.GetPropertyValue <string>("fileUploadAllowedExtensions");
                if (!string.IsNullOrEmpty(extensions))
                {
                    settings.FileUploadAllowedExtensions = extensions.ToLower()
                                                           .TrimStart(',').TrimEnd(',')
                                                           .Split(',')
                                                           .Where(x => !string.IsNullOrEmpty(x)).ToList();
                }
                else
                {
                    settings.FileUploadAllowedExtensions = new List <string>();
                }

                settings.FileUploadMaximumFilesize = forumRootNode.GetPropertyValue <int>("fileUploadMaximumFilesize");

                settings.AllowRssFeeds                         = forumRootNode.GetPropertyValue <bool>("allowRssFeeds");
                settings.SuspendRegistration                   = forumRootNode.GetPropertyValue <bool>("suspendRegistration");
                settings.EnableSpamReporting                   = forumRootNode.GetPropertyValue <bool>("enableSpamReporting");
                settings.EnableMemberReporting                 = forumRootNode.GetPropertyValue <bool>("enableMemberReporting");
                settings.AllowEmailSubscriptions               = forumRootNode.GetPropertyValue <bool>("allowEmailSubscriptions");
                settings.ManuallyAuthoriseNewMembers           = forumRootNode.GetPropertyValue <bool>("manuallyAuthoriseNewMembers");
                settings.EmailAdminOnNewMemberSignup           = forumRootNode.GetPropertyValue <bool>("emailAdminOnNewMemberSignup");
                settings.NewMembersMustConfirmAccountsViaEmail = forumRootNode.GetPropertyValue <bool>("newMembersMustConfirmAccountsViaEmail");
                settings.AllowMemberSignatures                 = forumRootNode.GetPropertyValue <bool>("allowMemberSignatures");
                settings.TopicsPerPage                         = forumRootNode.GetPropertyValue <int>("topicsPerPage");
                settings.AllowPostsToBeMarkedAsSolution        = forumRootNode.GetPropertyValue <bool>("allowPostsToBeMarkedAsSolution");
                settings.PostsPerPage               = forumRootNode.GetPropertyValue <int>("postsPerPage");
                settings.ActivitiesPerPage          = forumRootNode.GetPropertyValue <int>("activitiesPerPage");
                settings.AllowPrivateMessages       = forumRootNode.GetPropertyValue <bool>("allowPrivateMessages");
                settings.PrivateMessageInboxSize    = forumRootNode.GetPropertyValue <int>("privateMessageInboxSize");
                settings.PrivateMessageFloodControl = forumRootNode.GetPropertyValue <int>("privateMessageFloodControl");

                // Points
                settings.AllowPoints = forumRootNode.GetPropertyValue <bool>("allowPoints");
                settings.AmountOfPointsBeforeAUserCanVote = forumRootNode.GetPropertyValue <int>("amountOfPointsBeforeAUserCanVote");
                settings.PointsAddedPerNewPost            = forumRootNode.GetPropertyValue <int>("pointsAddedPerNewPost");
                settings.PointsAddedForPositiveVote       = forumRootNode.GetPropertyValue <int>("pointsAddedForPositiveVote");
                settings.PointsDeductedForNegativeVote    = forumRootNode.GetPropertyValue <int>("pointsDeductedForNegativeVote");
                settings.PointsAddedForASolution          = forumRootNode.GetPropertyValue <int>("pointsAddedForASolution");

                // Email
                settings.AdminEmailAddress             = forumRootNode.GetPropertyValue <string>("adminEmailAddress");
                settings.NotificationReplyEmailAddress = forumRootNode.GetPropertyValue <string>("notificationReplyEmailAddress");

                // Theme
                settings.Theme = forumRootNode.GetPropertyValue <string>("theme");

                // Member Group
                var memberGroupService = AppHelpers.UmbServices().MemberGroupService;
                var memberGroupCsv     = forumRootNode.GetPropertyValue <string>("newMemberStartingGroup");

                //NOTE: Take the FIRST one only if there are multiple
                if (memberGroupCsv != null)
                {
                    var memberGroupId = memberGroupCsv.Split(',').FirstOrDefault();
                    settings.Group = memberGroupService.GetByName(memberGroupId);
                }
                else
                {
                    settings.Group = memberGroupService.GetByName(AppConstants.MemberGroupDefault);
                }

                // Spam
                settings.EnableAkismetSpamControl = forumRootNode.GetPropertyValue <bool>("enableAkismetSpamControl");
                settings.AkismetKey   = forumRootNode.GetPropertyValue <string>("enterYourAkismetKeyHere");
                settings.SpamQuestion = forumRootNode.GetPropertyValue <string>("enterASpamRegistrationPreventionQuestion");
                settings.SpamAnswer   = forumRootNode.GetPropertyValue <string>("enterTheAnswerToYourSpamQuestion");

                // Social
                settings.FacebookAppId      = forumRootNode.GetPropertyValue <string>("FacebookAppId");
                settings.FacebookAppSecret  = forumRootNode.GetPropertyValue <string>("FacebookAppSecret");
                settings.GoogleClientId     = forumRootNode.GetPropertyValue <string>("googleClientId");
                settings.GoogleClientSecret = forumRootNode.GetPropertyValue <string>("googleClientSecret");


                // Meta
                settings.PageTitle       = forumRootNode.GetPropertyValue <string>("pageTitle");
                settings.MetaDescription = forumRootNode.GetPropertyValue <string>("metaDescription");

                // Umbraco Properties
                settings.LastModified = forumRootNode.UpdateDate;

                return(settings);
            }
            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Метод для получения настроек диалога.
        /// </summary>
        /// <param name="dialogueID">Идентификатор диалога. ID диалога в базе данных диалогов.</param>
        /// <returns>Настройки диалогового окна.</returns>
        /// <example>
        /// Примеры использования:
        /// <code language = "c#">
        ///int dialogueSettingsID = 0;
        ///DialogueSettings primarySettings;
        ///DialogueSettings externalSettings = GetDialogueSettings(dialogueSettingsID);
        ///primarySettings.Text = externalSettings.Text;
        /// </code>
        /// </example>
        public override DialogueSettings GetDialogueSettings(int dialogueID)
        {
            DialogueSettings result = _dialoguesSettings.Find(x => x.ID == dialogueID);

            return(result);
        }
Beispiel #7
0
 public void Load()
 {
     _asset            = Resources.Load <TextAsset>(TEXT_ASSET_PATH);
     _dialogueSettings = DialogueSettings.Load(_asset);
 }