Beispiel #1
0
        private void showVerificationForm(ApplicationEntry ae, string oauthToken, string sessionId)
        {
            TextBox verifyTextBox = new TextBox("verify");

            HiddenField oauthTokenHiddenField = new HiddenField("oauth_token");
            oauthTokenHiddenField.Value = oauthToken;

            HiddenField modeHiddenField = new HiddenField("mode");
            modeHiddenField.Value = "verify";

            SubmitButton submitButton = new SubmitButton("submit", core.Prose.GetString("AUTHORISE"));
            Button cancelButton = new Button("cancel", core.Prose.GetString("CANCEL"), "cancel");
            cancelButton.Script.OnClick = "window.external.notify('cancel'); return false;";

            template.SetTemplate("oauth_authorize.html");
            template.Parse("U_POST", core.Hyperlink.AppendSid("/oauth/approve", true, sessionId));
            template.Parse("VERIFY", "TRUE");
            template.Parse("AUTHORISE_APPLICATION", string.Format(core.Prose.GetString("AUTHORISE_APPLICATION"), ae.Title));
            template.Parse("APPLICATION_ICON", ae.Icon);
            template.Parse("S_VERIFY", verifyTextBox);
            template.Parse("S_OAUTH_TOKEN", oauthTokenHiddenField);
            template.Parse("S_MODE", modeHiddenField);
            template.Parse("S_SUBMIT", submitButton);
            template.Parse("S_CANCEL", cancelButton);

            EndResponse();
        }
Beispiel #2
0
        void McpMain_Show(object sender, EventArgs e)
        {
            //AuthoriseRequestSid();
            SetTemplate("mcp_main");

            /* */
            SubmitButton submitButton = new SubmitButton("submit", "Submit");

            /* */
            SelectBox actionsSelectBox = new SelectBox("mode");

            long forumId = core.Functions.RequestLong("f", 0);
            Forum thisForum = null;
            ForumSettings settings = null;

            try
            {
                settings = new ForumSettings(core, Owner);
                if (forumId > 0)
                {
                    thisForum = new Forum(core, settings, forumId);
                }
                else
                {
                    thisForum = new Forum(core, settings);
                }
            }
            catch (InvalidForumSettingsException)
            {
                core.Functions.Generate404();
            }
            catch (InvalidForumException)
            {
                core.Functions.Generate404();
            }

            if (thisForum.Access.Can("LOCK_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("lock", "Lock"));
                actionsSelectBox.Add(new SelectBoxItem("unlock", "Unlock"));
            }
            if (thisForum.Access.Can("MOVE_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("move", "Move"));
            }
            if (thisForum.Access.Can("DELETE_TOPICS"))
            {
                actionsSelectBox.Add(new SelectBoxItem("delete", "Delete"));
            }

            List<ForumTopic> announcements = thisForum.GetAnnouncements();
            List<ForumTopic> topics = thisForum.GetTopics(core.TopLevelPageNumber, settings.TopicsPerPage);
            List<ForumTopic> allTopics = new List<ForumTopic>();
            allTopics.AddRange(announcements);
            allTopics.AddRange(topics);

            Dictionary<long, TopicPost> topicLastPosts;

            topicLastPosts = TopicPost.GetTopicLastPosts(core, allTopics);

            foreach (ForumTopic topic in allTopics)
            {
                core.LoadUserProfile(topic.PosterId);
            }

            foreach (ForumTopic topic in allTopics)
            {
                VariableCollection topicVariableCollection = template.CreateChild("topic_list");

                CheckBox checkBox = new CheckBox("checkbox[" + topic.Id.ToString() + "]");

                topicVariableCollection.Parse("TITLE", topic.Title);
                topicVariableCollection.Parse("URI", topic.Uri);
                topicVariableCollection.Parse("VIEWS", topic.Views.ToString());
                topicVariableCollection.Parse("REPLIES", topic.Posts.ToString());
                topicVariableCollection.Parse("DATE", core.Tz.DateTimeToString(topic.GetCreatedDate(core.Tz)));
                topicVariableCollection.Parse("USERNAME", core.PrimitiveCache[topic.PosterId].DisplayName);
                topicVariableCollection.Parse("U_POSTER", core.PrimitiveCache[topic.PosterId].Uri);
                topicVariableCollection.Parse("S_CHECK", checkBox);

                if (topicLastPosts.ContainsKey(topic.LastPostId))
                {
                    core.Display.ParseBbcode(topicVariableCollection, "LAST_POST", string.Format("[iurl={0}]{1}[/iurl]\n{2}",
                        topicLastPosts[topic.LastPostId].Uri, Functions.TrimStringToWord(topicLastPosts[topic.LastPostId].Title, 20), core.Tz.DateTimeToString(topicLastPosts[topic.LastPostId].GetCreatedDate(core.Tz))));
                }
                else
                {
                    topicVariableCollection.Parse("LAST_POST", "No posts");
                }

                switch (topic.Status)
                {
                    case TopicStates.Normal:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_NORMAL_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_NORMAL_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_NORMAL_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_NORMAL_UNREAD_UNLOCKED", "TRUE");
                            }
                        }
                        break;
                    case TopicStates.Sticky:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_STICKY_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_STICKY_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_STICKY_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_STICKY_UNREAD_UNLOCKED", "TRUE");
                            }
                        }

                        break;
                    case TopicStates.Announcement:
                    case TopicStates.Global:
                        if (topic.IsRead)
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_READ_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_READ_UNLOCKED", "TRUE");
                            }
                        }
                        else
                        {
                            if (topic.IsLocked)
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_UNREAD_LOCKED", "TRUE");
                            }
                            else
                            {
                                topicVariableCollection.Parse("IS_ANNOUNCEMENT_UNREAD_UNLOCKED", "TRUE");
                            }
                        }

                        break;
                }
            }

            template.Parse("TOPICS", allTopics.Count.ToString());
            template.Parse("S_ACTIONS", actionsSelectBox);
            template.Parse("S_SUBMIT", submitButton);
        }
