Commit 5a355bb4 authored by Nigel McNie's avatar Nigel McNie
Browse files

Fixed a notice being generated. Added TODOs about all the broken exceptions

parent db1b6270
...@@ -49,6 +49,7 @@ if ($institution || $add) { ...@@ -49,6 +49,7 @@ if ($institution || $add) {
if ($delete) { if ($delete) {
function delete_validate(Pieform $form, $values) { function delete_validate(Pieform $form, $values) {
if (get_field('usr', 'COUNT(*)', 'institution', $values['i'])) { if (get_field('usr', 'COUNT(*)', 'institution', $values['i'])) {
// TODO: exception is of the wrong type
throw new Exception('Attempt to delete an institution that has members'); throw new Exception('Attempt to delete an institution that has members');
} }
} }
...@@ -107,7 +108,7 @@ if ($institution || $add) { ...@@ -107,7 +108,7 @@ if ($institution || $add) {
$instancestring = implode(',',$instancearray); $instancestring = implode(',',$instancearray);
$inuserecords = array(); $inuserecords = array();
$records = get_records_sql_assoc('select authinstance, count(id) from {usr} where authinstance in ('.$instancestring.') group by authinstance'); $records = get_records_sql_assoc('select authinstance, count(id) from {usr} where authinstance in ('.$instancestring.') group by authinstance', array());
foreach ($records as $record) { foreach ($records as $record) {
$inuserecords[] = $record->authinstance; $inuserecords[] = $record->authinstance;
} }
...@@ -264,16 +265,19 @@ function institution_submit(Pieform $form, $values) { ...@@ -264,16 +265,19 @@ function institution_submit(Pieform $form, $values) {
$allinstances = array_merge($values['authplugin']['instancearray'], $values['authplugin']['deletearray']); $allinstances = array_merge($values['authplugin']['instancearray'], $values['authplugin']['deletearray']);
if (array_diff($allinstances, $instancearray)) { if (array_diff($allinstances, $instancearray)) {
// TODO wrong exception type
throw new Exception('Attempt to delete or update another institution\'s auth instance'); throw new Exception('Attempt to delete or update another institution\'s auth instance');
} }
if (array_diff($instancearray, $allinstances)) { if (array_diff($instancearray, $allinstances)) {
// TODO wrong exception type
throw new Exception('One of your instances is unaccounted for in this transaction'); throw new Exception('One of your instances is unaccounted for in this transaction');
} }
foreach($values['authplugin']['instancearray'] as $priority => $instanceid) { foreach($values['authplugin']['instancearray'] as $priority => $instanceid) {
if (in_array($instanceid, $values['authplugin']['deletearray'])) { if (in_array($instanceid, $values['authplugin']['deletearray'])) {
// Should never happen: // Should never happen:
// TODO wrong exception type
throw new Exception('Attempt to update AND delete an auth instance'); throw new Exception('Attempt to update AND delete an auth instance');
} }
$record = new StdClass; $record = new StdClass;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment