mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 16:33:17 +01:00
* impportexport/document merge: better control of exportlimits, you are now able to exempt groups or users from any exportlimits set (backport of nathans work, with enhancements from ralf)
This commit is contained in:
parent
92897d7c15
commit
a3b17caa5f
@ -38,8 +38,9 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
$uicontacts = new addressbook_ui();
|
||||
$selection = array();
|
||||
|
||||
// Addressbook defines its own export limits
|
||||
if($GLOBALS['egw_info']['server']['contact_export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin']) {
|
||||
// Addressbook defines its own export imits
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
if($GLOBALS['egw_info']['server']['contact_export_limit'] == 'no' && !$limit_exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi
|
||||
}
|
||||
$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
|
||||
|
||||
if($GLOBALS['egw_info']['server']['contact_export_limit'] && !$GLOBALS['egw_info']['user']['apps']['admin']) {
|
||||
if($GLOBALS['egw_info']['server']['contact_export_limit'] && !$limit_exception) {
|
||||
$selection = array_slice($selection, 0, $GLOBALS['egw_info']['server']['contact_export_limit']);
|
||||
}
|
||||
if($options['explode_multiselects']) {
|
||||
|
@ -568,7 +568,7 @@ class addressbook_ui extends addressbook_bo
|
||||
}
|
||||
|
||||
// check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no)
|
||||
if (isset($GLOBALS['egw_info']['user']['apps']['admin']) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
|
||||
if (bo_merge::is_export_limit_excepted() || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
|
||||
{
|
||||
$actions['export'] = array(
|
||||
'caption' => 'Export',
|
||||
@ -798,8 +798,7 @@ class addressbook_ui extends addressbook_bo
|
||||
$action = substr($action,0,7);
|
||||
}
|
||||
// Security: stop non-admins to export more then the configured number of contacts
|
||||
if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] &&
|
||||
!isset($GLOBALS['egw_info']['user']['apps']['admin']) &&
|
||||
if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !bo_merge::is_export_limit_excepted() &&
|
||||
(!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit']))
|
||||
{
|
||||
$action_msg = lang('exported');
|
||||
|
@ -25,7 +25,7 @@
|
||||
<td>{lang_Timeout_for_application_session_data_in_seconds_(default_86400_=_1_day)}:</td>
|
||||
<td><input size="8" name="newsettings[sessions_app_timeout]" value="{value_sessions_app_timeout}"></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr class="row_on">
|
||||
<td>{lang_Would_you_like_to_show_each_application's_upgrade_status_?}:</td><td>
|
||||
<select name="newsettings[checkappversions]">
|
||||
@ -294,12 +294,15 @@
|
||||
<td>{lang_How_many_entries_should_non-admins_be_able_to_export_(empty_=_no_limit,_no_=_no_export)}:<br />{lang_This_controls_exports_and_merging.}</td>
|
||||
<td><input name="newsettings[export_limit]" value="{value_export_limit}" size="5"></td>
|
||||
</tr>
|
||||
</tr>
|
||||
<tr class="row_on">
|
||||
<td>{lang_Group_excepted_from_above_export_limit_(admins_are_always_excepted)}:</td>
|
||||
<td>{call_bo_merge::hook_export_limit_excepted}</td>
|
||||
</tr>
|
||||
<tr class="row_off">
|
||||
<td>{lang_Allow_remote_administration_from_following_install_ID's_(comma_separated)}:<br />{lang_Own_install_ID:_}{value_install_id}</td>
|
||||
<td><input name="newsettings[allow_remote_admin]" value="{value_allow_remote_admin}" size="40"></td>
|
||||
</tr>
|
||||
<tr class="row_off">
|
||||
<tr class="row_on">
|
||||
<td>{lang_Should_exceptions_contain_a_trace_(including_function_arguments)}:</td>
|
||||
<td>
|
||||
<select name="newsettings[exception_show_trace]">
|
||||
|
@ -26,6 +26,8 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$this->bo = new calendar_bo();
|
||||
$config = config::read('phpgwapi');
|
||||
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
|
||||
// Custom fields need to be specifically requested
|
||||
$cfs = array();
|
||||
foreach($options['mapping'] as $key => $label) {
|
||||
@ -42,7 +44,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
'users' => $options['selection']['owner'],
|
||||
'cfs' => $cfs // Otherwise we shouldn't get any custom fields
|
||||
);
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['offset'] = 0;
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
@ -55,7 +57,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$query['start'] = 0;
|
||||
$query['cfs'] = $cfs;
|
||||
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
$ui = new calendar_uilist();
|
||||
@ -64,7 +66,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
$query['users'] = explode(',', $query['owner']);
|
||||
$query['num_rows'] = -1;
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
if($key[0] == '#') $cfs[] = substr($key,1);
|
||||
}
|
||||
|
||||
$limit_exception = bo_merge::is_export_limit_excepted();
|
||||
|
||||
if($options['selection']['select'] == 'criteria') {
|
||||
$query = array(
|
||||
'start' => $options['selection']['start'],
|
||||
@ -42,7 +44,7 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
'users' => $options['selection']['owner'],
|
||||
'cfs' => $cfs // Otherwise we shouldn't get any custom fields
|
||||
);
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['offset'] = 0;
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
@ -55,7 +57,7 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
$query['start'] = 0;
|
||||
$query['cfs'] = $cfs;
|
||||
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
$ui = new calendar_uilist();
|
||||
@ -64,7 +66,7 @@ class calendar_export_ical extends calendar_export_csv {
|
||||
$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
|
||||
$query['users'] = explode(',', $query['owner']);
|
||||
$query['num_rows'] = -1;
|
||||
if($config['export_limit']) {
|
||||
if($config['export_limit'] && !$limit_exception) {
|
||||
$query['num_rows'] = (int)$config['export_limit'];
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,19 @@ abstract class bo_merge
|
||||
$this->export_limit = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook returning options for export_limit_excepted groups
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public static function hook_export_limit_excepted($config)
|
||||
{
|
||||
$accountsel = new uiaccountsel();
|
||||
|
||||
return '<input type="hidden" value="" name="newsettings[export_limit_excepted]" />'.
|
||||
$accountsel->selection('newsettings[export_limit_excepted]','export_limit_excepted',$config['export_limit_excepted'],'both',4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all replacements, must be implemented in extending class
|
||||
*
|
||||
@ -282,6 +295,33 @@ abstract class bo_merge
|
||||
return egw_time::to($time,$format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current user is excepted from the export-limit:
|
||||
* a) access to admin application
|
||||
* b) he or one of his memberships is named in export_limit_excepted config var
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function is_export_limit_excepted()
|
||||
{
|
||||
static $is_excepted;
|
||||
|
||||
if (is_null($is_excepted))
|
||||
{
|
||||
$is_excepted = isset($GLOBALS['egw_info']['user']['apps']['admin']);
|
||||
|
||||
// check export-limit and fail if user tries to export more entries then allowed
|
||||
if (!$is_excepted && (is_array($export_limit_excepted = $GLOBALS['egw_info']['server']['export_limit_excepted']) ||
|
||||
is_array($export_limit_excepted = unserialize($export_limit_excepted))))
|
||||
{
|
||||
$id_and_memberships = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
|
||||
$id_and_memberships[] = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$is_excepted = (bool) array_intersect($id_and_memberships, $export_limit_excepted);
|
||||
}
|
||||
}
|
||||
return $is_excepted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges a given document with contact data
|
||||
*
|
||||
@ -300,9 +340,7 @@ abstract class bo_merge
|
||||
return false;
|
||||
}
|
||||
|
||||
// check export-limit and fail if user tries to export more entries then allowed
|
||||
if ($this->export_limit && !$GLOBALS['egw_info']['user']['apps']['admin'] &&
|
||||
count($ids) > (int)$this->export_limit)
|
||||
if ($this->export_limit && !self::is_export_limit_excepted() && count($ids) > (int)$this->export_limit)
|
||||
{
|
||||
$err = lang('No rights to export more then %1 entries!',(int)$this->export_limit);
|
||||
return false;
|
||||
@ -568,7 +606,7 @@ abstract class bo_merge
|
||||
return $contentstart.implode('<text:line-break />',$contentrepeatpages).$contentend;
|
||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
||||
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
||||
return $contentstart.implode('<w:br w:type="page" />',$contentrep).$contentend;
|
||||
return $contentstart.implode('<w:br w:type="page" />',$contentrepeatpages).$contentend;
|
||||
case 'text/plain':
|
||||
return $contentstart.implode("\r\n",$contentrep).$contentend;
|
||||
}
|
||||
@ -1172,8 +1210,7 @@ abstract class bo_merge
|
||||
'caption' => $caption,
|
||||
'children' => $documents,
|
||||
// disable action if no document or export completly forbidden for non-admins
|
||||
'enabled' => (boolean)$documents && (empty($export_limit) ||
|
||||
(int)$export_limit > 0 || $GLOBALS['egw_info']['user']['apps']['admin']),
|
||||
'enabled' => (boolean)$documents && (empty($export_limit) || (int)$export_limit > 0 || self::is_export_limit_excepted()),
|
||||
'hideOnDisabled' => true, // do not show 'Insert in document', if no documents defined or no export allowed
|
||||
'group' => $group,
|
||||
);
|
||||
|
@ -278,7 +278,7 @@ class nextmatch_widget
|
||||
|
||||
$value['no_csv_export'] = $value['csv_fields'] === false ||
|
||||
$GLOBALS['egw_info']['server']['export_limit'] && !is_numeric($GLOBALS['egw_info']['server']['export_limit']) &&
|
||||
!isset($GLOBALS['egw_info']['user']['apps']['admin']);
|
||||
!bo_merge::is_export_limit_excepted();
|
||||
|
||||
if (!$value['filter_onchange']) $value['filter_onchange'] = 'this.form.submit();';
|
||||
if (!$value['filter2_onchange']) $value['filter2_onchange'] = 'this.form.submit();';
|
||||
@ -1447,7 +1447,7 @@ class nextmatch_widget
|
||||
*/
|
||||
static public function csv_export(&$value,$separator=';')
|
||||
{
|
||||
if (!isset($GLOBALS['egw_info']['user']['apps']['admin']))
|
||||
if (!bo_merge::is_export_limit_excepted())
|
||||
{
|
||||
$export_limit = $GLOBALS['egw_info']['server']['export_limit'];
|
||||
//if (isset($value['export_limit'])) $export_limit = $value['export_limit'];
|
||||
|
@ -38,7 +38,7 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
),
|
||||
);
|
||||
$config = config::read('phpgwapi');
|
||||
if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['export_limit'] !== 'no')
|
||||
if(bo_merge::is_export_limit_excepted() || $config['export_limit'] !== 'no')
|
||||
{
|
||||
$file[] = array(
|
||||
'text' => 'Export',
|
||||
@ -122,7 +122,7 @@ class importexport_admin_prefs_sidebox_hooks
|
||||
}
|
||||
}
|
||||
$config = config::read('phpgwapi');
|
||||
if (($GLOBALS['egw_info']['user']['apps']['admin'] || !$config['export_limit'] || $config['export_limit'] > 0) && $cache[$appname]['export'])
|
||||
if ((bo_merge::is_export_limit_excepted() || !$config['export_limit'] || $config['export_limit'] > 0) && $cache[$appname]['export'])
|
||||
{
|
||||
$file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('".
|
||||
egw::link('/index.php',array(
|
||||
|
@ -87,7 +87,7 @@ class importexport_definitions_ui
|
||||
// Filter private definitions
|
||||
$filter['owner'] = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$config = config::read('phpgwapi');
|
||||
if($config['export_limit'] == 'no') {
|
||||
if($config['export_limit'] == 'no' && !bo_merge::is_export_limit_excepted()) {
|
||||
$filter['type'] = 'import';
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
$this->csv_options = array_merge( $this->csv_options, $_options );
|
||||
}
|
||||
|
||||
if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
|
||||
if(!bo_merge::is_export_limit_excepted()) {
|
||||
$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'];
|
||||
@ -164,7 +164,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
}
|
||||
|
||||
// Check for limit
|
||||
if($this->export_limit && $this->num_of_records > $this->export_limit) {
|
||||
if($this->export_limit && $this->num_of_records >= $this->export_limit) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class importexport_export_ui {
|
||||
|
||||
public $public_functions = array(
|
||||
'export_dialog' => true,
|
||||
'download' => true,
|
||||
'download' => true,
|
||||
);
|
||||
|
||||
private $js;
|
||||
@ -49,7 +49,7 @@ class importexport_export_ui {
|
||||
$preserv = array();
|
||||
|
||||
// Check global setting
|
||||
if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
|
||||
if(!bo_merge::is_export_limit_excepted()) {
|
||||
$config = config::read('phpgwapi');
|
||||
if($config['export_limit'] == 'no') {
|
||||
die(lang('Admin disabled exporting'));
|
||||
|
Loading…
Reference in New Issue
Block a user