Exemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                MoreSmilies.Text        = PageContext.Localization.GetText("SMILIES_MORE");
                MoreSmilies.NavigateUrl = YafBuildLink.GetLink(ForumPages.showsmilies);
                MoreSmilies.Target      = "yafShowSmilies";
                MoreSmilies.Attributes.Add("onclick",
                                           String.Format("var smiliesWin = window.open('{0}', '{1}', 'height={2},width={3},scrollbars=yes,resizable=yes');smiliesWin.focus();return false;",
                                                         MoreSmilies.NavigateUrl,
                                                         MoreSmilies.Target,
                                                         550,
                                                         300));
            }

            YafBoardSettings bs = PageContext.BoardSettings;

            _pagesize = bs.SmiliesColumns * bs.SmiliesPerRow;
            _perrow   = bs.SmiliesPerRow;

            // setup the header
            AddSmiley.Attributes.Add("colspan", _perrow.ToString());
            AddSmiley.InnerHtml = PageContext.Localization.GetText("SMILIES_HEADER");
            // setup footer
            MoreSmiliesCell.Attributes.Add("colspan", _perrow.ToString());

            _dtSmileys = YAF.Classes.Data.DB.smiley_listunique(base.PageContext.PageBoardID);

            if (_dtSmileys.Rows.Count == 0)
            {
                SmiliesPlaceholder.Visible = false;
            }
            else
            {
                MoreSmiliesHolder.Visible = (_dtSmileys.Rows.Count > _pagesize);
                CreateSmileys();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AttachmentEventHandleFileDelete"/> class.
 /// </summary>
 /// <param name="boardSettings">
 /// The board settings.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="attachmentRepository">
 /// The attachment repository.
 /// </param>
 public AttachmentEventHandleFileDelete(YafBoardSettings boardSettings, ILogger logger, IRepository <Attachment> attachmentRepository)
 {
     this._boardSettings        = boardSettings;
     this._logger               = logger;
     this._attachmentRepository = attachmentRepository;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the YAF user.
        /// </summary>
        /// <param name="dnnUserInfo">The DNN user info.</param>
        /// <param name="dnnUser">The DNN user.</param>
        /// <param name="boardID">The board ID.</param>
        /// <param name="portalID">The portal identifier.</param>
        /// <param name="boardSettings">The board settings.</param>
        /// <returns>
        /// Returns the User ID of the new User
        /// </returns>
        public static int CreateYafUser(
            UserInfo dnnUserInfo,
            MembershipUser dnnUser,
            int boardID,
            int portalID,
            YafBoardSettings boardSettings)
        {
            // setup roles
            RoleMembershipHelper.SetupUserRoles(boardID, dnnUser.UserName);

            // create the user in the YAF DB so profile can gets created...
            var yafUserId = RoleMembershipHelper.CreateForumUser(dnnUser, dnnUserInfo.DisplayName, boardID);

            if (yafUserId == null)
            {
                return(0);
            }

            // create profile
            var userProfile = YafUserProfile.GetProfile(dnnUser.UserName);

            // setup their initial profile information
            userProfile.Initialize(dnnUser.UserName, true);

            if (dnnUserInfo.Profile.FullName.IsSet())
            {
                userProfile.RealName = dnnUserInfo.Profile.FullName;
            }

            if (dnnUserInfo.Profile.Country.IsSet() && !dnnUserInfo.Profile.Country.Equals("N/A"))
            {
                var regionInfo = ProfileSyncronizer.GetRegionInfoFromCountryName(dnnUserInfo.Profile.Country);

                if (regionInfo != null)
                {
                    userProfile.Country = regionInfo.TwoLetterISORegionName;
                }
            }

            if (dnnUserInfo.Profile.City.IsSet())
            {
                userProfile.City = dnnUserInfo.Profile.City;
            }

            if (dnnUserInfo.Profile.Website.IsSet())
            {
                userProfile.Homepage = dnnUserInfo.Profile.Website;
            }

            userProfile.Save();

            // Save User
            LegacyDb.user_save(
                yafUserId,
                boardID,
                dnnUserInfo.Username,
                dnnUserInfo.DisplayName,
                dnnUserInfo.Email,
                0,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null);

            var autoWatchTopicsEnabled =
                boardSettings.DefaultNotificationSetting.Equals(UserNotificationSetting.TopicsIPostToOrSubscribeTo);

            // save notification Settings
            LegacyDb.user_savenotification(
                yafUserId,
                true,
                autoWatchTopicsEnabled,
                boardSettings.DefaultNotificationSetting,
                boardSettings.DefaultSendDigestEmail);

            RoleSyncronizer.SynchronizeUserRoles(boardID, portalID, yafUserId.ToType <int>(), dnnUserInfo);

            return(yafUserId.ToType <int>());
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="YafAvatars"/> class.
 /// </summary>
 /// <param name="boardSettings">
 /// The board settings.
 /// </param>
 public YafAvatars(YafBoardSettings boardSettings)
 {
     this._yafBoardSettings = boardSettings;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateProviderOnInitEvent"/> class.
 /// </summary>
 /// <param name="membershipProvider">
 /// The membership provider.
 /// </param>
 /// <param name="roleProvider">
 /// The role provider.
 /// </param>
 /// <param name="boardSettings">
 /// The board settings.
 /// </param>
 public UpdateProviderOnInitEvent([NotNull] MembershipProvider membershipProvider, [NotNull] RoleProvider roleProvider, [NotNull] YafBoardSettings boardSettings)
 {
     this._membershipProvider = membershipProvider;
     this._roleProvider       = roleProvider;
     this._boardSettings      = boardSettings;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates the YAF user.
        /// </summary>
        /// <param name="dnnUserInfo">The DNN user info.</param>
        /// <param name="dnnUser">The DNN user.</param>
        /// <param name="boardId">The board ID.</param>
        /// <param name="portalId">The portal identifier.</param>
        /// <param name="boardSettings">The board settings.</param>
        /// <returns>
        /// Returns the User ID of the new User
        /// </returns>
        public static int CreateYafUser(
            UserInfo dnnUserInfo,
            MembershipUser dnnUser,
            int boardId,
            int portalId,
            YafBoardSettings boardSettings)
        {
            // setup roles
            RoleMembershipHelper.SetupUserRoles(boardId, dnnUser.UserName);

            // create the user in the YAF DB so profile can gets created...
            var yafUserId = RoleMembershipHelper.CreateForumUser(dnnUser, dnnUserInfo.DisplayName, boardId);

            if (yafUserId == null)
            {
                return(0);
            }

            // create profile
            var userProfile = YafUserProfile.GetProfile(dnnUser.UserName);

            // setup their initial profile information
            userProfile.Initialize(dnnUser.UserName, true);

            if (dnnUserInfo.Profile.FullName.IsSet())
            {
                userProfile.RealName = dnnUserInfo.Profile.FullName;
            }

            if (dnnUserInfo.Profile.Country.IsSet() && !dnnUserInfo.Profile.Country.Equals("N/A"))
            {
                var regionInfo = ProfileSyncronizer.GetRegionInfoFromCountryName(dnnUserInfo.Profile.Country);

                if (regionInfo != null)
                {
                    userProfile.Country = regionInfo.TwoLetterISORegionName;
                }
            }

            if (dnnUserInfo.Profile.City.IsSet())
            {
                userProfile.City = dnnUserInfo.Profile.City;
            }

            if (dnnUserInfo.Profile.Website.IsSet())
            {
                userProfile.Homepage = dnnUserInfo.Profile.Website;
            }

            userProfile.Save();

            var autoWatchTopicsEnabled =
                boardSettings.DefaultNotificationSetting.Equals(UserNotificationSetting.TopicsIPostToOrSubscribeTo);

            // Save User
            LegacyDb.user_save(
                userID: yafUserId,
                boardID: boardId,
                userName: dnnUserInfo.Username,
                displayName: dnnUserInfo.DisplayName,
                email: dnnUserInfo.Email,
                timeZone: dnnUserInfo.Profile.PreferredTimeZone.Id,
                languageFile: null,
                culture: null,
                themeFile: null,
                textEditor: null,
                useMobileTheme: null,
                approved: null,
                pmNotification: boardSettings.DefaultNotificationSetting,
                autoWatchTopics: autoWatchTopicsEnabled,
                dSTUser: dnnUserInfo.Profile.PreferredTimeZone.SupportsDaylightSavingTime,
                hideUser: null,
                notificationType: null);

            // save notification Settings
            LegacyDb.user_savenotification(
                yafUserId,
                true,
                autoWatchTopicsEnabled,
                boardSettings.DefaultNotificationSetting,
                boardSettings.DefaultSendDigestEmail);

            RoleSyncronizer.SynchronizeUserRoles(boardId, portalId, yafUserId.ToType <int>(), dnnUserInfo);

            return(yafUserId.ToType <int>());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Gets link to the page.
 /// </summary>
 /// <param name="boardSettings">The board settings.</param>
 /// <param name="page">Page to which to create a link.</param>
 /// <param name="fullUrl">if set to <c>true</c> [full URL].</param>
 /// <returns>
 /// URL to the given page.
 /// </returns>
 public static string GetLink(YafBoardSettings boardSettings, ForumPages page, bool fullUrl = false)
 {
     return(fullUrl
                ? YafFactoryProvider.UrlBuilder.BuildUrlFull(boardSettings, $"g={page}")
                : YafFactoryProvider.UrlBuilder.BuildUrl(boardSettings, $"g={page}"));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Gets base path to the page without ampersand.
 /// </summary>
 /// <param name="boardSettings">The board settings.</param>
 /// <returns>
 /// Base URL to the given page.
 /// </returns>
 public static string GetBasePath(YafBoardSettings boardSettings)
 {
     return(YafFactoryProvider.UrlBuilder.BuildUrl(boardSettings, string.Empty).TrimEnd('&'));
 }
        /// <summary>
        /// DNN Profile is newer, sync YAF now
        /// NOTE : no need to manually sync Email Address
        /// </summary>
        /// <param name="yafUserId">The YAF user id.</param>
        /// <param name="yafUserProfile">The YAF user profile.</param>
        /// <param name="yafUserData">The YAF user data.</param>
        /// <param name="dnnUserInfo">The DNN user info.</param>
        /// <param name="portalGUID">The portal GUID.</param>
        /// <param name="boardSettings">The board settings.</param>
        private static void SyncYafProfile(int yafUserId, YafUserProfile yafUserProfile, IUserData yafUserData, UserInfo dnnUserInfo, Guid portalGUID, YafBoardSettings boardSettings)
        {
            /*var userCuluture = new YafCultureInfo
             * {
             *  LanguageFile = yafUserData.LanguageFile,
             *  Culture = yafUserData.CultureUser
             * };
             *
             * if (dnnUserInfo.Profile.PreferredLocale.IsSet())
             * {
             *  CultureInfo newCulture = new CultureInfo(dnnUserInfo.Profile.PreferredLocale);
             *
             *  foreach (DataRow row in
             *      StaticDataHelper.Cultures().Rows.Cast<DataRow>().Where(
             *          row => dnnUserInfo.Profile.PreferredLocale == row["CultureTag"].ToString() || newCulture.TwoLetterISOLanguageName == row["CultureTag"].ToString()))
             *  {
             *      userCuluture.LanguageFile = row["CultureFile"].ToString();
             *      userCuluture.Culture = row["CultureTag"].ToString();
             *  }
             * }*/

            LegacyDb.user_save(
                yafUserId,
                boardSettings.BoardID,
                null,
                dnnUserInfo.DisplayName,
                dnnUserInfo.Email,
                yafUserData.TimeZone,
                yafUserData.LanguageFile.IsSet() ? yafUserData.LanguageFile : null,
                yafUserData.CultureUser,
                yafUserData.ThemeFile,
                yafUserData.TextEditor,
                yafUserData.UseMobileTheme,
                null,
                null,
                null,
                yafUserData.DSTUser,
                yafUserData.IsActiveExcluded,
                null);

            if (dnnUserInfo.Profile.FullName.IsSet())
            {
                yafUserProfile.RealName = dnnUserInfo.Profile.FullName;
            }

            if (dnnUserInfo.Profile.Country.IsSet() && !dnnUserInfo.Profile.Country.Equals("N/A"))
            {
                var regionInfo = GetRegionInfoFromCountryName(dnnUserInfo.Profile.Country);

                if (regionInfo != null)
                {
                    yafUserProfile.Country = regionInfo.TwoLetterISORegionName;
                }
            }

            if (dnnUserInfo.Profile.City.IsSet())
            {
                yafUserProfile.City = dnnUserInfo.Profile.City;
            }

            if (dnnUserInfo.Profile.Website.IsSet())
            {
                yafUserProfile.Homepage = dnnUserInfo.Profile.Website;
            }

            yafUserProfile.LastSyncedWithDNN = DateTime.Now;

            yafUserProfile.Save();

            yafUserProfile.Save();

            try
            {
                if (dnnUserInfo.Profile.Photo.IsSet() && !dnnUserInfo.Profile.PhotoURL.Contains("no_avatar.gif"))
                {
                    SaveDnnAvatar(
                        "fileid={0}".FormatWith(dnnUserInfo.Profile.Photo),
                        yafUserId,
                        portalGUID);
                }
                else
                {
                    LegacyDb.user_deleteavatar(yafUserId);
                }
            }
            catch (Exception)
            {
            }

            YafContext.Current.Get <IRaiseEvent>().Raise(new UpdateUserEvent(yafUserId));

            YafContext.Current.Get <IDataCache>().Clear();
        }
Exemplo n.º 10
0
 /// <summary>
 /// Gets link to the page.
 /// </summary>
 /// <param name="boardSettings">The board settings.</param>
 /// <param name="page">Page to which to create a link.</param>
 /// <param name="fullUrl">if set to <c>true</c> [full URL].</param>
 /// <returns>
 /// URL to the given page.
 /// </returns>
 public static string GetLink(YafBoardSettings boardSettings, ForumPages page, bool fullUrl = false)
 {
     return(fullUrl
                ? YafFactoryProvider.UrlBuilder.BuildUrlFull(boardSettings, "g={0}".FormatWith(page))
                : YafFactoryProvider.UrlBuilder.BuildUrl(boardSettings, "g={0}".FormatWith(page)));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Save DNN Avatar as YAF Remote Avatar with relative Path.
 /// </summary>
 /// <param name="fileId">The file id.</param>
 /// <param name="yafUserId">The YAF user id.</param>
 /// <param name="portalGUID">The portal GUID.</param>
 /// <param name="boardSettings">The board settings.</param>
 private static void SaveDnnAvatar(string fileId, int yafUserId, Guid portalGUID, YafBoardSettings boardSettings)
 {
     LegacyDb.user_saveavatar(
         yafUserId,
         "{0}LinkClick.aspx?fileticket={1}".FormatWith(
             YafBuildLink.GetBasePath(boardSettings),
             UrlUtils.EncryptParameter(fileId, portalGUID.ToString())),
         null,
         null);
 }