From 127976b1efeae6141e0e0a92c06585ae328c0850 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 22 Feb 2011 18:17:13 +0000 Subject: [PATCH] Enforce export limit for csv exports --- .../inc/class.importexport_export_csv.inc.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/importexport/inc/class.importexport_export_csv.inc.php b/importexport/inc/class.importexport_export_csv.inc.php index 5ca87e22cc..7f82f34a1a 100644 --- a/importexport/inc/class.importexport_export_csv.inc.php +++ b/importexport/inc/class.importexport_export_csv.inc.php @@ -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']; + } } /** @@ -142,6 +153,11 @@ class importexport_export_csv implements importexport_iface_export_record $mapping = $this->translation->convert( $mapping, $this->translation->charset(), $this->csv_charset ); 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 )) {