[pLog-svn] r3439 - plog/trunk

pwestbro at devel.lifetype.net pwestbro at devel.lifetype.net
Sat May 20 05:47:06 GMT 2006


Author: pwestbro
Date: 2006-05-20 05:47:05 +0000 (Sat, 20 May 2006)
New Revision: 3439

Modified:
   plog/trunk/xmlrpc.php
Log:
Now posting via xmlrpc will set the ArticleNotification if the user
enabled it in the blog settings 


Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php	2006-05-19 04:12:34 UTC (rev 3438)
+++ plog/trunk/xmlrpc.php	2006-05-20 05:47:05 UTC (rev 3439)
@@ -100,27 +100,43 @@
             );
             
             $article->setDate(date("YmdHis"));
+            
+            $blogInfo = $blogsG->getBlogInfo( $blogid );
 
-			// Get the plugin manager
-			$plugMgr =& PluginManager::getPluginManager();
-			$plugMgr->setBlogInfo( $blogsG->getBlogInfo( $blogid ) );
-			$plugMgr->setUserInfo( $userInfo );
-			$plugMgr->loadPlugins();
-			// Send the PRE_POST_POST_ADD message
-			$plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));            
 
+            // Get the plugin manager
+            $plugMgr =& PluginManager::getPluginManager();
+            $plugMgr->setBlogInfo( $blogInfo);
+            $plugMgr->setUserInfo( $userInfo );
+            $plugMgr->loadPlugins();
+            // Send the PRE_POST_POST_ADD message
+            $plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));            
+
             $postid = $articles->addArticle($article);
-	    
+        
             if ($postid != 0) {
-				// The post was successful
-				// Send the EVENT_POST_POST_ADD messages to the plugins
-				$plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));				
-				CacheControl::resetBlogCache( $blogid );
-				return sprintf( "%d", $postid );
-	    	} 
-	    	else {
-				return new IXR_Error(-1, 'Internal error occured creating your post!');
-	    	}
+                // The post was successful
+                // Send the EVENT_POST_POST_ADD messages to the plugins
+                $plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));               
+                CacheControl::resetBlogCache( $blogid );
+                
+                $blogSettings = $blogInfo->getSettings();
+                
+                // Add article notifcations if this is specified by the default setting.
+                if ($blogSettings->getValue( "default_send_notification" ))
+                {
+                    require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
+
+                    $artNotifications = new ArticleNotifications();
+                    $artNotifications->addNotification( $postid, $blogid, $userInfo->getId());
+                }
+                
+                
+                return sprintf( "%d", $postid );
+            } 
+            else {
+                return new IXR_Error(-1, 'Internal error occured creating your post!');
+            }
         } 
         else {
             return new IXR_Error(-1, 'You did not provide the correct password');
@@ -224,28 +240,43 @@
             
             $article->setDate($articleDate);
             
-			// Get the plugin manager
-			$plugMgr =& PluginManager::getPluginManager();
-			$plugMgr->setBlogInfo( $blogsG->getBlogInfo( $blogid ) );
-			$plugMgr->setUserInfo( $userInfo );
-			$plugMgr->loadPlugins();
-			// Send the PRE_POST_POST_ADD message
-			$plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));            
+            $blogInfo = $blogsG->getBlogInfo( $blogid );
             
+            
+            // Get the plugin manager
+            $plugMgr =& PluginManager::getPluginManager();
+            $plugMgr->setBlogInfo( $blogInfo );
+            $plugMgr->setUserInfo( $userInfo );
+            $plugMgr->loadPlugins();
+            // Send the PRE_POST_POST_ADD message
+            $plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));            
+            
             $postid = $articles->addArticle($article);
-	    if ($postid != 0)
-	    {
-			// The post was successful
-			
-			// Send the EVENT_POST_POST_ADD messages to the plugins
-			$plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
-			
-			CacheControl::resetBlogCache( $blogid );
-			return sprintf( "%d", $postid );
-	    } else
-	    {
-		return new IXR_Error(-1, 'Internal error occured creating your post!');
-	    }
+            if ($postid != 0)
+            {
+                // The post was successful
+                
+                // Send the EVENT_POST_POST_ADD messages to the plugins
+                $plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
+                
+                CacheControl::resetBlogCache( $blogid );
+                
+                $blogSettings = $blogInfo->getSettings();
+                
+                // Add article notifcations if this is specified by the default setting.
+                if ($blogSettings->getValue( "default_send_notification" ))
+                {
+                    require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
+
+                    $artNotifications = new ArticleNotifications();
+                    $artNotifications->addNotification( $postid, $blogid, $userInfo->getId());
+                }
+                
+                return sprintf( "%d", $postid );
+            } else
+            {
+            return new IXR_Error(-1, 'Internal error occured creating your post!');
+            }
         } else
         {
             return new IXR_Error(-1, 'You did not provide the correct password');



More information about the pLog-svn mailing list