diff --git a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php
index 6c85577923..58a470f02b 100644
--- a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php
+++ b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php
@@ -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 = bo_merge::getExportLimit($GLOBALS['egw_info']['server']['contact_export_limit']);
+ $export_limit = $export_object->export_limit = addressbook_hooks::getAppExportLimit($location='addressbook');
if($export_limit == 'no' && !$limit_exception) {
return;
}
diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php
index 67177d9c6a..cb484dfb6a 100644
--- a/addressbook/inc/class.addressbook_hooks.inc.php
+++ b/addressbook/inc/class.addressbook_hooks.inc.php
@@ -374,6 +374,17 @@ class addressbook_hooks
);
}
+ /**
+ * Hook called to retrieve a app specific exportLimit
+ *
+ * @param array/string $location location and other parameters (not used)
+ * @return the export_limit to be applied for the app, may be empty, int or string
+ */
+ static function getAppExportLimit($location)
+ {
+ return bo_merge::getExportLimit($GLOBALS['egw_info']['server']['contact_export_limit']);
+ }
+
/**
* Register contacts as calendar resources (items which can be sheduled by the calendar)
*
diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php
index b175edee2a..82e0d5c9d3 100644
--- a/addressbook/inc/class.addressbook_merge.inc.php
+++ b/addressbook/inc/class.addressbook_merge.inc.php
@@ -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 = bo_merge::getExportLimit($GLOBALS['egw_info']['server']['contact_export_limit']);
+ $this->export_limit = addressbook_hooks::getAppExportLimit($location='addressbook');
}
/**
diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php
index 3f3a486e17..0d2cc9a3cc 100644
--- a/addressbook/inc/class.addressbook_ui.inc.php
+++ b/addressbook/inc/class.addressbook_ui.inc.php
@@ -82,17 +82,15 @@ class addressbook_ui extends addressbook_bo
{
$GLOBALS['egw_info']['flags']['java_script'].= $this->js();
}
+
+ // make sure the hook for export_limit is registered
+ if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_hooks('addressbook');
+
$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
- if ($this->config['contact_export_limit'])
- {
- $this->config['export_limit'] = $this->config['contact_export_limit'];
- }
- else // if not use the global one
- {
- $this->config['contact_export_limit'] = $this->config['export_limit'];
- }
+ $this->config['export_limit'] = $this->config['contact_export_limit'] = addressbook_hooks::getAppExportLimit($location='addressbook');
+
if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ?
$this->config['copy_fields'] : unserialize($this->config['copy_fields'])))
{
diff --git a/addressbook/setup/setup.inc.php b/addressbook/setup/setup.inc.php
index 74b6b177be..9ebcfc868c 100755
--- a/addressbook/setup/setup.inc.php
+++ b/addressbook/setup/setup.inc.php
@@ -45,6 +45,8 @@ $setup_info['addressbook']['hooks']['edit_user'] = 'addressbook_hooks::edit_u
$setup_info['addressbook']['hooks'][] = 'config';
$setup_info['addressbook']['hooks']['group_acl'] = 'addressbook_hooks::group_acl';
$setup_info['addressbook']['hooks']['not_enum_group_acls'] = 'addressbook_hooks::not_enum_group_acls';
+$setup_info['addressbook']['hooks']['export_limit'] = 'addressbook_hooks::getAppExportLimit';
+
/* Dependencies for this app to work */
$setup_info['addressbook']['depends'][] = array(
diff --git a/calendar/inc/class.calendar_export_csv.inc.php b/calendar/inc/class.calendar_export_csv.inc.php
index 04619bed9d..bef98d36c5 100644
--- a/calendar/inc/class.calendar_export_csv.inc.php
+++ b/calendar/inc/class.calendar_export_csv.inc.php
@@ -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 = bo_merge::getExportLimit($GLOBALS['egw_info']['server']['calendar_export_limit']);
+ if (!$limit_exception) $export_limit = calendar_hooks::getAppExportLimit($location='calendar');
// Custom fields need to be specifically requested
$cfs = array();
foreach($options['mapping'] as $key => $label) {
diff --git a/calendar/inc/class.calendar_export_ical.inc.php b/calendar/inc/class.calendar_export_ical.inc.php
index 0d6bb96f36..cf7d0fe38b 100644
--- a/calendar/inc/class.calendar_export_ical.inc.php
+++ b/calendar/inc/class.calendar_export_ical.inc.php
@@ -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 = bo_merge::getExportLimit($GLOBALS['egw_info']['server']['calendar_export_limit']);
+ if (!$limit_exception) $export_limit = calendar_hooks::getAppExportLimit($location='calendar');
if($options['selection']['select'] == 'criteria') {
$query = array(
diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php
index f3de40931d..14d21cf969 100644
--- a/calendar/inc/class.calendar_hooks.inc.php
+++ b/calendar/inc/class.calendar_hooks.inc.php
@@ -43,6 +43,17 @@ class calendar_hooks
);
}
+ /**
+ * Hook called to retrieve a app specific exportLimit
+ *
+ * @param array/string $location location and other parameters (not used)
+ * @return the export_limit to be applied for the app, may be empty, int or string
+ */
+ static function getAppExportLimit($location)
+ {
+ return bo_merge::getExportLimit($GLOBALS['egw_info']['server']['calendar_export_limit']);
+ }
+
/**
* Draw calendar part of home
*/
diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php
index 26782dfe82..e860d1f145 100644
--- a/calendar/inc/class.calendar_ui.inc.php
+++ b/calendar/inc/class.calendar_ui.inc.php
@@ -164,10 +164,8 @@ class calendar_ui
// calendar does not work with hidden sidebox atm.
unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
- $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['calendar_export_limit'] = bo_merge::getExportLimit($this->config['calendar_export_limit']);
+ // make sure the hook for export_limit is registered
+ if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','calendar')) $GLOBALS['egw']->hooks->register_hooks('calendar');
}
/**
@@ -825,7 +823,7 @@ function load_cal(url,id) {
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
);
}
- $documents = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', $mime_filter);
+ $documents = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', $mime_filter,'calendar');
foreach($documents as $key => $value)
{
$options .= '\n";
diff --git a/calendar/setup/setup.inc.php b/calendar/setup/setup.inc.php
index 71504fbded..67642d210a 100755
--- a/calendar/setup/setup.inc.php
+++ b/calendar/setup/setup.inc.php
@@ -43,6 +43,7 @@ $setup_info['calendar']['hooks']['sidebox_menu'] = 'calendar.calendar_ui.sidebox
$setup_info['calendar']['hooks']['search_link'] = 'calendar_hooks::search_link';
$setup_info['calendar']['hooks']['config_validate'] = 'calendar_hooks::config_validate';
$setup_info['calendar']['hooks']['timesheet_set'] = 'calendar.calendar_bo.timesheet_set';
+$setup_info['calendar']['hooks']['export_limit'] = 'calendar_hooks::getAppExportLimit';
/* Dependencies for this app to work */
$setup_info['calendar']['depends'][] = array(
diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php
index c49f5f630b..8f7f4b501f 100644
--- a/etemplate/inc/class.bo_merge.inc.php
+++ b/etemplate/inc/class.bo_merge.inc.php
@@ -1170,9 +1170,11 @@ abstract class bo_merge
* @param array|string $mime_filter=null allowed mime type(s), default all, negative filter if $mime_filter[0] === '!'
* @return array List of documents, suitable for a selectbox. The key is document_.
*/
- public static function get_documents($dirs, $prefix='document_', $mime_filter=null)
+ public static function get_documents($dirs, $prefix='document_', $mime_filter=null, $app='')
{
- if (!$dirs || (!self::hasExportLimit('','ISALLOWED') && !self::is_export_limit_excepted())) return array();
+ $export_limit = null;
+ if (!empty($app)) $export_limit=$GLOBALS['egw']->hooks->single('export_limit',$app);
+ if (!$dirs || (!self::hasExportLimit($export_limit,'ISALLOWED') && !self::is_export_limit_excepted())) return array();
// split multiple comma or whitespace separated directories
// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
diff --git a/etemplate/inc/class.nextmatch_widget.inc.php b/etemplate/inc/class.nextmatch_widget.inc.php
index 46d9424143..10e7a6a297 100644
--- a/etemplate/inc/class.nextmatch_widget.inc.php
+++ b/etemplate/inc/class.nextmatch_widget.inc.php
@@ -275,9 +275,11 @@ class nextmatch_widget
// save values in persistent extension_data to be able use it in post_process
unset($value['rows']);
$extension_data += $value;
-
+ $tname = is_object($value['template']) ? $value['template']->name : $value['template'];
+ list($app) = explode('.',$tname);
+ $export_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
$value['no_csv_export'] = $value['csv_fields'] === false ||
- $GLOBALS['egw_info']['server']['export_limit'] && !is_numeric($GLOBALS['egw_info']['server']['export_limit']) &&
+ !bo_merge::hasExportLimit($export_limit,'ISALLOWED') &&
!bo_merge::is_export_limit_excepted();
if (!$value['filter_onchange']) $value['filter_onchange'] = 'this.form.submit();';
@@ -1447,9 +1449,12 @@ class nextmatch_widget
*/
static public function csv_export(&$value,$separator=';')
{
- if (!bo_merge::is_export_limit_excepted())
+ $exportLimitExempted = bo_merge::is_export_limit_excepted();
+ if (!$exportLimitExempted)
{
- $export_limit = $GLOBALS['egw_info']['server']['export_limit'];
+ $name = is_object($value['template']) ? $value['template']->name : $value['template'];
+ list($app) = explode('.',$name);
+ $export_limit = $GLOBALS['egw']->hooks->single('export_limit',$app);
//if (isset($value['export_limit'])) $export_limit = $value['export_limit'];
}
$charset = $charset_out = translation::charset();
@@ -1473,9 +1478,9 @@ class nextmatch_widget
{
break; // nothing to export
}
- if ($export_limit && (!is_numeric($export_limit) || $export_limit < $total))
+ if (!$exportLimitExempted && (!bo_merge::hasExportLimit($export_limit,'ISALLOWED') || (int)$export_limit < $total))
{
- etemplate::set_validation_error($name,lang('You are not allowed to export more than %1 entries!',$export_limit));
+ etemplate::set_validation_error($name,lang('You are not allowed to export more than %1 entries!',(int)$export_limit));
return false;
}
if (!isset($value['no_csv_support'])) $value['no_csv_support'] = !is_array($value['csv_fields']);
diff --git a/phpgwapi/inc/class.hooks.inc.php b/phpgwapi/inc/class.hooks.inc.php
index bd47372322..582ff63edc 100644
--- a/phpgwapi/inc/class.hooks.inc.php
+++ b/phpgwapi/inc/class.hooks.inc.php
@@ -188,6 +188,19 @@ class hooks
return count($this->locations[$location]);
}
+ /**
+ * check if a given hook for an application is registered
+ *
+ * @param string $location location-name
+ * @param string $app appname
+ * @return int the number of found hooks
+ */
+ function hook_exists($location, $app)
+ {
+ //error_log(__METHOD__.__LINE__.array2string($this->locations[$location]));
+ return count($this->locations[$location][$app]);
+ }
+
/**
* Register and/or de-register an application's hooks
*