You are here

function heartbeat_update_410 in Heartbeat 6.4

Update to version 4.10.x

Return value

sql statements array

1 call to heartbeat_update_410()
heartbeat_comments_update_410 in modules/heartbeat_comments/heartbeat_comments.install
Update to version 4.10.x

File

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

Code

function heartbeat_update_410() {

  // Prevent this update hook from running twice.
  // @see heartbeat_comments_update_410().
  static $run = FALSE;
  if ($run) {
    return;
  }
  $run = TRUE;

  // Add the translations table for multilingual comments
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {heartbeat_activity} ADD nid_info VARCHAR(128) NULL DEFAULT '' AFTER language");
      $ret[] = update_sql("ALTER TABLE {heartbeat_activity} ADD nid_target_info VARCHAR(128) NULL DEFAULT '' AFTER nid_info");
      $ret[] = update_sql("ALTER TABLE {heartbeat_activity} ADD uaid_comments INT NULL DEFAULT 0 AFTER nid_target_info");
      break;
  }
  $result = db_query("SELECT uaid, nid, nid_target FROM {heartbeat_activity} WHERE nid > 0");
  while ($row = db_fetch_object($result)) {
    $save_nid = array();
    $save_nid_target = array();
    $this_node = NULL;
    $this_node = node_load($row->nid);
    $save_nid = array();
    $save_nid['uid'] = $this_node->uid;
    $save_nid['type'] = $this_node->type;
    $save_nid['format'] = $this_node->format;
    if ($row->nid_target > 0) {
      $this_node_target = node_load($row->nid_target);
      $save_nid_target['uid'] = $this_node_target->uid;
      $save_nid_target['type'] = $this_node_target->type;
      $save_nid_target['format'] = $this_node_target->format;
    }
    $save_nid_ser = serialize($save_nid);
    $save_nid_target_ser = serialize($save_nid_target);
    $update_q = "UPDATE {heartbeat_activity} set nid_info = '%s', nid_target_info = '%s' WHERE uaid = %d";
    db_query($update_q, $save_nid_ser, $save_nid_target_ser, $row->uaid);
  }
  return $ret;
}