[pLog-svn] r5360 - plog/branches/lifetype-1.2

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sat Apr 28 12:36:00 EDT 2007


Author: oscar
Date: 2007-04-28 12:36:00 -0400 (Sat, 28 Apr 2007)
New Revision: 5360

Modified:
   plog/branches/lifetype-1.2/wizard.php
Log:
Fixed at least part of the issues related to ugprading installations that are using user data providers. Rather than accessign the user data by looking at the lt_users table (which we shoulnd't have done in the first place) now we'll use the proper interfaces via the User class and let the user data provider handle the database logic for us. I have tested this fix with a phpbb2 integration and it seemed to work pretty well, although more testing would be good.

I've also fixed a few issues related to lt_include/include, it seems that lt_include doesn't work very well if we're including a file that for example defines an array rather than a class (it seems like the contents of the file don't get loaded)


Modified: plog/branches/lifetype-1.2/wizard.php
===================================================================
--- plog/branches/lifetype-1.2/wizard.php	2007-04-28 16:30:50 UTC (rev 5359)
+++ plog/branches/lifetype-1.2/wizard.php	2007-04-28 16:36:00 UTC (rev 5360)
@@ -31,52 +31,50 @@
 
     // many hosts don't have this enabled and we, for the time being, need it...
     ini_set("arg_seperator.output", "&");
-    
+
     include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
