Index: cvs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v retrieving revision 1.106.2.19.2.32 diff -u -p -r1.106.2.19.2.32 cvs.module --- cvs.module 3 Dec 2006 01:56:05 -0000 1.106.2.19.2.32 +++ cvs.module 4 Dec 2006 00:55:56 -0000 @@ -1,6 +1,6 @@ FALSE, ); if (user_access('administer CVS')) { + // Due to the workaround being used in hook_menu to allow CVS administrators + // access to the user's account/edit section, the page title is incorrect. + if ($uid != $user->uid) { + $account = user_load(array('uid' => $uid)); + drupal_set_title(check_plain($account->name)); + } + $form['cvs']['cvs_name'] = array( '#type' => 'textfield', '#title' => t('CVS username'), @@ -932,7 +939,6 @@ function cvs_alter_project_release_form( unset($form['file']); } - /** * Alters the project_release node form during edits * @see cvs_form_alter @@ -1205,10 +1211,9 @@ function cvs_show_messages_format($resul return $output; } - function cvs_page() { _cvs_styles(); - print theme('page', cvs_show_messages()); + return cvs_show_messages(); } function cvs_page_search() { @@ -1261,7 +1266,7 @@ function cvs_page_search() { $output .= theme('box', t('Search results'), cvs_show_messages()); } - print theme('page', $output); + return $output; } /** @@ -1309,7 +1314,7 @@ function cvs_account_tracker() { _cvs_styles(); $_REQUEST['uid'] = $account->uid; drupal_set_title($account->name); - print theme('page', cvs_show_messages()); + return cvs_show_messages(); } else { drupal_not_found(); @@ -1330,7 +1335,7 @@ function cvs_mail_user($uid, $extra = '' '%manage-cvs-account-url' => url("user/$account->uid/edit/cvs", NULL, NULL, TRUE), '%cvs-admin-message' => $extra, '%cvs-admin-name' => $user->name, - '%motivation-message' => wordwrap(check_plain($account->motivation), 72) + '%motivation-message' => wordwrap($account->motivation, 72) ); switch ($account->status) { case CVS_APPROVED: @@ -1537,7 +1542,7 @@ function cvs_account_status() { $output .= '
If you are interested in reapplying for a CVS account, please amend your application accordingly and resubmit.
') + ); + } - $form['cvs_overview'] = array('#type' => 'fieldset', '#title' => t('Overview')); + $form['cvs_overview'] = array('#type' => 'fieldset', '#title' => t('Overview')); $form['cvs_overview']['overview'] = array( '#type' => 'item', '#value' => variable_get('cvs_message_auth', $strings['cvs_message_auth']), @@ -1974,6 +2023,7 @@ function cvs_application_form() { '#maxlength' => 50, '#description' => t('Choose a username to access the CVS repository with. CVS usernames should be lowercase. Spaces or other special characters are not allowed.'), '#required' => TRUE, + '#attributes' => $attributes ); $form['cvs_details']['cvs_pass'] = array( '#type' => 'password_confirm', @@ -1998,7 +2048,7 @@ function cvs_application_form() { $form['cvs_motivation']['motivation'] = array( '#type' => 'textarea', '#title' => t('Motivation'), - '#default_value' => $edit['motivation'], + '#default_value' => $application['motivation'], '#cols' => 60, '#rows' => 9, '#description' => variable_get('cvs_motivation_description', $strings['cvs_motivation_description']), @@ -2013,9 +2063,6 @@ function cvs_application_form() { function cvs_application_page_validate($form_id, $form_values) { global $user; - if (db_result(db_query("SELECT name FROM {cvs_accounts} WHERE uid = %d", $user->uid))) { - form_set_error('', t('You already requested/have a CVS account.'), 'error'); - } if ($form_values['maintain'] != 1) { form_set_error('maintain', t('Your application cannot be considered: CVS accounts are only granted to users wishing to maintain a module, theme or translation.')); } @@ -2025,7 +2072,7 @@ function cvs_application_page_validate($ if (ereg("[^[:alnum:]]", $form_values['user'])) { form_set_error('user', t('The CVS username you have chosen is invalid.')); } - if (db_result(db_query("SELECT name FROM {cvs_accounts} WHERE name = '%s'", $form_values['user']))) { + if (db_result(db_query("SELECT name FROM {cvs_accounts} WHERE name = '%s' AND uid != %d", $form_values['user'], $user->uid))) { form_set_error('user', t('The CVS username you have chosen is already in use.')); } if (strlen($form_values['cvs_pass']) < CVS_MIN_PASS_LENGTH) { @@ -2033,7 +2080,6 @@ function cvs_application_page_validate($ } } - function cvs_application_page_submit($form_id, $form_values) { global $user; @@ -2053,20 +2099,22 @@ function cvs_application_page_submit($fo $message_variables = array( '%account-name' => $user->name, '%user-account-url' => url("user/$user->uid", NULL, NULL, TRUE), - '%motivation-message' => wordwrap(check_plain($form_values['motivation']), 72), + '%motivation-message' => wordwrap($form_values['motivation'], 72), '%client-information' => implode("\n", $client_information) ); + $subject = isset($form_values['cvs_reapplication']) ? t('CVS account request [reapplication]') : t('CVS account request'); + $message = strtr(variable_get('cvs_new_application_email', $strings['cvs_new_application_email']), $message_variables); - user_mail(variable_get('cvs_email_address', 'cvs@example.com'), t('CVS account request'), $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + user_mail(variable_get('cvs_email_address', 'cvs@example.com'), $subject, $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); // Send an e-mail to the applicant: $from = t('Drupal CVS administrator <%mail>', array('%mail' => variable_get('cvs_email_address', 'cvs@example.com'))); $message = strtr(variable_get('cvs_received_email', $strings['cvs_received_email']), $message_variables); - user_mail($user->mail, t('CVS account request'), $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + user_mail($user->mail, $subject, $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); - // Add a record to the database: - db_query("INSERT INTO {cvs_accounts} (uid, name, pass, motivation, status) VALUES (%d, '%s', '%s', '%s', %d)", $user->uid, $form_values['user'], $form_values['cvs_pass'], $form_values['motivation'], CVS_QUEUED); + // Add/update a record to the database: + db_query("REPLACE INTO {cvs_accounts} (uid, name, pass, motivation, status) VALUES (%d, '%s', '%s', '%s', %d)", $user->uid, $form_values['user'], $form_values['cvs_pass'], $form_values['motivation'], CVS_QUEUED); // Display a status message: drupal_set_message(t('Your CVS account request has been sent to the CVS administrators and will be processed as soon as possible.'));