Enforce export limit for csv exports

This commit is contained in:
Nathan Gray 2011-02-22 18:17:13 +00:00
parent a019e94e55
commit 127976b1ef

View File

@ -49,6 +49,11 @@ class importexport_export_csv implements importexport_iface_export_record
*/
protected $num_of_records = 0;
/**
* @var int holds max. number of records allowed to be exported
*/
protected $export_limit = 0;
/**
* @var stream stream resource of csv file
*/
@ -94,6 +99,12 @@ class importexport_export_csv implements importexport_iface_export_record
if ( !empty( $_options ) ) {
$this->csv_options = array_merge( $this->csv_options, $_options );
}
if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
$config = config::read('phpgwapi');
if($config['export_limit'] == 'no') throw new egw_exception_no_permission_admin('Export disabled');
$this->export_limit = (int)$config['export_limit'];
}
}
/**
@ -143,6 +154,11 @@ class importexport_export_csv implements importexport_iface_export_record
fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
}
// Check for limit
if($this->export_limit && $this->num_of_records > $this->export_limit) {
return;
}
// do conversions
if ( !empty( $this->conversion )) {
$this->record = importexport_helper_functions::conversion( $this->record, $this->conversion );