[pLog-svn] r6874 - plugins/branches/lifetype-1.2/moblog/install

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Tue Apr 28 13:13:15 EDT 2009


Author: jondaley
Date: 2009-04-28 13:13:14 -0400 (Tue, 28 Apr 2009)
New Revision: 6874

Modified:
   plugins/branches/lifetype-1.2/moblog/install/moblog.php
Log:
allow symlinks to moblog.php to the install directory (like openid).  text changes.  Now use array of categories to match the admin side.  Also allow backward compatible one category only posts.

Modified: plugins/branches/lifetype-1.2/moblog/install/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-04-28 16:27:35 UTC (rev 6873)
+++ plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-04-28 17:13:14 UTC (rev 6874)
@@ -1,14 +1,21 @@
 <?php
 
     // define the entry point
-    if (!defined( "PLOG_CLASS_PATH" )) {
-    	define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+if (!defined( "PLOG_CLASS_PATH" )) {
+    $path = dirname(__FILE__);
+    $pos = strpos($path, "moblog");
+    if($pos !== FALSE){
+            // get path to root, ie. strip off "plugins/moblog/install"
+            // don't search for '/' since windows uses '\\'
+        $path = substr($path, 0, $pos-8);
     }
+    define( "PLOG_CLASS_PATH", $path."/");
+}
     
     //
     // set this to false if you want logging enabled
     //
-    define( "MOBLOG_DEBUG", false );
+    define( "MOBLOG_DEBUG", true );
     
     // bring in some code that we need
     include_once( PLOG_CLASS_PATH."class/bootstrap.php" );    
@@ -155,9 +162,9 @@
 	    $blogInfo->getOwnerId() != $userInfo->getId()) {
         $response = new MoblogResponse( $request->getReplyTo(),
                                   "LifeType Moblog: Error",
-                                  "You have no permissions in the given blog."
+                                  "You do not have permission to add posts to the given blog."
                                  );
-        MoblogLogger::log( "User '".$request->getUser()."' has no permissions in blog ".$request->getBlogId());
+        MoblogLogger::log( "User '".$request->getUser()."' does not have permission to add posts to blog ".$request->getBlogId());
         $response->send();         
         return false;
     }
@@ -169,21 +176,38 @@
     //
     $articleCategories = new ArticleCategories();    
     // load the category as defined in the plugin settings page
-    $categoryId = $blogSettings->getValue( "plugin_moblog_article_category_id" );
-    $category = $articleCategories->getCategory( $categoryId, $blogInfo->getId());
+    $requestedCategoryIds = $blogSettings->getValue( "plugin_moblog_article_category_id" );
+
+    // old method, is without a category
+    if(!is_array($requestedCategoryIds)){
+        $requestedCategoryIds = array($requestedCategoryIds);
+    }
+
+$verifiedCategoryIds = array();
+foreach($requestedCategoryIds as $catId){
+    $category = $articleCategories->getCategory( $catId, $blogInfo->getId());
+    if(!$category)
+        continue;
+    $verifiedCategoryIds[] = $category->getId();
+}
+
+if(!count($verifiedCategoryIds)){
     // if there was no such category, we should send an error and to make it more useful, send
     // as part of the error message the list of available categories
-    if( !$category ) {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "The category does not exist."
-                                );
-        MoblogLogger::log( "User '".$request->getUser()."' tried to use category '".$categoryId.
-                     "' which does not exist.");
-        $response->send(); 
-        return false;                
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "The categories do not exist."
+                                    );
+    $msg = "User '".$request->getUser()."' tried to use category: '";
+    foreach($requestedCategoryIds as $catId){
+        $msg .= $catId . ",";
     }
-    
+    $msg .= "' which does not exist.";
+    MoblogLogger::log($msg);
+    $response->send(); 
+    return false;
+}
+
     //
     // finally, add the resources to the database
     //
@@ -282,7 +306,7 @@
 
     $article = new Article( $postTopic, 
                             $postBody,
-                            Array( $category->getId()),
+                            $verifiedCategoryIds,
                             $userInfo->getId(),
                             $blogInfo->getId(),
                             POST_STATUS_PUBLISHED,



More information about the pLog-svn mailing list