Using db wrappers in schema_proc, add missing function

This commit is contained in:
Miles Lott 2001-06-11 01:55:38 +00:00
parent f6bfb99964
commit bee1d3fa6f

View File

@ -11,12 +11,43 @@
/* $Id$ */
function calendar_v0_9_2to0_9_3update_owner($table, $field)
{
global $phpgw_setup, $phpgw_setup;
$oProc = $phpgw_setup->oProc;
$oProc->query("select distinct($field) from $table");
if ($oProc->num_rows())
{
while ($oProc->next_record())
{
$owner[count($owner)] = $oProc->f($field);
}
if($phpgw_setup->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre4'))
{
$acctstbl = 'accounts';
}
else
{
$acctstbl = 'phpgw_accounts';
}
for($i=0;$i<count($owner);$i++)
{
$oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'");
$oProc->next_record();
$oProc->query("UPDATE $table SET $field=".$oProc->f("account_id")." WHERE $field='".$owner[$i]."'");
}
}
$oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0));
}
$test[] = '0.9.3pre1';
function calendar_upgrade0_9_3pre1()
{
global $setup_info;
v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by');
v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login');
calendar_v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by');
calendar_v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login');
$setup_info['calendar']['currentver'] = '0.9.3pre2';
return True;
}
@ -40,7 +71,7 @@
global $setup_info, $phpgw_setup;
$oProc = $phpgw_setup->oProc;
$db2 = $oProc->m_odb;
$db2 = $oProc;
$oProc->CreateTable('calendar_entry', array(
'fd' => array(
@ -62,23 +93,23 @@
'uc' => array()
));
$oProc->m_odb->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__);
$oProc->m_odb->next_record();
if($oProc->m_odb->f(0))
$oProc->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__);
$oProc->next_record();
if($oProc->f(0))
{
$oProc->m_odb->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->m_odb->next_record())
$oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->next_record())
{
$cal_id = $oProc->m_odb->f('cal_id');
$cal_owner = $oProc->m_odb->f('cal_owner');
$cal_duration = $oProc->m_odb->f('cal_duration');
$cal_priority = $oProc->m_odb->f('cal_priority');
$cal_type = $oProc->m_odb->f('cal_type');
$cal_access = $oProc->m_odb->f('cal_access');
$cal_name = $oProc->m_odb->f('cal_name');
$cal_description = $oProc->m_odb->f('cal_description');
$datetime = mktime(intval(strrev(substr(strrev($oProc->m_odb->f('cal_time')),4))),intval(strrev(substr(strrev($oProc->m_odb->f('cal_time')),2,2))),intval(strrev(substr(strrev($oProc->m_odb->f('cal_time')),0,2))),intval(substr($oProc->m_odb->f('cal_date'),4,2)),intval(substr($oProc->m_odb->f('cal_date'),6,2)),intval(substr($oProc->m_odb->f('cal_date'),0,4)));
$moddatetime = mktime(intval(strrev(substr(strrev($oProc->m_odb->f('cal_mod_time')),4))),intval(strrev(substr(strrev($oProc->m_odb->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($oProc->m_odb->f('cal_mod_time')),0,2))),intval(substr($oProc->m_odb->f('cal_mod_date'),4,2)),intval(substr($oProc->m_odb->f('cal_mod_date'),6,2)),intval(substr($oProc->m_odb->f('cal_mod_date'),0,4)));
$cal_id = $oProc->f('cal_id');
$cal_owner = $oProc->f('cal_owner');
$cal_duration = $oProc->f('cal_duration');
$cal_priority = $oProc->f('cal_priority');
$cal_type = $oProc->f('cal_type');
$cal_access = $oProc->f('cal_access');
$cal_name = $oProc->f('cal_name');
$cal_description = $oProc->f('cal_description');
$datetime = mktime(intval(strrev(substr(strrev($oProc->f('cal_time')),4))),intval(strrev(substr(strrev($oProc->f('cal_time')),2,2))),intval(strrev(substr(strrev($oProc->f('cal_time')),0,2))),intval(substr($oProc->f('cal_date'),4,2)),intval(substr($oProc->f('cal_date'),6,2)),intval(substr($oProc->f('cal_date'),0,4)));
$moddatetime = mktime(intval(strrev(substr(strrev($oProc->f('cal_mod_time')),4))),intval(strrev(substr(strrev($oProc->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($oProc->f('cal_mod_time')),0,2))),intval(substr($oProc->f('cal_mod_date'),4,2)),intval(substr($oProc->f('cal_mod_date'),6,2)),intval(substr($oProc->f('cal_mod_date'),0,4)));
$db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id,__LINE__,__FILE__);
$db2->next_record();
$cal_group = $db2->f('groups');
@ -102,16 +133,16 @@
'uc' => array()
));
$oProc->m_odb->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__);
$oProc->m_odb->next_record();
if($oProc->m_odb->f(0))
$oProc->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__);
$oProc->next_record();
if($oProc->f(0))
{
$oProc->m_odb->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->m_odb->next_record())
$oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->next_record())
{
$cal_id = $oProc->m_odb->f('cal_id');
$cal_login = $oProc->m_odb->f('cal_login');
$cal_status = $oProc->m_odb->f('cal_status');
$cal_id = $oProc->f('cal_id');
$cal_login = $oProc->f('cal_login');
$cal_status = $oProc->f('cal_status');
$db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')",__LINE__,__FILE__);
}
}
@ -133,18 +164,18 @@
'uc' => array()
));
$oProc->m_odb->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__);
$oProc->m_odb->next_record();
if($oProc->m_odb->f(0))
$oProc->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__);
$oProc->next_record();
if($oProc->f(0))
{
$oProc->m_odb->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->m_odb->next_record())
$oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__);
while($oProc->next_record())
{
$cal_id = $oProc->m_odb->f('cal_id');
$cal_type = $oProc->m_odb->f('cal_type');
if(isset($oProc->m_odb->Record['cal_end']))
$cal_id = $oProc->f('cal_id');
$cal_type = $oProc->f('cal_type');
if(isset($oProc->Record['cal_end']))
{
$enddate = mktime(0,0,0,intval(substr($oProc->m_odb->f('cal_end'),4,2)),intval(substr($oProc->m_odb->f('cal_end'),6,2)),intval(substr($oProc->m_odb->f('cal_end'),0,4)));
$enddate = mktime(0,0,0,intval(substr($oProc->f('cal_end'),4,2)),intval(substr($oProc->f('cal_end'),6,2)),intval(substr($oProc->f('cal_end'),0,4)));
$useend = 1;
}
else
@ -152,14 +183,14 @@
$enddate = 0;
$useend = 0;
}
$cal_frequency = $oProc->m_odb->f('cal_frequency');
$cal_days = $oProc->m_odb->f('cal_days');
$cal_frequency = $oProc->f('cal_frequency');
$cal_days = $oProc->f('cal_days');
$db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__);
}
}
$oProc->DropTable('webcal_entry_repeats');
$oProc->m_odb->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
$oProc->query("UPDATE applications SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__);
$setup_info['calendar']['currentver'] = '0.9.7pre2';
return True;
@ -171,21 +202,21 @@
global $oldversion, $setup_info, $phpgw_setup, $oProc, $oDelta;
$oProc = $phpgw_setup->oProc;
$db2 = $oProc->m_odb;
$db2 = $oProc;
$oProc->RenameColumn('calendar_entry', 'cal_duration', 'cal_edatetime');
$oProc->m_odb->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__);
if($oProc->m_odb->num_rows())
$oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__);
if($oProc->num_rows())
{
while($oProc->m_odb->next_record())
while($oProc->next_record())
{
$db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$phpgw_setup->db->f('cal_owner'),__LINE__,__FILE__);
$db2->next_record();
$tz = $db2->f('preference_value');
$cal_id = $oProc->m_odb->f('cal_id');
$datetime = $oProc->m_odb->f("cal_datetime") - ((60 * 60) * $tz);
$mdatetime = $oProc->m_odb->f("cal_mdatetime") - ((60 * 60) * $tz);
$edatetime = $datetime + (60 * $oProc->m_odb->f("cal_edatetime"));
$cal_id = $oProc->f('cal_id');
$datetime = $oProc->f("cal_datetime") - ((60 * 60) * $tz);
$mdatetime = $oProc->f("cal_mdatetime") - ((60 * 60) * $tz);
$edatetime = $datetime + (60 * $oProc->f("cal_edatetime"));
$db2->query("UPDATE calendar_entry SET cal_datetime=".$datetime.", cal_edatetime=".$edatetime.", cal_mdatetime=".$mdatetime." WHERE cal_id=".$cal_id,__LINE__,__FILE__);
}
}
@ -208,7 +239,7 @@
global $setup_info, $phpgw_setup;
$oProc = $phpgw_setup->oProc;
$db2 = $oProc->m_odb;
$db2 = $oProc;
if(extension_loaded('mcal') == False)
{
@ -252,12 +283,12 @@
)
);
$oProc->m_odb->query('SELECT * FROM calendar_entry',__LINE__,__FILE__);
while($oProc->m_odb->next_record())
$oProc->query('SELECT * FROM calendar_entry',__LINE__,__FILE__);
while($oProc->next_record())
{
$id = $oProc->m_odb->f('cal_id');
$owner = $oProc->m_odb->f('cal_owner');
$access = $oProc->m_odb->f('cal_access');
$id = $oProc->f('cal_id');
$owner = $oProc->f('cal_owner');
$access = $oProc->f('cal_access');
switch($access)
{
case 'private':
@ -270,14 +301,14 @@
$is_public = 2;
break;
}
$groups = $oProc->m_odb->f('cal_group');
$datetime = $oProc->m_odb->f('cal_datetime');
$mdatetime = $oProc->m_odb->f('cal_mdatetime');
$edatetime = $oProc->m_odb->f('cal_edatetime');
$priority = $oProc->m_odb->f('cal_priority');
$type = $oProc->m_odb->f('cal_type');
$title = $oProc->m_odb->f('cal_name');
$description = $oProc->m_odb->f('cal_description');
$groups = $oProc->f('cal_group');
$datetime = $oProc->f('cal_datetime');
$mdatetime = $oProc->f('cal_mdatetime');
$edatetime = $oProc->f('cal_edatetime');
$priority = $oProc->f('cal_priority');
$type = $oProc->f('cal_type');
$title = $oProc->f('cal_name');
$description = $oProc->f('cal_description');
$db2->query("INSERT INTO phpgw_cal(cal_id,owner,groups,datetime,mdatetime,edatetime,priority,cal_type,is_public,title,description) "
. "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')",__LINE__,__FILE__);
@ -299,11 +330,11 @@
'ix' => array(),
'uc' => array()
));
$oProc->m_odb->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__);
while($oProc->m_odb->next_record())
$oProc->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__);
while($oProc->next_record())
{
$id = $oProc->m_odb->f('cal_id');
$recur_type = $oProc->m_odb->f('cal_type');
$id = $oProc->f('cal_id');
$recur_type = $oProc->f('cal_type');
switch($recur_type)
{
case 'daily':
@ -322,10 +353,10 @@
$recur_type_num = RECUR_YEARLY;
break;
}
$recur_end_use = $oProc->m_odb->f('cal_use_end');
$recur_end = $oProc->m_odb->f('cal_end');
$recur_interval = $oProc->m_odb->f('cal_frequency');
$days = strtoupper($oProc->m_odb->f('cal_days'));
$recur_end_use = $oProc->f('cal_use_end');
$recur_end = $oProc->f('cal_end');
$recur_interval = $oProc->f('cal_frequency');
$days = strtoupper($oProc->f('cal_days'));
$recur_data = 0;
$recur_data += (substr($days,0,1)=='Y'?M_SUNDAY:0);
$recur_data += (substr($days,1,1)=='Y'?M_MONDAY:0);