Wrap definition constructor in a try/catch to catch & ignore permission errors

This commit is contained in:
Nathan Gray 2011-02-14 15:54:28 +00:00
parent 45d3e8d82a
commit 1cedf20503
4 changed files with 37 additions and 9 deletions

View File

@ -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;

View File

@ -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').");");

View File

@ -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);
}

View File

@ -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);