Deleted recurrences (exceptions) now show when using deleted filter

This commit is contained in:
Nathan Gray 2012-10-31 22:48:12 +00:00
parent 7bb16b4823
commit a6de0724bb
2 changed files with 54 additions and 10 deletions

View File

@ -487,7 +487,11 @@ class calendar_so
$where['cal_public'] = 1; $where['cal_public'] = 1;
$where[] = "$this->user_table.cal_status NOT IN ('R','X')"; break; $where[] = "$this->user_table.cal_status NOT IN ('R','X')"; break;
case 'deleted': case 'deleted':
$where[] = 'cal_deleted IS NOT NULL'; break; // Change source of recur date to get deleted recurrence exceptions
$cols = str_replace("{$this->user_table}.cal_recur_date","{$this->dates_table}.cal_start AS cal_recur_date",$cols);
$remove_rejected_by_user = false;
$where[] = "$this->user_table.cal_recur_date=0";
$where[] = "($this->cal_table.cal_deleted IS NOT NULL OR (recur_exception=1 AND $this->user_table.cal_recur_date = 0))"; break;
case 'unknown': case 'unknown':
$where[] = "$this->user_table.cal_status='U'"; break; $where[] = "$this->user_table.cal_status='U'"; break;
case 'not-unknown': case 'not-unknown':
@ -571,6 +575,11 @@ class calendar_so
if ($params['enum_recuring']) // dates table join only needed to enum recuring events if ($params['enum_recuring']) // dates table join only needed to enum recuring events
{ {
$select['join'] = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$select['join']; $select['join'] = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$select['join'];
// Add in deleted exceptions to recurring
if($filter == 'deleted')
{
$select['join'] .= "LEFT JOIN (SELECT egw_cal.cal_reference AS ref, egw_cal.cal_recurrence AS rec FROM $this->cal_table) AS cal_exception ON $this->cal_table.cal_id = cal_exception.ref AND $this->dates_table.cal_start = cal_exception.rec ";
}
} }
$selects = array(); $selects = array();
// we check if there are parts to use for the construction of our UNION query, // we check if there are parts to use for the construction of our UNION query,
@ -582,8 +591,11 @@ class calendar_so
$selects[] = $select; $selects[] = $select;
$selects[count($selects)-1]['where'][] = $user_sql; $selects[count($selects)-1]['where'][] = $user_sql;
if ($params['enum_recuring']) if ($params['enum_recuring'])
{
if($filter != 'deleted')
{ {
$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
}
$selects[] = $select; $selects[] = $select;
$selects[count($selects)-1]['where'][] = $user_sql; $selects[count($selects)-1]['where'][] = $user_sql;
$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
@ -595,8 +607,11 @@ class calendar_so
$selects[] = $select; $selects[] = $select;
$selects[count($selects)-1]['where'][] = $owner_or; $selects[count($selects)-1]['where'][] = $owner_or;
if ($params['enum_recuring']) if ($params['enum_recuring'])
{
if($filter != 'deleted')
{ {
$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
}
$selects[] = $select; $selects[] = $select;
$selects[count($selects)-1]['where'][] = $owner_or; $selects[count($selects)-1]['where'][] = $owner_or;
$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
@ -608,8 +623,11 @@ class calendar_so
// if the query is to be filtered by neither by user nor owner (should not happen?) we need 2 selects for the union // if the query is to be filtered by neither by user nor owner (should not happen?) we need 2 selects for the union
$selects[] = $select; $selects[] = $select;
if ($params['enum_recuring']) if ($params['enum_recuring'])
{
if($filter != 'deleted')
{ {
$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
}
$selects[] = $select; $selects[] = $select;
$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
} }
@ -625,6 +643,10 @@ class calendar_so
{ {
$selects[$key]['cols'] = str_replace('cal_start','MIN(cal_start) AS cal_start',$selects[$key]['cols']); $selects[$key]['cols'] = str_replace('cal_start','MIN(cal_start) AS cal_start',$selects[$key]['cols']);
} }
if($filter == 'deleted')
{
$selects[$key]['cols'] = str_replace("{$this->user_table}.cal_recur_date","{$this->dates_table}.cal_start AS cal_recur_date",$selects[$key]['cols']);
}
} }
if (!isset($param['cols'])) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); if (!isset($param['cols'])) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);

View File

@ -364,6 +364,13 @@ class calendar_uilist extends calendar_ui
{ {
$event['class'] .= 'rowDeleted '; $event['class'] .= 'rowDeleted ';
} }
// Disable everything for 'deleted' exceptions - there's nothing
// logical to do except undelete it
if($search_params['filter'] == 'deleted' && $event['recur_type'])
{
$event['class'] .= ' rowNoView rowNoDelete rowDeleted';
}
// Filemanager disabled for other applications // Filemanager disabled for other applications
$readonlys['filemanager['.$event['id'].']'] = !is_numeric($event['id']); $readonlys['filemanager['.$event['id'].']'] = !is_numeric($event['id']);
@ -591,8 +598,9 @@ class calendar_uilist extends calendar_ui
break; break;
case 'undelete': case 'undelete':
$action_msg = lang('recovered'); $action_msg = lang('recovered');
if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id) && if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(EGW_ACL_EDIT,$id))
is_array($event) && $event['deleted']) {
if(is_array($event) && $event['deleted'])
{ {
$event['deleted'] = null; $event['deleted'] = null;
if($this->bo->save($event)) if($this->bo->save($event))
@ -601,6 +609,19 @@ class calendar_uilist extends calendar_ui
break; break;
} }
} }
// Undelete an exception by removing it
else if (is_array($event) && $event['recur_type'])
{
$original = $this->bo->read($id);
$key = array_search($recur_date, $original['recur_exception']);
if($key !== false) unset($original['recur_exception'][$key]);
if($key !== false && $this->bo->save($original))
{
$success++;
break;
}
}
}
$failed++; $failed++;
break; break;
case 'status': case 'status':
@ -843,6 +864,7 @@ class calendar_uilist extends calendar_ui
$actions['undelete'] = array( $actions['undelete'] = array(
'caption' => 'Un-delete', 'caption' => 'Un-delete',
'hint' => 'Recover this event', 'hint' => 'Recover this event',
'icon' => 'revert',
'group' => $group, 'group' => $group,
'enabled' => 'javaScript:nm_enableClass', 'enabled' => 'javaScript:nm_enableClass',
'enableClass' => 'rowDeleted', 'enableClass' => 'rowDeleted',