Avoid some errors from apps/plugins that don't do filters

This commit is contained in:
Nathan Gray 2013-01-02 22:38:43 +00:00
parent 81a674cd8c
commit 21fdd9abf2
2 changed files with 20 additions and 17 deletions

View File

@ -130,7 +130,7 @@ class importexport_definition implements importexport_iface_egw_record {
case 'plugin_options' : case 'plugin_options' :
return $this->set_options($_data); return $this->set_options($_data);
case 'filter': case 'filter':
return $this->set_filter($_data); return $this->set_filter((Array)$_data);
default : default :
$this->definition[$_attribute_name] = $_data; $this->definition[$_attribute_name] = $_data;
return; return;

View File

@ -194,7 +194,7 @@ class importexport_export_ui {
} }
// fill selection tab // fill selection tab
if($definition && $definition->plugin_options['selection'] && !$content['selection_passed']) { if($definition && is_array($definition->plugin_options) && $definition->plugin_options['selection'] && !$content['selection_passed']) {
$_selection = $definition->plugin_options['selection']; $_selection = $definition->plugin_options['selection'];
} }
@ -291,23 +291,26 @@ class importexport_export_ui {
// Set filter // Set filter
// Note that because not all dates are DB dates, the plugin has to handle them // Note that because not all dates are DB dates, the plugin has to handle them
$filter = $definition->filter; $filter = $definition->filter;
foreach($_content['filter'] as $key => $value) if(is_array($_content['filter']))
{ {
// Handle multiple values foreach($_content['filter'] as $key => $value)
if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value);
$filter[$key] = $value;
// Skip empty values or empty ranges
if(!$value || is_array($value) && array_key_exists('from',$value) && !$value['from'] && !$value['to'] )
{ {
unset($filter[$key]); // Handle multiple values
} if(!is_array($value) && strpos($value,',') !== false) $value = explode(',',$value);
// If user selects an end date, they most likely want entries including that date
if(is_array($value) && array_key_exists('to',$value) && $value['to'] ) $filter[$key] = $value;
{
// Adjust time to 23:59:59 // Skip empty values or empty ranges
$filter[$key]['to'] = mktime(23,59,59,date('n',$value['to']),date('j',$value['to']),date('Y',$value['to'])); if(!$value || is_array($value) && array_key_exists('from',$value) && !$value['from'] && !$value['to'] )
{
unset($filter[$key]);
}
// If user selects an end date, they most likely want entries including that date
if(is_array($value) && array_key_exists('to',$value) && $value['to'] )
{
// Adjust time to 23:59:59
$filter[$key]['to'] = mktime(23,59,59,date('n',$value['to']),date('j',$value['to']),date('Y',$value['to']));
}
} }
} }
unset($_content['filter']); unset($_content['filter']);