'radios', '#title' => t('Update method'), '#description' => t('Automatic log retrieval requires cron.'), '#default_value' => isset($repository) ? $repository['fakevcs_specific']['update_method'] : VERSIONCONTROL_FAKEVCS_UPDATE_CRON, '#weight' => 10, '#options' => array( VERSIONCONTROL_FAKEVCS_UPDATE_CRON => t('Automatic log retrieval.'), VERSIONCONTROL_FAKEVCS_UPDATE_SCRIPT => t('Use external script to insert data.'), ), ); } /** * Implementation of hook_versioncontrol_repository_submit(): * Extract repository data from the repository editing/adding form's * submitted values, and add it to the @p $repository array. Later, that array * will be passed to hook_versioncontrol_repository() as part of the repository * insert/update procedure. */ function versioncontrol_fakevcs_versioncontrol_repository_submit(&$repository, $form, $form_state) { if (!isset($form['#versioncontrol_fakevcs'])) { return; } $repository['fakevcs_specific']['update_method'] = $form_state['values']['update_method']; } /** * Implementation of hook_versioncontrol_alter_repository_list(): * Add CVS specific columns into the list of CVS repositories. * By changing the @p $header and @p $rows_by_repo_id arguments, * the repository list can be customized accordingly. * * @param $vcs * The unique string identifier for the version control system that * the passed repository list covers. * @param $repositories * An array of repositories of the given version control system. * Array keys are the repository ids, and array values are the * repository arrays like returned from versioncontrol_get_repository(). * @param $header * A list of columns that will be passed to theme('table'). * @param $rows_by_repo_id * An array of existing table rows, with repository ids as array keys. * Each row already includes the generic column values, and for each row * there is a repository with the same repository id given in the * @p $repositories parameter. */ function versioncontrol_fakevcs_versioncontrol_alter_repository_list($vcs, $repositories, &$header, &$rows_by_repo_id) { if ($vcs != 'fakevcs') { return; } $header[] = t('Update method'); foreach ($rows_by_repo_id as $repo_id => $row) { switch ($repositories[$repo_id]['fakevcs_specific']['update_method']) { case VERSIONCONTROL_FAKEVCS_UPDATE_SCRIPT: $rows_by_repo_id[$repo_id][] = t('external script'); break; case VERSIONCONTROL_FAKEVCS_UPDATE_CRON: $rows_by_repo_id[$repo_id][] = t('logs (!fetch)', array( '!fetch' => l(t('fetch now'), 'admin/content/versioncontrol-repositories/update/'. $repo_id) )); break; default: break; } } } /** * Add FakeVCS specific elements to the edit/register user account form. */ function versioncontrol_fakevcs_account_form_alter(&$form, $form_state, $form_id) { $form['#versioncontrol_fakevcs'] = TRUE; if (empty($form['#original_username'])) { // creating the account $description = t('Choose a password to access the FakeVCS repository with.'); } else { // editing the account $description = t('To change the current FakeVCS password, enter the new password in both fields.'); } $form['account']['account_password'] = array( '#type' => 'password_confirm', '#title' => t('FakeVCS password'), '#description' => $description, '#weight' => 10, ); $form['#validate'][] = 'versioncontrol_fakevcs_account_form_validate'; } /** * Additional validation for the edit/register user account form. */ function versioncontrol_fakevcs_account_form_validate($form, &$form_state) { if (!empty($form['#original_username']) && empty($form_state['values']['account_password'])) { return; // The (existing) user didn't change the password. } elseif (drupal_strlen($form_state['values']['account_password']) < VERSIONCONTROL_FAKEVCS_MIN_PASSWORD_LENGTH) { form_set_error('account_password', t('The FakeVCS password you have chosen is too short (it must be at least !min characters long).', array('!min' => VERSIONCONTROL_FAKEVCS_MIN_PASSWORD_LENGTH))); } }