function mailing_list_block in Mailing List 6
Implementation of hook_block().
File
- ./
mailing_list.module, line 131 - Minimalistic mailing list module.
Code
function mailing_list_block($op = 'list', $delta = 0, $edit = array()) {
$block = array();
switch ($op) {
case 'configure':
$form['mailing_list_show_name_' . $delta] = array(
'#type' => 'checkbox',
'#title' => t('Show name field in subscription form'),
'#default_value' => variable_get('mailing_list_show_name_' . $delta, 1),
'#description' => t('Whether or not to show a text field in the subscription form that this block displays, letting a subscriber enter his or her name. If the name field is shown, it also becomes required.'),
);
return $form;
case 'save':
variable_set('mailing_list_show_name_' . $delta, $edit['mailing_list_show_name_' . $delta]);
case 'list':
$query = "SELECT * FROM {mailing_list}";
$result = db_query($query);
while ($list = db_fetch_object($result)) {
$block[$list->mlid] = array(
'info' => t('Mailing list: @name', array(
'@name' => $list->name,
)),
);
}
break;
case 'view':
$list = mailing_list_load($delta);
$block = array(
'subject' => check_plain($list->name),
'content' => drupal_get_form('mailing_list_subscription_form_' . $delta),
);
break;
}
return $block;
}