/// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //if not an editor or scout then return an error
            if (InputContext.ViewingUser.UserID == 0 || !(InputContext.ViewingUser.IsEditor || InputContext.ViewingUser.IsScout))
            {
                AddErrorXml("NOT-EDITOR", "You cannot allocate recommended entries to sub editors unless you are logged in as an Editor.", RootElement);
                return;
            }

            ArticleList recommendations = new ArticleList(InputContext);
            recommendations.CreateUndecidedRecommendationsList(0, 50);

            RootElement.RemoveAll();
            XmlElement undecidedRecommendations = AddElementTag(RootElement, "UNDECIDED-RECOMMENDATIONS");
            AddInside(undecidedRecommendations, recommendations);  
        }
Exemple #2
0
        public void TestGetUndecidedRecommendationsArticleListTest()
        {
            Console.WriteLine("Before ArticleListTests - TestGetUndecidedRecommendationsArticleListTest");
            //Create the mocked inputcontext
            Mockery mock = new Mockery();

            // Create the app context for the poll to run in
            string rootPath = TestConfig.GetConfig().GetRipleyServerPath();
            BBC.Dna.AppContext.OnDnaStartup(rootPath);

            // Create the stored procedure reader for the CommentList object
            IInputContext context = DnaMockery.CreateDatabaseInputContext();

            //XmlDocument siteconfig = new XmlDocument();
            //siteconfig.LoadXml("<SITECONFIG />");

            ISite site = mock.NewMock<ISite>();
            //Stub.On(site).GetProperty("SiteConfig").Will(Return.Value(siteconfig.FirstChild));
            Stub.On(site).GetProperty("SiteID").Will(Return.Value(1));

            User user = new User(context);
            Stub.On(context).GetProperty("ViewingUser").Will(Return.Value(user));
            Stub.On(context).GetProperty("CurrentSite").Will(Return.Value(site));

            SetupArticles(context);

            using (IDnaDataReader reader = context.CreateDnaDataReader("FetchUndecidedRecommendations"))
            {
                Stub.On(context).Method("CreateDnaDataReader").With("FetchUndecidedRecommendations").Will(Return.Value(reader));

                // Create a new ArtiocleList object and get the list of undecided articles
                ArticleList testArticleList = new ArticleList(context);
                testArticleList.CreateUndecidedRecommendationsList(0, 50);

                XmlElement xml = testArticleList.RootElement;
                Assert.IsTrue(xml.SelectSingleNode("ARTICLE-LIST") != null, "The xml is not generated correctly!!!");

                Assert.IsTrue(xml.SelectSingleNode("ARTICLE-LIST[@TYPE='UNDECIDED-RECOMMENDATIONS']") != null, "The xml is not generated correctly (TYPE != UNDECIDED-RECOMMENDATIONS)!!!");

                DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
                validator.Validate();

            }
            Console.WriteLine("After ArticleListTests - TestGetUndecidedRecommendationsArticleListTest");
        }
