You are here

function zoomapi_update_7201 in Zoom API 7.2

Migrate Zoom API users to v2.

File

./zoomapi.install, line 105
Install, update, and uninstall hooks for the Zoom API module.

Code

function zoomapi_update_7201(&$sandbox) {
  module_load_include('inc', 'zoomapi', 'zoomapi.migrate');
  if (!isset($sandbox['progress'])) {
    db_truncate('zoomapi_users')
      ->execute();
    $sandbox['items'] = db_query('SELECT uid, data FROM {users} WHERE uid > 0 AND data IS NOT NULL')
      ->fetchAllKeyed(0, 1);
    $sandbox['progress'] = 0;
    $sandbox['max'] = count($sandbox['items']);
    $sandbox['current_id'] = 0;
  }
  reset($sandbox['items']);
  $uid = key($sandbox['items']);
  $item = $sandbox['items'][$uid];
  unset($sandbox['items'][$uid]);
  $data = unserialize($item);
  $sandbox['current_id'] = $uid;
  if (!empty($data['zoomapi_user_id'])) {
    zoomapi_migrate_users_batch_operation_populate_table($uid, $data);
    zoomapi_migrate_users_batch_operation_clean_data($uid, $data);
  }
  $sandbox['progress']++;
  $sandbox['#finished'] = $sandbox['progress'] >= $sandbox['max'] ? TRUE : $sandbox['progress'] / $sandbox['max'];
  if ($sandbox['#finished']) {
    return t('Completed Zoom API users v1 to v2 migration.');
  }
}