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

// start 0.6.5 -> 0.7.1 
	$sql  = "CREATE TABLE ".TABLE."_permission (";
	$sql .= "  permissionID int(4) NOT NULL auto_increment,";
	$sql .= "  name varchar(64) NOT NULL default '',";
	$sql .= "  type varchar(64) NOT NULL default '',";
	$sql .= "  value int(10) unsigned NOT NULL default '0',";
	$sql .= "  parameter varchar(64) NOT NULL default '',";
	$sql .= "  PRIMARY KEY  (permissionID),";
	$sql .= "  UNIQUE KEY name (name,parameter,type)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	mysql_query("ALTER TABLE ".TABLE."_columns ADD options INT(10) UNSIGNED DEFAULT '1' NOT NULL AFTER mfolder;");

	$sql =  "CREATE TABLE ".TABLE."_forum_category (".
			"  categoryID int(10) unsigned NOT NULL auto_increment,".
			"  name varchar(255) NOT NULL default '',".
			"  description text NOT NULL,".
			"  options int(10) unsigned NOT NULL default '0',".
			"  datetime datetime NOT NULL default '0000-00-00 00:00:00',".
			"  parentID int(10) unsigned NOT NULL default '0',".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  leftID int(10) unsigned NOT NULL default '0',".
			"  rightID int(10) unsigned NOT NULL default '0',".
			"  level int(10) unsigned NOT NULL default '0',".
			"  order_num int(10) unsigned NOT NULL default '0',".
			"  PRIMARY KEY  (categoryID)".
			") TYPE=MyISAM;";
			
	$sql .= "INSERT INTO ".TABLE."_forum_category VALUES (1, 'Test Forum', 'Dies ist ein kleines Test Forum ... Mal schauen wie das alles so weiter geht :)', 1, '2004-05-02 14:56:10', 0, 1, 1, 2, 1, 1);";
	
	$sql .= "CREATE TABLE ".TABLE."_forum_message (".
			"  messageID int(10) unsigned NOT NULL auto_increment,".
			"  userID int(10) unsigned NOT NULL default '0',".
			"  title varchar(255) NOT NULL default '',".
			"  message text NOT NULL,".
			"  originalMessage text NOT NULL,".
			"  insertDate datetime NOT NULL default '0000-00-00 00:00:00',".
			"  editDate datetime NOT NULL default '0000-00-00 00:00:00',".
			"  parentID int(10) unsigned NOT NULL default '0',".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  leftID int(10) unsigned NOT NULL default '0',".
			"  rightID int(10) unsigned NOT NULL default '0',".
			"  level int(10) unsigned NOT NULL default '0',".
			"  order_num int(10) unsigned NOT NULL default '0',".
			"  PRIMARY KEY  (messageID)".
			") TYPE=MyISAM;";
	
	$sql .= "CREATE TABLE ".TABLE."_forum_thread (".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  categoryID int(10) unsigned NOT NULL default '0',".
			"  options int(10) unsigned NOT NULL default '0',".
			"  lastModified datetime NOT NULL default '0000-00-00 00:00:00'".
			") TYPE=MyISAM;";
	
	if(mysql_query($sql)) {
		$messageList[] = "Forum Tables created";
	}
	
	mysql_query("ALTER TABLE ".TABLE."_forum_thread ADD lastModifiedBy INT( 10 ) UNSIGNED NOT NULL;");
	
	define("ADMIN",         1 << 0);  // wer weiss was 1 << 0 bedeutet, darf vielleicht Admin werden
	define("COL_MNG",       1 << 8);  // Rubriken verwalten duerfen
	
	$groupQuery = mysql_query("SELECT * FROM ".TABLE."_usergroups AS ugroup LEFT JOIN cb_perms as perm ON ugroup.permID = perm.permID");
	while($groupRow = mysql_fetch_assoc($groupQuery)) {
		$groupRow['system'] &= ~COL_MNG;
		mysql_query("UPDATE ".TABLE."_perms SET system = '".$groupRow['system']."' WHERE permID = '".$groupRow['permID']."'");
		mysql_query("INSERT INTO ".TABLE."_permission (name, type, value, parameter) VALUES ('general', 'columnPerms', '31', '".$groupRow['groupID']."')");
		$messageList[] = "Permission Column Management for group ".$groupRow['name']." removed";
		$messageList[] = "General Permission Set for group ".$groupRow['name']." created";
	}
	
	$userQuery = mysql_query("SELECT * FROM ".TABLE."_user AS user LEFT JOIN cb_perms as perm ON user.userid = perm.permID");
	while($userRow = mysql_fetch_assoc($userQuery)) {
		if(!(ADMIN & $userRow['system'])) {
			$userRow['system'] &= ~COL_MNG;
			mysql_query("UPDATE ".TABLE."_perms SET system = '".$userRow['system']."' WHERE permID = '".$userRow['permID']."'");
			$messageList[] = "Permission 'Column Management' for user ".$userRow['fullname']." removed";
		}
	}
// end 0.7.1

?>
Return current item: Content*Builder