Exemple #3
0
        /// <summary>
        /// Implements generating the XML for the More Pages page
        /// </summary>
        /// <param name="skip">Number of articles to skip</param>
        /// <param name="show">Number of articles to show</param>
        /// <param name="userID">User ID of the page to return</param>
        /// <param name="type">type is either 1 (approved) 2 (normal) 3 (cancelled) or 4 (normal and approved)</param>
        /// <param name="guideType">See if we've been given a specified article type to search for</param>
        private void TryCreateMorePagesXML(int skip, int show, int userID, int type, int guideType)
        {
            //Clean any existing XML.
            RootElement.RemoveAll();

            if ((type == (int) ArticleList.ArticleListType.ARTICLELISTTYPE_CANCELLED) && ((InputContext.ViewingUser.UserLoggedIn == false) || (InputContext.ViewingUser.UserID != userID)))
	        {
		        throw new DnaException("MorePages - TryCreateMorePagesXML - You cannot view the cancelled entries of another user");
	        }

            _pageOwnerElement = AddElementTag(RootElement, "PAGE-OWNER");
            User pageOwner = new User(InputContext);
            pageOwner.CreateUser(userID);
            AddInside(_pageOwnerElement, pageOwner);

            XmlElement articles = AddElementTag(RootElement, "ARTICLES");
            AddAttribute(articles, "USERID", userID);
            AddAttribute(articles, "WHICHSET", type);

            ArticleList articleList = new ArticleList(InputContext);

            if (type == (int) ArticleList.ArticleListType.ARTICLELISTTYPE_APPROVED)
		    {
			    articleList.CreateRecentApprovedArticlesList(userID, 0, skip, show, guideType);
		    }
            else if (type == (int) ArticleList.ArticleListType.ARTICLELISTTYPE_NORMAL)
		    {
                articleList.CreateRecentArticleList(userID, 0, skip, show, guideType);
		    }
		    else if (type == (int) ArticleList.ArticleListType.ARTICLELISTTYPE_NORMALANDAPPROVED)
		    {
                articleList.CreateRecentNormalAndApprovedArticlesList(userID, 0, skip, show, guideType);
		    }
		    else
		    {
                articleList.CreateCancelledArticlesList(userID, 0, skip, show, guideType);
		    }
            AddInside(articles, articleList);

            AddInside(articles, pageOwner);

        }
        /// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //if not an editor then return an error
            if (InputContext.ViewingUser == null || !InputContext.ViewingUser.IsEditor)
            {
                AddErrorXml("NOT-EDITOR", "You cannot allocate recommended entries to sub editors unless you are logged in as an Editor.", RootElement);
                return;
            }

            string sCommand = InputContext.GetParamStringOrEmpty("Command","Gets command switch string");
            if (sCommand == String.Empty)
                sCommand = "View";

            RootElement.RemoveAll();
            XmlElement subAllFormXML = AddElementTag(RootElement, "SUB-ALLOCATION-FORM");
           

            switch(sCommand.ToUpper())
            {
                case "VIEW":
                    break;// do nothing for simple view requests

                case "NOTIFYSUBS"://if this is a notification request then send the notification emails
                    int totalSent=0;
                    SendNotificationEmails(ref totalSent);
                    break;

                default:
                    ProcessAllocationSubmission(sCommand);
                    
                    break;//TODO: else process any submission of allocated entries

            }

            
            // after doing any processing requests get all the data for the form
		    // now tell the form to get the other data it needs
            // - subs list, accepted recommendations list, and allocated recommendations list
            SubAllocationForm subAllForm = new SubAllocationForm(InputContext);
            subAllForm.InsertSubEditorList();
            ImportAndAppend(subAllForm.RootElement.FirstChild, "/DNAROOT/SUB-ALLOCATION-FORM");

           
            //get unallocation recommendation list
            ArticleList articleList = new ArticleList(InputContext);
            articleList.CreateUnallocatedRecommendationsList();
            AddElementTag(subAllFormXML, "UNALLOCATED-RECOMMENDATIONS");
            ImportAndAppend(articleList.RootElement.FirstChild, "/DNAROOT/SUB-ALLOCATION-FORM/UNALLOCATED-RECOMMENDATIONS");

            //get skip and show amounts
            int skip = InputContext.GetParamIntOrZero("skip","Amount of items in result set to skip");
            int show = InputContext.GetParamIntOrZero("show", "Amount of items in result set to show");
            if (show <= 0)
                show = 20;
            //get allocated recommendation list
            articleList.CreateAllocatedRecommendationsList(show, skip);
            AddElementTag(subAllFormXML, "ALLOCATED-RECOMMENDATIONS");
            ImportAndAppend(articleList.RootElement.FirstChild, "/DNAROOT/SUB-ALLOCATION-FORM/ALLOCATED-RECOMMENDATIONS");


            //insert the notification status
            subAllForm.InsertNotificationStatus();
            ImportAndAppend(subAllForm.RootElement.FirstChild, "/DNAROOT/SUB-ALLOCATION-FORM");

        }
Exemple #5
0
 private bool CreateRecentArticles(IUser user, ref ArticleList recentArticles)
 {
     return recentArticles.CreateRecentArticleList(user.UserID, InputContext.CurrentSite.SiteID, 0, 100, 0);
 }
