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

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Thu Jun 18 09:22:57 EDT 2009


Author: jondaley
Date: 2009-06-18 09:22:57 -0400 (Thu, 18 Jun 2009)
New Revision: 6904

Modified:
   plugins/branches/lifetype-1.2/moblog/install/moblog.php
Log:
whitespace change only - all of this is at the global level, so emacs doesn't like it to be indented

Modified: plugins/branches/lifetype-1.2/moblog/install/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-06-17 16:28:11 UTC (rev 6903)
+++ plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-06-18 13:22:57 UTC (rev 6904)
@@ -15,62 +15,62 @@
     //
     // set this to false if you want logging enabled
     //
-    define( "MOBLOG_DEBUG", true );
-    
+define( "MOBLOG_DEBUG", true );
+
     // bring in some code that we need
-    include_once( PLOG_CLASS_PATH."class/bootstrap.php" );    
-    lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
-    lt_include( PLOG_CLASS_PATH."plugins/moblog/class/log/mobloglogger.class.php" );
-    lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogrequest.class.php" );
-    lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogresponse.class.php" );
-	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
-	lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" ); 
-	lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
-	lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-	lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );	
-	lt_include( PLOG_CLASS_PATH."class/file/fileupload.class.php" );
+include_once( PLOG_CLASS_PATH."class/bootstrap.php" );    
+lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
+lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
+lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
+lt_include( PLOG_CLASS_PATH."plugins/moblog/class/log/mobloglogger.class.php" );
+lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogrequest.class.php" );
+lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogresponse.class.php" );
+lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
+lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" ); 
+lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );	
+lt_include( PLOG_CLASS_PATH."class/file/fileupload.class.php" );
     
     // initialize the logging system
-    MoblogLogger::log( "-- Initialized");
+MoblogLogger::log( "-- Initialized");
 
     // get the request
-    $request = HttpVars::getRequest();
-	isset( $request["message"] ) ? $message = $request["message"] : $message = "";
+$request = HttpVars::getRequest();
+isset( $request["message"] ) ? $message = $request["message"] : $message = "";
     
-    if( $message == "" ) {
-        MoblogLogger::log( "There was no message!" );
-        die();
-    }
+if( $message == "" ) {
+    MoblogLogger::log( "There was no message!" );
+    die();
+}
     
     // check if we need to remove any quotes..
-    if( get_magic_quotes_gpc()) {
-        $message = stripslashes( $message );
-    }
+if( get_magic_quotes_gpc()) {
+    $message = stripslashes( $message );
+}
 
-    MoblogLogger::log("-- message --");
-    MoblogLogger::log($message);
-    MoblogLogger::log("-- message end --");
+MoblogLogger::log("-- message --");
+MoblogLogger::log($message);
+MoblogLogger::log("-- message end --");
     
     // parse the message
-    $request = new MoblogRequest( $request );
+$request = new MoblogRequest( $request );
     
     // let's see what we get...    
-    MoblogLogger::log( "user = '".$request->getUser()."'");
+MoblogLogger::log( "user = '".$request->getUser()."'");
     // uncomment the following if you want to see passwords... :)
     //MoblogLogger::log( "pass = ".$request->getPassword()."'");
-    MoblogLogger::log( "blog id = ".$request->getBlogId());
-    MoblogLogger::log( "topic = ".$request->getTopic());
-    MoblogLogger::log( "reply to = ".$request->getReplyTo());
-    MoblogLogger::log( "body = ".$request->getBody());
+MoblogLogger::log( "blog id = ".$request->getBlogId());
+MoblogLogger::log( "topic = ".$request->getTopic());
+MoblogLogger::log( "reply to = ".$request->getReplyTo());
+MoblogLogger::log( "body = ".$request->getBody());
     
     //
     // start processing the message...
@@ -79,106 +79,106 @@
     //
     // first, try to authenticate the user
     //
