[pLog-svn] r4294 - plog/branches/lifetype-1.1.3/class/action

oscar at devel.lifetype.net oscar at devel.lifetype.net
Mon Nov 13 18:35:03 GMT 2006


Author: oscar
Date: 2006-11-13 18:35:02 +0000 (Mon, 13 Nov 2006)
New Revision: 4294

Modified:
   plog/branches/lifetype-1.1.3/class/action/blogaction.class.php
Log:
fix for issue 1113 (http://bugs.lifetype.net/view.php?id=1113) -- Conflict between weblogs when users added


Modified: plog/branches/lifetype-1.1.3/class/action/blogaction.class.php
===================================================================
--- plog/branches/lifetype-1.1.3/class/action/blogaction.class.php	2006-11-13 18:04:45 UTC (rev 4293)
+++ plog/branches/lifetype-1.1.3/class/action/blogaction.class.php	2006-11-13 18:35:02 UTC (rev 4294)
@@ -159,19 +159,14 @@
                 include_once( PLOG_CLASS_PATH."class/net/http/subdomains.class.php" );
 
                 $subdomainInfo = Subdomains::getSubdomainInfoFromRequest();
-                if( !empty($subdomainInfo["blogdomain"])
-                    && $this->_request->getValue( 'blogDomain' ) == "" )
-                {
+
+                if( !empty($subdomainInfo["blogdomain"]) && $this->_request->getValue( 'blogDomain' ) == "" ) {
                     $this->_request->setValue( 'blogDomain', $subdomainInfo["blogdomain"] );
                 }
-                if( !empty($subdomainInfo["username"])
-                    && $this->_request->getValue( 'blogUserName' ) == "" )
-                {
+                if( !empty($subdomainInfo["username"]) && $this->_request->getValue( 'blogUserName' ) == "" ) {
                     $this->_request->setValue( 'blogUserName', $subdomainInfo["username"] );
                 }
-                if( !empty($subdomainInfo["blogname"])
-                    && $this->_request->getValue( 'blogName' ) == "" )
-                {
+                if( !empty($subdomainInfo["blogname"]) && $this->_request->getValue( 'blogName' ) == "" ) {
                     $this->_request->setValue( 'blogName', $subdomainInfo["blogname"] );
                 }
             }
@@ -194,14 +189,23 @@
                     // if the user exists and is valid...
                 	if( $userInfo ) {
                     	$userBlogs = $users->getUsersBlogs( $userInfo->getId(), BLOG_STATUS_ACTIVE );
-                        // check if he or she belogs to any blog. If he or she does, simply
-                        // get the first one (any better rule for this?)
-                    	if( !empty($userBlogs)) {						
-	                		$blogId = $userBlogs[0]->getId();
-                        } else {
+						// check all the blogs and pick the first one that is owned. If none is owned, then pick a random
+						// one (the last one that was processed)
+                    	if( !empty($userBlogs)) {
+							$i = 0;
+							$found = false;
+							while( $i < count($userBlogs) && !$found ) {
+								$blog = $userBlogs[$i];
+								if( $blog->getOwnerId() == $userInfo->getId()) $found = true;
+								$i++;
+							}
+							$blogId = $blog->getId();
+                        } 
+						else {
                         	$blogId = $this->_config->getValue('default_blog_id');
                         }
-                    } else {
+                    } 
+					else {
                     	$blogId = $this->_config->getValue('default_blog_id');
                     }
                 }



More information about the pLog-svn mailing list