Exemple #6
0
        /// <summary>
        /// Calls the individual objects to generate the User Page XML
        /// </summary>
        /// <param name="userPageParameters"></param>
        private void GenerateUserPageXml(UserPageParameters userPageParameters)
        {
            // all the XML objects we need to build the page
            if (userPageParameters.IsRegistering)
            {
                //TODO REGISTER USER STUFF
            }
            else
            {
	            // introducing the players - these will point to the BBC.DNA Component objects required
	            // to construct a user page
                PageUI          pageInterface = new PageUI(userPageParameters.UserID);
	            User			owner = new User(InputContext);
	            GuideEntry		masthead = null;
	            Forum			pageForum = new Forum(InputContext);
	            Forum			journal = new Forum(InputContext);
	            PostList		recentPosts = new PostList(InputContext);
	            ArticleList	    recentArticles = new ArticleList(InputContext);
	            ArticleList	    recentApprovals = new ArticleList(InputContext);
	            CommentsList	recentComments = new CommentsList(InputContext);
                ArticleSubscriptionsList subscribedUsersArticles = new ArticleSubscriptionsList(InputContext);

                // get or create all the appropriate xml objects
                bool gotMasthead = false;
                bool gotPageForum = false;
                bool gotJournal = false;
                bool gotRecentPosts = false;
                bool gotRecentArticles = false;
                bool gotRecentApprovals = false;
                bool gotRecentComments = false;
                bool gotSubscribedToUsersRecentArticles = false;

                bool gotOwner = CreatePageOwner(userPageParameters.UserID, ref owner);

		        if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntry")      || userPageParameters.IncludeUsersGuideEntries ||
                    InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums)
		        {
                    gotMasthead = CreatePageArticle(userPageParameters.UserID, owner, out masthead);

                    if (gotMasthead && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums))
			        {
				        // GuideEntry forum can not be returned if GuideEntry is not being returned.
                        gotPageForum = CreatePageForum(masthead, ref pageForum);
			        }
		        }

                bool gotInterface = CreateUserInterface(owner, masthead, ref pageInterface);
        		
		        // Only display other information if the page has a valid masthead
		        if (gotMasthead)
		        {
                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeJournal") || userPageParameters.IncludeJournals)
			        {
                        gotJournal = CreateJournal(owner, ref journal);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentPosts") || userPageParameters.IncludeRecentPosts)
			        {
                        gotRecentPosts = CreateRecentPosts(owner, ref recentPosts);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentComments") || userPageParameters.IncludeRecentComments)
			        {
                        gotRecentComments = CreateRecentComments(owner, ref recentComments);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentGuideEntries") || userPageParameters.IncludeRecentGuideEntries)
			        {
                        gotRecentArticles = CreateRecentArticles(owner, ref recentArticles);
                        gotRecentApprovals = CreateRecentApprovedArticles(owner, ref recentApprovals);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUploads") || userPageParameters.IncludeRecentUploads)
			        {
				        //string sUploadsXML;
				        //CUpload Upload(m_InputContext);
				        //Upload.GetUploadsForUser(iUserID,sUploadsXML);
				        //pWholePage->AddInside("H2G2",sUploadsXML);
			        }

                    if (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeRecentArticlesOfSubscribedToUsers") || userPageParameters.IncludeRecentArticlesOfSubscribedUsers)
			        {
                        gotSubscribedToUsersRecentArticles = CreateSubscribedToUsersRecentArticles(owner, InputContext.CurrentSite.SiteID, ref subscribedUsersArticles); 
			        }
                }


                XmlElement pageOwner = AddElementTag(RootElement, "PAGE-OWNER");
                if(gotOwner)
                {
                    AddInside(pageOwner, owner);
                }
                else
                {
                    XmlElement pretendUser = AddElementTag(pageOwner, "USER");
                    AddIntElement(pretendUser, "USERID", userPageParameters.UserID);
                    AddTextTag(pretendUser, "USERNAME", "Researcher " + userPageParameters.UserID.ToString());
                }
                if(gotInterface)
                {
                    AddInside(pageInterface, "");
                }

                if (userPageParameters.Clip)
                {
                    string clipSubject = String.Empty;
                    if (gotOwner)
                    {
                        clipSubject = owner.UserName;
                    }
                    else
                    {
                        clipSubject = "U" + userPageParameters.UserID.ToString();
                    }
                    Link link = new Link(InputContext);
                    //TODO ClipPageToUser page
                    link.ClipPageToUserPage("userpage", userPageParameters.UserID, clipSubject, String.Empty, InputContext.ViewingUser, userPageParameters.Private);
                    AddInside(link);                       
                }

                // if masthead NULL stylesheet should do the default response
                if (gotMasthead && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntry") || userPageParameters.IncludeUsersGuideEntries))
                {
                    AddInside(masthead);
                }
                // add page forum if there is one => this is the forum associated with
                // the guide enty that is the masthead for this user
                if (gotPageForum && (InputContext.GetSiteOptionValueBool("PersonalSpace", "IncludeUsersGuideEntryForum") || userPageParameters.IncludeUsersGuideEntriesForums))
                {
                    XmlElement articleForumTag = AddElementTag(RootElement, "ARTICLEFORUM");
                    AddInside(articleForumTag, pageForum);
                }
                // add journal if it exists
                if ( gotJournal)
                {
                    XmlElement journalTag = AddElementTag(RootElement, "JOURNAL");
                    AddInside(journalTag, journal);
                }
                // add recent posts if they exist, this may add an empty
                // POST-LIST tag if the user exists but has never posted
                if ( gotRecentPosts)
                {
                    XmlElement recentPostsTag = AddElementTag(RootElement, "RECENT-POSTS");
                    AddInside(recentPostsTag, recentPosts);
                }
                // add recent articles if they exist, this may add an empty
                // ARTICLES-LIST tag if the user exists but has never written a guide entry
                if ( gotRecentArticles)
                {
                    XmlElement recentEntries = AddElementTag(RootElement, "RECENT-ENTRIES");
                    AddInside(recentEntries, recentArticles);
                    // add the user XML for the owner too
                    if (gotOwner)
                    {
                        AddInside(recentEntries, owner);
                    }
                }
                // add recent approvals if they exist, this may add an empty
                // ARTICLES-LIST tag if the user exists but has never had an entry approved
                if ( gotRecentApprovals)
                {
                    XmlElement recentApprovalsTag = AddElementTag(RootElement, "RECENT-APPROVALS");
                    AddInside(recentApprovalsTag, recentApprovals);
                    // add the user XML for the owner too
                    if (gotOwner)
                    {
                        AddInside(recentApprovalsTag, owner);
                    }
                }
                // add recent comments if they exist, this may add an empty
                // COMMENTS-LIST tag if the user exists but has never posted
                if ( gotRecentComments)
                {
                    XmlElement recentCommentsTag = AddElementTag(RootElement, "RECENT-COMMENTS");
                    AddInside(recentCommentsTag, recentComments);
                }

                if ( gotSubscribedToUsersRecentArticles)
                {
                    XmlElement subscribedUsersArticlesTag = AddElementTag(RootElement, "RECENT-SUBSCRIBEDARTICLES");
                    AddInside(subscribedUsersArticlesTag, subscribedUsersArticles);
                }

                SiteXmlBuilder siteXml = new SiteXmlBuilder(InputContext);
                RootElement.AppendChild(ImportNode(siteXml.GenerateAllSitesXml(InputContext.TheSiteList).FirstChild));

                AddWatchListSection(userPageParameters, gotMasthead);

                AddWhosOnlineSection();

                AddClubsSection(userPageParameters, gotMasthead);

                AddPrivateForumSection(userPageParameters, gotMasthead, gotOwner);

                AddLinksSection(userPageParameters, owner, gotMasthead, gotOwner);

                AddTaggedNodesSection(userPageParameters, owner, gotMasthead);

                AddNoticeBoardPostcoderSection(userPageParameters, gotMasthead);

                AddSiteOptionSection(userPageParameters);
            }
        }