forked from extern/egroupware
rework of bo_merge::getExportLimit, apply to etemplate, importexport, addressbook, calendar
This commit is contained in:
parent
7f7e84afaa
commit
2d494997ab
@ -40,7 +40,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
|
||||
// Addressbook defines its own export imits
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
$export_limit = $export_object->export_limit = addressbook_hooks::getAppExportLimit($location='addressbook');
|
||||
$export_limit = $export_object->export_limit = bo_merge::getExportLimit($app='addressbook');
|
||||
if($export_limit == 'no' && !$limit_exception) {
|
||||
return;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ class addressbook_hooks
|
||||
*/
|
||||
static function getAppExportLimit($location)
|
||||
{
|
||||
return bo_merge::getExportLimit($GLOBALS['egw_info']['server']['contact_export_limit']);
|
||||
return $GLOBALS['egw_info']['server']['contact_export_limit'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ class addressbook_merge extends bo_merge
|
||||
parent::__construct();
|
||||
|
||||
// overwrite global export-limit, if an addressbook one is set
|
||||
$this->export_limit = addressbook_hooks::getAppExportLimit($location='addressbook');
|
||||
$this->export_limit = bo_merge::getExportLimit('addressbook');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,7 +89,7 @@ class addressbook_ui extends addressbook_bo
|
||||
$this->config =& $GLOBALS['egw_info']['server'];
|
||||
|
||||
// check if a contact specific export limit is set, if yes use it also for etemplate's csv export
|
||||
$this->config['export_limit'] = $this->config['contact_export_limit'] = addressbook_hooks::getAppExportLimit($location='addressbook');
|
||||
$this->config['export_limit'] = $this->config['contact_export_limit'] = bo_merge::getExportLimit($app='addressbook');
|
||||
|
||||
if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ?
|
||||
$this->config['copy_fields'] : unserialize($this->config['copy_fields'])))
|
||||
|
@ -26,7 +26,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$this->bo = new calendar_bo();
|
||||
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
if (!$limit_exception) $export_limit = calendar_hooks::getAppExportLimit($location='calendar');
|
||||
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
|
||||
// Custom fields need to be specifically requested
|
||||
$cfs = array();
|
||||
foreach($options['mapping'] as $key => $label) {
|
||||
|
@ -33,7 +33,7 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
}
|
||||
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
if (!$limit_exception) $export_limit = calendar_hooks::getAppExportLimit($location='calendar');
|
||||
if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
|
||||
|
||||
if($options['selection']['select'] == 'criteria') {
|
||||
$query = array(
|
||||
|
@ -51,7 +51,7 @@ class calendar_hooks
|
||||
*/
|
||||
static function getAppExportLimit($location)
|
||||
{
|
||||
return bo_merge::getExportLimit($GLOBALS['egw_info']['server']['calendar_export_limit']);
|
||||
return $GLOBALS['egw_info']['server']['calendar_export_limit'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ class calendar_merge extends bo_merge
|
||||
parent::__construct();
|
||||
|
||||
// overwrite global export-limit, if one is set for calendar/appointments
|
||||
$this->export_limit = bo_merge::getExportLimit($GLOBALS['egw_info']['server']['calendar_export_limit']);
|
||||
$this->export_limit = bo_merge::getExportLimit('calendar');
|
||||
|
||||
$this->bo = new calendar_boupdate();
|
||||
|
||||
|
@ -799,9 +799,9 @@ class calendar_uilist extends calendar_ui
|
||||
'hint' => 'Download this event as iCal',
|
||||
'disableClass' => 'rowNoView',
|
||||
);
|
||||
$actions['documents'] = addressbook_merge::document_action(
|
||||
$actions['documents'] = calendar_merge::document_action(
|
||||
$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
|
||||
$this->bo->cal_prefs['default_document']
|
||||
$this->bo->cal_prefs['default_document'],bo_merge::getExportLimit('calendar')
|
||||
);
|
||||
++$group;
|
||||
$actions['delete'] = array(
|
||||
|
@ -345,30 +345,40 @@ abstract class bo_merge
|
||||
* @return mixed - no if no export is allowed, false if there is no restriction and int as there is a valid restriction
|
||||
* you may have to cast the returned value to int, if you want to use it as number
|
||||
*/
|
||||
public static function getExportLimit($app_limit='')
|
||||
public static function getExportLimit($app='common')
|
||||
{
|
||||
//error_log(__METHOD__.__LINE__.' -> '.$app_limit.' '.function_backtrace());
|
||||
$exportLimit = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
if (!empty($app_limit))
|
||||
static $exportLimitStore;
|
||||
if (is_null($exportLimitStore)) $exportLimitStore=array();
|
||||
if (empty($app)) $app='common';
|
||||
//error_log(__METHOD__.__LINE__.' called with app:'.$app);
|
||||
if (!array_key_exists($app,$exportLimitStore))
|
||||
{
|
||||
$exportLimit = $app_limit;
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.' -> '.$exportLimit);
|
||||
if (empty($exportLimit))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.' -> '.$app_limit.' '.function_backtrace());
|
||||
$exportLimitStore[$app] = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
if ($app !='common')
|
||||
{
|
||||
$app_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
|
||||
if ($app_limit) $exportLimitStore[$app] = $app_limit;
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.' building cache for app:'.$app.' -> '.$exportLimitStore[$app]);
|
||||
if (empty($exportLimitStore[$app]))
|
||||
{
|
||||
$exportLimitStore[$app] = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_numeric($exportLimit))
|
||||
{
|
||||
$exportLimit = (int)$exportLimit;
|
||||
if (is_numeric($exportLimitStore[$app]))
|
||||
{
|
||||
$exportLimitStore[$app] = (int)$exportLimitStore[$app];
|
||||
}
|
||||
else
|
||||
{
|
||||
$exportLimitStore[$app] = 'no';
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.' -> '.$exportLimit);
|
||||
}
|
||||
else
|
||||
{
|
||||
$exportLimit = $limit = 'no';
|
||||
}
|
||||
//error_log(__METHOD__.__LINE__.' -> '.$exportLimit);
|
||||
return $exportLimit;
|
||||
//error_log(__METHOD__.__LINE__.' app:'.$app.' -> '.$exportLimitStore[$app]);
|
||||
return $exportLimitStore[$app];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,9 +389,8 @@ abstract class bo_merge
|
||||
*
|
||||
* @return bool - true if no export is allowed or a limit is set, false if there is no restriction
|
||||
*/
|
||||
public static function hasExportLimit($app_limit='',$checkas='AND')
|
||||
public static function hasExportLimit($app_limit,$checkas='AND')
|
||||
{
|
||||
$app_limit = self::getExportLimit($app_limit);
|
||||
if (strtoupper($checkas) == 'ISALLOWED') return (empty($app_limit) || ($app_limit !='no' && $app_limit > 0) );
|
||||
if (empty($app_limit)) return false;
|
||||
if ($app_limit == 'no') return true;
|
||||
@ -406,7 +415,7 @@ abstract class bo_merge
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::hasExportLimit() && !self::is_export_limit_excepted() && count($ids) > (int)$this->export_limit)
|
||||
if (self::hasExportLimit($this->export_limit) && !self::is_export_limit_excepted() && count($ids) > (int)$this->export_limit)
|
||||
{
|
||||
$err = lang('No rights to export more than %1 entries!',(int)$this->export_limit);
|
||||
return false;
|
||||
@ -1172,8 +1181,7 @@ abstract class bo_merge
|
||||
*/
|
||||
public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='')
|
||||
{
|
||||
$export_limit = null;
|
||||
if (!empty($app)) $export_limit=$GLOBALS['egw']->hooks->single('export_limit',$app);
|
||||
$export_limit=self::getExportLimit($app);
|
||||
if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) return array();
|
||||
|
||||
// split multiple comma or whitespace separated directories
|
||||
@ -1231,10 +1239,8 @@ abstract class bo_merge
|
||||
public static function document_action($dirs, $group=0, $caption='Insert in document', $prefix='document_', $default_doc='',
|
||||
$export_limit=null)
|
||||
{
|
||||
$export_limit = self::getExportLimit($export_limit);
|
||||
|
||||
$documents = array();
|
||||
|
||||
if ($export_limit == null) $export_limit = self::getExportLimit(); // check if there is a globalsetting
|
||||
if ($default_doc && ($file = egw_vfs::stat($default_doc))) // put default document on top
|
||||
{
|
||||
$documents['document'] = array(
|
||||
|
@ -276,8 +276,7 @@ class nextmatch_widget
|
||||
unset($value['rows']);
|
||||
$extension_data += $value;
|
||||
list($app) = explode('.',$tmpl->name);
|
||||
$export_limit = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
if (empty($app)) $export_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
|
||||
$export_limit = bo_merge::getExportLimit($app);
|
||||
$value['no_csv_export'] = $value['csv_fields'] === false ||
|
||||
!bo_merge::hasExportLimit($export_limit,'ISALLOWED') &&
|
||||
!bo_merge::is_export_limit_excepted();
|
||||
@ -1454,8 +1453,7 @@ class nextmatch_widget
|
||||
{
|
||||
$name = is_object($value['template']) ? $value['template']->name : $value['template'];
|
||||
list($app) = explode('.',$name);
|
||||
$export_limit = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
if (!empty($app)) $export_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
|
||||
$export_limit = bo_merge::getExportLimit($app);
|
||||
//if (isset($value['export_limit'])) $export_limit = $value['export_limit'];
|
||||
}
|
||||
$charset = $charset_out = translation::charset();
|
||||
|
@ -37,7 +37,8 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
'icon' => 'import'
|
||||
),
|
||||
);
|
||||
$export_limit = bo_merge::getExportLimit();
|
||||
$export_limit = bo_merge::getExportLimit($appname);
|
||||
//error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit);
|
||||
if(bo_merge::is_export_limit_excepted() || $export_limit !== 'no')
|
||||
{
|
||||
$file[] = array(
|
||||
@ -121,8 +122,8 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
$file['Import CSV']['link'] = '';
|
||||
}
|
||||
}
|
||||
$export_limit = $GLOBALS['egw']->hooks->single('export_limit',$appname);
|
||||
//error_log(__METHOD__.__LINE__.$appname.$export_limit);
|
||||
$export_limit = bo_merge::getExportLimit($appname);
|
||||
//error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit);
|
||||
if ((bo_merge::is_export_limit_excepted() || bo_merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export'])
|
||||
{
|
||||
$file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('".
|
||||
|
@ -100,9 +100,10 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
if ( !empty( $_options ) ) {
|
||||
$this->csv_options = array_merge( $this->csv_options, $_options );
|
||||
}
|
||||
|
||||
//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
|
||||
if(!bo_merge::is_export_limit_excepted()) {
|
||||
$this->export_limit = bo_merge::getExportLimit();
|
||||
$this->export_limit = bo_merge::getExportLimit($_options['appname']);
|
||||
//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
|
||||
if($this->export_limit == 'no') throw new egw_exception_no_permission_admin('Export disabled');
|
||||
}
|
||||
}
|
||||
|
@ -48,20 +48,19 @@ class importexport_export_ui {
|
||||
$readonlys = array();
|
||||
$preserv = array();
|
||||
|
||||
// Check global setting
|
||||
if(!bo_merge::is_export_limit_excepted()) {
|
||||
$export_limit = bo_merge::getExportLimit();
|
||||
if($export_limit == 'no') {
|
||||
die(lang('Admin disabled exporting'));
|
||||
}
|
||||
}
|
||||
|
||||
$et = new etemplate(self::_appname. '.export_dialog');
|
||||
$_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname'];
|
||||
$_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition'];
|
||||
$_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin'];
|
||||
$_selection = $_content['selection'] ? $_content['selection'] : $_GET['selection'];
|
||||
|
||||
// Check global setting
|
||||
if(!bo_merge::is_export_limit_excepted()) {
|
||||
$export_limit = bo_merge::getExportLimit($_appname);
|
||||
if($export_limit == 'no') {
|
||||
die(lang('Admin disabled exporting'));
|
||||
}
|
||||
}
|
||||
//error_log(__FILE__.__FUNCTION__. '::$_GET[\'appname\']='. $_appname. ',$_GET[\'definition\']='. $_definition. ',$_GET[\'plugin\']='.$_plugin. ',$_GET[\'selection\']='.$_selection);
|
||||
// if appname is given and valid, list available definitions (if no definition is given)
|
||||
$readonlys['appname'] = (!empty($_appname) && $GLOBALS['egw']->acl->check('run',1,$_appname));
|
||||
|
Loading…
Reference in New Issue
Block a user