Location: PHPKode > projects > Axis Groupware > musiclib/setup/tables_update.inc.php
<?php
  /**************************************************************************\
  * phpGroupWare - Setup                                                     *
  * http://www.phpgroupware.org                                              *
  * --------------------------------------------                             *
  *  This program is free software; you can redistribute it and/or modify it *
  *  under the terms of the GNU General Public License as published by the   *
  *  Free Software Foundation; either version 2 of the License, or (at your  *
  *  option) any later version.                                              *
  \**************************************************************************/

	$test[] = '1.1.5';
	function musiclib_upgrade1_1_5() 
	{

		echo "Renaming _playlist_contents table to _playlistdata to support pgsql short table names<br>";
		$GLOBALS['phpgw_setup']->oProc->RenameTable('phpgw_musiclib_playlist_contents','phpgw_musiclib_playlistdata');	

		# phpgw_config
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_music_url','http://mp3.dev.axisgroupware.org')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_music_dir','/music')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_albums_subdir','/albums')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_misc_subdir','/misc')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_filename_format','1')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_separator',' - ')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_file_extensions','mp3 Mp3 MP3 ogg Ogg OGG')");
		
		# hook admin
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_hooks (hook_appname, hook_location, hook filename) VALUES ('musiclib','admin','hook_admin.inc.php')");
		
		# update version number
		$GLOBALS['setup_info']['axislinks']['currentver'] = '1.1.8';
		return $GLOBALS['setup_info']['axislinks']['currentver'];
	}

	$test[] = '1.1.8';
	function musiclib_upgrade1_1_8() 
	{
		# Drop _misc
		echo "Dropping misc table<br>";
		$GLOBALS['phpgw_setup']->oProc->DropTable('phpgw_musiclib_misc');
		
		echo "Adding column path to songs table<br>";
		$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_musiclib_songs', 'path', 
												  array('type' => 'varchar','precision' => 255));

		echo "Adding column filename to songs table<br>";
		$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_musiclib_songs', 'filename', 
												  array('type' => 'varchar','precision' => 255));

		echo "Adding column repository to songs table<br>";
		$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_musiclib_songs', 'repository', 
												  array('type' => 'int','precision' => 2));

		echo "Dropping column song_table from playlistdata table<br>";
		$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_musiclib_playlistdata',array(
			'fd' => array(
				'id' => array('type' => 'auto', 'nullable' => false),
				'playlist_id' => array('type' => 'int', 'precision' => 8),
				'play_order'  => array('type' => 'int', 'precision' => 8),
				
				# this duplication exists so that an attempt can be made to self-repair a playlist
				# in the case where songs are removed and reinserted into the database
				'artist_name' => array('type' => 'varchar', 'precision' => 255),
				'album_title' => array('type' => 'varchar', 'precision' => 255),
				'track' => array('type' => 'varchar', 'precision' => 2),
				
				'song_id' => array('type' => 'int', 'precision' => 8)
			),
			'pk' => array('id'),
			'fk' => array('playlist_id,song_id'),
			'ix' => array(),
			'uc' => array()
		),'song_table');

		# update version number
		$GLOBALS['setup_info']['axislinks']['currentver'] = '1.2';
		return $GLOBALS['setup_info']['axislinks']['currentver'];
	}
	
	$test[] = '1.2';
	function musiclib_upgrade1_2() 
	{
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_remote_library','2')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_music_list','/music')");
		$GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_config (config_app, config_name, config_value) VALUES ('musiclib','musiclib_validation','1')");

		$GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_config SET config_name='musiclib_libraries' WHERE config_name='musiclib_url'");
		$GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_config SET config_name='musiclib_path' WHERE config_name='musiclib_dir'");

		$GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_config WHERE config_name='musiclib_filename_format'");

	
		# update version number
		$GLOBALS['setup_info']['axislinks']['currentver'] = '1.2.5';
		return $GLOBALS['setup_info']['axislinks']['currentver'];
	}
?>
Return current item: Axis Groupware