scs_addon_default_audience.module in Simplenews Content Selection 6.2
Adds the possibility to add a default audience to the created newsletter
File
contrib/scs_addon_default_audience/scs_addon_default_audience.moduleView source
<?php
//$Id$
/**
* @file
* Adds the possibility to add a default audience to the created newsletter
*/
/**
* Implements hook_scs_addon_settings()
*/
function scs_addon_default_audience_scs_addon_settings() {
$options = _get_tids(variable_get('simplenews_vid', ''));
$form['scs_addon_default_audience']['scs_addon_default_audience_tid'] = array(
'#type' => 'select',
'#title' => 'default taxonomy term',
'#default_value' => variable_get('scs_addon_default_audience_tid', 0),
'#options' => $options,
);
return $form;
}
/**
* Implements hook_scs_create_newsletter()
*/
function scs_addon_default_audience_scs_create_newsletter(&$newsletter, $options) {
$tid = variable_get('scs_addon_default_audience_tid', '');
$taxonomy = taxonomy_get_term($tid);
$newsletter->taxonomy = array(
$tid => $taxonomy,
);
}
function _get_tids($vid) {
$result = taxonomy_get_tree($vid);
$options = array();
$options[0] = t('Select default taxonomy');
foreach ($result as $key => $obj) {
$options[$obj->tid] = $obj->name;
}
return $options;
}
Functions
Name![]() |
Description |
---|---|
scs_addon_default_audience_scs_addon_settings | Implements hook_scs_addon_settings() |
scs_addon_default_audience_scs_create_newsletter | Implements hook_scs_create_newsletter() |
_get_tids |