You are here

function workflow_notify_settings_form_submit in Workflow 7

Same name and namespace in other branches
  1. 7.2 workflow_notify/workflow_notify.pages.inc \workflow_notify_settings_form_submit()

File

workflow_notify/workflow_notify.admin.inc, line 204
Admin UI to Notify roles for Workfllow state transitions.

Code

function workflow_notify_settings_form_submit($form, $form_state) {
  $roles = variable_get('workflow_notify_roles', array());
  $workflow = $form['#workflow'];
  variable_set('workflow_notify_from_address_' . $workflow->wid, $form_state['values']['from_address']);
  variable_set('workflow_notify_filter_format_' . $workflow->wid, $form_state['values']['filter']);
  foreach ($form_state['values']['states'] as $sid => $values) {
    $selected = array_filter($values['roles']);

    // Are there any roles selected?
    if ($selected) {
      $roles[$sid] = $selected;
    }
    else {

      // No, so make sure this state is gone.
      unset($roles[$sid]);
    }
    variable_set("workflow_notify_subject_{$sid}", $values['subject']);
    variable_set("workflow_notify_body_{$sid}", $values['body']);
  }
  variable_set('workflow_notify_roles', $roles);
  drupal_set_message(t('The notification settings have been saved.'));
  $form_state['redirect'] = "admin/config/workflow/workflow/{$workflow->wid}";
}