You are here

function install_from_db_form in Open Atrium 7.2

Prompt user to select normal or quick installation method TODO: Check db to be sure it is mysql, or provide mechanism for using dumps of other database types.

See also

install_from_db_form_validate()

install_from_db_form_submit()

1 string reference to 'install_from_db_form'
install_from_db_install_tasks_alter in install_from_db/install_from_db.profile
CALL THIS from your profile_install_tasks_alter() hook function.

File

install_from_db/install_from_db.profile, line 50
Install profile helper to add option for importing from database.

Code

function install_from_db_form($form, &$form_state, &$install_state) {
  $profile = $install_state['parameters']['profile'];

  // Find database dump in the /db folder within the profile
  // TODO: support different database dump formats.
  $filename = DRUPAL_ROOT . '/profiles/' . $profile . '/db/' . $profile . '.mysql';
  $conn = Database::getConnection('default');
  if (!file_exists($filename) || !$conn || $conn
    ->driver() !== 'mysql') {

    // can't do quickstart if no db dump exists
    // also only allow quickstart for mysql databases currently.
    unset($install_state['parameters']['quickstart']);
    $form_state['executed'] = TRUE;
    return;
  }
  $install_state['parameters']['db_import_filename'] = $filename;
  if ($install_state['interactive'] && !empty($install_state['parameters']['quickstart'])) {

    // If url argument is already specified, then just use it.
    $form_state['input']['quickstart'] = $install_state['parameters']['quickstart'];
    $form_state['executed'] = TRUE;
    return;
  }
  if (!$install_state['interactive'] && !isset($form_state['values']['quickstart'])) {

    // Default non-interactive to quickstart.
    $install_state['parameters']['quickstart'] = 'quick';
    $form_state['input']['quickstart'] = 'quick';
  }
  $form['quickstart']['quick'] = array(
    '#type' => 'radio',
    '#value' => 'quick',
    '#return_value' => 'quick',
    '#title' => st('Quick installation'),
    '#description' => st('Quickly install using a predefined database dump. (recommended)'),
    '#parents' => array(
      'quickstart',
    ),
  );
  $form['quickstart']['standard'] = array(
    '#type' => 'radio',
    '#value' => 'quick',
    '#return_value' => 'standard',
    '#title' => st('Standard installation'),
    '#description' => st('Install using the full Drupal process.  This is slower.'),
    '#parents' => array(
      'quickstart',
    ),
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => st('Save and continue'),
  );
  return $form;
}