[pLog-svn] r651 - plog/trunk

oscar at devel.plogworld.net oscar at devel.plogworld.net
Mon Jan 3 01:05:42 GMT 2005


Author: oscar
Date: 2005-01-03 01:05:42 +0000 (Mon, 03 Jan 2005)
New Revision: 651

Modified:
   plog/trunk/xmlrpc.php
Log:
support for also updating posts added.


Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php	2005-01-03 00:59:37 UTC (rev 650)
+++ plog/trunk/xmlrpc.php	2005-01-03 01:05:42 UTC (rev 651)
@@ -453,16 +453,42 @@
             } else
             {
                 $status = POST_STATUS_DRAFT;
-            }
-    
+            }            
 
             $title = $content["title"];
             $body = $content["description"];
-
+            
             $article = $articles->getUserArticle($postid);
+            
+            $catList = $content["categories"];
+            //
+            // :KLUDGE:
+            // not exactly the smartest and fastest bit of code ever but it seems to work :-)
+            //
+            $categories = Array();
+            $blogid = $article->getBlog();
+            $cats = $category->getBlogCategories($blogid);
+            if ( $catList != NULL )
+            {
+                foreach( $catList as $categoryName ) {
+                    foreach( $cats as $blogCategory ) {
+                        if ( strcmp( $categoryName, $blogCategory->getName()) == 0 )
+                        {
+                            $categories[] = $blogCategory->getId();
+                        }
+                    }
+                }
+            }
+            else {
+                // if no category, let's pick a random one
+                $blogCategory = array_pop( $cats );
+                $categories[] = $blogCategory->getId();
+            }
+            
             $article->setText($body);
             $article->setTopic($title);
             $article->setStatus($status);
+            $article->setCategoryIds( $categories );
 
             $articles->updateArticle($article);
             




More information about the pLog-svn mailing list