Form validation handler for trigger_assign_form().
Makes sure that the user is not re-assigning an action to an event.
function trigger_assign_form_validate($form, $form_state) {
$form_values = $form_state['values'];
if (!empty($form_values['aid'])) {
$aid = actions_function_lookup($form_values['aid']);
$aid_exists = db_query("SELECT aid FROM {trigger_assignments} WHERE hook = :hook AND aid = :aid", array(
':hook' => $form_values['hook'],
':aid' => $aid,
))
->fetchField();
if ($aid_exists) {
form_set_error($form_values['hook'], t('The action you chose is already assigned to that trigger.'));
}
}
}