PortingTikiWikiPackages

This is documentation of the process used while porting Trackers V2 from TikiWiki 1.9 to bitweaver.

Created by: Stephan Borg, Last modification: 18 May 2008 (20:42 UTC) by laetzer

Database Schema

Now for table creation - the TW1.9 database schema for Trackers 2 is quite lengthy, but we will use the main one as an example and explain the rest of the conversion in less detail. The main trackers table is as follows:


<?php
 CREATE TABLE tiki_trackers 
(
  
trackerId int(12NOT NULL auto_increment,
  
name varchar(80) default NULL,
  
description text,
  
created int(14) default NULL,
  
lastModif int(14) default NULL,
  
showCreated char(1) default NULL,
  
showStatus char(1) default NULL,
  
showLastModif char(1) default NULL,
  
useComments char(1) default NULL,
  
showComments char(1) default NULL,
  
useAttachments char(1) default NULL,
  
showAttachments char(1) default NULL,
  
orderAttachments varchar(255NOT NULL default 'filename,created,filesize,downloads,desc',
  
items int(10) default NULL,
  
PRIMARY KEY  (trackerId)
 ) 
TYPE=MyISAM AUTO_INCREMENT=;
?>


We need to create an AdoDB DataDict PHP file to create the tables as required. I have used the trackers file as a template and created trackers2/admin/schema_inc.php. This file shows how SQL create scripts are converted into DataDict PHP scripts. For more information, see DataDictTutorial.

<?php
$tables 
= array(
'tiki_trackers' => "
  tracker_id I4 AUTO PRIMARY,
  name C(80),
  description X,
  created I8,
  lastModif I8,
  showCreated C(1),
  showStatus C(1),
  showLastModif C(1),
  useComments C(1),
  showComments C(1),
  useAttachments C(1),
  showAttachments C(1),
  orderAttachments C(255) NOTNULL DEFAULT 'filename,created,filesize,downloads,desc',
  items I8
"
,
...
);

global 
$gTikiInstaller;
foreach( 
array_keys$tables ) AS $tableName ) {
    
$gTikiInstaller->registerSchemaTableTRACKERS2_PKG_DIR$tableName$tables[$tableName] );
}

After each of the tables have been specified, you would specify the indices. In this case, there are none.

Next we specify the inserts. These usually consist of permissions and default preferences.

<?php
$gTikiInstaller
->registerSchemaDefaultTRACKERS2_PKG_DIR, array(
    
"INSERT INTO `".TIKI_DB_PREFIX."users_permissions` (`perm_name`, `perm_desc`, `level`, `package`)
    VALUES ('tiki_p_admin_trackers', 'Can admin trackers', 'editors', 'trackers')"
,
...
    
"INSERT INTO `".TIKI_DB_PREFIX."tiki_preferences`(`package`,`name`,`value`) VALUES ('trackers2',
    'feature_trackers', 'n')"
) );
?>
?>