Update to move resource pictures in the regular attachment dir with name

.picture.jpg
This commit is contained in:
Ralf Becker 2008-10-10 17:51:06 +00:00
parent b7d41043ac
commit 82bbc1238f
3 changed files with 359 additions and 340 deletions

View File

@ -13,7 +13,7 @@
$setup_info['resources']['name'] = 'resources';
$setup_info['resources']['title'] = 'Resources';
$setup_info['resources']['version'] = '1.4';
$setup_info['resources']['version'] = '1.6';
$setup_info['resources']['app_order'] = 5;
$setup_info['resources']['tables'] = array('egw_resources','egw_resources_extra');
$setup_info['resources']['enable'] = 1;

View File

@ -1,5 +1,5 @@
<?php
/**
/**
* eGroupWare - resources
* http://www.egroupware.org
* Created by eTemplates DB-Tools written by ralfbecker@outdoor-training.de
@ -11,7 +11,7 @@
* @version $Id$
*/
$phpgw_baseline = array(
$phpgw_baseline = array(
'egw_resources' => array(
'fd' => array(
'res_id' => array('type' => 'auto'),
@ -47,4 +47,4 @@
'ix' => array(),
'uc' => array()
)
);
);

View File

@ -1,5 +1,5 @@
<?php
/**
/**
* eGroupWare - resources
* http://www.egroupware.org
* Created by eTemplates DB-Tools written by ralfbecker@outdoor-training.de
@ -11,9 +11,8 @@
* @version $Id$
*/
$test[] = '0.0.1.008';
function resources_upgrade0_0_1_008()
{
function resources_upgrade0_0_1_008()
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('egw_resources','picture_src',array(
'type' => 'varchar',
'precision' => '20'
@ -21,24 +20,22 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.012';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.012';
function resources_upgrade0_0_1_012()
{
function resources_upgrade0_0_1_012()
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('egw_resources','picture_thumb',array(
'type' => 'blob'
));
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.013';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.013';
function resources_upgrade0_0_1_013()
{
function resources_upgrade0_0_1_013()
{
$GLOBALS['phpgw_setup']->oProc->DropColumn('egw_resources',array(
'fd' => array(
'id' => array('type' => 'auto'),
@ -85,12 +82,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.014';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.014';
function resources_upgrade0_0_1_014()
{
function resources_upgrade0_0_1_014()
{
$GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_resources','quantity',array(
'type' => 'int',
'precision' => '11',
@ -104,12 +100,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.015';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.015';
function resources_upgrade0_0_1_015()
{
function resources_upgrade0_0_1_015()
{
$GLOBALS['phpgw_setup']->oProc->AlterColumn('egw_resources','accessories',array(
'type' => 'varchar',
'precision' => '100'
@ -126,12 +121,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.016';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.016';
function resources_upgrade0_0_1_016()
{
function resources_upgrade0_0_1_016()
{
$GLOBALS['phpgw_setup']->oProc->DropColumn('egw_resources',array(
'fd' => array(
'id' => array('type' => 'auto'),
@ -202,12 +196,11 @@
));
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.017';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.017';
function resources_upgrade0_0_1_017()
{
function resources_upgrade0_0_1_017()
{
$GLOBALS['phpgw_setup']->oProc->RenameColumn('egw_resources','id','res_id');
$GLOBALS['phpgw_setup']->oProc->RefreshTable('egw_resources',array(
'fd' => array(
@ -233,12 +226,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.018';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.018';
function resources_upgrade0_0_1_018()
{
function resources_upgrade0_0_1_018()
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('egw_resources','storage_info',array(
'type' => 'varchar',
'precision' => '200'
@ -246,12 +238,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.019';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.019';
function resources_upgrade0_0_1_019()
{
function resources_upgrade0_0_1_019()
{
$GLOBALS['phpgw_setup']->oProc->AddColumn('egw_resources','inventory_number',array(
'type' => 'varchar',
'precision' => '20'
@ -259,12 +250,11 @@
$GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.020';
return $GLOBALS['setup_info']['resources']['currentver'];
}
}
$test[] = '0.0.1.020';
function resources_upgrade0_0_1_020()
{
function resources_upgrade0_0_1_020()
{
$GLOBALS['egw_setup']->oProc->CreateTable('egw_resources_extra',array(
'fd' => array(
'extra_id' => array('type' => 'int','precision' => '4','nullable' => False),
@ -279,17 +269,46 @@
));
return $GLOBALS['setup_info']['resources']['currentver'] = '0.0.1.021';
}
}
$test[] = '0.0.1.021';
function resources_upgrade0_0_1_021()
{
function resources_upgrade0_0_1_021()
{
return $GLOBALS['setup_info']['resources']['currentver'] = '1.2';
}
}
$test[] = '1.2';
function resources_upgrade1_2()
{
function resources_upgrade1_2()
{
return $GLOBALS['setup_info']['resources']['currentver'] = '1.4';
}
/**
* Move resource pictures into the regular attachmen dirs with name .picture.jpg
*
* @return string
*/
function resources_upgrade1_4()
{
egw_vfs::$is_root = true;
egw_vfs::load_wrapper('sqlfs');
if (egw_vfs::is_dir('/resources/pictures'))
{
egw_vfs::remove('/resources/pictures/thumbs'); // remove thumb dir incl. thumbnails
foreach(egw_vfs::find('sqlfs://default/resources/pictures',array('url' => true)) as $url)
{
if (is_numeric($id = basename($url,'.jpg')))
{
if (!egw_vfs::is_dir($dir = "/apps/resources/$id"))
{
egw_vfs::mkdir($dir,0777,STREAM_MKDIR_RECURSIVE);
}
?>
rename($url,'sqlfs://default'.$dir.'/.picture.jpg'); // we need to rename on the same wrapper!
}
}
egw_vfs::rmdir('/resources/pictures',0);
egw_vfs::rmdir('/resources',0);
}
return $GLOBALS['setup_info']['resources']['currentver'] = '1.6';
}