/YetAnotherForum.Mojo.Src/YAF.Mojo.UI/YAFModule/Forum.ascx.cs

https://github.com/vzrus/YAF-and-MojoPortal-Add-Ons · C# · 123 lines · 72 code · 14 blank · 37 comment · 7 complexity · d6bea517fece0564276b391b7f8d80e2 MD5 · raw file

  1. /* ***************************************************************************************************
  2. * The MIT License (MIT)
  3. * Copyright (c) 2006-2009,2011 vzrus 2009,2010 Mek
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
  5. * associated documentation files (the "Software"), to deal in the Software without restriction,
  6. * including without limitation the rights to use, copy, modify, merge, publish, distribute,
  7. * sublicense, and/or sell copies of the Software, and to permit persons
  8. * to whom the Software is furnished to do so, subject to the following conditions:
  9. *The above copyright notice and this permission notice shall be included in all copies
  10. *or substantial portions of the Software.
  11. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  12. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
  13. * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. * ***************************************************************************************************
  17. */
  18. using YAF.Classes;
  19. namespace YAF.Mojo.UI.YAFModule
  20. {
  21. #region Region
  22. using System;
  23. using System.Web;
  24. using YAF.Classes.Data;
  25. using YAF.Types.EventProxies;
  26. using mojoPortal.Business;
  27. using mojoPortal.Web;
  28. using mojoPortal.Web.Framework;
  29. using YAF.Core;
  30. using YAF.Types;
  31. using YAF.Types.Interfaces;
  32. using YAF.Utils;
  33. #endregion
  34. public partial class YafForum : SiteModuleControl
  35. {
  36. /// <summary>
  37. /// The page_ load.
  38. /// </summary>
  39. /// <param name="sender">
  40. /// The sender.
  41. /// </param>
  42. /// <param name="e">
  43. /// The e.
  44. /// </param>
  45. protected void Page_Load(object sender, EventArgs e)
  46. {
  47. Page.EnableViewState = true; // MojoPortal disables Viewstate by default and YAF requires it
  48. // Disable Jquery Register
  49. if (HttpContext.Current.Items["AddJQueryRegistedHandler"] == null)
  50. {
  51. HttpContext.Current.Items["AddJQueryRegistedHandler"] = true;
  52. }
  53. try
  54. {
  55. this.forum1.BoardID = WebUtils.ParseInt32FromHashtable(Settings, "BoardID", 1);
  56. this.forum1.CategoryID = WebUtils.ParseInt32FromHashtable(Settings, "CategoryID", 0);
  57. this.forum1.LockedForum = WebUtils.ParseInt32FromHashtable(Settings, "LockedForum", 0);
  58. }
  59. catch (Exception)
  60. {
  61. this.forum1.BoardID = 0;
  62. }
  63. if (HttpContext.Current.User.Identity.IsAuthenticated)
  64. {
  65. SiteUser su = SiteUtils.GetCurrentSiteUser();
  66. SyncUserProfile.UpdateTimeZone(su);
  67. SyncUserProfile.UpdateProfile(su);
  68. int? newTimeZone = SyncUserProfile.UpdateTimeZone(su);
  69. if (newTimeZone != null || YafContext.Current.CurrentUserData.DisplayName != su.Name)
  70. {
  71. SaveUser(su, newTimeZone);
  72. }
  73. }
  74. }
  75. /// <summary>
  76. /// The method saves a YAF user data to database.
  77. /// </summary>
  78. /// <param name="su">
  79. /// The MP SiteUser Method.
  80. /// </param>
  81. /// <param name="timeZone">
  82. /// The time zone offset as int in minutes.
  83. /// </param>
  84. private void SaveUser(SiteUser su, int? timeZone)
  85. {
  86. LegacyDb.user_save(
  87. YafContext.Current.PageUserID,
  88. YafContext.Current.PageBoardID,
  89. null,
  90. su.Name,
  91. null,
  92. timeZone ?? YafContext.Current.CurrentUserData.TimeZone,
  93. YafContext.Current.LanguageFile.IsSet() ? YafContext.Current.LanguageFile.Trim() : null,
  94. YafContext.Current.CultureUser.Trim(),
  95. YafContext.Current.Get<ITheme>().ThemeFile,
  96. false, YafContext.Current.TextEditor,
  97. YafContext.Current.CurrentUserData.UseMobileTheme,
  98. null,
  99. null,
  100. null,
  101. YafContext.Current.CurrentUserData.DSTUser,
  102. YafContext.Current.CurrentUserData.IsActiveExcluded,
  103. null);
  104. // clear the cache for this user...)
  105. YafContext.Current.Get<IRaiseEvent>().Raise(new UpdateUserEvent(YafContext.Current.PageUserID));
  106. YafContext.Current.Get<IDataCache>().Clear();
  107. }
  108. }
  109. }