function mailing_list_update_6000 in Mailing List 6
Same name and namespace in other branches
- 7 mailing_list.install \mailing_list_update_6000()
Update mailing lists to allow subscriber names (not just e-mails), and clean up field names.
File
- ./
mailing_list.install, line 97 - Install and update functions for mailing_list.
Code
function mailing_list_update_6000() {
$ret = array();
db_change_field($ret, 'mailing_list', 'id', 'mlid', array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
));
db_change_field($ret, 'mailing_list', 'list', 'name', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
), array(
'indexes' => array(
'name' => array(
'name',
),
),
));
db_change_field($ret, 'mailing_list_emails', 'id', 'eid', array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
));
db_change_field($ret, 'mailing_list_emails', 'mailing_list_id', 'mlid', array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
), array(
'indexes' => array(
'mlid' => array(
'mlid',
),
),
));
db_change_field($ret, 'mailing_list_emails', 'email', 'mail', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
), array(
'indexes' => array(
'mail' => array(
'mail',
),
),
'unique keys' => array(
'mlid_mail' => array(
'mlid',
'mail',
),
),
));
db_add_field($ret, 'mailing_list_emails', 'name', array(
'type' => 'varchar',
'not null' => TRUE,
'length' => 255,
), array(
'indexes' => array(
'name' => array(
'name',
),
),
));
$ret[] = update_sql("DELETE FROM {permission} WHERE perm = 'export mailing list'");
$result = db_query("SELECT rid, perm FROM {permission} WHERE perm = 'administer mailing list' ORDER BY rid");
while ($role = db_fetch_object($result)) {
$ret[] = update_sql("UPDATE {permission} SET perm = 'administer mailing lists' WHERE rid = {$role->rid}");
}
return $ret;
}