Index: modules/cvslog/cvs.info =================================================================== RCS file: modules/cvslog/cvs.info diff -N modules/cvslog/cvs.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/cvslog/cvs.info 20 Dec 2006 04:18:44 -0000 @@ -0,0 +1,5 @@ +; $Id$ +name = "CVS integration" +description = "Provides access to commit logs, account management, and access control for the Concurrent Versions System (CVS)." +package = Project +version = "$Name$" Index: modules/cvslog/cvs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v retrieving revision 1.131 diff -u -p -r1.131 cvs.module --- modules/cvslog/cvs.module 5 Dec 2006 21:52:41 -0000 1.131 +++ modules/cvslog/cvs.module 20 Dec 2006 04:18:46 -0000 @@ -30,10 +30,10 @@ if (file_exists("$path/cvs_local.inc")) */ function cvs_help($section) { switch ($section) { - case 'admin/modules#description': - return t('Provides access to CVS commit logs.'); case 'cvs': - case 'admin/cvs': + case 'admin/project/cvs-accounts': + case 'admin/project/cvs-repositories': + case 'admin/project/cvs-settings': return t('CVS (Concurrent Versions System) is a code management system used by developers to collaborate and track modifications of code.'); } } @@ -85,110 +85,132 @@ function cvs_menu($may_cache) { 'weight' => 2, ); */ - + } + else { // Admin pages: $access = user_access('administer CVS'); + + // If for some reason someone is using this module without + // project.module (which is technically legitimate, though hard to + // imagine), we need to define our own version of /admin/project + // so the rest of our admin pages all work. + if (!module_exists('project')) { + $items[] = array( + 'path' => 'admin/project', + 'title' => t('Project administration'), + 'description' => t('Administrative interface for project management and related modules.'), + 'callback' => 'system_admin_menu_block_page', + 'access' => $access, + 'type' => MENU_NORMAL_ITEM, + ); + } + $items[] = array( - 'path' => 'admin/cvs', - 'title' => t('CVS'), - 'callback' => 'cvs_account', + 'path' => 'admin/project/cvs-settings', + 'description' => t('Modify CVS management settings, such as how it integrates with projects on your site, the text used on the CVS account application form, and the default wording for emails sent when CVS accounts are approved or denied.'), + 'title' => t('CVS settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('cvs_settings_form'), 'access' => $access, 'type' => MENU_NORMAL_ITEM, ); // Accounts: $items[] = array( - 'path' => 'admin/cvs/list', - 'title' => t('list'), + 'path' => 'admin/project/cvs-accounts', + 'title' => t('CVS accounts'), + 'description' => t('Approve or deny requests from the !application_url, import CVS users from an existing CVSROOT/password file, or export a CVSROOT/passwd file to install in any of your CVS repositories.', array('!application_url' => l(t('CVS application'), '/cvs-application'))), + 'callback' => 'cvs_account', + 'access' => $access, + 'type' => MENU_NORMAL_ITEM, + ); + $items[] = array( + 'path' => 'admin/project/cvs-accounts/list', + 'title' => t('List'), 'callback' => 'cvs_account', 'access' => $access, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[] = array( - 'path' => 'admin/cvs/import', - 'title' => t('import'), - 'callback' => 'cvs_account_import', + 'path' => 'admin/project/cvs-accounts/import', + 'title' => t('Import'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('cvs_account_import'), 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); - $items[] = array('path' => 'admin/cvs/export', - 'title' => t('export'), + $items[] = array( + 'path' => 'admin/project/cvs-accounts/export', + 'title' => t('Export'), 'callback' => 'cvs_account_export', 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 3, ); $items[] = array( - 'path' => 'admin/cvs/status', - 'title' => t('status'), + 'path' => 'admin/project/cvs-accounts/status', + 'title' => t('Status'), 'callback' => 'cvs_account_status', 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 4, ); - $items[] = array( - 'path' => 'admin/cvs/edit', - 'title' => t('edit account'), - 'callback' => 'cvs_account_edit', - 'access' => $access, - 'type' => MENU_CALLBACK, - ); // Repositories: $items[] = array( - 'path' => 'admin/cvs/repositories', - 'title' => t('repositories'), + 'path' => 'admin/project/cvs-repositories', + 'title' => t('CVS repositories'), + 'description' => t('Define and configure what CVS repositories are connected to your site, how CVS log messages should be saved, and how to integrate each repository with a source browsing tool such as ViewCVS.'), 'callback' => 'cvs_repository', 'access' => $access, 'type' => MENU_NORMAL_ITEM, ); $items[] = array( - 'path' => 'admin/cvs/repositories/list', - 'title' => t('list'), + 'path' => 'admin/project/cvs-repositories/list', + 'title' => t('List'), 'callback' => 'cvs_repository', 'access' => $access, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[] = array( - 'path' => 'admin/cvs/repositories/add', - 'title' => t('add repository'), - 'callback' => 'cvs_repository_add', + 'path' => 'admin/project/cvs-repositories/add', + 'title' => t('Add repository'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('cvs_repository_form'), 'access' => $access, 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); $items[] = array( - 'path' => 'admin/cvs/repositories/edit', - 'title' => t('edit repository'), + 'path' => 'admin/project/cvs-repositories/edit', + 'title' => t('Edit repository'), 'callback' => 'cvs_repository_edit', 'access' => $access, 'type' => MENU_CALLBACK, ); $items[] = array( - 'path' => 'admin/cvs/repositories/delete', - 'title' => t('delete'), + 'path' => 'admin/project/cvs-repositories/delete', + 'title' => t('Delete'), 'callback' => 'cvs_repository_delete', 'access' => $access, 'type' => MENU_CALLBACK, ); $items[] = array( - 'path' => 'admin/cvs/repositories/fetch', - 'title' => t('fetch log'), + 'path' => 'admin/project/cvs-repositories/fetch', + 'title' => t('Fetch log'), 'callback' => 'cvs_repository_fetch', 'access' => $access, 'type' => MENU_CALLBACK, ); - } - else { if (arg(0) == 'user' && is_numeric(arg(1))) { $result = db_query('SELECT uid, status FROM {cvs_accounts} WHERE uid = %d', arg(1)); if ($account = db_fetch_object($result)) { // If the user has a CVS account, add a 'track CVS messages' tab to the tracker page. $items[] = array( 'path' => 'user/'. arg(1) .'/track/code', - 'title' => t('track code'), + 'title' => t('Track code'), 'callback' => 'cvs_account_tracker', 'access' => user_access('access CVS messages') && $account->status == CVS_APPROVED, 'type' => MENU_LOCAL_TASK, @@ -203,8 +225,8 @@ function cvs_menu($may_cache) { $items[] = array( 'path' => 'user/'. arg(1) .'/edit/cvs', 'title' => t('CVS'), - 'callback' => 'cvs_user_edit_form', - 'callback arguments' => array($account->uid), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('cvs_user_edit_form', $account->uid), 'access' => ($user->uid == $account->uid && $account->status == CVS_APPROVED) || user_access('administer CVS'), 'type' => MENU_LOCAL_TASK, 'weight' => 3, @@ -223,7 +245,8 @@ function cvs_menu($may_cache) { $items[] = array( 'path' => 'node/'. arg(1) .'/cvs-access', 'title' => t('CVS access'), - 'callback' => 'cvs_project_access_form', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('cvs_project_access_form'), 'access' => TRUE, 'type' => MENU_LOCAL_TASK, 'weight' => 4, @@ -239,7 +262,7 @@ function cvs_menu($may_cache) { } } } - + drupal_set_message("adding cvs menu"); return $items; } @@ -261,9 +284,9 @@ function cvs_cron() { } /** - * Implementation of hook_settings(). + * Form builder function for system settings. */ -function cvs_settings() { +function cvs_settings_form() { $strings = _cvs_get_strings(); $form['cvs_email_address'] = array( @@ -303,25 +326,25 @@ function cvs_settings() { '#default_value' => variable_get('cvs_restrict_project_creation', 1), '#description' => t('If this box is checked, only users with CVS accounts will be allowed to create project nodes.'), ); - if (module_exist('project') && project_use_taxonomy()) { + if (module_exists('project') && project_use_taxonomy()) { $form['cvs_directory_validate_by_type'] = array( - '#title' => t('Validate %cvs_dir using %type', array('%cvs_dir' => theme('placeholder', 'CVS directory'), '%type' => theme('placeholder', 'Project type'))), + '#title' => t('Validate %cvs_dir using %type', array('%cvs_dir' => 'CVS directory', '%type' => 'Project type')), '#type' => 'checkbox', '#default_value' => variable_get('cvs_directory_validate_by_type', 1), - '#description' => t("If this box is checked, the first element of the path specified in the %cvs_dir field must match the selected %type for project nodes. Note: this is a case insensitive comparison, and spaces in the %type field will be converted to hypens ('-') for the purpose of the comparison.", array('%cvs_dir' => theme('placeholder', 'CVS directory'), '%type' => theme('placeholder', 'Project type'))), + '#description' => t("If this box is checked, the first element of the path specified in the %cvs_dir field must match the selected %type for project nodes. Note: this is a case insensitive comparison, and spaces in the %type field will be converted to hypens ('-') for the purpose of the comparison.", array('%cvs_dir' => 'CVS directory', '%type' => 'Project type')), ); } $form['cvs_validate_by_short_name'] = array( - '#title' => t('Validate %cvs_dir using %short_name', array('%cvs_dir' => theme('placeholder', 'CVS directory'), '%short_name' => theme('placeholder', 'Project short name'))), + '#title' => t('Validate %cvs_dir using %short_name', array('%cvs_dir' => 'CVS directory', '%short_name' => 'Project short name')), '#type' => 'checkbox', '#default_value' => variable_get('cvs_validate_by_short_name', 1), - '#description' => t("If this box is checked, the last element of the path specified in the %cvs_dir field must match the %short_name field for project nodes.", array('%cvs_dir' => theme('placeholder', 'CVS directory'), '%short_name' => theme('placeholder', 'Project short name'))), + '#description' => t("If this box is checked, the last element of the path specified in the %cvs_dir field must match the %short_name field for project nodes.", array('%cvs_dir' => 'CVS directory', '%short_name' => 'Project short name')), ); $form['cvs_directory_validate_dir_root_by_case'] = array( - '#title' => t('Ensure lowercase for first element of %cvs_dir', array('%cvs_dir' => theme('placeholder', 'CVS directory'))), + '#title' => t('Ensure lowercase for first element of %cvs_dir', array('%cvs_dir' => 'CVS directory')), '#type' => 'checkbox', '#default_value' => variable_get('cvs_directory_validate_dir_root_by_case', 1), - '#description' => t("If this box is checked, the first element of the path specified in the %cvs_dir field must be lowercase.", array('%cvs_dir' => theme('placeholder', 'CVS directory'))), + '#description' => t("If this box is checked, the first element of the path specified in the %cvs_dir field must be lowercase.", array('%cvs_dir' => 'CVS directory')), ); $form['cvs_list_per_page'] = array( '#title' => t('Number of CVS accounts listed per page'), @@ -403,7 +426,7 @@ function cvs_settings() { '#description' => t('The message to send to users whose accounts have been declined.'), ); - if (module_exist('project_release')) { + if (module_exists('project_release')) { $form['cvs_message_new_release_branch'] = array( '#title' => t('Message when new releases are added from a branch'), '#type' => 'textarea', @@ -417,7 +440,7 @@ function cvs_settings() { '#description' => t('Message to show to project maintainers when they add a new official release from a tag.'), ); } - return $form; + return system_settings_form($form); } /** @@ -466,21 +489,21 @@ function cvs_nodeapi(&$node, $op, $arg = $path_elems = array_filter($path_elems); if (variable_get('cvs_directory_validate_dir_root_by_case', 1)) { if ($path_elems[1] != drupal_strtolower($path_elems[1])) { - form_set_error('cvs_directory', t("The root of the CVS directory (%root) must be lowercase.", array('%root' => theme('placeholder', $path_elems[1])))); + form_set_error('cvs_directory', t("The root of the CVS directory (%root) must be lowercase.", array('%root' => $path_elems[1]))); } } if (project_use_taxonomy() && variable_get('cvs_directory_validate_by_type', 1)) { $tree = taxonomy_get_term($node->project_type); $path_equiv = drupal_strtolower(str_replace(' ', '-', $tree->name)); if (drupal_strtolower($path_elems[1]) != $path_equiv) { - form_set_error('cvs_directory', t("The root of the CVS directory (%root) does not match the selected project type (%type). Spaces in the type name are converted to hyphens in the path, so given the current project type, the first element of the directory path should be: %goal.", array('%root' => theme('placeholder', $path_elems[1]), '%type' => theme('placeholder', $tree->name), '%goal' => theme('placeholder', $path_equiv)))); + form_set_error('cvs_directory', t("The root of the CVS directory (%root) does not match the selected project type (%type). Spaces in the type name are converted to hyphens in the path, so given the current project type, the first element of the directory path should be: %goal.", array('%root' => $path_elems[1], '%type' => $tree->name, '%goal' => $path_equiv))); } } if (variable_get('cvs_validate_by_short_name', 1)) { $last_elem = array_pop($path_elems); if ($last_elem != $node->uri) { - form_set_error('cvs_directory', t("The last part of the CVS directory (%last) does not match the short project name (%short).", array('%last' => theme('placeholder', $last_elem), '%short' => theme('placeholder', $node->uri)))); - form_set_error('uri', t("The short project name (%short) does not match the last part of the CVS directory (%last).", array('%last' => theme('placeholder', $last_elem), '%short' => theme('placeholder', $node->uri)))); + form_set_error('cvs_directory', t("The last part of the CVS directory (%last) does not match the short project name (%short).", array('%last' => $last_elem, '%short' => $node->uri))); + form_set_error('uri', t("The short project name (%short) does not match the last part of the CVS directory (%last).", array('%last' => $last_elem, '%short' => $node->uri))); } } } @@ -512,6 +535,7 @@ function cvs_form_alter($form_id, &$form /** * Menu Callback: Display the CVS account edit form. + * Form builder function for cvs_user_edit_form() */ function cvs_user_edit_form($uid) { global $user; @@ -605,7 +629,7 @@ function cvs_user_edit_form($uid) { $form['cvs']['cvs_uid'] = array('#type' => 'value', '#value' => $uid); $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); - return drupal_get_form('cvs_user_edit_form', $form); + return $form; } /** @@ -616,11 +640,11 @@ function cvs_user_edit_form_validate($fo // Check for duplicates: $id = db_result(db_query("SELECT uid FROM {cvs_accounts} WHERE name = '%s' AND uid != %d", $form_values['cvs_name'], $form_values['cvs_uid'])); if ($id != 0) { - form_set_error('cvs_name', t('The specified CVS username is already in use by user #%id.', array('%id' => $id))); + form_set_error('cvs_name', t('The specified CVS username is already in use by user #!id.', array('!id' => $id))); } } if (!empty($form_values['cvs_pass']) && strlen($form_values['cvs_pass']) < CVS_MIN_PASS_LENGTH) { - form_set_error('cvs_pass', t('The CVS password you have chosen is too short (it must be at least %min characters long).', array('%min' => CVS_MIN_PASS_LENGTH))); + form_set_error('cvs_pass', t('The CVS password you have chosen is too short (it must be at least !min characters long).', array('!min' => CVS_MIN_PASS_LENGTH))); } } @@ -651,8 +675,8 @@ function cvs_user_edit_form_submit($form if ($form_values['send_mail']) { cvs_mail_user($form_values['cvs_uid'], $form_values['message']); } - drupal_set_message(t('The CVS account %account has been updated successfully.', array('%account' => theme('placeholder', $form_values['cvs_name'])))); - return 'admin/cvs'; + drupal_set_message(t('The CVS account %account has been updated successfully.', array('%account' => $form_values['cvs_name']))); + return 'admin/project/cvs-accounts'; } elseif (strlen($cvs_name) && $form_values['cvs_uid'] == $user->uid && isset($form_values['cvs_pass']) && strlen($form_values['cvs_pass'])) { if($cvs_status) { @@ -720,8 +744,8 @@ function cvs_alter_project_release_form( $fields = array('version_major', 'version_minor', 'version_patch'); - if (isset($_POST['edit']['tag'])) { - $tag_name = $_POST['edit']['tag']; + if (isset($_POST['tag'])) { + $tag_name = $_POST['tag']; // We have to validate this here, since we're getting called // before a validate callback would be invoked... if (!isset($tag_name)) { @@ -733,6 +757,10 @@ function cvs_alter_project_release_form( $tag->tag = 'HEAD'; $tag->branch = 1; $tag->nid = $project->nid; + // form_builder() expects $_POST to already be in '#post', so we + // manually shove it in there. form_builder() is presumably more + // safe than inspecting $_POST directly... + $form['version']['#post'] = $_POST; $form['version'] = form_builder('project_release_node_form', $form['version']); foreach ($fields as $field) { $form_val = $form['version']['num'][$field]['#value']; @@ -755,11 +783,11 @@ function cvs_alter_project_release_form( // API selector has already been set and use that in our $version. $needs_api_none = true; if (isset($form['taxonomy'][$vid])) { - $post_val = $_POST['edit']['taxonomy'][$vid]; + $post_val = $_POST['taxonomy'][$vid]; if (isset($post_val)) { if (is_numeric($post_val) && !empty($post_val) && db_result(db_query('SELECT COUNT(*) FROM {term_data} WHERE tid = %d AND vid = %d', $post_val, $vid))) { $version->version_api_tid = $post_val; - $options[$post_val] = $form['taxonomy'][$vid]['#options'][$post_val]; + $options[$post_val] = _cvs_get_option_from_taxo($form, $vid, $post_val); $form['taxonomy'][$vid]['#options'] = $options; $form['taxonomy'][$vid]['#default_value'] = $post_val; $needs_api_none = false; @@ -834,6 +862,10 @@ function cvs_alter_project_release_form( '#type' => 'hidden', '#value' => $tag->branch, ); + // form_builder() expects $_POST to already be in '#post', so we + // manually shove it in there. form_builder() is presumably more + // safe than inspecting $_POST directly... + $form['cvs_tag']['#post'] = $_POST; $form['cvs_tag'] = form_builder('project_release_node_form', $form['cvs_tag']); unset($form['version']['version']); if (isset($version_str)) { @@ -868,7 +900,7 @@ function cvs_alter_project_release_form( } if (isset($form['taxonomy'][$vid])) { $tid = $version->version_api_tid; - $options[$tid] = $form['taxonomy'][$vid]['#options'][$tid]; + $options[$tid] = _cvs_get_option_from_taxo($form, $vid, $tid); $form['taxonomy'][$vid]['#options'] = $options; $form['taxonomy'][$vid]['#default_value'] = $tid; } @@ -924,7 +956,7 @@ function cvs_alter_project_release_form( // TODO: make this a setting or generate the text in some other way? $err = t('ERROR: There are no CVS tags for this module that do not already have a release associated with them.'); $err .= '

' . t('To create a release, you must first create either a new CVS tag on one of the existing branches for this project, or you must add a new CVS branch.'); - $err .= '

' . t('Once you have created a tag or branch that should be used for your new release, try pressing the %retry link to continue.', array('%retry' => theme('placeholder', t('Retry')))); + $err .= '

' . t('Once you have created a tag or branch that should be used for your new release, try pressing the %retry link to continue.', array('%retry' => t('Retry'))); drupal_set_message($err); unset($form['preview']); $form['retry'] = array( @@ -991,6 +1023,7 @@ function _cvs_alter_project_release_form unset($form['menu']); unset($form['options']); unset($form['path']); + unset($form['log']); // Change preview to next and hide submit $form['preview'] = array( @@ -1005,6 +1038,19 @@ function _cvs_alter_project_release_form $form['#redirect'] = FALSE; } +function _cvs_get_option_from_taxo($form, $vid, $tid) { + if (!isset($form['taxonomy'][$vid])) { + return NULL; + } + foreach ($form['taxonomy'][$vid]['#options'] as $key => $obj) { + if (isset($obj->option[$tid])) { + return $obj; + } + } + return NULL; +} + + /** * pre_render callback for the project_release node form. We use this * to set the required form attribute back to TRUE on the body field, @@ -1084,7 +1130,7 @@ function theme_cvs_commit_message($commi $output .= "

Commit ". l("#$commit->cid", "cvs", NULL, "commit=$commit->cid") . - t(' by %name', array('%name' => ($commit->uid ? theme('username', $commit) : $commit->user))) . + t(' by !name', array('!name' => ($commit->uid ? theme('username', $commit) : $commit->user))) . "
\n"; $output .= "
$commit->files
\n"; $output .= "
$commit->message
\n"; @@ -1160,14 +1206,14 @@ function cvs_show_messages_format($resul global $languages, $base_url; while ($commit = db_fetch_object($result)) { - $title = t('Commit %id by %user', array('%id' => $commit->cid, '%user' => $commit->user)); + $title = t('Commit !id by !user', array('!id' => $commit->cid, '!user' => $commit->user)); $link = url('cvs', "commit=$commit->cid", NULL, TRUE); $extra = array('pubDate' => gmdate('r', $commit->created)); $message = theme('cvs_commit_message', $commit); $items .= format_rss_item($title, $link, $message, $extra); } - $title = t('CVS commit messages for %site', array('%site' => variable_get('site_name', 'drupal'))); + $title = t('CVS commit messages for !site', array('!site' => variable_get('site_name', 'drupal'))); $link = url('cvs', NULL, NULL, TRUE); $language = count($languages) ? reset(array_keys($languages)) : 'en'; @@ -1227,6 +1273,19 @@ function cvs_page_search() { $repositories[$repository->rid] = $repository->name; } + $output = drupal_get_form('cvs_search', $repositories); + + if ($_REQUEST['rid'] || $_REQUEST['user'] || $_REQUEST['branch'] || $_REQUEST['file'] || $_REQUEST['message']) { + $output .= theme('box', t('Search results'), cvs_show_messages()); + } + + return $output; +} + +/** + * Form builder function for cvs_search form + */ +function cvs_search($repositories) { $form['cvs_search'] = array('#type' => 'fieldset', '#title' => t('Search criteria')); $form['cvs_search']['message'] = array( '#type' => 'textfield', @@ -1263,13 +1322,8 @@ function cvs_page_search() { //$output = preg_replace('/edit\[([^\]]+)\]/', '\1', $output); //$output = form($output, 'post', url($_GET['q'], NULL, 'cvs')); $form['cvs_search']['#action'] = url(); - $output = drupal_get_form('cvs_search',$form); - if ($_REQUEST['rid'] || $_REQUEST['user'] || $_REQUEST['branch'] || $_REQUEST['file'] || $_REQUEST['message']) { - $output .= theme('box', t('Search results'), cvs_show_messages()); - } - - return $output; + return $form; } /** @@ -1279,7 +1333,7 @@ function cvs_get_contributed_projects($u $projects = array(); $result = db_query("SELECT DISTINCT(f.nid), n.title, COUNT(f.nid) AS commits FROM {cvs_files} f INNER JOIN node n ON n.status = 1 AND n.nid = f.nid WHERE f.uid = %d GROUP BY f.nid ORDER BY commits DESC", $uid); while ($project = db_fetch_object($result)) { - $projects[] = array('value' => l($project->title, "node/$project->nid") ." (". format_plural($project->commits, '1 commit', '%count commits') .")"); + $projects[] = array('value' => l($project->title, "node/$project->nid") ." (". format_plural($project->commits, '1 commit', '@count commits') .")"); } return $projects; } @@ -1299,9 +1353,9 @@ function cvs_get_project_contributors($n while ($contributor = db_fetch_object($result)) { $rows[] = array( theme('username', $contributor), - t('%time ago', array('%time' => format_interval(time() - $contributor->last_commit, 1))), - t('%time ago', array('%time' => format_interval(time() - $contributor->first_commit, 1))), - format_plural($contributor->commits, '1 commit', '%count commits') + t('!time ago', array('!time' => format_interval(time() - $contributor->last_commit, 1))), + t('!time ago', array('!time' => format_interval(time() - $contributor->first_commit, 1))), + format_plural($contributor->commits, '1 commit', '@count commits') ); } @@ -1355,8 +1409,8 @@ function cvs_mail_user($uid, $extra = '' break; } - $from = t('Drupal CVS administrator <%mail>', array('%mail' => variable_get('cvs_email_address', 'cvs@example.com'))); - user_mail("$account->mail, ". variable_get('cvs_email_address', 'cvs@example.com'), t('CVS account maintenance'), $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $from = t('Drupal CVS administrator ', array('!mail' => variable_get('cvs_email_address', 'cvs@example.com'))); + drupal_mail('cvs_email_user', "$account->mail, ". variable_get('cvs_email_address', 'cvs@example.com'), t('CVS account maintenance'), $message, $from, array('X-Mailer' => 'Drupal')); } } @@ -1367,21 +1421,8 @@ function cvs_account() { if (!isset($_SESSION['cvs_list_view_filter'])) { $_SESSION['cvs_list_view_filter'] = CVS_QUEUED; } - $form['cvs_filter'] = array( - '#type' => 'select', - '#title' => t('Filter by status'), - '#options' => $status_options, - '#default_value' => $_SESSION['cvs_list_view_filter'], - '#prefix' => '
' - ); - - $form['submit'] = array( - '#type' => 'submit', - '#value' => t('Filter'), - '#suffix' => '
' - ); - $filter_output = drupal_get_form('cvs_list_view_form', $form); + $filter_output = drupal_get_form('cvs_list_view_form', $status_options); $header = array( array('data' => t('User'), 'field' => 'name'), @@ -1408,8 +1449,8 @@ function cvs_account() { $rows[] = array( $user->uid ? theme('username', $user) : $user->cvs_name, $user->commits, - $user->commits ? t('%time ago', array('%time' => format_interval(time() - $user->first_commit, 1))) : t('n/a'), - $user->commits ? t('%time ago', array('%time' => format_interval(time() - $user->last_commit, 1))) : t('n/a'), + $user->commits ? t('!time ago', array('!time' => format_interval(time() - $user->first_commit, 1))) : t('n/a'), + $user->commits ? t('!time ago', array('!time' => format_interval(time() - $user->last_commit, 1))) : t('n/a'), $status_options[$user->status], l(t('edit'), "user/$user->uid/edit/cvs") ); @@ -1419,6 +1460,25 @@ function cvs_account() { } /** + * Form builder function for cvs_list_view_form + */ +function cvs_list_view_form($status_options) { + $form['cvs_filter'] = array( + '#type' => 'select', + '#title' => t('Filter by status'), + '#options' => $status_options, + '#default_value' => $_SESSION['cvs_list_view_filter'], + '#prefix' => '
' + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Filter'), + '#suffix' => '
' + ); + return $form; +} + +/** * Form callback function for list filter. */ function cvs_list_view_form_submit($form_id, $form_values) { @@ -1430,6 +1490,10 @@ function cvs_list_view_form_submit($form * * @TODO: add support for multiple repositories. */ + +/** + * Form builder function for cvs_account_import + */ function cvs_account_import() { $form['instructions'] = array('#value' => t('Drupal lets you import CVS accounts from a CVS passwd-file, found in the CVSROOT-directory of a repository. Copy/paste the contents of the passwd-file (or parts thereof) into the form below to mass import existing CVS accounts.')); $form['data'] = array( @@ -1440,10 +1504,9 @@ function cvs_account_import() { '#required' => TRUE, ); $form['submit'] = array('#type' => 'submit', '#value' => t('Import accounts')); - - return drupal_get_form('cvs_account_import', $form); -} - + return $form; +} + /** * Process cvs_account_import form submissions. */ @@ -1454,12 +1517,12 @@ function cvs_account_import_submit($form if ($name && $pass && $user) { if (db_result(db_query("SELECT name FROM {cvs_accounts} WHERE name = '%s'", $name))) { db_query("UPDATE {cvs_accounts} SET pass = '%s', status = %d WHERE name = '%s'", $pass, CVS_APPROVED, $name); - $names[] = t('updated %name', array('%name' => $name)); + $names[] = t('updated !name', array('!name' => $name)); } else { $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $name)); db_query("INSERT INTO {cvs_accounts} (uid, name, pass, status) VALUES (%d, '%s', '%s', %d)", $uid, $name, $pass, CVS_APPROVED); - $names[] = t('added %name', array('%name' => $name)); + $names[] = t('added !name', array('!name' => $name)); } } } @@ -1471,7 +1534,7 @@ function cvs_account_import_submit($form drupal_set_message(t('Failed to import CVS accounts.'), 'error'); } - return 'admin/cvs'; + return 'admin/project/cvs-accounts'; } function cvs_account_export() { @@ -1502,7 +1565,7 @@ function cvs_account_status() { foreach ($options as $opt => $opt_name) { $count = db_result(db_query('SELECT COUNT(*) FROM {cvs_accounts} WHERE status = %d', $opt)); if ($count) { - $output .= '

