You are here

function commerce_email_list in Commerce Email 7

Returns an array of all defined emails

Parameters

$enabled: (optional) Defaults to FALSE Boolean to return enabled email names or all the enabled email content

Return value

array of emails

2 calls to commerce_email_list()
commerce_email_form_submit in ./commerce_email.module
commerce_email_list_languages in ./commerce_email.module
Returns a list of emails in all languages and automatically adds a version for each enabled language

File

./commerce_email.module, line 352
Defines additional menu item and order html email functonality.

Code

function commerce_email_list($enabled = FALSE) {
  if ($enabled) {
    $result = db_select('commerce_email')
      ->fields('commerce_email', array(
      'type',
    ))
      ->groupBy('type')
      ->execute();
    $array = array();
    while ($row = $result
      ->fetchObject()) {
      $array[] = $row->type;
    }
    return $array;
  }
  $result = db_select('commerce_email')
    ->fields('commerce_email', array(
    'email_id',
    'type',
    'template',
    'content',
    'subject',
    'language',
    'content_format',
  ))
    ->orderBy('type')
    ->execute();
  $array = array();
  while ($row = $result
    ->fetchObject()) {
    $array[$row->type][$row->language] = $row;
  }
  return $array;
}