Location: PHPKode > projects > Content*Builder > contentbuilder/system/setup/updates/update_060_061.php
<?php

// start 0.6.0 - 0.6.1 Updates
	/*
	* Comments updaten
	*/
	$query = mysql_query("SELECT * FROM ".TABLE."_comments");
	while($resultRow = mysql_fetch_object($query)) {
		$tmpQuery = mysql_query("INSERT INTO ".TABLE."_comment (type, entryID, author, title, text, datetime, homepage, email) VALUES ('article', '".$resultRow->ide."', '".$resultRow->cmauthor."', '".$resultRow->cmheadline."', '".$resultRow->cmtext."', '".$resultRow->cmdatum."', '".$resultRow->cmhomepage."', '".$resultRow->cmemail."')");
	}
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_comment COMMENT = 'v0.2'");
	
	/*
	* Article2 Nested Set Update
	*/
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_art_general ADD parentID INT( 10 ) UNSIGNED NOT NULL, ADD rootID INT( 10 ) UNSIGNED NOT NULL, ADD leftID INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL, ADD rightID INT( 10 ) UNSIGNED DEFAULT '2' NOT NULL, ADD level INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL, ADD order_num INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL");
	$tmpQuery = mysql_query("UPDATE ".TABLE."_art_general SET rootID = ide");
	
	/* 
	* Folder Nested Set Update
	*/
	require_once("../../".$cbDirLib."CB_NestedSet.class.php");
	
	$sql = "DROP TABLE IF EXISTS ".TABLE."_columns_temp";
	mysql_query($sql);
	
	$sql = 'CREATE TABLE '.TABLE.'_columns_temp( fname varchar( 40 ) NOT NULL default \'\',';
	$sql .= 'fid int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'writestatus char( 2 ) NOT NULL default \'\',';
	$sql .= 'describt text,';
	$sql .= 'loadurl varchar( 255 ) default NULL ,';
	$sql .= 'status int( 8 ) default NULL ,';
	$sql .= 'mfolder int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'usersallowed text,';
	$sql .= 'groupsAllowed varchar( 255 ) default NULL ,';
	$sql .= 'skin varchar( 255 ) NOT NULL default \'\',';
	$sql .= 'rootID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'leftID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'rightID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'level int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'order_num int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= ' KEY rootID( rootID ) ,';
	$sql .= ' KEY leftID( leftID ) ,';
	$sql .= ' KEY rightID( rightID ) ,';
	$sql .= ' KEY level ( level ) ,';
	$sql .= ' KEY order_num( order_num ) ) TYPE = MYISAM ';
 	mysql_query($sql);
	/* 
	* Initialisierung der NeSet Array's für das 
	* Folder Nested Set Objekt 
	*/
	$folderParams = array (
		'table'  => TABLE.'_columns_temp',
		'id'     => 'fid',
		'parent' => 'mfolder',
		'root'   => 'rootID',
		'l'   => 'leftID',
		'r'  => 'rightID',
		'level'  => 'level',
		'norder'  => 'order_num'
	);
	
	$folderAdditional = array (
		'name'          => 'fname',
		'status'        => 'status',
		'writestatus'   => 'writestatus',
		'description'   => 'describt',
		'loadurl'       => 'loadurl',
		'usersallowed'  => 'usersallowed',
		'groupsAllowed' => 'groupsAllowed',
		'skin'          => 'skin'
	);
	
	$nestedSet = CB_NestedSet::factory($folderParams, $folderAdditional);
	
	$counter = 1;
	$nodeQuery = mysql_query("SELECT SUBSTRING(status,5) as level, status, fname, fid, mfolder, writestatus, describt, loadurl, usersallowed, groupsAllowed, skin FROM ".TABLE."_columns ORDER BY level ASC");
	while($nodeRow = mysql_fetch_object($nodeQuery)) {
		if($nodeRow->status != null) {
			$ns_values = array (
				"name"          => $nodeRow->fname,
				"status"        => $nodeRow->status,
				"writestatus"   => $nodeRow->writestatus,
				"description"   => $nodeRow->describt,
				"loadurl"       => $nodeRow->loadurl,
				"usersallowed"  => $nodeRow->usersallowed,
				"groupsAllowed" => $nodeRow->groupsAllowed,
				"skin"          => $nodeRow->skin
			);
			if($nodeRow->mfolder == "" || $nodeRow->mfolder == "0") {
				$new_id = $nestedSet->createRootNode($ns_values);
			} else {
				$mfolder = $nodeRow->mfolder;
				$new_id = $nestedSet->createSubNode($oldID_newID[$mfolder], $ns_values);
			}
			$oldID_newID[$nodeRow->fid] = $new_id;
		}
	}
	foreach ($oldID_newID as $k => $v) {
		mysql_query("UPDATE ".TABLE."_article SET folder = '$v' WHERE folder = '$k'");
		mysql_query("UPDATE ".TABLE."_art_general SET folderID = '$v' WHERE folderID = '$k'");
	}
	mysql_query("CREATE TABLE IF NOT EXISTS ".TABLE."_columns_backup SELECT * FROM ".TABLE."_columns");
	mysql_query("DROP TABLE ".TABLE."_columns");
	mysql_query("RENAME TABLE ".TABLE."_columns_temp TO ".TABLE."_columns");
	
	// Statistik Update
	mysql_query("ALTER TABLE ".TABLE."_sext_statistik CHANGE time datetime DATETIME DEFAULT '0' NOT NULL");	
// end 0.6.0 - 0.6.1 Updates

?>
Return current item: Content*Builder