Esempio n. 1
0
        /// <summary>
        /// Removes the user reputation.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        protected void RemoveUserReputation(object sender, EventArgs e)
        {
            if (!YafReputation.CheckIfAllowReputationVoting(this.DataRow["ReputationVoteDate"]))
            {
                return;
            }

            this.AddReputation.Visible    = false;
            this.RemoveReputation.Visible = false;

            LegacyDb.user_removepoints(this.PostData.UserId, this.PageContext.PageUserID, 1);

            this.DataRow["ReputationVoteDate"] = DateTime.UtcNow;

            // Reload UserBox
            this.PageContext.CurrentForumPage.PageCache[Constants.Cache.UserBoxes] = null;

            this.DataRow["Points"]  = this.DataRow["Points"].ToType <int>() - 1;
            this.UserBox1.PageCache = null;

            this.PageContext.AddLoadMessage(
                this.GetTextFormatted(
                    "REP_VOTE_DOWN_MSG",
                    this.Get <HttpServerUtilityBase>().HtmlEncode(
                        this.DataRow[this.Get <YafBoardSettings>().EnableDisplayName ? "DisplayName" : "UserName"].ToString())),
                MessageTypes.success);
        }
Esempio n. 2
0
        /// <summary>
        /// Add Reputation Controls to the User PopMenu
        /// </summary>
        private void AddReputationControls()
        {
            if (this.PageContext.PageUserID != this.DataRow["UserID"].ToType <int>() &&
                this.Get <YafBoardSettings>().EnableUserReputation&& !this.IsGuest && !this.PageContext.IsGuest)
            {
                if (!YafReputation.CheckIfAllowReputationVoting(this.DataRow["ReputationVoteDate"]))
                {
                    return;
                }

                // Check if the User matches minimal requirements for voting up
                if (this.PageContext.Reputation >= this.Get <YafBoardSettings>().ReputationMinUpVoting)
                {
                    this.AddReputation.Visible = true;
                }

                // Check if the User matches minimal requirements for voting down
                if (this.PageContext.Reputation < this.Get <YafBoardSettings>().ReputationMinDownVoting)
                {
                    return;
                }

                // Check if the Value is 0 or Bellow
                if (this.DataRow["Points"].ToType <int>() > 0 &&
                    this.Get <YafBoardSettings>().ReputationAllowNegative)
                {
                    this.RemoveReputation.Visible = true;
                }
            }
            else
            {
                this.AddReputation.Visible    = false;
                this.RemoveReputation.Visible = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the user reputation.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        protected void AddUserReputation(object sender, EventArgs e)
        {
            if (!YafReputation.CheckIfAllowReputationVoting(this.DataRow["ReputationVoteDate"]))
            {
                return;
            }

            this.AddReputation.Visible    = false;
            this.RemoveReputation.Visible = false;

            LegacyDb.user_addpoints(this.PostData.UserId, this.PageContext.PageUserID, 1);

            this.DataRow["ReputationVoteDate"] = DateTime.UtcNow;

            // Reload UserBox
            this.PageContext.CurrentForumPage.PageCache[Constants.Cache.UserBoxes] = null;

            this.DataRow["Points"]  = this.DataRow["Points"].ToType <int>() + 1;
            this.UserBox1.PageCache = null;

            this.PageContext.AddLoadMessage(
                this.GetTextFormatted(
                    "REP_VOTE_UP_MSG",
                    this.Get <HttpServerUtilityBase>().HtmlEncode(
                        this.DataRow[this.Get <YafBoardSettings>().EnableDisplayName ? "DisplayName" : "UserName"].ToString())),
                MessageTypes.Success);

            YafContext.Current.PageElements.RegisterJsBlockStartup(
                "reputationprogressjs",
                JavaScriptBlocks.ReputationProgressChangeJs(
                    YafReputation.GenerateReputationBar(this.DataRow["Points"].ToType <int>(), this.PostData.UserId),
                    this.PostData.UserId.ToString()));
        }