Catch exception thrown when trying to instanciate a definition the user has no rights for, and discard it.

This commit is contained in:
Nathan Gray 2011-02-10 20:45:32 +00:00
parent 21c1f08322
commit 94c616bf12

View File

@ -438,9 +438,14 @@ class importexport_helper_functions {
$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
$list = array(); $list = array();
foreach((array)$def->get_definitions() as $id) { foreach((array)$def->get_definitions() as $id) {
$definition = new importexport_definition($id); // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
if($def->is_permitted($definition->get_record_array())) { try {
$list[$definition->application][$definition->type] = $id; $definition = new importexport_definition($id);
if($def->is_permitted($definition->get_record_array())) {
$list[$definition->application][$definition->type] = $id;
}
} catch (Exception $e) {
// That one doesn't work, keep going
} }
$definition = null; $definition = null;
} }