Index: cvs.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v
retrieving revision 1.109
diff -u -F^f -r1.109 cvs.module
--- cvs.module	16 Jun 2006 07:29:00 -0000	1.109
+++ cvs.module	16 Jun 2006 10:22:09 -0000
@@ -275,8 +275,22 @@ function cvs_settings() {
   $form['cvs_restrict_project_creation'] = array(
     '#title' => t('Restrict project creation to users with CVS accounts'),
     '#type' => 'checkbox',
-    '#default_value' => variable_get('cvs_restrict_project_creation', 0),
-    '#description' => t('If this box is checked, only users with CVS accounts will be allowed to create projects.'),
+    '#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 (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'))),
+      '#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.", array('%cvs_dir' => theme('placeholder', 'CVS directory'), '%type' => theme('placeholder', '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'))),
+    '#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'))),
   );
   $form['cvs_message_anon'] = array(
     '#title' => t('Message to anonymous users'),
@@ -321,11 +335,29 @@ function cvs_nodeapi(&$node, $op, $arg =
             form_set_error('cvs_directory', t('The path of the CVS directory should start with a leading slash.'));
           }
           else if (substr($node->cvs_directory, -1) != '/') {
-            form_set_error('cvs_directory', t('The path of the CVS directory should end with a leading slash.'));
+            form_set_error('cvs_directory', t('The path of the CVS directory should end with a trailing slash.'));
           }
           else if (db_result(db_query("SELECT nid FROM {cvs_projects} WHERE nid != %d AND rid = %d AND directory = '%s'", $node->nid, $node->cvs_repository, $node->cvs_directory))) {
             form_set_error('cvs_directory', t('The specified CVS directory conflicts with that of an existing project.'));
           }
+          else if(!in_array(strtolower($node->title), explode(',', strtolower(variable_get('cvs_allow_repo_selection', ''))))) {
+            $path_elems = explode('/', $node->cvs_directory);
+            // Remove empty elements caused by the trailing and leading '/'.
+            $path_elems = array_filter($path_elems);
+            if (project_use_taxonomy() && variable_get('cvs_directory_validate_by_type', 1)) {
+              $tree = taxonomy_get_term($node->project_type);
+              if ($path_elems[1] != $tree->name) {
+                form_set_error('cvs_directory', t("The root of the CVS directory (%root) does not match the selected project type (%type).", array('%root' => theme('placeholder', $path_elems[1]), '%type' => theme('placeholder', $tree->name))));
+              }
+            }
+            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))));
+              }
+            }
+          }
         }
         break;
       case 'delete':
