'fieldset',
'#title' => t('Show issues from'),
'#collapsible' => FALSE,
'#prefix' => '
',
'#suffix' => '
',
);
$header = array(t('Title'), t('Newsletter'), t('Date created'), t('Published'), t('Sent'), t('Edit'));
list($names, $queries) = array_values(simplenews_get_filter('simplenews_newsletters_filter'));
$filter = isset($_SESSION['simplenews_newsletters_filter']) ? $_SESSION['simplenews_newsletters_filter'] : '';
$queryfilter = isset($queries[$filter]) ? $queries[$filter] : '';
if ($action == 'notsent') {
$form['simplenews_issue_filter']['filter'] = array(
'#type' => 'select',
'#options' => $names,
'#default_value' => $filter,
);
$query = "SELECT DISTINCT n.*, s.s_status FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d". $queryfilter ." ORDER BY n.created DESC";
$count_query = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d". $queryfilter;
}
else {
$form['simplenews_issue_filter']['filter'] = array(
'#type' => 'select',
'#options' => $names,
'#default_value' => $filter,
);
$query = "SELECT n.*, s.s_status FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status > %d". $queryfilter ." ORDER BY n.created DESC";
$count_query = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {simplenews_newsletters} s ON n.nid = s.nid WHERE s.s_status > %d". $queryfilter;
}
$result = pager_query(db_rewrite_sql($query, 'n', 'nid', array(SIMPLENEWS_STATUS_SEND_NOT)), 10, 0, db_rewrite_sql($count_query, 'n', 'nid', array(SIMPLENEWS_STATUS_SEND_NOT)), 0);
$rows = array();
while ($node = db_fetch_object($result)) {
$terms = array_keys(taxonomy_node_get_terms_by_vocabulary($node, $vid, 'name'));
$rows[] = array(l($node->title, 'node/'. $node->nid),
isset($terms[0]) ? $terms[0] : t('n/a'),
format_date($node->created, 'small'),
theme('simplenews_status', $node->status, 'published'),
theme('simplenews_status', $node->s_status, 'sent'),
l(t('edit'), 'node/'. $node->nid .'/edit', array(), drupal_get_destination()));
}
if ($pager = theme('pager', NULL, 10, 0)) {
$rows[] = array(array('data' => $pager, 'colspan' => '6'));
}
if (!$rows) {
$rows[] = array(array('data' => t('No newsletters available.'), 'colspan' => '6'));
}
$form['simplenews_issue_filter']['submit'] = array(
'#type' => 'submit',
'#value' => t('Filter'),
);
$table = theme('table', $header, $rows);
$form['table'] = array('#value' => $table);
return $form;
}
function simplenews_admin_news_submit($form, &$form_state) {
_simplenews_set_filter('simplenews_newsletters_filter', $form_state['values']);
}
/**
* Store filter values in session var
*
* @param $type identification string
* @param $form_values array of values to be stored
*/
function _simplenews_set_filter($type, $values) {
if (empty($_SESSION[$type])) {
$_SESSION[$type] = 'all';
}
$op = $values['op'];
if ($op == t('Filter') && isset($values['filter'])) {
$_SESSION[$type] = $values['filter'];
}
}
/**
* Menu callback: newsletter admin form with list of available newsletter series.
*/
function simplenews_types_overview() {
$rows = array();
$header = array(t('Newsletter name'), t('Subscribers'), t('Operations'));
foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $term) {
$count_result = db_query('SELECT COUNT(s.snid) AS s_count FROM {simplenews_subscriptions} s INNER JOIN {simplenews_snid_tid} t ON s.snid = t.snid WHERE s.activated = %d AND t.tid = %d', 1, $term->tid);
$count = (int) db_result($count_result);
$rows[] = array(check_plain($term->name), $count, l(t('edit newsletter'), 'admin/content/simplenews/types/edit/'. $term->tid));
}
if (count($rows) == 0) {
$rows[] = array(array('data' => t('There are currently no newsletter series.'), 'colspan' => count($header)));
}
return theme('table', $header, $rows);
}
/**
* Menu callback: newsletter admin form for newsletter add/edit.
*
* @see simplenews_admin_types_form_validate()
* @see simplenews_admin_types_form_submit()
*/
function simplenews_admin_types_form(&$form_state, $tid = NULL) {
if (isset($tid)) {
// We are editing an existing newsletter.
$term = taxonomy_get_term($tid);
// If the given term is not a newsletter, don't allow editing.
if (variable_get('simplenews_vid', '') != $term->vid) {
drupal_not_found();
return;
}
// Redirect on a delete operation for posterity's sake.
if (isset($form_state['post']['op']) && $form_state['post']['op'] == t('Delete')) {
drupal_goto('admin/content/simplenews/types/delete/'. $term->tid);
}
}
else {
// We will create a new newsletter.
// Provide vocabulary id for the newsletter to be added to.
$term = (object)array('vid' => variable_get('simplenews_vid', ''));
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Newsletter name'),
'#size' => 50,
'#maxlength' => 128,
'#description' => t('This name of this newsletter.'),
'#required' => TRUE,
'#default_value' => isset($term->name) ? $term->name : '',
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#cols' => 60,
'#rows' => 5,
'#description' => t('A description of the newsletter. To be displayed on taxonomy/term pages and RSS feeds.'),
'#default_value' => isset($term->description) ? $term->description : '',
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#delta' => 10,
'#description' => t('Newsletters are displayed in ascending order by weight.'),
'#required' => TRUE,
'#default_value' => isset($term->weight) ? $term->weight : 0,
);
$form['simplenews_sender_information'] = array(
'#type' => 'fieldset',
'#title' => t('Sender information'),
'#collapsible' => FALSE,
);
$form['simplenews_sender_information']['simplenews_from_name_'. $term->tid] = array(
'#type' => 'textfield',
'#title' => t('From name'),
'#size' => 60,
'#maxlength' => 128,
'#default_value' => variable_get('simplenews_from_name_'. $term->tid, variable_get('simplenews_from_name', variable_get('site_name', 'Drupal'))),
);
$form['simplenews_sender_information']['simplenews_from_address_'. $term->tid] = array(
'#type' => 'textfield',
'#title' => t('From email address'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => variable_get('simplenews_from_address_'. $term->tid, variable_get('simplenews_from_address', variable_get('site_mail', ini_get('sendmail_from')))),
);
$form['simplenews_hyperlinks'] = array('#type' => 'fieldset',
'#title' => t('HTML to text conversion'),
'#collapsible' => FALSE,
'#description' => t('When your newsletter is sent as plain text, these options will determine how the conversion to text is performed.'),
);
$form['simplenews_hyperlinks']['simplenews_hyperlinks_'. $term->tid] = array(
'#type' => 'radios',
'#title' => t('Hyperlink conversion'),
'#options' => array(
t('Append hyperlinks as a numbered reference list'),
t('Display hyperlinks inline with the text')
),
'#default_value' => variable_get('simplenews_hyperlinks_'. $term->tid, 1),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 25,
);
$form['vid'] = array(
'#type' => 'hidden',
'#value' => isset($term->vid) ? $term->vid : variable_get('simplenews_vid', ''),
);
// If we are editing a newsletter term, show delete option and store tid.
// tid is used in validation and submission functions to differentiate
// between form actions of creating a new or editing an existing term.
if (isset($term->tid)) {
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#weight' => 30,
);
$form['tid'] = array(
'#type' => 'value',
'#value' => $term->tid,
);
}
// Return to Newsletter list page after submit
$form['#redirect'] = 'admin/content/simplenews/types';
return $form;
}
function simplenews_admin_types_form_validate($form, &$form_state) {
$tid = $form_state['values']['tid'];
$field_name = 'simplenews_from_address_'. $tid;
if (!valid_email_address($form_state['values'][$field_name])) {
form_set_error($field_name, t("The sender's email address you supplied is not valid."));
}
}
function simplenews_admin_types_form_submit($form, &$form_state) {
// Redirect on a delete operation for posterity's sake.
if (isset($form_state['post']['op']) && $form_state['post']['op'] == t('Delete')) {
drupal_goto('admin/content/simplenews/types/delete/'. $term->tid);
}
// Create or update taxonomy term for this newsletter.
// When creating a term $form_state['values']['tid'] is NULL.
if (isset($form_state['values']['tid'])) {
$termdata = (array)taxonomy_get_term($form_state['values']['tid']);
}
$termdata['tid'] = $form_state['values']['tid'];
$termdata['vid'] = $form_state['values']['vid'];
$termdata['name'] = $form_state['values']['name'];
$termdata['description'] = $form_state['values']['description'];
$termdata['weight'] = $form_state['values']['weight'];
switch (taxonomy_save_term($termdata)) {
case SAVED_NEW:
drupal_set_message(t('Created new term %name.', array('%name' => $form_state['values']['name'])));
break;
case SAVED_UPDATED:
drupal_set_message(t('Updated term %name.', array('%name' => $form_state['values']['name'])));
break;
}
// Store newsletter specific settings.
// When editing a newsletter fieldnames have $tid suffix.
// When creating a new newsletter field names have no suffix
// and $form_state['values']['tid'] is NULL.
if (isset($form_state['values']['tid'])) {
$tid = $suffix = $form_state['values']['tid'];
}
else {
// Get the tid from the database based on the form values used above to
// create a new term.
$tid = db_result(db_query("SELECT t.tid FROM {term_data} t WHERE t.vid = %d AND t.name = '%s' ORDER BY t.tid DESC", $form_state['values']['vid'], $form_state['values']['name']));
$suffix = '';
}
variable_set('simplenews_from_name_'. $tid, $form_state['values']['simplenews_from_name_'. $suffix]);
variable_set('simplenews_from_address_'. $tid, $form_state['values']['simplenews_from_address_'. $suffix]);
variable_set('simplenews_hyperlinks_'. $tid, $form_state['values']['simplenews_hyperlinks_'. $suffix]);
}
/**
* Menu callback: Delete newsletter series.
*
* @see simplenews_admin_types_delete_submit()
*/
function simplenews_admin_types_delete(&$form_state, $tid = NULL) {
if (!isset($tid)) {
drupal_not_found();
return;
}
$term = taxonomy_get_term($tid);
$form = array();
$form['tid'] = array(
'#type' => 'value',
'#value' => $tid,
);
$form['notice'] = array(
'#value' => ''. t('Note: All subscriptions associated with this newsletter will be lost.') .'
',
);
$form['#redirect'] = 'admin/content/simplenews/types';
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $term->name)),
'admin/content/simplenews/types',
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
);
}
function simplenews_admin_types_delete_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$tid = $form_state['values']['tid'];
$term = taxonomy_get_term($tid);
taxonomy_del_term($tid);
variable_del('simplenews_from_name_'. $tid);
variable_del('simplenews_from_address_'. $tid);
drupal_set_message(t('Newsletter %title has been deleted.', array('%title' => $term->name)));
}
}
/**
* Menu callback: Delete multiple subscriptions.
*
* @see simplenews_subscription_multiple_delete_confirm_submit()
*/
function simplenews_subscription_multiple_delete_confirm() {
// Subscriptions to be deleted are passed via session var.
$snids = $_SESSION['simplenews_subscriptions_delete'];
$form['snids'] = array('#prefix' => '', '#tree' => TRUE);
// array_filter returns only elements with TRUE values
foreach (array_filter($snids) as $snid => $value) {
$mail = db_result(db_query('SELECT mail FROM {simplenews_subscriptions} WHERE snid = %d', $snid));
$form['snids'][$snid] = array(
'#type' => 'hidden',
'#value' => $snid,
'#prefix' => '',
'#suffix' => check_plain($mail) ."\n"
);
}
$form['operation'] = array(
'#type' => 'hidden',
'#value' => 'delete',
);
$form['#submit'][] = 'simplenews_subscription_multiple_delete_confirm_submit';
return confirm_form($form,
t('Are you sure you want to delete these subscriptions?'),
'admin/content/simplenews/users',
t('This action cannot be undone.'),
t('Delete all'),
t('Cancel')
);
}
function simplenews_subscription_multiple_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
foreach ($form_state['values']['snids'] as $snid => $value) {
simplenews_delete_subscription($snid);
}
drupal_set_message(t('The subscriptions have been deleted.'));
}
return '';
}
/**
* Menu callback: Mass subscribe to newsletters.
*
* @see simplenews_subscription_list_add_submit()
*/
function simplenews_subscription_list_add() {
global $language;
$form['emails'] = array(
'#type' => 'textarea',
'#title' => t('Email addresses'),
'#cols' => 60,
'#rows' => 5,
'#description' => t('Email addresses must be separated by comma, space or newline.'),
);
$newsletters = array();
foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
$newsletters[$newsletter->tid] = check_plain($newsletter->name);
}
$form['newsletters'] = array(
'#type' => 'checkboxes',
'#title' => t('Subscribe to'),
'#options' => $newsletters,
'#required' => TRUE,
);
// Include language selection when the site is multilingual.
// Default value is the empty string which will result in receiving emails
// in the site's default language.
if (variable_get('language_count', 1) > 1) {
$options[''] = t('Site default language');
$languages = language_list('enabled');
foreach ($languages[1] as $langcode => $item) {
$name = t($item->name);
$options[$langcode] = $name . ($item->native != $name ? ' ('. $item->native .')' : '');
}
$form['language'] = array(
'#type' => 'radios',
'#title' => t('Anonymous user preferred language'),
'#default_value' => '',
'#options' => $options,
'#description' => t('Anonymous users will be subscribed with the selected preferred language. They will receive newsletters in this language if available. Registered users will be subscribed with their preferred language as set on their account page.'),
);
}
else {
$form['language'] = array('#type' => 'value', '#value' => '');
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Subscribe'),
);
return $form;
}
function simplenews_subscription_list_add_submit($form, &$form_state) {
$tree = taxonomy_get_tree(variable_get('simplenews_vid', ''));
$added = array();
$invalid = array();
$checked_newsletters = array_filter($form_state['values']['newsletters']);
$langcode = $form_state['values']['language'];
$emails = preg_split("/[\s,]+/", $form_state['values']['emails']);
foreach ($emails as $email) {
$email = trim($email);
if (valid_email_address($email)) {
foreach ($checked_newsletters as $tid) {
$newsletter = taxonomy_get_term($tid);
simplenews_subscribe_user($email, $newsletter->tid, FALSE, $langcode);
$added[] = $email;
}
}
else {
$invalid[] = $email;
}
}
if ($added) {
$added = implode(", ", $added);
drupal_set_message(t('The following addresses were added or updated: %added.', array('%added' => $added)));
$newsletter_names = array();
foreach ($checked_newsletters as $tid) {
$newsletter = taxonomy_get_term($tid);
$newsletter_names[] = $newsletter->name;
}
drupal_set_message(t('The addresses were subscribed to the following newsletters: %newsletters.', array('%newsletters' => implode(', ', $newsletter_names))));
}
else {
drupal_set_message(t('No addresses were added.'));
}
if ($invalid) {
$invalid = implode(", ", $invalid);
drupal_set_message(t('The following addresses were invalid: %invalid.', array('%invalid' => $invalid)), 'error');
}
}
/**
* Menu callback: Export email address of subscriptions.
*
* @see simplenews_admin_export_after_build()
*/
function simplenews_subscription_list_export() {
$form['states'] = array(
'#type' => 'checkboxes',
'#title' => t('Status'),
'#options' => array('active' => t('Active users'), 'inactive' => t('Inactive users')),
'#description' => t('Subscriptions matching the selected states will be exported.'),
'#required' => TRUE,
);
$newsletters = array();
foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
$newsletters[$newsletter->tid] = check_plain($newsletter->name);
}
$form['newsletters'] = array(
'#type' => 'checkboxes',
'#title' => t('Subscribed to'),
'#options' => $newsletters,
'#description' => t('Subscriptions matching the selected newsletters will be exported.'),
'#required' => TRUE,
);
// Emails item is initially empty. It serves as place holder. Data is added by
// simplenews_admin_export_after_build().
$form['emails'] = array();
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Export'),
);
$form['#after_build'] = array('simplenews_admin_export_after_build');
$form['#redirect'] = FALSE;
return $form;
}
function simplenews_admin_export_after_build($form, $form_element) {
if (isset($form_element['values']['op']) && $form_element['values']['op'] == t('Export')) {
$states = array_filter($form_element['values']['states']);
$newsletters = array_filter($form_element['values']['newsletters']);
// Build where clause for active/inactive state and newsletter selection.
if (isset($states['active'])) {
$where[] = 's.activated = 1';
}
if (isset($states['inactive'])) {
$where[] = 's.activated = 0';
}
$where = isset($where) ? implode(' OR ', $where) : NULL;
if ($tree = taxonomy_get_tree(variable_get('simplenews_vid', ''))) {
foreach ($tree as $newsletter) {
if (isset($newsletters[$newsletter->tid])) {
$where_tid[] = 't.tid = '. $newsletter->tid;
}
}
}
$where_tid = isset($where_tid) ? implode(' OR ', $where_tid) : NULL;
// Get subscription data
if (isset($where) && isset($where_tid)) {
$query = 'SELECT DISTINCT s.mail FROM {simplenews_subscriptions} s INNER JOIN {simplenews_snid_tid} t ON s.snid = t.snid WHERE ('. $where .') AND ('. $where_tid .')';
$result = db_query($query);
while ($mail = db_fetch_object($result)) {
$mails[] = $mail->mail;
}
}
// Build form field containing exported emails.
// The field will be included in the form where at the ['emails'] place holder.
if (isset($mails)) {
$exported_mails = implode(", ", $mails);
}
else {
$exported_mails = t('No addresses were found.');
}
$form['emails'] = array(
'#type' => 'textarea',
'#title' => t('Export results'),
'#cols' => 60,
'#rows' => 5,
'#value' => $exported_mails,
);
}
return $form;
}
/**
* Menu callback: Mass subscribe to newsletters.
*
* @see simplenews_subscription_list_remove_submit()
*/
function simplenews_subscription_list_remove() {
$form['emails'] = array(
'#type' => 'textarea',
'#title' => t('Email addresses'),
'#cols' => 60,
'#rows' => 5,
'#description' => t('Email addresses must be separated by comma, space or newline. Email addresses which are no longer subscribed to any newsletter, will be removed from the database.'),
);
$newsletters = array();
foreach (taxonomy_get_tree(variable_get('simplenews_vid', '')) as $newsletter) {
$newsletters[$newsletter->tid] = check_plain($newsletter->name);
}
$form['newsletters'] = array(
'#type' => 'checkboxes',
'#title' => t('Unsubscribe from'),
'#options' => $newsletters,
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Unsubscribe'),
);
return $form;
}
function simplenews_subscription_list_remove_submit($form, &$form_state) {
$tree = taxonomy_get_tree(variable_get('simplenews_vid', ''));
$removed = array();
$invalid = array();
$checked_newsletters = array_filter($form_state['values']['newsletters']);
$emails = preg_split("/[\s,]+/", $form_state['values']['emails']);
foreach ($emails as $email) {
$email = trim($email);
if (valid_email_address($email)) {
foreach ($checked_newsletters as $tid) {
$newsletter = taxonomy_get_term($tid);
simplenews_unsubscribe_user($email, $newsletter->tid, FALSE);
$removed[] = $email;
}
}
else {
$invalid[] = $email;
}
}
if ($removed) {
$removed = implode(", ", $removed);
drupal_set_message(t('The following addresses were unsubscribed or removed: %removed.', array('%removed' => $removed)));
$newsletter_names = array();
foreach ($checked_newsletters as $tid) {
$newsletter = taxonomy_get_term($tid);
$newsletter_names[] = $newsletter->name;
}
drupal_set_message(t('The addresses were unsubscribed from the following newsletters: %newsletters.', array('%newsletters' => implode(', ', $newsletter_names))));
}
else {
drupal_set_message(t('No addresses were removed.'));
}
if ($invalid) {
$invalid = implode(", ", $invalid);
drupal_set_message(t('The following addresses were invalid: %invalid.', array('%invalid' => $invalid)), 'error');
}
}
/**
* Menu callback: subscription administration.
*/
function simplenews_subscription_admin($form_state) {
// Delete subscriptions requires delete confirmation. This is handled with a different form
if (isset($form_state['post']['operation']) && $form_state['post']['operation'] == 'delete' && isset($form_state['post']['snids'])) {
$destination = drupal_get_destination();
$_SESSION['simplenews_subscriptions_delete'] = $form_state['post']['snids'];
// Note: we redirect from admin/content/simplenews/users to admin/content/simplenews/subscriptions/delete to make the tabs disappear.
drupal_goto("admin/content/simplenews/subscriptions/delete", $destination);
}
$form = simplenews_subscription_filter_form();
$form['admin'] = simplenews_subscription_list_form();
return $form;
}
/**
* Build the form for admin subscription.
*
* Form consists of a filter fieldset, an operation fieldset and a list of
* subscriptions maching the filter criteria.
*
* @see simplenews_subscription_list_form_validate()
* @see simplenews_subscription_list_form_submit()
*/
function simplenews_subscription_list_form() {
// Table header. Used as tablesort default
$header = array(
array('data' => t('Email'), 'field' => 'ss.mail', 'sort' => 'asc'),
array('data' => t('Username'), 'field' => 'u.name'),
array('data' => t('Status'), 'field' => 'ss.activated'),
t('Operations')
);
// Data collection with filter and sorting applied
$filter = simplenews_build_subscription_filter_query();
$query = 'SELECT DISTINCT ss.*, u.name FROM {simplenews_subscriptions} ss LEFT JOIN {users} u ON ss.uid = u.uid INNER JOIN {simplenews_snid_tid} s ON ss.snid = s.snid'. $filter['where'];
// $count_query used to count distinct records only
$count_query = preg_replace('/SELECT.*FROM /', 'SELECT COUNT(DISTINCT ss.mail) FROM ', $query);
$query .= tablesort_sql($header);
$result = pager_query($query, 30, 0, $count_query);
// Update options
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Update options'),
'#prefix' => '',
'#suffix' => '
',
);
$form['options']['operation'] = array(
'#type' => 'select',
'#options' => array(
'activate' => t('Activate'),
'inactivate' => t('Inactivate'),
'delete' => t('Delete'),
),
'#default_value' => 'activate');
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
'#submit' => array('simplenews_subscription_list_form_submit'),
'#validate' => array('simplenews_subscription_list_form_validate'),
);
$snids = array();
// Subscription table and table pager
while ($subscription = db_fetch_object($result)) {
$snids[$subscription->snid] = '';
$form['mail'][$subscription->snid] = array('#value' => $subscription->mail);
$form['name'][$subscription->snid] = array('#value' => isset($subscription->uid) ? l($subscription->name, 'user/'. $subscription->uid) : $subscription->name);
$form['status'][$subscription->snid] = array('#value' => theme('simplenews_status', $subscription->activated, 'activated'));
$form['operations'][$subscription->snid] = array('#value' => l(t('edit'), 'admin/content/simplenews/users/edit/'. $subscription->snid, array(), drupal_get_destination()));
}
$form['snids'] = array('#type' => 'checkboxes', '#options' => $snids);
$form['pager'] = array('#value' => theme('pager', NULL, 30, 0));
$form['#theme'] = 'simplenews_subscription_list';
return $form;
}
function simplenews_subscription_list_form_validate($form, &$form_state) {
if (isset($form_state['values']['operation'])) {
$snids = array_filter($form_state['values']['snids']);
if (empty($snids)) {
form_set_error('', t('No items selected.'));
}
}
}
function simplenews_subscription_list_form_submit($form, &$form_state) {
if (isset($form_state['values']['operation'])) {
$snids = array_filter($form_state['values']['snids']);
$args = array($snids);
switch ($form_state['values']['operation']) {
case 'activate':
call_user_func_array('simplenews_activate_subscription', $args);
drupal_set_message(t('The update has been performed.'));
break;
case 'inactivate':
call_user_func_array('simplenews_inactivate_subscription', $args);
drupal_set_message(t('The update has been performed.'));
break;
}
}
}
/**
* Menu callback: Simplenews admin settings - General.
*/
function simplenews_admin_settings(&$form_state) {
$vid = variable_get('simplenews_vid', '');
$address_default = variable_get('site_mail', ini_get('sendmail_from'));
$form = array();
$form['simplenews_general_settings']['simplenews_content_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types'),
'#required' => TRUE,
'#options' => array_map('check_plain', node_get_types('names')),
'#default_value' => variable_get('simplenews_content_types', array('simplenews' => 'simplenews')),
'#description' => t('Content types to be used as newsletter.'),
);
$vocabulary_options = array('' => t('