Add an option to keep deleted events, only an admin can purge them

This commit is contained in:
Nathan Gray 2010-03-05 20:01:44 +00:00
parent a6cc1cfe18
commit cb5054f2e4
4 changed files with 29 additions and 2 deletions

View File

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

View File

@ -380,8 +380,13 @@ class calendar_so
}
$where[] = '('.implode(' OR ',$to_or).')';
if($filter != 'deleted') {
$where[] = "sync_deleted IS NULL";
}
switch($filter)
{
case 'deleted':
$where[] = "sync_deleted IS NOT NULL"; break;
case 'unknown':
$where[] = "cal_status='U'"; break;
case 'accepted':
@ -417,7 +422,7 @@ class calendar_so
// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
$select = array(
'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' => "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=$this->cal_table.cal_id",
'cols' => $cols,
'where' => $where,
'app' => 'calendar',

View File

@ -719,6 +719,13 @@ class calendar_ui
list($label,$title) = $label;
$options .= '<option value="'.$value.'"'.($this->filter == $value ? ' selected="selected"' : '').' title="'.$title.'">'.$label.'</options>'."\n";
}
// Add in deleted for admins
$config = config::read('phpgwapi');
if($config['calendar_delete_history'] && $GLOBALS['egw_info']['user']['apps']['admin']) {
$options .= '<option value="deleted"'.($this->filter == 'deleted' ? ' selected="selected"' : '').' title="'.lang('Show events that have been deleted').'">'.lang('Deleted').'</options>'."\n";
}
$file[] = $this->_select_box('Filter','filter',$options,$baseurl ? $baseurl.'&filter=' : '');
// Calendarselection: User or Group

View File

@ -56,6 +56,18 @@
</select>
</td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_History_logging}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Prevent_deleting_of_entries}</td>
<td>
<select name="newsettings[calendar_delete_history]">
<option value="">{lang_No}</option>
<option value="history"{selected_calendar_delete_history_history}>{lang_Yes,_only_admins_can_purge_deleted_items}</option>
</select>
</td>
</tr>
<tr class="th">
<td colspan="2"><b>{lang_Birthdays}</b></td>
</tr>