function simplenews_subscription_list_form in Simplenews 7.2
Same name and namespace in other branches
- 5 simplenews.module \simplenews_subscription_list_form()
- 6.2 includes/simplenews.admin.inc \simplenews_subscription_list_form()
- 6 simplenews.admin.inc \simplenews_subscription_list_form()
- 7 includes/simplenews.admin.inc \simplenews_subscription_list_form()
Menu callback: subscription administration.
@todo Subscriber maintanance needs overhaul now we have more data availabale.
See also
simplenews_subscription_list_form_validate()
simplenews_subscription_list_form_submit()
1 call to simplenews_subscription_list_form()
- simplenews_admin_subscription in includes/
simplenews.admin.inc - Menu callback: subscription administration.
File
- includes/
simplenews.admin.inc, line 1040 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_subscription_list_form() {
// 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_subscription_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_subscription_list_form_submit',
),
'#validate' => array(
'simplenews_subscription_list_form_validate',
),
);
// Table header. Used as tablesort default
$header = array(
'mail' => array(
'data' => t('Email'),
'field' => 'sn.mail',
'sort' => 'asc',
),
'username' => array(
'data' => t('Username'),
'field' => 'u.name',
),
'status' => array(
'data' => t('Status'),
'field' => 'sn.activated',
),
'language' => array(
'data' => t('Language'),
'field' => 'sn.language',
),
'operations' => array(
'data' => t('Operations'),
),
);
$query = db_select('simplenews_subscriber', 'sn')
->extend('PagerDefault')
->extend('TableSort');
simplenews_build_subscription_filter_query($query);
$query
->leftJoin('users', 'u', 'sn.uid = u.uid');
$query
->innerJoin('simplenews_subscription', 'su', 'sn.snid = su.snid');
$query
->condition('su.status', SIMPLENEWS_SUBSCRIPTION_STATUS_SUBSCRIBED);
$query
->addField('u', 'name', 'name');
$result = $query
->fields('sn', array(
'snid',
'activated',
'mail',
'uid',
'language',
))
->limit(30)
->orderByHeader($header)
->execute();
$options = array();
$destination = drupal_get_destination();
foreach ($result as $subscriber) {
$options[$subscriber->snid] = array(
'mail' => check_plain($subscriber->mail),
'username' => isset($subscriber->uid) ? l($subscriber->name, 'user/' . $subscriber->uid) : check_plain($subscriber->name),
'status' => theme('simplenews_status', array(
'source' => 'activated',
'status' => $subscriber->activated,
)),
'language' => check_plain($subscriber->language),
'operations' => l(t('edit'), 'admin/people/simplenews/users/edit/' . $subscriber->snid, array(), $destination),
);
}
$form['subscribers'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No subscribers available.'),
);
$form['pager'] = array(
// Calling theme('pager') directly so that it the first call after the
// pager query executed above.
'#markup' => theme('pager'),
);
return $form;
}