[pLog-svn] r5617 - in plog/branches/lifetype-1.2/class: action net

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Jul 5 17:23:15 EDT 2007


Author: oscar
Date: 2007-07-05 17:23:15 -0400 (Thu, 05 Jul 2007)
New Revision: 5617

Modified:
   plog/branches/lifetype-1.2/class/action/rssaction.class.php
   plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php
Log:
Implemented feature request http://bugs.lifetype.net/view.php?id=1349 -- method BaseRequestGenerator::userRssLink($userInfo) is now available, and it will generate a link to an RSS feed containing only the posts by a certain user.


Modified: plog/branches/lifetype-1.2/class/action/rssaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/rssaction.class.php	2007-07-05 21:01:42 UTC (rev 5616)
+++ plog/branches/lifetype-1.2/class/action/rssaction.class.php	2007-07-05 21:23:15 UTC (rev 5617)
@@ -24,6 +24,7 @@
         	$this->BlogAction( $blogInfo, $request );
 			
 			$this->registerFieldValidator( "categoryId", new IntegerValidator(), true );
+			$this->registerFieldValidator( "userId", new IntegerValidator(), true );			
 			
 			// create a StringValidator and add an extra rule to make sure that the input string contains only
 			// alphanumeric characters
@@ -79,11 +80,15 @@
             $categoryId = $this->_request->getValue( "categoryId" );
             if( !is_numeric($categoryId))
             	$categoryId = 0;
+
+			// fetch the user id, if any
+			$userId = $this->_request->getValue( "userId", -1 );
 				
             // check if the template is available
             $this->_view = new RssView( $this->_blogInfo, $profile, 
 			                            Array( "profile" => $profile,
-										       "categoryId" => $categoryId ));
+										       "categoryId" => $categoryId,
+										        "userId" => $userId ));
 			
 			// do nothing if the view was already cached
 			if( $this->_view->isCached()) {
@@ -105,13 +110,22 @@
 
 			$t = new Timestamp();
 			if( $blogSettings->getValue( 'show_future_posts_in_calendar' )) {
-				$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), -1, $amount, 
-															$categoryId, POST_STATUS_PUBLISHED, 0 );
+				$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), 
+				                                            -1, 
+				                                            $amount, 
+															$categoryId, 
+															POST_STATUS_PUBLISHED, 
+															$userId );
 			}
 			else {
 				$today = $t->getTimestamp();
-				$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), -1, $amount, 
-															$categoryId, POST_STATUS_PUBLISHED, 0, $today );			
+				$blogArticles = $articles->getBlogArticles( $this->_blogInfo->getId(), 
+				                                            -1, 
+				                                            $amount, 
+															$categoryId, 
+															POST_STATUS_PUBLISHED, 
+															$userId, 
+															$today );			
 			}
 			
 			// load the category
@@ -127,6 +141,7 @@
 			$pm->setUserInfo( $this->_userInfo );
 			$result = $pm->notifyEvent( EVENT_POSTS_LOADED, Array( 'articles' => &$blogArticles ));
 			$articles = Array();
+			
 			foreach( $blogArticles as $article ) {
 				$postText = $article->getIntroText();
 				$postExtendedText = $article->getExtendedText();

Modified: plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php	2007-07-05 21:01:42 UTC (rev 5616)
+++ plog/branches/lifetype-1.2/class/net/baserequestgenerator.class.php	2007-07-05 21:23:15 UTC (rev 5617)
@@ -331,9 +331,32 @@
          */
         function categoryRssLink( $category, $profile = "", $blogInfo = null )
         {
-	        	throw( new Exception( "This function must be implemented by child classes." ));
+			throw( new Exception( "This function must be implemented by child classes." ));
 	    }	
+	
+        /**
+         * Returns the url for the rss feed of user posts. All URL generators use the same
+ 	 	 * format for this for the time being, so we'll keep the method in this base class.
+         *
+         * @param category The UserInfo object with information about the category
+         * whose RSS feed we'd like to generate
+         * @þaram profile The profile we'd like to generate: RSS 0.90, RSS 1.0, RSS 2.0
+         * or XML.
+         * @return The url pointing to the rss feed of user
+         * @see BlogInfo
+         */
+        function userRssLink( $userInfo, $profile = "" )
+        {
+			$rssLink = $this->getRssUrl();
+            $rssLink .= "?blogId=".$this->_blogInfo->getId();
+            
+            if( $profile != "" )
+            	$rssLink .= "&profile=$profile";
 
+			$rssLink .= "&userId=".$userInfo->getId();
+            return $rssLink;	
+		}	
+
         /**
          * Returns the link of a category. Must be implemented by child classes to generate a valid URL.
          * This method has been deprecated as of pLog 1.0 so please use the method BaseRequestGenerator::categoryLink()



More information about the pLog-svn mailing list