Пример #1
0
        void AccountForumRanks_Add(object sender, ModuleModeEventArgs e)
        {
            SetTemplate("account_forum_rank_edit");

            /* Title TextBox */
            TextBox titleTextBox = new TextBox("rank-title");

            /* Minimum Posts (to attain rank) TextBox */
            TextBox minPostsTextBox = new TextBox("min-posts");

            /* Special Rank TextBox */
            CheckBox specialCheckBox = new CheckBox("special");

            if (e.Mode == "edit")
            {
                template.Parse("EDIT", "TRUE");
                long id = core.Functions.RequestLong("id", 0);

                if (id == 0)
                {
                    core.Functions.Generate404();
                    return;
                }

                try
                {
                    ForumMemberRank fmr = new ForumMemberRank(core, id);

                    titleTextBox.Value = fmr.RankTitleText;
                    minPostsTextBox.Value = fmr.RankPosts.ToString();
                    specialCheckBox.IsChecked = fmr.RankSpecial;

                    template.Parse("S_ID", fmr.RankId.ToString());
                }
                catch (InvalidForumMemberRankException)
                {
                    core.Functions.Generate404();
                    return;
                }
            }

            /* Parse the form fields */
            template.Parse("S_TITLE", titleTextBox);
            template.Parse("S_MINIMUM_POSTS", minPostsTextBox);
            template.Parse("S_SPECIAL", specialCheckBox);
        }
Пример #2
0
        void AccountForumRanks_Add_Save(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            string title = core.Http.Form["rank-title"];
            long rankId = core.Functions.FormLong("id", 0);
            int posts = core.Functions.FormInt("min-posts", 0);
            bool special = (core.Http.Form["special"] != null);
            int colour = -1;

            if (rankId > 0)
            {
                // Edit
                ForumMemberRank theRank = new ForumMemberRank(core, rankId);
                theRank.RankTitleText = title;
                theRank.RankPosts = posts;
                theRank.RankSpecial = special;
                theRank.RankColourRaw = colour;

                theRank.Update();

                SetRedirectUri(BuildUri("ranks"));
                core.Display.ShowMessage("New Updated", "The rank has been updated.");
            }
            else
            {
                // New Rank
                ForumMemberRank newRank = ForumMemberRank.Create(core, Owner, title, posts, special, colour);
                SetRedirectUri(BuildUri("ranks"));
                core.Display.ShowMessage("New Rank Created", "The new rank has been created.");
            }
        }
Пример #3
0
        void AccountForumRanks_Delete(object sender, EventArgs e)
        {
            AuthoriseRequestSid();

            long rankId = core.Functions.RequestLong("id", 0);

            if (rankId > 0)
            {
                ForumMemberRank theRank = new ForumMemberRank(core, rankId);

                switch (core.Display.GetConfirmBoxResult())
                {
                    case ConfirmBoxResult.None:
                        Dictionary<string, string> hiddenFieldList = GetModeHiddenFieldList();
                        hiddenFieldList.Add("id", theRank.Id.ToString());

                        core.Display.ShowConfirmBox(HttpUtility.HtmlEncode(core.Hyperlink.AppendSid(Owner.AccountUriStub, true)),
                            "Delete the rank?",
                            "Do you really want to delete this rank?",
                            hiddenFieldList);

                        return;
                    case ConfirmBoxResult.Yes:
                        // Delete the rank
                        theRank.Delete();

                        SetRedirectUri(BuildUri());
                        core.Display.ShowMessage("Forum rank deleted", "You have deleted this forum rank from the database.");
                        break;
                    case ConfirmBoxResult.No:
                        // don't do anything
                        SetRedirectUri(BuildUri());
                        core.Display.ShowMessage("Delete cancelled", "The forum rank has not been deleted from the database.");
                        break;
                }
            }
        }
Пример #4
0
        public static Dictionary<long, ForumMemberRank> GetRanks(Core core, Primitive forumOwner)
        {
            Dictionary<long, ForumMemberRank> ranks = new Dictionary<long, ForumMemberRank>();

            SelectQuery sQuery = ForumMemberRank.GetSelectQueryStub(core, typeof(ForumMemberRank));
            sQuery.AddCondition("rank_owner_id", forumOwner.Id);
            sQuery.AddCondition("rank_owner_type_id", forumOwner.TypeId);

            System.Data.Common.DbDataReader ranksReader = core.Db.ReaderQuery(sQuery);

            while (ranksReader.Read())
            {
                ForumMemberRank fmr = new ForumMemberRank(core, ranksReader);
                ranks.Add(fmr.Id, fmr);
            }

            ranksReader.Close();
            ranksReader.Dispose();

            return ranks;
        }