Index: og_vocab.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_vocab/Attic/og_vocab.module,v
retrieving revision 1.18.2.2
diff -u -p -r1.18.2.2 og_vocab.module
--- og_vocab.module	17 Jun 2008 18:11:44 -0000	1.18.2.2
+++ og_vocab.module	8 Jul 2008 22:29:17 -0000
@@ -1,5 +1,7 @@
 <?php
 // $Id: og_vocab.module,v 1.18.2.2 2008/06/17 18:11:44 weitzman Exp $
+define(OG_VOCAB_TERMS,    '[%group] Home Folder,Unfiled');
+define(OG_VOCAB_TAXONOMY, '[%group] Group Files');
 
 /**
  * @file
@@ -48,6 +50,15 @@ function og_vocab_help($path, $arg) {
  */
 function og_vocab_menu() {
 
+  // display the administration page for the module
+  $items['admin/og/og_vocab'] = array(
+    'title'            => t('Organic groups vocabulary settings'),
+    'description'      => t('Configure the og_vocab module'),
+    'page callback'    => 'drupal_get_form',
+    'page arguments'   => array('og_vocab_admin_settings'),
+    'access arguments' => array('administer site configuration'),
+    'file'             => 'og_vocab.admin.inc',
+  );
   // categories tab that will display the vocabularies associated with the group
   $items['node/%node/og/vocab'] = array(
     'title'            => t('Categories'),
@@ -327,8 +338,14 @@ function og_vocab_nodeapi(&$node, $op, $
         $node->og_vocabularies = og_vocab_load_vocabularies($node->nid);
       }
       break;
+    case 'insert':
+      // if an og type node and we have og_vocab create set to true
+      if (og_is_group_type($node->type) && variable_get('og_vocab_create', false)) {
+        _og_vocab_create($node);
+      }
+      break;
     case 'delete':
-      if (og_is_group_type($node->type)) {
+      if (og_is_group_type($node->type) && variable_get('og_vocab_delete_on_group_delete', false)) {
         $sql = "DELETE FROM {og_vocab} WHERE nid = %d";
         db_query($sql, $node->nid);
         foreach ($node->og_vocabularies as $vocabulary) {
@@ -383,4 +400,52 @@ function og_vocab_pathauto_taxonomy($op,
     default:
       break;
   }
-}
\ No newline at end of file
+}
+
+/*
+ * Creates a default vocabulary for the organic group on group creation
+ */
+function _og_vocab_create(&$node) {
+  $name = trim(strtr(variable_get('og_vocab_taxonomy', OG_VOCAB_TAXONOMY), array('%group' => $node->title)));
+  // build the nodes array from the information in the configuration
+  $ntypes = variable_get('og_vocab_taxonomy_nodes', node_get_types());
+  $nodes = array();
+  foreach ($ntypes as $n) {
+    if ($ntypes[$n]) {
+      $nodes[$n] = $n;
+    }
+  }
+  $data = array(
+    'name' => $name,
+    'description' => variable_get('og_vocab_taxonomy_description', $name),
+    'help' => variable_get('og_vocab_taxonomy_help', ''),
+    'nodes' => $nodes,
+    'hierarchy' => variable_get('og_vocab_taxonomy_hierarchy', 1),
+    'relations' => variable_get('og_vocab_taxonomy_relations', 0),
+    'tags' => variable_get('og_vocab_taxonomy_tags', 0),
+    'multiple' => variable_get('og_vocab_taxonomy_multiple', 0),
+    'required' => variable_get('og_vocab_taxonomy_required', 0),
+    'weight' => variable_get('og_vocab_taxonomy_weight', 0),
+    'module' => 'og_vocab',
+  );
+  taxonomy_save_vocabulary($data);
+
+  $vocab = array('og' => $node->nid, 'vid' => $data['vid']);
+  og_vocab_taxonomy('insert', 'vocabulary', $vocab);
+
+  $terms = explode(',', variable_get('og_vocab_terms', OG_VOCAB_TERMS));
+  foreach($terms as $term) {
+    $term_name = trim(strtr($term, array('%group' => $node->title)));
+    if($term_name != '') {
+      $term_data = array(
+        'name' => $term_name,
+        'description' => $term_name,
+        'parent' => 0,
+        'weight' => 0,
+        'vid' => $data['vid'],
+      );
+      taxonomy_save_term($term_data);
+    }
+  }
+}
+