Beispiel #3
0
        private void OAuthAuthorize(bool fail)
        {
            bool forceLogin = (core.Http.Query["force_login"] == "true");
            string oauthToken = core.Http["oauth_token"];

            try
            {
                OAuthToken token = new OAuthToken(core, oauthToken);
                ApplicationEntry ae = token.Application;

                TextBox usernameTextBox = new TextBox("username");
                TextBox passwordTextBox = new TextBox("password", InputType.Password);

                HiddenField oauthTokenHiddenField = new HiddenField("oauth_token");
                oauthTokenHiddenField.Value = oauthToken;

                SubmitButton submitButton = new SubmitButton("submit", core.Prose.GetString("AUTHORISE"));
                Button cancelButton = new Button("cancel", core.Prose.GetString("CANCEL"), "cancel");
                cancelButton.Script.OnClick = "window.external.notify('cancel'); return false;";

                if (token.TokenExpired)
                {
                    core.Functions.Generate403();
                    EndResponse();
                    return;
                }

                template.SetTemplate("oauth_authorize.html");

                template.Parse("U_POST", core.Hyperlink.AppendSid("/oauth/approve", true));
                template.Parse("REQUIRE_LOGIN", ((forceLogin || (!core.Session.SignedIn)) ? "TRUE" : "FALSE"));
                template.Parse("AUTHORISE_APPLICATION", string.Format(core.Prose.GetString("AUTHORISE_APPLICATION"), ae.Title));
                template.Parse("APPLICATION_ICON", ae.Icon);
                template.Parse("S_USERNAME", usernameTextBox);
                template.Parse("S_PASSWORD", passwordTextBox);
                template.Parse("S_OAUTH_TOKEN", oauthTokenHiddenField);
                template.Parse("S_SUBMIT", submitButton);
                template.Parse("S_CANCEL", cancelButton);
            }
            catch (InvalidOAuthTokenException)
            {
                core.Functions.Generate403();
            }
            catch (InvalidApplicationException)
            {
                core.Functions.Generate403();
            }

            EndResponse();
        }