-    $users = new Users();
-    if( $users->authenticateUser( $request->getUser(), $request->getPassword())) {
-		$userInfo = $users->getUserInfoFromUsername( $request->getUser());
-	}
-    else {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "User or password are not correct."
-                                 );
-        MoblogLogger::log( "User ".$request->getUser()." did not authenticate correctly." );
-        $response->send();         
-        return false;
-    }
+$users = new Users();
+if( $users->authenticateUser( $request->getUser(), $request->getPassword())) {
+    $userInfo = $users->getUserInfoFromUsername( $request->getUser());
+}
+else {
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "User or password are not correct."
+                                    );
+    MoblogLogger::log( "User ".$request->getUser()." did not authenticate correctly." );
+    $response->send();         
+    return false;
+}
     
     //
     // if user was authenticated, then proceed... and the first thing we should do
     // is see if the blog id is correct and if the user has permissions in that
     // blog
     //
-    $blogs = new Blogs();
-    if( $request->getBlogId() == "" ) {
+$blogs = new Blogs();
+if( $request->getBlogId() == "" ) {
         // user gave a blog name instead of a blog id
-        $allBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES );
-        if( $allBlogs ) {
-            $found = false;
-            $blogName = stripslashes($request->getBlogName());
-            while( !$found && !empty($allBlogs)) {
-                $blogInfo = array_pop( $allBlogs );
-                if( strcasecmp($blogInfo->getBlog(), $blogName) == 0 ) {
-                    $found = true;
-                    MoblogLogger::log( "Blog '".$blogInfo->getBlog()."' found with id = '".$blogInfo->getId()."'");
-                }
+    $allBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES );
+    if( $allBlogs ) {
+        $found = false;
+        $blogName = stripslashes($request->getBlogName());
+        while( !$found && !empty($allBlogs)) {
+            $blogInfo = array_pop( $allBlogs );
+            if( strcasecmp($blogInfo->getBlog(), $blogName) == 0 ) {
+                $found = true;
+                MoblogLogger::log( "Blog '".$blogInfo->getBlog()."' found with id = '".$blogInfo->getId()."'");
             }
+        }
             
-            if( !$found ) {
-                $response = new MoblogResponse( $request->getReplyTo(),
-                                          "LifeType Moblog: Error",
-                                          "Incorrect blog."
-                                         );
-                MoblogLogger::log( "Blog ".$request->getBlogId()." does not exist." );
-                $response->send();         
-                return false;                
-            }
-        }
-    }
-    else {
-        $blogInfo = $blogs->getBlogInfo( $request->getBlogId());
-        if( !$blogInfo ) {
+        if( !$found ) {
             $response = new MoblogResponse( $request->getReplyTo(),
-                                      "LifeType Moblog: Error",
-                                      "Incorrect blog identifier."
-                                     );
-            MoblogLogger::log( "Blog ".$request->getBlogId()." is not valid." );
+                                            "LifeType Moblog: Error",
+                                            "Incorrect blog."
+                                            );
+            MoblogLogger::log( "Blog ".$request->getBlogId()." does not exist." );
             $response->send();         
-            return false;    
+            return false;                
         }
     }
+}
+else {
+    $blogInfo = $blogs->getBlogInfo( $request->getBlogId());
+    if( !$blogInfo ) {
+        $response = new MoblogResponse( $request->getReplyTo(),
+                                        "LifeType Moblog: Error",
+                                        "Incorrect blog identifier."
+                                        );
+        MoblogLogger::log( "Blog ".$request->getBlogId()." is not valid." );
+        $response->send();         
+        return false;    
+    }
+}
     
     //
     // check if the plugin has been enabled for this blog
     //
-    $blogSettings = $blogInfo->getSettings();
-    $pluginEnabled = $blogSettings->getValue( "plugin_moblog_enabled" );
-    if( !$pluginEnabled ) {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "The plugin has not been enabled for this blog."
-                                 );
-        MoblogLogger::log( "Plugin not enabled for blog ".$request->getBlogId());
-        $response->send();         
-        return false;
-    }
+$blogSettings = $blogInfo->getSettings();
+$pluginEnabled = $blogSettings->getValue( "plugin_moblog_enabled" );
+if( !$pluginEnabled ) {
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "The plugin has not been enabled for this blog."
+                                    );
+    MoblogLogger::log( "Plugin not enabled for blog ".$request->getBlogId());
+    $response->send();         
+    return false;
+}
     
     //
     // now check if the user is allowed to post in the given blog
     //
