[pLog-svn] r1240 - plog/trunk

oscar at devel.plogworld.net oscar at devel.plogworld.net
Mon Feb 28 14:09:56 GMT 2005


Author: oscar
Date: 2005-02-28 14:09:56 +0000 (Mon, 28 Feb 2005)
New Revision: 1240

Modified:
   plog/trunk/xmlrpc.php
Log:
merged patch 276 (http://bugs.plogworld.net/view.php?id=276), even though the xmlrpc.php should
be improved to throw events for all situations, not only PRE_POST_ADD and POST_POST_ADD but also
PRE/POST_POST_DELETE, PRE/POST_POST_UPDATE, etc.


Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php	2005-02-28 13:22:22 UTC (rev 1239)
+++ plog/trunk/xmlrpc.php	2005-02-28 14:09:56 UTC (rev 1240)
@@ -1,23 +1,5 @@
 <?php
 
-    /*
-
-	// working with pLOG 0.2 // 0.3
-
-        mhe at ltcgroup.de
-        todo
-            - security, can delete/post/update on blog ? ACL
-
-	hints
-            - blogid/categoryid hardcoded in "blogid", check int _encode()
-            - newline unix/windows/mac, currently hardcoded \r\n
-
-	history
-	    2003-12-27: added improved xmlrpc error handling
-	    2003-12-28: fixed hardcoded topic length
-	    2004-01-21: added xmlrpc_api_enabled config check
-    */
-
 	if (!defined( "PLOG_CLASS_PATH" )) {
     	define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
     }
@@ -36,6 +18,7 @@
 	include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
 	include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
 	include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+	include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );	
 	
 
     // init database
@@ -60,8 +43,8 @@
 
 
     function newPost($args)
-    {
-        global $users, $articles;
+    {	    	
+	    global $users, $articles, $blogsG;
         $appkey     = $args[0];
         $blogid     = $args[1];
         $username   = $args[2];
@@ -117,25 +100,37 @@
                 0, // numread
                 Array( "comments_enabled" => true ) // enable comments
             );
+            
+			// Get the plugin manager
+			$plugMgr =& PluginManager::getPluginManager();
+			$plugMgr->setBlogInfo( $blogsG->getBlogInfo( $blogid ) );
+			$plugMgr->setUserInfo( $erg );
+			$plugMgr->loadPlugins();
+			// Send the PRE_POST_POST_ADD message
+			$plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));            
+            
             $article->setDate(date("YmdHis"));
             $postid = $articles->addArticle($article);
-	    if ($postid != 0)
-	    {
-		CacheControl::resetBlogCache( $blogid );	    
-		return sprintf( "%d", $postid );
-	    } else
-	    {
-		return new IXR_Error(-1, 'Internal error occured creating your post!');
-	    }
-        } else
-        {
+	    
+            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!');
+	    	}
+        } 
+        else {
             return new IXR_Error(-1, 'You did not provide the correct password');
         }
     }
 
     function metaWeblogNewPost($args)
     {
-        global $users, $articles, $category;
+        global $users, $articles, $category, $blogsG;
         $blogid     = $args[0];
         $username   = $args[1];
         $password   = $args[2];
@@ -229,11 +224,25 @@
             }
             
             $article->setDate($articleDate);
+            
+			// Get the plugin manager
+			$plugMgr =& PluginManager::getPluginManager();
+			$plugMgr->setBlogInfo( $blogsG->getBlogInfo( $blogid ) );
+			$plugMgr->setUserInfo( $erg );
+			$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)
 	    {
-		CacheControl::resetBlogCache( $blogid );	    
-		return sprintf( "%d", $postid );
+			// 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!');
@@ -832,4 +841,4 @@
 	);
     
     }
-?>
\ No newline at end of file
+?>




More information about the pLog-svn mailing list