function simplenews_admin_issues in Simplenews 7.2
Same name and namespace in other branches
- 7 includes/simplenews.admin.inc \simplenews_admin_issues()
Form builder: Builds a list of newsletters with operations.
See also
simplenews_admin_issues_validate()
simplenews_admin_issues_submit()
1 call to simplenews_admin_issues()
- simplenews_admin_newsletter_issues in includes/
simplenews.admin.inc - Menu callback: Admin form for sent and draft newsletters.
File
- includes/
simplenews.admin.inc, line 115 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_admin_issues() {
// Build an 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
);
$options = array();
foreach (module_invoke_all('simplenews_issue_operations') as $operation => $array) {
$options[$operation] = $array['label'];
}
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => 'activate',
);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#submit' => array(
'simplenews_admin_issues_submit',
),
'#validate' => array(
'simplenews_admin_issues_validate',
),
);
if (variable_get('simplenews_last_cron', '')) {
$form['last_sent'] = array(
'#markup' => '<p>' . format_plural(variable_get('simplenews_last_sent', 0), 'Last batch: 1 mail sent at !time.', 'Last batch: !count mails sent at !time.', array(
'!time' => format_date(variable_get('simplenews_last_cron', ''), 'small'),
'!count' => variable_get('simplenews_last_sent', 0),
)) . "</p>\n",
);
}
// Table header. Used as tablesort default
$header = array(
'title' => array(
'data' => t('Title'),
'specifier' => 'title',
'type' => 'property',
),
'newsletter' => array(
'data' => t('Newsletter'),
'specified' => array(
'field' => variable_get('simplenews_newsletter_field', 'simplenews_newsletter'),
'column' => 'target_id',
),
'type' => 'field',
),
'created' => array(
'data' => t('Created'),
'specifier' => 'created',
'sort' => 'desc',
'type' => 'property',
),
'published' => array(
'data' => t('Published'),
),
'sent' => array(
'data' => t('Sent'),
),
'subscribers' => array(
'data' => t('Subscribers'),
),
'operations' => array(
'data' => t('Operations'),
),
);
$query = new EntityFieldQuery();
simplenews_build_issue_filter_query($query);
$result = $query
->entityCondition('entity_type', 'node')
->tableSort($header)
->entityCondition('bundle', simplenews_get_content_types())
->pager(30)
->execute();
$nids = !empty($result['node']) ? array_keys($result['node']) : array();
$options = array();
module_load_include('inc', 'simplenews', 'includes/simplenews.mail');
$categories = simplenews_newsletter_list();
foreach (node_load_multiple($nids) as $node) {
$subscriber_count = simplenews_count_subscriptions(simplenews_issue_newsletter_id($node));
$pending_count = simplenews_count_spool(array(
'entity_id' => $node->nid,
'entity_type' => 'node',
));
$send_status = simplenews_issue_status($node) == SIMPLENEWS_STATUS_SEND_PENDING ? $subscriber_count - $pending_count : theme('simplenews_status', array(
'source' => 'sent',
'status' => simplenews_issue_status($node),
));
$options[$node->nid] = array(
'title' => l($node->title, 'node/' . $node->nid),
'newsletter' => simplenews_issue_newsletter_id($node) && isset($categories[simplenews_issue_newsletter_id($node)]) ? $categories[simplenews_issue_newsletter_id($node)] : t('- Unassigned -'),
'created' => format_date($node->created, 'small'),
'published' => theme('simplenews_status', array(
'source' => 'published',
'status' => $node->status,
)),
'sent' => $send_status,
'subscribers' => $subscriber_count,
'operations' => l(t('edit'), 'node/' . $node->nid . '/edit', array(
'query' => drupal_get_destination(),
)),
);
}
$form['issues'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No newsletters available.'),
);
$form['pager'] = array(
'#theme' => 'pager',
);
return $form;
}