Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        protected void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                View.Model.Privileges        = (from t in PrivilegeCollection orderby t.Value ascending where t.Value > 0 select t).ToList();
                View.Model.SelectedPrivilege = PrivilegeCollection.Single(s => s.Key == Privilege.ToString());
                View.Model.CurrentUserScore  = UserScore.Score;

                // now that we have the user score, let's determine the next privilege they can achieve
                var colPrivs = (from t in PrivilegeCollection where t.Value > View.Model.CurrentUserScore orderby t.Value ascending select t).ToList();
                if (colPrivs.Count > 0)
                {
                    var objPriv = colPrivs.Take(1).ToList();
                    foreach (var priv in objPriv)
                    {
                        View.Model.NextAchievablePrivilege = priv;
                    }
                }

                View.ItemDataBound += ItemDataBound;
                View.Refresh();
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        private void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                var returnUrl = HttpContext.Request.RawUrl;
                var redirect  = false;

                if (ModuleContext.PortalSettings.UserId < 1)
                {
                    if (returnUrl.IndexOf("?returnurl=") != -1)
                    {
                        returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl="));
                    }
                    returnUrl = HttpUtility.UrlEncode(returnUrl);
                    returnUrl = Globals.LoginURL(returnUrl, true);
                    redirect  = true;
                }

                if (Tag.Trim().Length > 0)
                {
                    View.Model.SelectedTags = Tag + @", ";
                }

                var objRemoveNewUser = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.RemoveNewUser.ToString());
                if (UserScore.Score >= objRemoveNewUser.Value || ModuleContext.IsEditable)
                {
                    View.SaveEnabled(true);
                }
                else
                {
                    var objLastPost = Controller.GetUsersLastPost(ModuleContext.PortalSettings.UserId, ModuleContext.PortalId);
                    if (objLastPost != null)
                    {
                        View.SaveEnabled(objLastPost.CreatedDate <= DateTime.Now.AddMinutes(-1));
                    }
                    else
                    {
                        View.SaveEnabled(true);
                    }
                }

                View.Save += Save;
                View.Refresh();

                if (redirect)
                {
                    Response.Redirect(returnUrl, true);
                }
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        private void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                var returnUrl = HttpContext.Request.RawUrl;
                var redirect  = false;

                if (ModuleContext.PortalSettings.UserId < 1)
                {
                    if (returnUrl.IndexOf("?returnurl=") != -1)
                    {
                        returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl="));
                    }
                    returnUrl = HttpUtility.UrlEncode(returnUrl);
                    returnUrl = Globals.LoginURL(returnUrl, true);
                    redirect  = true;
                }

                var objTerm = (from t in Util.GetTermController().GetTermsByVocabulary(1) where t.Name.ToLower() == Tag.ToLower() select t).Single();

                if (objTerm != null)
                {
                    View.Model.SelectedTerm        = objTerm;
                    View.Model.SelectedTermHistory = Controller.GetTermHistory(ModuleContext.PortalId, objTerm.TermId);

                    var objRemoveNewUser = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.RemoveNewUser.ToString());
                    if (UserScore.Score >= objRemoveNewUser.Value || ModuleContext.IsEditable)
                    {
                        View.SaveEnabled(true);
                    }
                    else
                    {
                        View.SaveEnabled(false);
                    }

                    View.Save += Save;
                    View.Refresh();
                }
                else
                {
                    returnUrl = Globals.AccessDeniedURL("AccessDenied");
                    redirect  = true;
                }

                if (redirect)
                {
                    Response.Redirect(returnUrl, false);
                }
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This method checks to see if the currently logged in user has gained a privilege since the last time the page was loaded.
        /// </summary>
        /// <remarks>This should be run on every page load.</remarks>
        private void AwardMessaging()
        {
            if (ModContext.PortalSettings.UserId > 0)
            {
                if (UserScore.Message.Length > 0)
                {
                    int num;
                    var message = "";
                    var isNum   = int.TryParse(UserScore.Message, out num);

                    if (isNum)
                    {
                        var actionId         = Convert.ToInt32(UserScore.Message);
                        var usersAction      = (Constants.UserScoringActions)actionId;
                        var objScoringAction = UserScoringCollection.Single(s => s.Key == usersAction.ToString());

                        if (objScoringAction.Value > 0)
                        {
                            message = Localization.GetString("ReputationPoints", MyResourceFile);
                            var actionName = Localization.GetString(usersAction.ToString(), Constants.SharedResourceFileName);

                            message = message.Replace("{0}", objScoringAction.Value.ToString());
                            message = message.Replace("{1}", actionName);
                        }
                    }
                    else
                    {
                        message = Localization.GetString("NewPrivilege", MyResourceFile);
                        // we store the key in the message table
                        var objPriv  = PrivilegeCollection.Single(s => s.Key == UserScore.Message);
                        var privText = Localization.GetString(objPriv.Name, Constants.SharedResourceFileName);
                        var privDesc = Localization.GetString(objPriv.Description, Constants.SharedResourceFileName);
                        var privLink = Links.ViewPrivilege(ModContext, objPriv.Key);

                        if (objPriv.Key != Constants.Privileges.CreatePost.ToString())
                        {
                            var cntJournal = new Journal();
                            cntJournal.AddPrivilegeToJournal(objPriv, privText, privDesc, ModContext.PortalId, ModContext.TabId, ModContext.PortalSettings.UserId, privLink);
                        }

                        message = message.Replace("{0}", privText);
                        message = message.Replace("{1}", privLink);
                    }

                    litMessage.Text = message;

                    // clear the message from the db
                    Controller.ClearUserScoreMessage(UserScore.UserId, ModContext.PortalId);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks>There is a potential problem here. If a user attempts to view a term that is not used in the module (need to investigate).</remarks>
        protected void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                var objTermApprove =
                    ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymApproveCount.ToString());
                var objTermReject = ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymRejectCount.ToString());
                var objMaxSynonym = ThresholdCollection.Single(s => s.Key == Constants.OpThresholds.TermSynonymMaxCount.ToString());
                var synonymCount  = 0;

                var urlTerm =
                    (from t in Controller.GetTermsByContentType(ModuleContext.PortalId, ModuleContext.ModuleId, VocabularyId)
                     where t.Name.ToLower() == Tag.ToLower()
                     select t).SingleOrDefault();

                if (urlTerm != null)
                {
                    var portalSynonyms = Controller.GetTermSynonyms(ModuleContext.PortalId);
                    var activeSynonyms =
                        (from t in portalSynonyms
                         where t.MasterTermId == urlTerm.TermId && t.Score >= objTermApprove.Value
                         select t)
                        .ToList();
                    View.Model.SuggestedTermSynonyms =
                        (from t in portalSynonyms
                         where ((t.MasterTermId == urlTerm.TermId) && ((t.Score < objTermApprove.Value) && (t.Score > -objTermReject.Value))) select t).ToList();
                    View.Model.SelectedTerm = urlTerm;
                    var colTerms = new List <TermInfo>();

                    foreach (var objSynonym in activeSynonyms)
                    {
                        var synonym = objSynonym;

                        var termTerm = (from t in Controller.GetTermsByContentType(ModuleContext.PortalId, ModuleContext.ModuleId, VocabularyId)
                                        where t.TermId == synonym.RelatedTermId
                                        select t).SingleOrDefault();

                        if (termTerm == null)
                        {
                            // the term is not currently used within this module, go to core taxonomy store
                            var objTerm = (from t in Util.GetTermController().GetTermsByVocabulary(1)
                                           where t.TermId == synonym.RelatedTermId
                                           select t).SingleOrDefault();

                            var objTermInfo = new TermInfo
                            {
                                DayTermUsage   = 0,
                                TotalTermUsage = 0,
                                MonthTermUsage = 0,
                                WeekTermUsage  = 0,
                                TermId         = objTerm.TermId,
                                Name           = objTerm.Name,
                                Description    = objTerm.Description
                            };

                            colTerms.Add(objTermInfo);
                        }
                        else
                        {
                            // in taxonomy
                            colTerms.Add(termTerm);
                        }
                    }

                    View.Model.ActiveTermSynonyms = colTerms;
                    // we need to make sure we don't go above the max synonym count;
                    synonymCount = View.Model.ActiveTermSynonyms.Count + View.Model.SuggestedTermSynonyms.Count;
                }
                else
                {
                    // check to make sure this is a term in taxonomy (maybe it just wasn't associated with the content type)
                    var objTerm = (from t in Util.GetTermController().GetTermsByVocabulary(1)
                                   where t.Name.ToLower() == Tag.ToLower()
                                   select t).SingleOrDefault();
                    if (objTerm != null)
                    {
                        var objTermInfo = new TermInfo();

                        View.Model.ActiveTermSynonyms    = new List <TermInfo>();
                        View.Model.SuggestedTermSynonyms = new List <TermSynonymInfo>();
                        objTermInfo.DayTermUsage         = 0;
                        objTermInfo.TotalTermUsage       = 0;
                        objTermInfo.MonthTermUsage       = 0;
                        objTermInfo.WeekTermUsage        = 0;
                        objTermInfo.TermId      = objTerm.TermId;
                        objTermInfo.Name        = objTerm.Name;
                        objTermInfo.Description = objTerm.Description;
                        View.Model.SelectedTerm = objTermInfo;
                    }
                    else
                    {
                        Response.Redirect(Globals.AccessDeniedURL("AccessDenied"), false);
                    }
                }

                View.Model.SelectedView = ControlView;
                View.ItemDataBound     += ItemDataBound;
                View.AddSynonym        += AddSynonym;
                View.DeleteSynonym     += DeleteSynonym;

                View.ShowActiveSynonyms(View.Model.ActiveTermSynonyms.Count > 0);

                if (synonymCount < objMaxSynonym.Value)
                {
                    // check priv.
                    var objSuggestPriv = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.CreateTagSynonym.ToString());

                    if (objSuggestPriv != null)
                    {
                        //        var objMinSynonymCreateAnswer =
                        //colOpThresholds.Single(s => s.Key == Constants.OpThresholds.UserTermSynonymCreateMinAnswerCount.ToString());

                        if ((UserScore.Score >= objSuggestPriv.Value || ModuleContext.IsEditable))
                        {
                            View.ShowAddSynonym(true);
                            View.ShowSuggestedSynonyms(true);
                        }
                        else
                        {
                            View.ShowAddSynonym(false);
                            View.ShowSuggestedSynonyms(View.Model.SuggestedTermSynonyms.Count > 0);
                        }
                    }
                }
                else
                {
                    View.ShowAddSynonym(false);
                    View.ShowSuggestedSynonyms(View.Model.SuggestedTermSynonyms.Count > 0);
                }

                switch (View.Model.SelectedView.ToLower())
                {
                case "termsynonyms":
                    View.Model.PageTitle       = Localization.GetString("SynonymMetaTitle", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);
                    View.Model.PageDescription = Localization.GetString("SynonymMetaDescription", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);
                    break;

                default:
                    View.Model.PageTitle       = Localization.GetString("DetailMetaTitle", LocalResourceFile).Replace("[0]", View.Model.SelectedTerm.Name);;
                    View.Model.PageDescription = View.Model.SelectedTerm.Description;
                    break;
                }

                // this should only factor in privileges/moderation + any op thresholds

                View.Refresh();
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        private void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                if (!IsPostBack)
                {
                    Controller.IncreaseViewCount(QuestionID, ModuleContext.PortalId);
                    IsPostBack = true;
                }

                if (QuestionID < 1)
                {
                    Response.Redirect(Globals.AccessDeniedURL("AccessDenied"), false);
                    return;
                }
                var question = Controller.GetQuestion(QuestionID, ModuleContext.PortalId);

                if (question == null)
                {
                    Response.Redirect(Globals.AccessDeniedURL(Localization.GetString("InvalidPost", LocalResourceFile)), false);
                    return;
                }

                // NOTE: I may want to revisit this, to add link to specific postid.
                if (question.ParentId != 0)
                {
                    question = Controller.GetQuestion(question.ParentId, ModuleContext.PortalId);
                }

                var questionVotes = Controller.GetPostVotes(QuestionID);

                View.Model.Privileges    = PrivilegeCollection.ToList();
                View.Model.Question      = question;
                View.Model.QuestionVotes = questionVotes;
                View.ItemDataBound      += ItemDataBound;

                var allUserSubs = Controller.GetUserSubscriptions(ModuleContext.PortalId, ModuleContext.PortalSettings.UserId);
                var colSubs     = (from t in allUserSubs where t.PostId == QuestionID select t).SingleOrDefault();
                View.SubscribeButtonMode(colSubs != null);

                View.Model.NewPost = new PostInfo();

                var returnUrl = HttpContext.Request.RawUrl;
                if (ModuleContext.PortalSettings.UserId < 1)
                {
                    if (returnUrl.IndexOf("?returnurl=") != -1)
                    {
                        returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl="));
                    }
                    returnUrl = HttpUtility.UrlEncode(returnUrl);
                    returnUrl = Globals.LoginURL(returnUrl, true);
                }

                var objRemoveNewUser = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.RemoveNewUser.ToString());
                if (question.CreatedUserId == ModuleContext.PortalSettings.UserId)
                {
                    // we would only leave false if removing ability for question authors to answer their own questions (would need to update SaveEnabled method in questions.ascx.cs)
                    if ((UserScore.Score >= objRemoveNewUser.Value) || ModuleContext.IsEditable)
                    {
                        View.SaveEnabled(true);
                    }
                    else
                    {
                        View.SaveEnabled(false);
                    }
                }
                else
                {
                    if ((UserScore.Score >= objRemoveNewUser.Value) || ModuleContext.IsEditable)
                    {
                        View.SaveEnabled(true);
                    }
                    else
                    {
                        var objLastPost = Controller.GetUsersLastPost(ModuleContext.PortalSettings.UserId, ModuleContext.PortalId);
                        if (objLastPost != null)
                        {
                            View.SaveEnabled(objLastPost.CreatedDate <= DateTime.Now.AddMinutes(-1));
                        }
                        else
                        {
                            View.SaveEnabled(true);
                        }
                    }
                }

                View.Model.ColAnswers = BindAnswers(0);

                if (View.Model.ColAnswers.Count() >= PageSize)
                {
                    View.ShowAnswerArea(false);
                }
                else
                {
                    var colUserAnswers = (from t in View.Model.ColAnswers where t.CreatedUserId == ModuleContext.PortalSettings.UserId select t);
                    View.ShowAnswerArea(colUserAnswers.Count() <= 0);
                }

                View.Model.LoginUrl = returnUrl;
                View.Model.SortBy   = Sort;

                var objScore = Controller.GetUserScore(question.CreatedUserId, ModuleContext.PortalId) ??
                               new UserScoreInfo {
                    Score = 0
                };

                View.Model.QuestionAuthorScore = objScore.Score;

                View.Model.QuestionEditedUserScore = question.CreatedUserId == question.LastModifiedUserId ? View.Model.QuestionAuthorScore : Controller.GetUserScore(question.LastModifiedUserId, ModuleContext.PortalId).Score;

                if (ModuleContext.Settings.ContainsKey(Constants.SettingsFacebookAppId))
                {
                    if (Convert.ToString(ModuleContext.Settings[Constants.SettingsFacebookAppId]).Length > 0)
                    {
                        View.Model.FacebookAppId = Convert.ToString(ModuleContext.Settings[Constants.SettingsFacebookAppId]);
                    }
                }

                View.Model.EnablePlusOne  = ModuleContext.Settings.ContainsKey(Constants.SettingsEnablePlusOne) && Convert.ToBoolean(ModuleContext.Settings[Constants.SettingsEnablePlusOne]);
                View.Model.EnableTwitter  = ModuleContext.Settings.ContainsKey(Constants.SettingsEnableTwitter) && Convert.ToBoolean(ModuleContext.Settings[Constants.SettingsEnableTwitter]);
                View.Model.EnableLinkedIn = ModuleContext.Settings.ContainsKey(Constants.SettingsEnableLinkedIn) && Convert.ToBoolean(ModuleContext.Settings[Constants.SettingsEnableLinkedIn]);

                View.Save              += Save;
                View.Subscribe         += Subscribe;
                View.FlagPost          += FlagPost;
                View.DeletePost        += DeletePost;
                View.AcceptAnswer      += AcceptAnswer;
                View.PagerChanged      += PagerChanged;
                View.QuestionDataBound += QuestionDataBound;
                View.Refresh();
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        protected void ViewLoad(object sender, EventArgs eventArgs)
        {
            try
            {
                var returnUrl = HttpContext.Request.RawUrl;
                var redirect  = false;

                if (ModuleContext.PortalSettings.UserId < 1)
                {
                    if (returnUrl.IndexOf("?returnurl=") != -1)
                    {
                        returnUrl = returnUrl.Substring(0, returnUrl.IndexOf("?returnurl="));
                    }
                    returnUrl = HttpUtility.UrlEncode(returnUrl);
                    returnUrl = Globals.LoginURL(returnUrl, true);
                    redirect  = true;
                }

                if (PostId != Null.NullInteger)
                {
                    var objPost = Controller.GetPost(PostId, ModuleContext.PortalId);

                    if (objPost != null)
                    {
                        View.Model.SelectedPost = objPost;
                        View.ShowAuditControl(true);

                        if (objPost.ParentId > 0)
                        {
                            View.ShowQuestionSpecific(false);
                            var objQuestion = Controller.GetPost(objPost.ParentId, ModuleContext.PortalId);
                            View.Model.QuestionUrl = Links.ViewQuestion(objQuestion.PostId, objQuestion.Title, ModuleContext.PortalSettings.ActiveTab, ModuleContext.PortalSettings);
                        }
                        else
                        {
                            View.ShowQuestionSpecific(true);
                            View.Model.QuestionUrl = Links.ViewQuestion(objPost.PostId, objPost.Title, ModuleContext.PortalSettings.ActiveTab, ModuleContext.PortalSettings);
                        }

                        // change from just iseditable?
                        View.ShowDeleteButton(ModuleContext.IsEditable);

                        if (objPost.ParentId > 0)
                        {
                            View.ShowTagEdits(false);
                        }
                        else
                        {
                            // if the user is the original question author (new user status controls the 'edit' button display)
                            var objEdit = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.EditQuestionsAndAnswers.ToString());

                            if (View.Model.SelectedPost.CreatedUserId == ModuleContext.PortalSettings.UserId)
                            {
                                View.ShowTagEdits(true);
                                View.PermitPostEdit(true, (objPost.ParentId < 1));
                            }
                            else
                            {
                                var objRetag = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.RetagQuestion.ToString());
                                if (UserScore.Score >= objRetag.Value || ModuleContext.IsEditable)
                                {
                                    View.ShowTagEdits(true);
                                    View.PermitPostEdit(((UserScore.Score >= objEdit.Value) || ModuleContext.IsEditable), (objPost.ParentId < 1));
                                }
                                else
                                {
                                    View.ShowTagEdits(false);
                                    View.PermitPostEdit(((UserScore.Score >= objEdit.Value) || ModuleContext.IsEditable), (objPost.ParentId < 1));
                                }
                            }

                            View.Model.SelectedTags = Controller.GetTermsByContentItem(objPost.ContentItemId, VocabularyId);
                        }
                    }
                    else
                    {
                        returnUrl = Globals.AccessDeniedURL("AccessDenied");
                        redirect  = true;
                    }
                }
                else
                {
                    returnUrl = Globals.AccessDeniedURL("AccessDenied");
                    redirect  = true;
                }

                if (redirect)
                {
                    Response.Redirect(returnUrl, false);
                    return;
                }

                var objRemoveNewUser = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.RemoveNewUser.ToString());
                if (UserScore.Score >= objRemoveNewUser.Value || ModuleContext.IsEditable)
                {
                    View.SaveEnabled(true);
                }
                else
                {
                    var objLastPost = Controller.GetUsersLastPost(ModuleContext.PortalSettings.UserId, ModuleContext.PortalId);
                    View.SaveEnabled(objLastPost.CreatedDate <= DateTime.Now.AddMinutes(-1));
                }

                View.Delete += Delete;
                View.Save   += Save;
                View.Refresh();
            }
            catch (Exception exc)
            {
                ProcessModuleLoadException(exc);
            }
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        private void SetVoteOptions()
        {
            if (ModContext != null)
            {
                _voteUp.Text   = Services.Localization.Localization.GetString("VoteUp", SharedResourceFile);
                _voteDown.Text = Services.Localization.Localization.GetString("VoteDown", SharedResourceFile);

                VoteInfo objUserVote;
                switch (VotingMode)
                {
                case Constants.VoteMode.Synonym:
                    var col = Controller.GetTermSynonymVotes(RelatedTermId, ModContext.PortalId);
                    objUserVote = (from t in col where ((t.CreatedByUserId == ModContext.PortalSettings.UserId) && ((t.VoteTypeId == (int)Constants.VoteType.VoteSynonymUp) || (t.VoteTypeId == (int)Constants.VoteType.VoteSynonymDown))) select t).SingleOrDefault();
                    break;

                //case Constants.VoteMode.Term:
                //    objUserVote = (from t in Controller.GetPostVotes(CurrentPostID) where ((t.CreatedByUserId == ModContext.PortalSettings.UserId) && (t.VoteTypeId == (int)Constants.VoteType.FlagPost)) select t).SingleOrDefault();
                //break;
                default:                         // question/answer
                    var colPostVotes = Controller.GetPostVotes(CurrentPostID);
                    objUserVote = (from t in colPostVotes where ((t.CreatedByUserId == ModContext.PortalSettings.UserId) && ((t.VoteTypeId == (int)Constants.VoteType.VoteUpPost) || (t.VoteTypeId == (int)Constants.VoteType.VoteDownPost))) select t).SingleOrDefault();
                    break;
                }

                if (objUserVote != null)
                {
                    switch (objUserVote.VoteTypeId)
                    {
                    case (int)Constants.VoteType.VoteDownPost:
                        _voteUp.ToolTip    = Services.Localization.Localization.GetString("VoteUpTitle" + VotingMode, SharedResourceFile);
                        _voteUp.Enabled    = false;
                        _voteDown.ToolTip  = Services.Localization.Localization.GetString("VoteDownSelectedTitle" + VotingMode, SharedResourceFile);
                        _voteDown.CssClass = "selected";
                        break;

                    case (int)Constants.VoteType.VoteSynonymDown:
                        _voteUp.ToolTip    = Services.Localization.Localization.GetString("VoteUpTitle" + VotingMode, SharedResourceFile);
                        _voteUp.Enabled    = false;
                        _voteDown.ToolTip  = Services.Localization.Localization.GetString("VoteDownSelectedTitle" + VotingMode, SharedResourceFile);
                        _voteDown.CssClass = "selected";
                        break;

                    case (int)Constants.VoteType.VoteUpPost:
                        _voteDown.ToolTip = Services.Localization.Localization.GetString("VoteDownTitle" + VotingMode, SharedResourceFile);
                        _voteDown.Enabled = false;
                        _voteUp.ToolTip   = Services.Localization.Localization.GetString("VoteUpSelectedTitle" + VotingMode, SharedResourceFile);
                        _voteUp.CssClass  = "selected";
                        break;

                    case (int)Constants.VoteType.VoteSynonymUp:
                        _voteDown.ToolTip = Services.Localization.Localization.GetString("VoteDownTitle" + VotingMode, SharedResourceFile);
                        _voteDown.Enabled = false;
                        _voteUp.ToolTip   = Services.Localization.Localization.GetString("VoteUpSelectedTitle" + VotingMode, SharedResourceFile);
                        _voteUp.CssClass  = "selected";
                        break;
                    }
                }
                else
                {
                    _voteUp.ToolTip   = Services.Localization.Localization.GetString("VoteUpTitle" + VotingMode, SharedResourceFile);
                    _voteDown.ToolTip = Services.Localization.Localization.GetString("VoteDownTitle" + VotingMode, SharedResourceFile);

                    var privVoteUp   = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.VoteUp.ToString());
                    var privVoteDown = PrivilegeCollection.Single(s => s.Key == Constants.Privileges.VoteDown.ToString());

                    switch (VotingMode)
                    {
                    case Constants.VoteMode.Synonym:
                        var colPortalSynonyms = Controller.GetTermSynonyms(ModContext.PortalId);
                        var objSynonym        = (from t in colPortalSynonyms where ((t.RelatedTermId == RelatedTermId) && (t.PortalId == ModContext.PortalId) && (t.MasterTermId == TermId)) select t).SingleOrDefault();

                        if (objSynonym.CreatedByUserId == ModContext.PortalSettings.UserId)
                        {
                            _voteUp.Enabled   = false;
                            _voteDown.Enabled = false;
                            _voteUp.ToolTip   = Services.Localization.Localization.GetString("VoteOwnSynonym", SharedResourceFile);
                            _voteDown.ToolTip = Services.Localization.Localization.GetString("VoteOwnSynonym", SharedResourceFile);
                        }
                        else
                        {
                            _voteUp.Enabled   = ((UserScore.Score >= privVoteUp.Value) || (ModContext.IsEditable));
                            _voteDown.Enabled = ((UserScore.Score >= privVoteDown.Value) || (ModContext.IsEditable));
                        }
                        break;

                    //case Constants.VoteMode.Term:
                    //    // currently not supported
                    //        _voteUp.Enabled = ((UserScore >= privVoteUp.Value) || (ModContext.IsEditable));
                    //        _voteDown.Enabled = ((UserScore >= privVoteDown.Value) || (ModContext.IsEditable));
                    //    break;
                    default:                              // question/answer
                        var objPost = Controller.GetPost(CurrentPostID, ModContext.PortalId);

                        if (objPost != null)
                        {
                            if (objPost.CreatedUserId == ModContext.PortalSettings.UserId)
                            {
                                _voteUp.Enabled   = false;
                                _voteDown.Enabled = false;
                                _voteUp.ToolTip   = Services.Localization.Localization.GetString("VoteOwnPost", SharedResourceFile);
                                _voteDown.ToolTip = Services.Localization.Localization.GetString("VoteOwnPost", SharedResourceFile);
                            }
                            else
                            {
                                if ((UserScore.Score >= privVoteUp.Value) || (ModContext.IsEditable))
                                {
                                    _voteUp.Enabled = true;
                                }
                                else
                                {
                                    _voteUp.Enabled = false;
                                    _voteUp.ToolTip = Services.Localization.Localization.GetString("NoUpVotePrivs", SharedResourceFile);
                                }
                                if ((UserScore.Score >= privVoteDown.Value) || (ModContext.IsEditable))
                                {
                                    _voteDown.Enabled = true;
                                }
                                else
                                {
                                    _voteDown.Enabled = false;
                                    _voteDown.ToolTip = Services.Localization.Localization.GetString("NoDownVotePrivs", SharedResourceFile);
                                }
                            }
                        }

                        break;
                    }
                }
            }
        }