Index: mailing_list.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mailing_list/mailing_list.admin.inc,v retrieving revision 1.3 diff -u -p -r1.3 mailing_list.admin.inc --- mailing_list.admin.inc 5 Aug 2009 00:31:16 -0000 1.3 +++ mailing_list.admin.inc 6 Aug 2009 02:37:53 -0000 @@ -20,7 +20,7 @@ function mailing_list_lists() { $rows = array(); $destination = drupal_get_destination(); while ($list = db_fetch_object($result)) { - $row = array(l(check_plain($list->name), "admin/build/mailing-list/$list->mlid"), l(t('list e-mails'), "admin/build/mailing-list/$list->mlid"), l(t('import e-mails'), "admin/build/mailing-list/$list->mlid/import", array('query' => $destination)), l(t('export list'), "admin/build/mailing-list/$list->mlid/export", array('query' => $destination)), l(t('rename list'), "admin/build/mailing-list/$list->mlid/edit", array('query' => $destination)), l(t('delete list'), "admin/build/mailing-list/$list->mlid/delete", array('query' => $destination))); + $row = array(l(check_plain($list->name), "admin/build/mailing-list/$list->mlid"), l(t('list e-mails'), "admin/build/mailing-list/$list->mlid"), l(t('import e-mails'), "admin/build/mailing-list/$list->mlid/import", array('query' => $destination)), l(t('export list'), "admin/build/mailing-list/$list->mlid/export", array('query' => $destination)), l(t('edit list'), "admin/build/mailing-list/$list->mlid/edit", array('query' => $destination)), l(t('delete list'), "admin/build/mailing-list/$list->mlid/delete", array('query' => $destination))); $rows[] = $row; } @@ -76,7 +76,7 @@ function mailing_list_emails($list = NUL } /** - * Form for adding / renaming a mailing list. + * Form for adding / editing a mailing list. */ function mailing_list_form(&$form_state, $list = null) { if (empty($list)) { @@ -100,6 +100,13 @@ function mailing_list_form(&$form_state, '#required' => TRUE, '#default_value'=> isset($form_state['values']['name']) ? $form_state['values']['name']: isset($list)?$list->name : '', ); + $form['show_subscriber_name'] = array( + '#title' => t('Show name field in subscription form'), + '#type' => 'checkbox', + '#required' => TRUE, + '#default_value'=> isset($form_state['values']['show_subscriber_name']) ? $form_state['values']['show_subscriber_name']: isset($list)?$list->show_subscriber_name : 1, + '#description' => t('Whether to show a text field on the subscription block form where a subscriber must enter her name.'), + ); $form['submit'] = array( '#value' => t('Save'), '#type' => 'submit', @@ -111,22 +118,22 @@ function mailing_list_form(&$form_state, } /** - * Submit handler for the add / rename mailing list form. + * Submit handler for the add / edit mailing list form. */ function mailing_list_form_submit($form, &$form_state) { // drupal_set_message('
'. print_r($form_state['values'],1 ) . '
'); if (isset($form_state['values']['mlid'])) { - $query = "UPDATE {mailing_list} SET name = '%s' WHERE mlid = %d"; - $result = db_query($query, $form_state['values']['name'], $form_state['values']['mlid']); + $query = "UPDATE {mailing_list} SET name = '%s', show_subscriber_name = %d WHERE mlid = %d"; + $result = db_query($query, $form_state['values']['name'], $form_state['values']['show_subscriber_name'], $form_state['values']['mlid']); } else { - $query = "INSERT INTO {mailing_list} (name) VALUES ('%s')"; - $result = db_query($query, $form_state['values']['name']); + $query = "INSERT INTO {mailing_list} (name, show_subscriber_name) VALUES ('%s', %d)"; + $result = db_query($query, $form_state['values']['name'], $form_state['values']['show_subscriber_name']); } if ($result) { if (isset($form_state['values']['mlid']) ) { - drupal_set_message(t('Renamed mailing list %name', array('%name' => $form_state['values']['name']))); + drupal_set_message(t('Updated mailing list %name', array('%name' => $form_state['values']['name']))); watchdog('mailing_list', 'Mailing list: renamed %name.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE, l(t('view'), 'admin/build/mailing-list/'. $form_state['values']['mlid'])); } else { Index: mailing_list.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mailing_list/mailing_list.install,v retrieving revision 1.5 diff -u -p -r1.5 mailing_list.install --- mailing_list.install 5 Aug 2009 00:31:16 -0000 1.5 +++ mailing_list.install 6 Aug 2009 02:37:53 -0000 @@ -41,6 +41,12 @@ function mailing_list_schema() { 'length' => 255, 'not null' => TRUE, ), + 'show_subscriber_name' => array( + 'description' => 'Boolean indicating whether to show a text field on the subscription block form where a subscriber must enter her name.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), ), 'primary key' => array('mlid'), 'indexes' => array( @@ -167,3 +173,22 @@ function mailing_list_update_6000() { return $ret; } + +/** + * Migrate from 'mailing_list_show_name_x' variables to having a + * 'show_subscriber_name' field in the 'mailing_list' table. + */ +function mailing_list_update_6001() { + $ret = array(); + + db_add_field($ret, 'mailing_list', 'show_subscriber_name', array('type' => 'int', 'not null' => TRUE, 'default' => 0)); + + $query = db_query('SELECT * FROM {mailing_list}'); + while ($list = db_fetch_object($query)) { + $show_subscriber_name = variable_get('mailing_list_show_name_'. $list->mlid, 1); + $ret[] = update_sql("UPDATE {mailing_list} SET show_subscriber_name = %d WHERE mlid = %d", $show_subscriber_name, $list->mlid); + variable_del('mailing_list_show_name_'. $list->mlid); + } + + return $ret; +} Index: mailing_list.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mailing_list/mailing_list.module,v retrieving revision 1.5 diff -u -p -r1.5 mailing_list.module --- mailing_list.module 5 Aug 2009 00:31:16 -0000 1.5 +++ mailing_list.module 6 Aug 2009 02:37:54 -0000 @@ -89,7 +89,7 @@ function mailing_list_menu() { 'file' => 'mailing_list.admin.inc', ); $items['admin/build/mailing-list/%mailing_list/edit'] = array( - 'title' => t('Rename list'), + 'title' => t('Edit list'), 'page callback' => 'drupal_get_form', 'page arguments' => array('mailing_list_form', 3), 'access arguments' => array('administer mailing lists'), @@ -132,18 +132,6 @@ function mailing_list_menu() { 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); @@ -241,7 +229,7 @@ function mailing_list_subscription_form( '#type' => 'hidden', '#value' => $list->name, ); - if (variable_get('mailing_list_show_name_'. $list->mlid, 1)) { + if ($list->show_subscriber_name) { $form['name'] = array( '#title' => t('Name'), '#type' => 'textfield',