You are here

function heartbeat_update_7017 in Heartbeat 7

Set 'in_group' for existing activity records.

File

./heartbeat.install, line 451
Installation file for the heartbeat module. @author Jochen Stals - Menhir - www.menhir.be

Code

function heartbeat_update_7017() {

  // Add the in_group field if it does not exists yet.
  if (!db_field_exists('heartbeat_activity', 'in_group')) {
    db_add_field('heartbeat_activity', 'in_group', array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'big',
      'description' => t('Indicates whether the activity is related to a group.'),
      'default' => 0,
    ));

    // Change the value for each record that has something to do with groups.
    if (module_exists('og')) {
      db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid IN (SELECT DISTINCT etid FROM {og})");
      db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid_target IN (SELECT DISTINCT etid FROM {og})");
    }
  }
}