You are here

function workbench_email_get in Workbench Email 7.3

Same name and namespace in other branches
  1. 7 workbench_email.module \workbench_email_get()

Determines the email attributes to retrieve.

Parameters

object $transition: The transition object

int $rid: The role ID

Return value

emails Returns the workbench_email object or FALSE

5 calls to workbench_email_get()
workbench_email_features_export_options in ./workbench_email.features.inc
Implements COMPONENT_features_export_options().
workbench_email_form in ./workbench_email.admin.inc
Administration form to create and delete email transitions.
workbench_email_form_node_form_alter in ./workbench_email.form.inc
Implements hook_form_BASE_FORM_ID_alter().
workbench_email_form_validate in ./workbench_email.admin.inc
Validates the form values.
workbench_email_workbench_moderation_transition in ./workbench_email.module
Implements hook_workbench_moderation_transition().

File

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

Code

function workbench_email_get($transition = NULL, $rid = NULL, $author = NULL, $automatic = NULL) {
  $emails = array();
  $query = db_select('workbench_emails', 'wve')
    ->fields('wve', array(
    'rid',
    'from_name',
    'to_name',
    'subject',
    'message',
    'author',
    'automatic',
  ));
  if ($transition) {
    $query
      ->condition('wve.from_name', $transition->from_name);
    $query
      ->condition('wve.to_name', $transition->to_name);
  }
  if ($rid) {
    $query
      ->condition('wve.rid', $rid);
  }
  if ($author) {
    $query
      ->condition('wve.author', $author);
  }
  if ($automatic) {
    $query
      ->condition('wve.automatic', $automatic);
  }
  $result = $query
    ->execute();
  foreach ($result as $row) {
    $emails[$row->from_name . '_to_' . $row->to_name][$row->rid] = $row;
  }
  return $emails;
}