mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-27 10:23:28 +01:00
Fix iCal export selectors & date defaults
This commit is contained in:
parent
8eb52a2f1d
commit
ba7cd8a7ca
@ -84,6 +84,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$query += $this->get_query_month($states);
|
||||
break;
|
||||
case 'week':
|
||||
case 'weekN':
|
||||
$query += $this->get_query_week($states);
|
||||
break;
|
||||
case 'day':
|
||||
@ -96,7 +97,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
{
|
||||
ob_start();
|
||||
$ui->$states['view']();
|
||||
ob_end_flush();
|
||||
ob_end_clean();
|
||||
}
|
||||
$query += array(
|
||||
'start' => is_array($ui->first) ? $this->bo->date2ts($ui->first) : $ui->first,
|
||||
@ -120,19 +121,30 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$fields = importexport_helper_functions::get_filter_fields($_definition->application, $this);
|
||||
$filter = $_definition->filter;
|
||||
|
||||
// Handle ranges
|
||||
foreach($filter as $field => $value)
|
||||
{
|
||||
if($field == 'filter' && $value)
|
||||
{
|
||||
$query['filter'] = $value;
|
||||
continue;
|
||||
}
|
||||
if(!is_array($value) || (!$value['from'] && !$value['to']))
|
||||
{
|
||||
$query['query']["cal_$field"] = $value;
|
||||
continue;
|
||||
}
|
||||
$events = array();
|
||||
switch($states['view']) {
|
||||
case 'month':
|
||||
$query += $this->get_query_month($states);
|
||||
break;
|
||||
case 'week':
|
||||
$query += $this->get_query_week($states);
|
||||
break;
|
||||
case 'day':
|
||||
$query += $this->get_query_day($states);
|
||||
break;
|
||||
default:
|
||||
// Let UI set the date ranges
|
||||
$ui = new calendar_uiviews($query);
|
||||
if(method_exists($ui, $states['view']))
|
||||
{
|
||||
ob_start();
|
||||
$ui->$states['view']();
|
||||
ob_end_flush();
|
||||
}
|
||||
$query += array(
|
||||
'start' => is_array($ui->first) ? $this->bo->date2ts($ui->first) : $ui->first,
|
||||
'end' => is_array($ui->last) ? $this->bo->date2ts($ui->last) : $ui->last
|
||||
);
|
||||
|
||||
// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
|
||||
if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
|
||||
@ -237,24 +249,30 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
*/
|
||||
public function get_selectors_etpl($definition = null) {
|
||||
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
$start= new egw_time($states['date']);
|
||||
if($states['view'] == 'week')
|
||||
{
|
||||
$days = isset($_GET['days']) ? $_GET['days'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['days_in_weekview'];
|
||||
if ($days != 5) $days = 7;
|
||||
$end = "+$days days";
|
||||
$end = strtotime($end, $start->format('ts'))-1;
|
||||
switch($states['view']) {
|
||||
case 'month':
|
||||
$query = $this->get_query_month($states);
|
||||
break;
|
||||
case 'week':
|
||||
case 'weekN':
|
||||
$query = $this->get_query_week($states);
|
||||
break;
|
||||
case 'day':
|
||||
$query = $this->get_query_day($states);
|
||||
break;
|
||||
}
|
||||
elseif ($states['view'] == 'listview')
|
||||
$start= new egw_time($query['start']);
|
||||
$end = new egw_time($query['end']);
|
||||
if ($states['view'] == 'listview')
|
||||
{
|
||||
$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
|
||||
|
||||
// Use UI to get dates
|
||||
$ui = new calendar_uilist();
|
||||
$list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
|
||||
$ui->get_rows($list,$rows,$readonlys);
|
||||
if($ui->first) $start = $ui->first;
|
||||
if($ui->last) $end = $ui->last;
|
||||
$ui->get_rows($list,$rows);
|
||||
$start = $ui->first ? $ui->first : new egw_time($ui->date);
|
||||
$end = $ui->last;
|
||||
|
||||
// Special handling
|
||||
if($list['filter'] == 'all') $start = $end = null;
|
||||
@ -265,21 +283,22 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
}
|
||||
$ui = null;
|
||||
}
|
||||
else
|
||||
elseif(!$end)
|
||||
{
|
||||
$end = '+1 ' . $states['view'];
|
||||
$end = strtotime($end, $start->format('ts'))-1;
|
||||
}
|
||||
|
||||
$prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]);
|
||||
$data = array(
|
||||
'name' => 'calendar.export_csv_select',
|
||||
'content' => array(
|
||||
'plugin_override' => true, // Plugin overrides preferences
|
||||
'selection' => $prefs['selection'] ? $prefs['selection'] : 'criteria',
|
||||
'start' => is_object($start) ? $start->format('ts') : $start,
|
||||
'end' => $end,
|
||||
'owner' => $states['owner']
|
||||
'criteria' => array(
|
||||
'start' => is_object($start) ? $start->format('ts') : $start,
|
||||
'end' => $end,
|
||||
'owner' => $states['owner']
|
||||
)
|
||||
)
|
||||
);
|
||||
return $data;
|
||||
@ -308,7 +327,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
|
||||
if ($days != 5) $days = 7;
|
||||
}
|
||||
if ($days == 4) // next 4 days view
|
||||
if ($states['view'] == 'week' && $days == 4) // next 4 days view
|
||||
{
|
||||
$query['start'] = $this->bo->date2ts($states['date']);
|
||||
$query['end'] = strtotime("+$days days",$query['start']) - 1;
|
||||
@ -328,7 +347,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$query['end'] = strtotime("+$days days",$query['start']) - 1;
|
||||
$query['end'] = strtotime($states['view'] == 'week' ? "+$days days" : "+{$ui->cal_prefs['multiple_weeks']} weeks",$query['start']) - 1;
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
@ -35,13 +35,14 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
|
||||
|
||||
if($options['selection']['select'] == 'criteria') {
|
||||
if($options['selection'] == 'criteria')
|
||||
{
|
||||
$query = array(
|
||||
'start' => $options['selection']['start'],
|
||||
'end' => strtotime('+1 day',$options['selection']['end'])-1,
|
||||
'categories' => $options['categories'] ? $options['categories'] : $options['selection']['categories'],
|
||||
'start' => $options['criteria']['start'],
|
||||
'end' => strtotime('+1 day',$options['criteria']['end'])-1,
|
||||
'categories' => $options['categories'],
|
||||
'daywise' => false,
|
||||
'users' => $options['selection']['owner'],
|
||||
'users' => $options['criteria']['owner'],
|
||||
'cfs' => $cfs // Otherwise we shouldn't get any custom fields
|
||||
);
|
||||
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
|
||||
@ -49,9 +50,12 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
|
||||
}
|
||||
$events =& $this->bo->search($query);
|
||||
} elseif ($options['selection']['select'] == 'search_results') {
|
||||
}
|
||||
elseif ($options['selection'] == 'search_results')
|
||||
{
|
||||
$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
if($states['view'] == 'listview') {
|
||||
if($states['view'] == 'listview')
|
||||
{
|
||||
$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
|
||||
$query['num_rows'] = -1; // all
|
||||
$query['start'] = 0;
|
||||
@ -62,16 +66,20 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
}
|
||||
$ui = new calendar_uilist();
|
||||
$ui->get_rows($query, $events, $unused);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
$query['users'] = explode(',', $query['owner']);
|
||||
$query['num_rows'] = -1;
|
||||
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
|
||||
if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
|
||||
{
|
||||
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
|
||||
}
|
||||
|
||||
$events = array();
|
||||
switch($states['view']) {
|
||||
switch($states['view'])
|
||||
{
|
||||
case 'month':
|
||||
$query += calendar_export_csv::get_query_month($states);
|
||||
break;
|
||||
@ -82,7 +90,14 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
$query += calendar_export_csv::get_query_day($states);
|
||||
break;
|
||||
default:
|
||||
// Let UI set the date ranges
|
||||
$ui = new calendar_uiviews($query);
|
||||
if(method_exists($ui, $states['view']))
|
||||
{
|
||||
ob_start();
|
||||
$ui->$states['view']();
|
||||
ob_end_clean();
|
||||
}
|
||||
$query += array(
|
||||
'start' => is_array($ui->first) ? $this->bo->date2ts($ui->first) : $ui->first,
|
||||
'end' => is_array($ui->last) ? $this->bo->date2ts($ui->last) : $ui->last
|
||||
@ -143,13 +158,8 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
* returns selectors of this plugin
|
||||
*
|
||||
*/
|
||||
public function get_selectors_etpl() {
|
||||
return array(
|
||||
'name' => 'calendar.export_csv_select',
|
||||
'content' => array(
|
||||
'start' => time(),
|
||||
'end' => time()
|
||||
)
|
||||
);
|
||||
public function get_selectors_etpl($definition = null) {
|
||||
$data = parent::get_selectors_etpl($definition);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user