function simplenews_update_6005 in Simplenews 6.2
Same name and namespace in other branches
- 6 simplenews.install \simplenews_update_6005()
Add language field to subscription table and set language of existing subscribers.
File
- ./
simplenews.install, line 622 - Simplenews installation.
Code
function simplenews_update_6005() {
$ret = array();
db_add_field($ret, 'simplenews_subscriptions', 'language', array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => 'Subscriber preferred language.',
));
// Set preferred language for all current none anonymous subscribers.
$result = db_query('
SELECT s.snid, u.language
FROM {simplenews_subscriptions} s
INNER JOIN {users} u
ON u.uid = s.uid
WHERE s.uid > %d', 0);
while ($subscriber = db_fetch_object($result)) {
$ret[] = update_sql("\n UPDATE {simplenews_subscriptions}\n SET language = '%s'\n WHERE snid = %d", $subscriber->language, $subscriber->snid);
}
return $ret;
}