function newsletter_draft_manual_list in Newsletter 7
Menu callback; List manual lists and newsletter drafts.
1 string reference to 'newsletter_draft_manual_list'
- newsletter_menu in ./
newsletter.module - Implements hook_menu().
File
- includes/
newsletter.admin.inc, line 468 - Admin page callbacks for the newsletter module.
Code
function newsletter_draft_manual_list() {
$header = array(
'title' => array(
'data' => t('Title'),
),
'status' => array(
'data' => t('Status'),
),
'template' => array(
'data' => t('Template'),
),
'operations' => array(
'data' => t('Operations'),
),
);
$query = db_select('newsletter_list', 'lists');
$query
->join('field_data_field_newsletter_template', 't', 't.entity_id = lists.nlid');
$query
->join('newsletter_template', 'templates', 'templates.ntid = t.field_newsletter_template_target_id');
$query
->addField('templates', 'subject', 'template_title');
$query
->fields('lists', array(
'title',
));
$query
->addField('lists', 'nlid', 'id');
$query
->condition('send_rate', 'Manual');
$manual_lists = $query
->execute()
->fetchAll();
$options = array();
$destination = drupal_get_destination();
$custom_newsletters = newsletter_load_custom_newsletters();
$result = array_merge($manual_lists, $custom_newsletters);
foreach ($result as $key => $row) {
$operations['data'] = array();
if (!isset($row->custom)) {
$status = t('Newsletter List with Manual send rate');
$send_path = 'admin/config/media/newsletter/create-send/send/';
$delete_path = 'admin/config/media/newsletter/lists/delete/';
$class = 'manual';
}
elseif ($row->custom && !isset($row->sent)) {
$status = t('Newsletter draft');
$send_path = 'admin/config/media/newsletter/create-send/draft/';
$delete_path = 'admin/config/media/newsletter/create-send/draft/delete/';
$class = 'draft';
}
elseif ($row->custom && $row->sent) {
$status = t('<strong>Sent</strong> Newsletter Draft');
$delete_path = 'admin/config/media/newsletter/create-send/newsletter/delete/';
$class = 'sent-draft';
}
if (!isset($row->sent)) {
$operations['data'][] = array(
'#type' => 'link',
'#title' => t('send'),
'#href' => $send_path . $row->id,
'#options' => array(
'query' => $destination,
),
);
$operations['data'][] = array(
'#markup' => ' | ',
);
}
$operations['data'][] = array(
'#type' => 'link',
'#title' => t('delete'),
'#href' => $delete_path . $row->id,
'#options' => array(
'query' => $destination,
),
);
$options[$key] = array(
'class' => array(
$class,
),
'data' => array(
'title' => check_plain($row->title),
'status' => $status,
'template' => check_plain($row->template_title),
'operations' => $operations,
),
);
}
$table = array(
'header' => $header,
'rows' => $options,
'attributes' => array(),
'caption' => '',
'colgroups' => array(),
'sticky' => TRUE,
'empty' => t('No custom newsletters or drafts available.'),
);
return theme_table($table);
}