From 1cedf20503994ae38c1fffbc9e52308ee7a29ec4 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 14 Feb 2011 15:54:28 +0000 Subject: [PATCH] Wrap definition constructor in a try/catch to catch & ignore permission errors --- .../class.importexport_definitions_ui.inc.php | 7 ++++++- .../inc/class.importexport_export_ui.inc.php | 10 ++++++++++ .../inc/class.importexport_import_ui.inc.php | 16 ++++++++++++---- .../inc/class.importexport_schedule_ui.inc.php | 13 +++++++++---- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/importexport/inc/class.importexport_definitions_ui.inc.php b/importexport/inc/class.importexport_definitions_ui.inc.php index 60e94cbf0d..3e0a5e1f7f 100644 --- a/importexport/inc/class.importexport_definitions_ui.inc.php +++ b/importexport/inc/class.importexport_definitions_ui.inc.php @@ -116,7 +116,12 @@ class importexport_definitions_ui $definitions = array('row0'); foreach ($bodefinitions->get_definitions() as $identifier) { - $definition = new importexport_definition($identifier); + try { + $definition = new importexport_definition($identifier); + } catch (Exception $e) { + // permission error + continue; + } $array = $definition->get_record_array(); $array['menuaction'] = $array['type'] == 'import' ? 'importexport.importexport_import_ui.import_dialog':'importexport.importexport_export_ui.export_dialog'; $definitions[] = $array; diff --git a/importexport/inc/class.importexport_export_ui.inc.php b/importexport/inc/class.importexport_export_ui.inc.php index e40b270699..92732fc5bc 100644 --- a/importexport/inc/class.importexport_export_ui.inc.php +++ b/importexport/inc/class.importexport_export_ui.inc.php @@ -70,7 +70,12 @@ class importexport_export_ui { 'application' => isset($content['appname']) ? $content['appname'] : '%' )); foreach ((array)$definitions->get_definitions() as $identifier) { + try { $definition = new importexport_definition($identifier); + } catch (Exception $e) { + // permission error + continue; + } if ($title = $definition->get_title()) { $sel_options['definition'][$title] = $title; } @@ -311,7 +316,12 @@ class importexport_export_ui { )); $response->addScript("clear_options('exec[definition]');"); foreach ((array)$definitions->get_definitions() as $identifier) { + try { $definition = new importexport_definition($identifier); + } catch (Exception $e) { + // Permission error + continue; + } if ($title = $definition->get_title()) { if (!$selected_plugin) $selected_plugin = $title; $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',".($selected_plugin == $title ? 'true' : 'false').");"); diff --git a/importexport/inc/class.importexport_import_ui.inc.php b/importexport/inc/class.importexport_import_ui.inc.php index 4c2c30d144..3c40ab4f94 100644 --- a/importexport/inc/class.importexport_import_ui.inc.php +++ b/importexport/inc/class.importexport_import_ui.inc.php @@ -104,11 +104,19 @@ 'application' => $data['appname'] )); foreach ((array)$definitions->get_definitions() as $identifier) { + try + { $definition = new importexport_definition($identifier); - if ($title = $definition->get_title()) { - $options['definition'][$title] = $title; - } - unset($definition); + } + catch (Exception $e) + { + // Permission error + continue; + } + if ($title = $definition->get_title()) { + $options['definition'][$title] = $title; + } + unset($definition); } unset($definitions); } diff --git a/importexport/inc/class.importexport_schedule_ui.inc.php b/importexport/inc/class.importexport_schedule_ui.inc.php index 426a3091da..13c4853b97 100644 --- a/importexport/inc/class.importexport_schedule_ui.inc.php +++ b/importexport/inc/class.importexport_schedule_ui.inc.php @@ -167,11 +167,16 @@ if($data['plugin']) $query['plugin'] = $data['plugin']; $definitions = new importexport_definitions_bo($query); foreach ((array)$definitions->get_definitions() as $identifier) { + try { $definition = new importexport_definition($identifier); - if ($title = $definition->get_title()) { - $options['definition'][$title] = $title; - } - unset($definition); + } catch (Exception $e) { + // permission error + continue; + } + if ($title = $definition->get_title()) { + $options['definition'][$title] = $title; + } + unset($definition); } unset($definitions);