-	if( !$userInfo->hasPermissionByName( "add_post", $blogInfo->getId()) &&
-	    $blogInfo->getOwnerId() != $userInfo->getId()) {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "You do not have permission to add posts to the given blog."
-                                 );
-        MoblogLogger::log( "User '".$request->getUser()."' does not have permission to add posts to blog ".$request->getBlogId());
-        $response->send();         
-        return false;
-    }
+if( !$userInfo->hasPermissionByName( "add_post", $blogInfo->getId()) &&
+    $blogInfo->getOwnerId() != $userInfo->getId()) {
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "You do not have permission to add posts to the given blog."
+                                    );
+    MoblogLogger::log( "User '".$request->getUser()."' does not have permission to add posts to blog ".$request->getBlogId());
+    $response->send();         
+    return false;
+}
     
     //
     // if everything's correct, then we can proceed to find if the category 
     // chosen by the user exists. Since there is no way to fetch a category by its name,
     // we'll have to fetch them all and loop through them
     //
-    $articleCategories = new ArticleCategories();    
+$articleCategories = new ArticleCategories();    
     // load the category as defined in the plugin settings page
-    $requestedCategoryIds = $blogSettings->getValue( "plugin_moblog_article_category_id" );
+$requestedCategoryIds = $blogSettings->getValue( "plugin_moblog_article_category_id" );
 
     // old method, is without a category
-    if(!is_array($requestedCategoryIds)){
-        $requestedCategoryIds = array($requestedCategoryIds);
-    }
+if(!is_array($requestedCategoryIds)){
+    $requestedCategoryIds = array($requestedCategoryIds);
+}
 
 $verifiedCategoryIds = array();
 foreach($requestedCategoryIds as $catId){
@@ -189,8 +189,8 @@
 }
 
 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 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
     $response = new MoblogResponse( $request->getReplyTo(),
                                     "LifeType Moblog: Error",
                                     "The categories do not exist."
@@ -210,45 +210,45 @@
     //
     
     // first, create a new album to hold these attachments
-    $albums = new GalleryAlbums();
-    $userAlbums = $albums->getUserAlbums( $blogInfo->getId());
-    $t = new Timestamp();    
-    $albumId = $blogSettings->getValue( "plugin_moblog_gallery_resource_album_id" );
-    $album = $albums->getAlbum( $albumId, $blogInfo->getId());
+$albums = new GalleryAlbums();
+$userAlbums = $albums->getUserAlbums( $blogInfo->getId());
+$t = new Timestamp();    
+$albumId = $blogSettings->getValue( "plugin_moblog_gallery_resource_album_id" );
+$album = $albums->getAlbum( $albumId, $blogInfo->getId());
     // check if the album was loaded
-    if( !$album ) {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "The album does not exist."
-                                );
-        MoblogLogger::log( "User '".$request->getUser()."' tried to use album '".$albumId.
-                     "' which does not exist.");
-        $response->send(); 
-        return false;                
-    }
-    MoblogLogger::log( "Adding resources to album ".$album->getName());    
+if( !$album ) {
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "The album does not exist."
+                                    );
+    MoblogLogger::log( "User '".$request->getUser()."' tried to use album '".$albumId.
+                       "' which does not exist.");
+    $response->send(); 
+    return false;                
+}
+MoblogLogger::log( "Adding resources to album ".$album->getName());    
     
-    $attachments = $request->getAttachments();
-    $res = new GalleryResources();
-    $resourceIds = Array();
+$attachments = $request->getAttachments();
+$res = new GalleryResources();
+$resourceIds = Array();
     
