You are here

function fb_connect_update_6201 in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb_connect.install \fb_connect_update_6201()

File

./fb_connect.install, line 36
Install functions for fb_connect.module.

Code

function fb_connect_update_6201() {
  $items = array();
  foreach (array(
    'fb_connect_primary',
    'fb_connect_login',
  ) as $prefix) {
    $oldvar = $prefix . '_nid';
    $newvar = $prefix . '_label';

    // Variable fb_connect_primary_apikey is now fb_connect_primary_nid
    if ($old = variable_get($oldvar, NULL)) {
      $result = db_query("SELECT * FROM {fb_app} WHERE nid = %d", $old);
      $data = db_fetch_object($result);
      if ($data->label) {
        variable_set($newvar, $data->label);
        $items[] = array(
          'success' => TRUE,
          'query' => "updated {$newvar} to be {$data->label}",
        );
        variable_del($oldvar);
      }
      else {
        $items[] = array(
          'success' => FALSE,
          'query' => "Could not find {$oldvar} by nid ({$old})",
        );
      }
    }
  }
  return $items;
}