'. t('%option CVS accounts: %count', array('%option' => $opt_name, '%count' => $count)) .'

'; + $output .= '

'. t('!option CVS accounts: !count', array('!option' => $opt_name, '!count' => $count)) .'

'; } } @@ -1522,23 +1585,23 @@ function cvs_account_status() { $count = db_result(db_query('SELECT COUNT(*) FROM {cvs_messages}')); if ($count) { - $output .= '

'. t('There have been %count commits.', array('%count' => $count)) .'

'; + $output .= '

'. t('There have been !count commits.', array('!count' => $count)) .'

'; } $warnings = array(); $count = db_result(db_query('SELECT COUNT(*) FROM {cvs_messages} WHERE uid = 0')); if ($count) { - $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('%count rows in the {cvs_messages}-table have no user ID associated with them.', array('%count' => $count)) .'
  • '; + $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('!count rows in the {cvs_messages}-table have no user ID associated with them.', array('!count' => $count)) .'
  • '; } $count = db_result(db_query('SELECT COUNT(*) FROM {cvs_files} WHERE uid = 0')); if ($count) { - $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('%count rows in the {cvs_files}-table have no user ID associated with them.', array('%count' => $count)) .'
  • '; + $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('!count rows in the {cvs_files}-table have no user ID associated with them.', array('!count' => $count)) .'
  • '; } $count = db_result(db_query('SELECT COUNT(*) FROM {cvs_files} WHERE nid = 0')); if ($count) { - $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('%count rows in the {cvs_files}-table have no project associated with them.', array('%count' => $count)) .'
  • '; + $warnings[] = '
  • '. theme('image', 'misc/watchdog-warning.png', t('warning'), t('warning')) .' '. t('!count rows in the {cvs_files}-table have no project associated with them.', array('!count' => $count)) .'
  • '; } if ($warnings) { @@ -1560,16 +1623,16 @@ function cvs_repository() { $result = db_query("SELECT * FROM {cvs_repositories}" . tablesort_sql($header)); while ($repo = db_fetch_object($result)) { $ops = array( - l(t('edit'), "admin/cvs/repositories/edit/$repo->rid"), - l(t('delete'), "admin/cvs/repositories/delete/$repo->rid") + l(t('edit'), "admin/project/cvs-repositories/edit/$repo->rid"), + l(t('delete'), "admin/project/cvs-repositories/delete/$repo->rid") ); if ($repo->method) { - $updated = message_na(); + $updated = t('n/a'); $repo->method = t('external'); } else { $updated = $repo->updated ? format_date($repo->updated) : t('never'); - $repo->method = l(t('fetch log'), "admin/cvs/repositories/fetch/$repo->rid"); + $repo->method = l(t('fetch log'), "admin/project/cvs-repositories/fetch/$repo->rid"); } $rows[] = array_merge(array($repo->name, $repo->modules, $repo->method, $updated), $ops);; @@ -1634,21 +1697,12 @@ function cvs_fetch_repository(&$repo, $o } } -function cvs_repository_edit($rid) { - if ($repo = db_fetch_object(db_query("SELECT * FROM {cvs_repositories} WHERE rid = '%s'", $rid))) { - if ($_POST['op'] == t('Save repository')) { - $repo = (object) $_POST['edit']; - db_query("UPDATE {cvs_repositories} SET name = '%s', root = '%s', modules = '%s', diffurl = '%s', newurl = '%s', trackerurl = '%s', method = %d WHERE rid = '%s'", $repo->name, $repo->root, $repo->modules, $repo->diffurl, $repo->newurl, $repo->trackerurl, $repo->method, $rid); - watchdog('special', 'cvs: updated repository '. $repo->name, l('view', 'admin/cvs')); - drupal_set_message(t('Updated CVS repository: %repo', array('%repo' => $repo->name))); - drupal_goto('admin/cvs/repositories'); - } - - return cvs_repository_form($repo); - } - else { - drupal_not_found(); +function cvs_repository_edit() { + $args = func_get_args(); + if (isset($args[0]) && is_numeric($args[0]) && $repo = db_fetch_object(db_query("SELECT * FROM {cvs_repositories} WHERE rid = %d", $args[0]))) { + return drupal_get_form('cvs_repository_form', $repo); } + drupal_not_found(); } function cvs_repository_delete($rid) { @@ -1656,33 +1710,44 @@ function cvs_repository_delete($rid) { db_query("DELETE FROM {cvs_messages} WHERE rid = %d", $rid); db_query("DELETE FROM {cvs_files} WHERE rid = %d", $rid); drupal_set_message(t('The repository has been removed.')); - drupal_goto('admin/cvs/repositories'); + drupal_goto('admin/project/cvs-repositories'); } -function cvs_repository_add() { - if ($_POST['op'] == t('Save repository')) { - $repo = (object) $_POST['edit']; - db_query("INSERT INTO {cvs_repositories} (name, root, modules, diffurl, newurl, trackerurl, method) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d)", $repo->name, $repo->root, $repo->modules, $repo->diffurl, $repo->newurl, $repo->trackerurl, $repo->method); - watchdog('special', 'cvs: added repository '. $repo->name, l('view', 'admin/cvs')); - drupal_set_message(t('Added CVS repository: %repo', array('%repo' => $repo->name))); - drupal_goto('admin/cvs/repositories'); +function cvs_repository_form_submit($form_id, $form_values) { + if ($form_values['op'] == t('Save repository')) { + $repo = (object)$form_values; + if ($repo->rid > 0) { + db_query("UPDATE {cvs_repositories} SET name = '%s', root = '%s', modules = '%s', diffurl = '%s', newurl = '%s', trackerurl = '%s', method = %d WHERE rid = %d", $repo->name, $repo->root, $repo->modules, $repo->diffurl, $repo->newurl, $repo->trackerurl, $repo->method, $repo->rid); + watchdog('special', 'cvs: repository updated'. $repo->name, l('view', 'admin/project/cvs-repositories')); + drupal_set_message(t('Updated CVS repository: %repo', array('%repo' => $repo->name))); + } + else { + db_query("INSERT INTO {cvs_repositories} (name, root, modules, diffurl, newurl, trackerurl, method) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', %d)", $repo->name, $repo->root, $repo->modules, $repo->diffurl, $repo->newurl, $repo->trackerurl, $repo->method); + watchdog('special', 'cvs: added repository '. $repo->name, l('view', 'admin/project/cvs-repositories')); + drupal_set_message(t('Added CVS repository: %repo', array('%repo' => $repo->name))); + } + drupal_goto('admin/project/cvs-repositories'); } - return cvs_repository_form($repo); + return drupal_get_form('cvs_repository_form', $repo); } -function cvs_repository_form($repo = 0) { +function cvs_repository_form($repo = NULL) { $form['cvs_information'] = array('#type' => 'fieldset', '#title' => t('Repository information')); + $form['cvs_information']['rid'] = array( + '#type' => 'value', + '#value' => !is_null($repo) ? $repo->rid : 0, + ); $form['cvs_information']['name'] = array( '#type' => 'textfield', '#title' => t('Repository name'), - '#default_value' => $repo->name, + '#default_value' => !is_null($repo) ? $repo->name : '', '#size' => 40, '#maxlength' => 255, ); $form['cvs_information']['method'] = array('#type' => 'radios', '#title' => t('Update method'), - '#default_value' => $repo->method, + '#default_value' => !is_null($repo) ? $repo->method : '', '#options' => array(t('Automatic log retrieval.'), t('Use external script to insert data.')), '#description' => t('Automatic log retrieval requires cron.'), ); @@ -1692,14 +1757,14 @@ function cvs_repository_form($repo = 0) ); $form['cvs_automatic']['root'] = array('#type' => 'textfield', '#title' => t('CVS root'), - '#default_value' => $repo->root, + '#default_value' => !is_null($repo) ? $repo->root : '', '#size' => 60, '#maxlength' => 255, '#description' => t('Examples: /path or :pserver:user:password@server:/path.'), ); $form['cvs_automatic']['modules'] = array('#type' => 'textfield', '#title' => t('Modules'), - '#default_value' => $repo->modules, + '#default_value' => !is_null($repo) ? $repo->modules : '', '#size' => 40, '#maxlength' => 255, '#description' => t('Separate multiple modules with spaces.'), @@ -1713,7 +1778,7 @@ function cvs_repository_form($repo = 0) $form['cvs_urls']['diffurl'] = array( '#type' => 'textfield', '#title' => t('Diff URL'), - '#default_value' => $repo->diffurl, + '#default_value' => !is_null($repo) ? $repo->diffurl : '', '#size' => 40, '#maxlength' => 255, '#description' => t('Enter URL to diff web site. Use the %file, %old, %revision variables in the right place to represent the file, old version and new version.'), @@ -1721,21 +1786,21 @@ function cvs_repository_form($repo = 0) $form['cvs_urls']['newurl'] = array( '#type' => 'textfield', '#title' => t('New file URL'), - '#default_value' => $repo->newurl, + '#default_value' => !is_null($repo) ? $repo->newurl : '', '#size' => 40, '#maxlength' => 255, '#description' => t('Enter URL to for the initial revision of a file. Use the %file and %revision variables in the right place to represent the file and initial revision.'), ); $form['cvs_urls']['trackerurl'] = array('#type' => 'textfield', '#title' => t('Issue tracker URL'), - '#default_value' => $repo->trackerurl, + '#default_value' => !is_null($repo) ? $repo->trackerurl : '', '#size' => 40, '#maxlength' => 255, '#description' => t('Enter URL to link to issues in log messages. Use the %d variable in the right place to represent the issue id.'), ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save repository')); - - return drupal_get_form('cvs_repository_add',$form); + + return $form; } function cvs_explode($text, $delim = ':') { @@ -1970,12 +2035,12 @@ function cvs_application_page() { break; case CVS_DECLINED: case CVS_DISABLED: - $output = cvs_application_form($application); + $output = drupal_get_form('cvs_application_form', $application); break; } } else { - $output = cvs_application_form(); + $output = drupal_get_form('cvs_application_form'); } } else { @@ -2060,10 +2125,10 @@ function cvs_application_form($applicati $form['submit'] = array('#type' => 'submit', '#value' => t('Request CVS account')); - return drupal_get_form('cvs_application_page', $form); + return $form; } -function cvs_application_page_validate($form_id, $form_values) { +function cvs_application_form_validate($form_id, $form_values) { global $user; if ($form_values['maintain'] != 1) { @@ -2079,11 +2144,11 @@ function cvs_application_page_validate($ 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) { - form_set_error('cvs_pass', t('The CVS password you have chosen is too short (it must be at least %min characters long).', array('%min' => CVS_MIN_PASS_LENGTH))); + form_set_error('cvs_pass', t('The CVS password you have chosen is too short (it must be at least !min characters long).', array('!min' => CVS_MIN_PASS_LENGTH))); } } -function cvs_application_page_submit($form_id, $form_values) { +function cvs_application_form_submit($form_id, $form_values) { global $user; $strings = _cvs_get_strings(); @@ -2117,12 +2182,12 @@ function cvs_application_page_submit($fo } $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'), $subject, $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + drupal_mail('cvs_email_submit_admin', variable_get('cvs_email_address', 'cvs@example.com'), t('CVS account request'), $message, $from, array('X-Mailer' => 'Drupal')); // Send an e-mail to the applicant: - $from = t('Drupal CVS administrator <%mail>', array('%mail' => variable_get('cvs_email_address', 'cvs@example.com'))); + $from = t('Drupal CVS administrator ', 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, $subject, $message, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + drupal_mail('cvs_email_submit_applicant', $user->mail, t('CVS account request'), $message, $from, array('X-Mailer' => 'Drupal')); // 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.')); @@ -2204,9 +2269,9 @@ function theme_cvs_project_access($form) $nid = arg(1); $node = node_load($nid); - drupal_set_title(t('CVS access for %title', array('%title' => theme('placeholder', $node->title)))); + drupal_set_title(t('CVS access for %title', array('%title' => $node->title))); - $output = '

    ' . t("This page controls CVS access for the %title project. All users listed in this table have permission to commit and tag files in this project's directory in the CVS repository (%cvs_dir). The project owner is listed first and always has full access.", array('%cvs_dir' => theme('placeholder', '/contributions' . $node->cvs_directory), '%title' => theme('placeholder', $node->title))) . '

    '; + $output = '

    ' . t("This page controls CVS access for the %title project. All users listed in this table have permission to commit and tag files in this project's directory in the CVS repository (%cvs_dir). The project owner is listed first and always has full access.", array('%cvs_dir' => '/contributions' . $node->cvs_directory, '%title' => $node->title)) . '

    '; $rows = array(); $header = array(); @@ -2224,9 +2289,9 @@ function theme_cvs_project_access($form) l(t('delete'), "node/$nid/cvs-access/delete/$user->uid")); } - $rows[] = array(form_render($form['user']), form_render($form['submit'])); + $rows[] = array(drupal_render($form['user']), drupal_render($form['submit'])); $output .= theme('table', $header, $rows); - $output .= form_render($form); + $output .= drupal_render($form); return $output; } @@ -2247,7 +2312,7 @@ function cvs_project_access_form() { '#value' => 0, ); $form['submit'] = array('#type' => 'submit', '#value' => t('Grant access')); - return drupal_get_form('cvs_project_access', $form); + return $form; } function cvs_project_access_validate($form_id, $form_values, $form) { @@ -2257,15 +2322,15 @@ function cvs_project_access_validate($fo } $user = $form_values['user']; if (!$user_result = db_fetch_object(db_query("SELECT name, uid FROM {users} WHERE name = '%s'", $user))) { - form_set_error('user', t('%user is not a valid user on this site.', array('%user' => theme('placeholder', $user))), 'error'); + form_set_error('user', t('%user is not a valid user on this site.', array('%user' => $user)), 'error'); return; } if (!db_num_rows(db_query("SELECT * FROM {cvs_accounts} WHERE status = %d AND uid = %d", CVS_APPROVED, $user_result->uid))) { - form_set_error('user', t('%user does not have a CVS account.', array('%user' => theme('placeholder',$user))), 'error'); + form_set_error('user', t('%user does not have a CVS account.', array('%user' => $user)), 'error'); } if (db_num_rows(db_query("SELECT * FROM {cvs_project_maintainers} WHERE uid = %d AND nid = %d", $user_result->uid, arg(1))) || (($node = node_load(arg(1))) && $user == $node->name)) { - form_set_error('user', t('%user already has CVS access for this project.', array('%user' => theme('placeholder', $user))), 'error'); + form_set_error('user', t('%user already has CVS access for this project.', array('%user' => $user)), 'error'); } // save the uid in the form so we don't have to look it up again in @@ -2281,7 +2346,7 @@ function cvs_project_access_submit($form $user->uid = $form_values['uid']; $user->name = $form_values['user']; - drupal_set_message(t('CVS access has been granted to %user.', array('%user' => theme('username', $user)))); + drupal_set_message(t('CVS access has been granted to !user.', array('!user' => theme('username', $user)))); } /** @@ -2294,8 +2359,8 @@ function cvs_project_delete_access($nid, $form['user'] = array('#type' => 'value', '#value' => $user); return confirm_form('cvs_project_delete_access_confirm', $form, - t('Are you sure you want to delete CVS access for %user?', - array('%user' => theme('username', $user))), + t('Are you sure you want to delete CVS access for !user?', + array('!user' => theme('username', $user))), "node/$nid/cvs-access/", t('This action cannot be undone.'), t('Delete'), @@ -2311,7 +2376,7 @@ function cvs_project_delete_access_confi $uid = $form_values['uid']; $user = $form_values['user']; db_query("DELETE FROM {cvs_project_maintainers} WHERE nid = %d AND uid = %d", $nid, $uid); - drupal_set_message(t('CVS access for %user has been deleted.', array('%user' => theme('username', $user)))); + drupal_set_message(t('CVS access for !user has been deleted.', array('!user' => theme('username', $user)))); drupal_goto("node/$nid/cvs-access"); } @@ -2351,9 +2416,9 @@ function _cvs_get_strings() { $strings['cvs_message_anon'] = t('The Concurrent Versioning System (CVS) is a software development tool available to volunteers with experience in software development, translation, theming, or documentation who wish to participate in the Drupal project. -

    To request access to the Drupal CVS repository you must create -an account and login. Come back to this page after you have -logged on.

    ', array('%register' => url('user/register'), '%login' => url('user/login'))); +

    To request access to the Drupal CVS repository you must create +an account and login. Come back to this page after you have +logged on.

    ', array('!register' => url('user/register'), '!login' => url('user/login'))); $strings['cvs_message_auth'] = t('The Concurrent Versioning System (CVS) is a software development tool used to manage programs and files for the Drupal project. It is available to volunteers with experience in software development, translation, theming @@ -2361,15 +2426,15 @@ or documentation who wish to participate

    A CVS account is not required to contribute patches to the Drupal project or community contributed projects. Anonymous access to the Drupal CVS repository is available which can be used to accomplish this. Please peruse the -CVS handbookand patch guide for more +CVS handbookand patch guide for more information.

    If you are an open source software developer, themer, translator or documentation writer, please use the form below to request access to Drupal\'s CVS repository. Prior to applying, please ensure that:

    ', array('%projects' => url('project'), '%handbook' => url('handbook/cvs'), '%patch' => url('patch'))); +
  • you are not duplicating any existing projects.
  • +

    ', array('!projects' => url('project'), '!handbook' => url('handbook/cvs'), '!patch' => url('patch'))); $strings['cvs_motivation_description'] = t('A message providing information about yourself and your planned contributions.