-    if ( count($attachments) > 0) {
-        foreach( $attachments as $attachment ) {
-            MoblogLogger::log( "-- Processing attachment ".$attachment->getFileName()." - tmp filename = ".$attachment->getTmpName());
-            $result = $res->addResourceFromDisk( $blogInfo->getId(), $albumId, $attachment->getFileName(), $attachment->getTmpName());
-            MoblogLogger::log( "   Completed: result = $result" );
-            if( $result ) {
+if ( count($attachments) > 0) {
+    foreach( $attachments as $attachment ) {
+        MoblogLogger::log( "-- Processing attachment ".$attachment->getFileName()." - tmp filename = ".$attachment->getTmpName());
+        $result = $res->addResourceFromDisk( $blogInfo->getId(), $albumId, $attachment->getFileName(), $attachment->getTmpName());
+        MoblogLogger::log( "   Completed: result = $result" );
+        if( $result ) {
                 // keep this for later
-                array_push( $resourceIds, $result );
-            }
-    		else {
-    			MoblogLogger::log("false???");
-    		}
+            array_push( $resourceIds, $result );
         }
+        else {
+            MoblogLogger::log("false???");
+        }
     }
-    else {
-        MoblogLogger::log( "  No Attachments found" );
-    }
+}
+else {
+    MoblogLogger::log( "  No Attachments found" );
+}
     
     //
     // if everything went fine, we can now proceed and publish the post, finally!!!! :)
@@ -256,96 +256,96 @@
     
     // before adding the article, we need to add some additional markup 
     // with links to the attachments that were sent
-    $rg = $blogInfo->getBlogRequestGenerator();
-    $postBody = $request->getBody()."<br/>";
-    $numItems = count($resourceIds);
-    $curItem = 0;
-    foreach( $resourceIds as $resId ) {
-        $resource = $res->getResource( $resId );
-        $markup = "<a id=\"res_".$resId."\" href=\"".$rg->resourceLink( $resource )."\">";        
-        if( $resource->isImage()) {
-            $previewType = $blogSettings->getValue( "plugin_moblog_resource_preview_type" );
-            if( $previewType == MOBLOG_EMBED_MEDIUM_PREVIEW ) {
-                $link = $rg->resourceMediumSizePreviewLink( $resource );
-                $cssClass = "res_image_medium";
-            }
-            elseif( $previewType == MOBLOG_EMBED_FULL_SIZE_VIEW ) {
-                $link = $rg->resourceDownloadLink( $resource );
-                $cssClass = "res_image";
-            }
-            else {
-                $link = $rg->resourcePreviewLink( $resource );          
-                $cssClass = "res_image_small";
-            }
-                
-            $markup .= "<img class=\"$cssClass\" src=\"$link\" alt=\"".$resource->getDescription()."\" />";
+$rg = $blogInfo->getBlogRequestGenerator();
+$postBody = $request->getBody()."<br/>";
+$numItems = count($resourceIds);
+$curItem = 0;
+foreach( $resourceIds as $resId ) {
+    $resource = $res->getResource( $resId );
+    $markup = "<a id=\"res_".$resId."\" href=\"".$rg->resourceLink( $resource )."\">";        
+    if( $resource->isImage()) {
+        $previewType = $blogSettings->getValue( "plugin_moblog_resource_preview_type" );
+        if( $previewType == MOBLOG_EMBED_MEDIUM_PREVIEW ) {
+            $link = $rg->resourceMediumSizePreviewLink( $resource );
+            $cssClass = "res_image_medium";
         }
+        elseif( $previewType == MOBLOG_EMBED_FULL_SIZE_VIEW ) {
+            $link = $rg->resourceDownloadLink( $resource );
+            $cssClass = "res_image";
+        }
         else {
-            $markup .= $resource->getDescription();
+            $link = $rg->resourcePreviewLink( $resource );          
+            $cssClass = "res_image_small";
         }
-        $markup .= "</a>";
-        $curItem++;
-        if( $curItem < $numItems ) 
-            $markup .= "<br/><br/>";        
-        MoblogLogger::log( "Adding markup $markup" );
-        $postBody .= $markup;
-        $postBody = TextFilter::autoP( trim( $postBody ));
-        $resNames .= $resource->getDescription();        
+                
+        $markup .= "<img class=\"$cssClass\" src=\"$link\" alt=\"".$resource->getDescription()."\" />";
     }
+    else {
+        $markup .= $resource->getDescription();
+    }
+    $markup .= "</a>";
+    $curItem++;
+    if( $curItem < $numItems ) 
+        $markup .= "<br/><br/>";        
+    MoblogLogger::log( "Adding markup $markup" );
+    $postBody .= $markup;
+    $postBody = TextFilter::autoP( trim( $postBody ));
+    $resNames .= $resource->getDescription();        
+}
     
     // add the article
-    $articles = new Articles();
-    $postTopic = $request->getTopic();
+$articles = new Articles();
+$postTopic = $request->getTopic();
 
 // some phones need this (I think only if the phone sends UTF-8 and the locale isn't in UTF-8 like in the German case)
 // a little more testing, and I'll have this finally figured out.
 //    $postTopic = utf8_decode($postTopic);
 //    $postBody = utf8_decode($postBody);
 
-    $article = new Article( $postTopic, 
-                            $postBody,
-                            $verifiedCategoryIds,
-                            $userInfo->getId(),
-                            $blogInfo->getId(),
-                            POST_STATUS_PUBLISHED,
-                            0
-                            );
-    $article->setDateObject( new Timestamp());
+$article = new Article( $postTopic, 
+                        $postBody,
+                        $verifiedCategoryIds,
+                        $userInfo->getId(),
+                        $blogInfo->getId(),
+                        POST_STATUS_PUBLISHED,
+                        0
+                        );
+$article->setDateObject( new Timestamp());
     // enable or disable comments by default depending on the current config
-    $commentsEnabled = $blogSettings->getValue( "comments_enabled" );
-    $article->setCommentsEnabled( $commentsEnabled );
+$commentsEnabled = $blogSettings->getValue( "comments_enabled" );
+$article->setCommentsEnabled( $commentsEnabled );
     
-    $result = $articles->addArticle( $article );
+$result = $articles->addArticle( $article );
     
     // add an article notification
-    $notifications = new ArticleNotifications();
-    $notifications->addNotification( $result, $blogInfo->getId(), $userInfo->getId());
+$notifications = new ArticleNotifications();
+$notifications->addNotification( $result, $blogInfo->getId(), $userInfo->getId());
     
     // reset the cache in case it is enabled
-    CacheControl::resetBlogCache( $blogInfo->getId());    
+CacheControl::resetBlogCache( $blogInfo->getId());    
     
-    if( !$result ) {
-        $response = new MoblogResponse( $request->getReplyTo(),
-                                  "LifeType Moblog: Error",
-                                  "There was an error adding the post to the database."
-                                 );
-        MoblogLogger::log( "There was an error adding the post to the database.");
-    }
-    else {
-        lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );	
-        $config =& Config::getConfig();
-        $locale =& Locales::getLocale( $config->getValue("default_locale" ));
+if( !$result ) {
+    $response = new MoblogResponse( $request->getReplyTo(),
+                                    "LifeType Moblog: Error",
+                                    "There was an error adding the post to the database."
+                                    );
+    MoblogLogger::log( "There was an error adding the post to the database.");
+}
+else {
+    lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );	
+    $config =& Config::getConfig();
+    $locale =& Locales::getLocale( $config->getValue("default_locale" ));
         
-        $responseBody = $locale->pr("moblog_body",$request->getTopic());
-        if( count($request->getAttachments()) > 0 ) {
-            $responseBody .= $locale->tr("moblog_attachments");
-            $responseBody .= $resNames;
-        }
-        $response = new MoblogResponse( $request->getReplyTo(), $locale->tr("moblog_mailsubject"), $responseBody ); 
-        MoblogLogger::log( "Post was successfully added to the database." );
+    $responseBody = $locale->pr("moblog_body",$request->getTopic());
+    if( count($request->getAttachments()) > 0 ) {
+        $responseBody .= $locale->tr("moblog_attachments");
+        $responseBody .= $resNames;
     }
-    $response->send();
+    $response = new MoblogResponse( $request->getReplyTo(), $locale->tr("moblog_mailsubject"), $responseBody ); 
+    MoblogLogger::log( "Post was successfully added to the database." );
+}
+$response->send();
     
     // end of it...
-    MoblogLogger::log( "-- End");    
+MoblogLogger::log( "-- End");    
 ?>



More information about the pLog-svn mailing list