You are here

function scald_enable in Scald: Media Management made easy 6

Same name and namespace in other branches
  1. 7 scald.install \scald_enable()

Implementation of hook_enable().

Ensures that various configuration options are set so that Scald Core can make certain assumptions about the contents of variables.

File

./scald.install, line 633

Code

function scald_enable() {
  variable_set('scald_context_fallbacks', array(
    '@default' => array(
      'title',
    ),
  ));

  // Must be run *here* so that everything Scald Core provides is registered.
  //  Other Provider modules will have the function run for them on the basis
  //  of a custom submit handler on the Drupal System Modules form.
  scald_update_providers();

  // Register all existing Users as Scald Authors
  // Determine wether we can run it straight, or need to switch to batch processing,
  // depending on the number of users account that need to be registered.
  if (variable_get('scald_register_users_as_authors', TRUE) == FALSE) {
    return;
  }
  $count = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE uid > 0"));
  if ($count < SCALD_ENABLE_BATCH_LIMIT) {
    $context = array();
    scald_enable_batch($context);
  }
  else {
    batch_set(array(
      'title' => t('Registering all Users as potential Scald Authors'),
      'operations' => array(
        array(
          'scald_enable_batch',
          array(),
        ),
      ),
      'progress_message' => '',
      // No message because the batch function provides its own
      'file' => drupal_get_path('module', 'scald') . '/scald.install',
    ));
    batch_process('admin/build/modules');
  }
}