Change preserving deleted events. For speed improvements, use an extra column instead of joining to the sync tables

This commit is contained in:
Nathan Gray 2010-04-22 16:09:36 +00:00
parent 27e54cb692
commit 074b893e37
5 changed files with 27 additions and 6 deletions

View File

@ -1165,9 +1165,15 @@ class calendar_boupdate extends calendar_bo
if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
{ {
$config = config::read('phpgwapi'); $config = config::read('phpgwapi');
if(!$config['calendar_delete_history'] || $GLOBALS['egw']->contenthistory->getTSforAction('calendar', $cal_id, 'delete')) { if(!$config['calendar_delete_history'] || $event['deleted'])
{
$this->so->delete($cal_id); $this->so->delete($cal_id);
} }
elseif ($config['calendar_delete_history'])
{
$event['deleted'] = true;
$this->save($event);
}
$GLOBALS['egw']->contenthistory->updateTimeStamp('calendar',$cal_id,'delete',time()); $GLOBALS['egw']->contenthistory->updateTimeStamp('calendar',$cal_id,'delete',time());
// delete all links to the event // delete all links to the event

View File

@ -399,12 +399,12 @@ class calendar_so
if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
if($filter != 'deleted') { if($filter != 'deleted') {
$where[] = "sync_deleted IS NULL"; $where[] = "!cal_deleted";
} }
switch($filter) switch($filter)
{ {
case 'deleted': case 'deleted':
$where[] = "sync_deleted IS NOT NULL"; break; $where[] = "cal_deleted"; break;
case 'unknown': case 'unknown':
$where[] = "cal_status='U'"; break; $where[] = "cal_status='U'"; break;
case 'accepted': case 'accepted':
@ -448,7 +448,7 @@ class calendar_so
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5 // changed the original OR in the query into a union, to speed up the query execution under MySQL 5
$select = array( $select = array(
'table' => $this->cal_table, 'table' => $this->cal_table,
'join' => "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id JOIN egw_api_content_history ON egw_api_content_history.sync_appname = 'calendar' AND egw_api_content_history.sync_contentid = $history_id", 'join' => "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id",
'cols' => $cols, 'cols' => $cols,
'where' => $where, 'where' => $where,
'app' => 'calendar', 'app' => 'calendar',

View File

@ -10,7 +10,7 @@
*/ */
$setup_info['calendar']['name'] = 'calendar'; $setup_info['calendar']['name'] = 'calendar';
$setup_info['calendar']['version'] = '1.7.010'; $setup_info['calendar']['version'] = '1.7.011';
$setup_info['calendar']['app_order'] = 3; $setup_info['calendar']['app_order'] = 3;
$setup_info['calendar']['enable'] = 1; $setup_info['calendar']['enable'] = 1;
$setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index'; $setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index';
@ -66,3 +66,4 @@ $setup_info['calendar']['check_install'] = array(
), ),
); );

View File

@ -30,7 +30,8 @@ $phpgw_baseline = array(
'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'), 'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'),
'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'), 'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'),
'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'), 'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'),
'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones') 'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'),
'cal_deleted' => array('type' => 'bool','nullable' => False,'default' => '0','comment' => '1 if the event has been deleted, but you want to keep it around')
), ),
'pk' => array('cal_id'), 'pk' => array('cal_id'),
'fk' => array(), 'fk' => array(),

View File

@ -2077,3 +2077,16 @@ function calendar_upgrade1_7_009()
return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010'; return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010';
} }
function calendar_upgrade1_7_010()
{
$GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_deleted',array(
'type' => 'bool',
'nullable' => False,
'default' => '0',
'comment' => '1 if the event has been deleted, but you want to keep it around'
));
return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.011';
}