-    include_once( PLOG_CLASS_PATH."class/controller/controller.class.php" );
-    include_once( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
-    include_once( PLOG_CLASS_PATH."class/action/action.class.php" );
-    include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
-    include_once( PLOG_CLASS_PATH."class/template/template.class.php" );
-    include_once( PLOG_CLASS_PATH."class/view/view.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/usernamevalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );    
-    include_once( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
-    include_once( PLOG_CLASS_PATH."class/misc/version.class.php" );
-    include_once( PLOG_CLASS_PATH."class/file/file.class.php" );
-    include_once( PLOG_CLASS_PATH."class/file/finder/filefinder.class.php" );
-    include_once( PLOG_CLASS_PATH."class/gallery/resizers/gddetector.class.php" );
-    include_once( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
-    include_once( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-    include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
-    include_once( PLOG_CLASS_PATH."class/locale/localefinder.class.php" );
-    include_once( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
-    include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );     
-	include_once( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/permission.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/userpermission.class.php" );
-	include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/controller/controller.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/template/templateservice.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/action/action.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/template/template.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/view/view.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/usernamevalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.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/misc/version.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/file/finder/filefinder.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/gallery/resizers/gddetector.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/config/configfilestorage.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/locale/localefinder.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesets.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/blogcategories.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/globalarticlecategories.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );     
+	lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/permission.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/userpermission.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
     
     // table schemas
-    include_once( PLOG_CLASS_PATH."install/dbschemas.properties.php" );
+    include( PLOG_CLASS_PATH."install/dbschemas.properties.php" );
     // default configuration values for 1.1
-    include_once( PLOG_CLASS_PATH."install/defaultconfig.properties.php" );
-    // post schema changes after upgrade
-    include_once( PLOG_CLASS_PATH."install/changes_10_11.properties.php" );
+    include( PLOG_CLASS_PATH."install/defaultconfig.properties.php" );
 
     define( "TEMP_FOLDER", "./tmp" );
 
@@ -536,7 +534,7 @@
          */
         function getPageFromRequest()
         {
-            include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php");    	
+            lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php");    	
 			// get the value from the request
 			$page = HttpVars::getRequestValue( "page" );
 			// but first of all, validate it
@@ -1009,7 +1007,7 @@
             }
 
 			// load the core permissions
-		    include_once( PLOG_CLASS_PATH."install/corepermissions.properties.php" );
+		    include( PLOG_CLASS_PATH."install/corepermissions.properties.php" );
 
 		    // process permissions
 		    $total = 0;		
@@ -1294,7 +1292,7 @@
             }
             
             // clean the data cache to avoid problems when we're done
-            include_once( PLOG_CLASS_PATH."class/cache/cachemanager.class.php" );
+            lt_include( PLOG_CLASS_PATH."class/cache/cachemanager.class.php" );
             $cache =& CacheManager::getCache();
             $cache->clearCache();
 
@@ -1321,7 +1319,7 @@
     {
         function perform()
         {
-			include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+			lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
 			$config =& Config::getConfig();
 			$resourcesNamingRule = $config->getValue( "resources_naming_rule", "original_file_name" );
 			
@@ -1446,8 +1444,6 @@
 			$tablesArray = array_keys( $Tables );
 			$curTable = $tablesArray[$this->page-1];
 						
-			//print("Processing page: ".$this->page." - table: ".$curTable."<br/>" );			
-
 			$db =& Db::getDb();
             $dict = NewPDbDataDictionary( $db );
             $errors = false;
@@ -1564,7 +1560,7 @@
 			$errors = false;
 			
 			// load the core permissions
-		    include_once( PLOG_CLASS_PATH."install/corepermissions.properties.php" );	
+		    include( PLOG_CLASS_PATH."install/corepermissions.properties.php" );	
 
 		    // process permissions
 		    $total = 0;		
@@ -1719,30 +1715,37 @@
         
             // load each one of the categories and update them
             // list of categories
-            $query3 = "SELECT id, site_admin FROM ".$this->dbPrefix."users";
+            /*$query3 = "SELECT id, site_admin FROM ".$this->dbPrefix."users";
             $res3 = $this->Execute( $query3, $this->page, $this->itemsPerPage );
             if( $res3->RecordCount() == 0 ) {
 				$this->message .= "No more records to process";
 				return( true );
-			}
+			}*/
 			
+			$users = new Users();
+			$allUsers = $users->getAllUsers( USER_STATUS_ALL, "", "", $this->page, $this->itemsPerPage );
+			
 			$permissions = new Permissions();
 			$userPermissions = new UserPermissions();
 			$loginPerm = $permissions->getPermissionByName( "login_perm" );
 			$allPerms = $permissions->getAllPermissions();
 			
-            while( $row = $res3->FetchRow()) {
-            	if( $row["site_admin"] > 0 ) {
+            //while( $row = $res3->FetchRow()) {
+			foreach( $allUsers as $user ) {
+				print("Processing user: ".$user->getUsername()."<br/>");
+            	//if( $row["site_admin"] > 0 ) {
+				if( $user->isSiteAdmin()) {
 					// it's an admin, let's grant all the appropriate permissions
 					foreach( $allPerms as $perm ) {
 						if( $perm->isAdminOnlyPermission() && $perm->getName() != "login_perm" ) {
-							$userPerm = new UserPermission( $row["id"], 0, $perm->getId());
+							//$userPerm = new UserPermission( $row["id"], 0, $perm->getId());
+							$userPerm = new UserPermission( $user->getId(), 0, $perm->getId());
 							$userPermissions->grantPermission( $userPerm );
 						}
 					}
 				}
 				// grant the login_perm permission or else users won't be able to log in
-				$newPerm = new UserPermission( $row["id"], 0, $loginPerm->getId());
+				$newPerm = new UserPermission( $user->getId(), 0, $loginPerm->getId());
 				$userPermissions->grantPermission( $newPerm );
 				
 				$this->updatedRecords++;
@@ -2176,7 +2179,7 @@
                     else {
                         // no more data to transform, we can finalize the installation!
 						// delete the contents of the temporary folder
-						include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+						lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
 						$config =& Config::getConfig();
 						$tmpFolder = $config->getValue( "temp_folder", TEMP_FOLDER );
                         WizardTools::cleanTmpFolder();
@@ -2297,7 +2300,7 @@
                     else {
                         // no more data to transform, we can finalize the installation!
 						// delete the contents of the temporary folder
-						include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+						lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
 						$config =& Config::getConfig();
 						$tmpFolder = $config->getValue( "temp_folder", TEMP_FOLDER );
                         WizardTools::cleanTmpFolder();



More information about the pLog-svn mailing list