function party_simplenews_form_simplenews_admin_subscription_alter in Party 8.2
Implements hook_form_FORM_ID_alter.
File
- modules/
party_simplenews/ party_simplenews.module, line 364 - Main module file for Party Simplenews integration
Code
function party_simplenews_form_simplenews_admin_subscription_alter(&$form, &$form_state) {
$table =& $form['admin']['subscribers'];
$new_header = array();
foreach ($table['#header'] as $key => $array) {
$new_header[$key] = $array;
if ($key == 'username') {
$new_header['party'] = array(
'data' => 'Party',
'field' => 'sn.party_id',
);
}
}
$table['#header'] = $new_header;
// Do a query to get the party ID's from the table
$query = db_select('party_simplenews_subscriber', 'sn');
$query
->leftJoin('party', 'p', 'sn.party_id = p.pid');
$party_ids = $query
->fields('sn', array(
'snid',
'party_id',
))
->fields('p', array(
'label',
))
->execute()
->fetchAllAssoc('snid', PDO::FETCH_ASSOC);
foreach ($table['#options'] as $key => $row) {
//$party = party_load($party_ids[$key]['party_id']);
if (!empty($party_ids[$key])) {
$row['party'] = l($party_ids[$key]['label'], 'party/' . $party_ids[$key]['party_id']);
}
else {
$row['party'] = '';
}
$table['#options'][$key] = $row;
}
}