You are here

function notifications_update_6006 in Notifications 6.3

Same name and namespace in other branches
  1. 6.4 notifications.install \notifications_update_6006()

Language enable everything and normalize language field

File

./notifications.install, line 394

Code

function notifications_update_6006() {
  $ret = array();
  $language_field = array(
    'type' => 'varchar',
    'length' => 12,
    'not null' => TRUE,
    'default' => '',
  );
  $language_default = language_default('language');
  $ret[] = update_sql("UPDATE {notifications_queue} SET language = '{$language_default}' WHERE language = '' OR language IS NULL");
  $ret[] = update_sql("UPDATE {notifications_event} SET language = '{$language_default}' WHERE language = '' OR language IS NULL");
  db_change_field($ret, 'notifications_queue', 'language', 'language', $language_field);

  //db_change_field($ret, 'notifications_event', 'language', 'language', $language_field);

  // Add language to 'notifications' and populate with user's language or default language
  db_add_field($ret, 'notifications', 'language', $language_field);
  $ret[] = update_sql("UPDATE {notifications} n SET language = (SELECT language FROM {users} u WHERE n.uid = u.uid AND u.language <> '')");
  $ret[] = update_sql("UPDATE {notifications} SET language = '{$language_default}' WHERE language = '' OR language IS NULL");
  return $ret;
}