You are here

function workbench_email_create_form_element in Workbench Email 7

Same name and namespace in other branches
  1. 7.3 workbench_email.form.inc \workbench_email_create_form_element()

Create the email selection form element.

Creates the appropriate multi select list for a given role and stores some email transition information into the form element.

Parameters

array $form: The form array passed by reference

object $params: A object containing information relating to the email transition

1 call to workbench_email_create_form_element()
workbench_email_form_node_form_alter in ./workbench_email.module
Implements hook_node_form_alter().

File

./workbench_email.module, line 510
Code for the Workbench Email Module.

Code

function workbench_email_create_form_element(&$form, $email_transition) {
  $users = workbench_email_get_users($email_transition->rid);
  if ($users) {
    global $user;
    $emails = array(
      '0' => '- None -',
    );
    foreach ($users as $uid => $account) {
      if ($user->mail != $account->mail) {
        $emails[$account->mail] = $account->name;
      }
    }
    $role = user_role_load($email_transition->rid);
    $form['options']['#access'] ? $wrapper_id = 'options' : ($wrapper_id = 'revision_information');
    $form[$wrapper_id]['workflow_email'][$role->rid] = array(
      '#type' => 'select',
      '#title' => t("@role_name", array(
        '@role_name' => ucwords($role->name),
      )),
      '#options' => $emails,
      '#description' => t('Select one or more users to notify'),
      '#multiple' => TRUE,
      '#hidden' => $email_transition,
    );
  }
}