示例#1
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);
            }
        }
示例#2
0
 private bool CreateSubscribedToUsersRecentArticles(IUser user, int siteID, ref ArticleSubscriptionsList subscribedUsersArticles)
 {
     return subscribedUsersArticles.CreateArticleSubscriptionsList(user.UserID, siteID, 0, 10);
 }
        /// <summary>
        /// Calls the User Subscription list class to generate the most recent UserSubscriptions
        /// </summary>
        /// <param name="userID">The user of the subscriptions to get</param>
        /// <param name="skip">number of posts to skip</param>
        /// <param name="show">number to show</param>
        private void GenerateMoreArticleSubscriptionsPageXml(int userID, int skip, int show)
        {
            ArticleSubscriptionsList articleSubscriptionList = new ArticleSubscriptionsList(InputContext);

            articleSubscriptionList.CreateArticleSubscriptionsList(userID, InputContext.CurrentSite.SiteID, skip, show);

            // Put in the wrapping <MoreUserSubscriptions> tag which has the user ID in it
            XmlElement moreArticleSubscriptions = AddElementTag(RootElement, "MoreArticleSubscriptions");
            AddAttribute(moreArticleSubscriptions, "USERID", userID);
			if ( InputContext.ViewingUser.UserID != 0 && InputContext.ViewingUser.UserLoggedIn)
			{
				AddAttribute(moreArticleSubscriptions, "ACCEPTSUBSCRIPTIONS", Convert.ToInt32(InputContext.ViewingUser.AcceptSubscriptions));
			}

            AddInside(moreArticleSubscriptions, articleSubscriptionList);

            FileCache.PutItem(AppContext.TheAppContext.Config.CachePath, "ArticleSubscriptions", _cacheName, moreArticleSubscriptions.OuterXml);
        }