cvs diff: Diffing .
Index: og_project.install
===================================================================
RCS file: og_project.install
diff -N og_project.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ og_project.install	31 Jul 2009 07:06:26 -0000
@@ -0,0 +1,16 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Database configuration for og_project.
+ */
+
+/**
+ * Implement hook_install().
+ */
+function og_project_install() {
+  // Make this module heavier than project_release and og.
+  db_query("UPDATE {system} SET weight = %d WHERE name = 'og_project'", 3);
+}
+
Index: og_project.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og_project/og_project.module,v
retrieving revision 1.3
diff -u -p -r1.3 og_project.module
--- og_project.module	18 Jun 2009 04:41:30 -0000	1.3
+++ og_project.module	31 Jul 2009 07:06:26 -0000
@@ -7,3 +7,91 @@
  * Handles the interaction between organic groups and the project module.
  */
 
+
+/**
+ * Implement hook_menu().
+ */
+function og_project_menu() {
+  $items['admin/project/og-project-settings'] = array(
+    'description' => 'Configure settings for the integration between Organic Groups and the Project family of modules.',
+    'title' => 'OG Project settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('og_project_settings_form'),
+    'access arguments' => array('administer projects'),
+    'weight' => 1,
+    'type' => MENU_NORMAL_ITEM,
+    'file' => 'og_project.settings.inc',
+  );
+  return $items;
+}
+
+/**
+ * Implement hook_form_alter().
+ *
+ * Note: we have to use hook_form_alter(), not the form_id-specific version,
+ * so that we're sure to come after other modules (namely OG) have altered the
+ * forms.
+ */
+function og_project_form_alter(&$form, $form_state, $form_id) {
+  if ($form_id == 'project_release_node_form') {  
+    return og_project_release_node_form_alter($form, $form_state);
+  }
+  if ($form_id == 'project_issue_node_form') {  
+    return og_project_issue_node_form_alter($form, $form_state);
+  }
+}
+
+/**
+ * Alter the project_release node form.
+ */
+function og_project_release_node_form_alter(&$form, $form_state) {
+  if (variable_get('og_project_release_automatic_audience', FALSE)) {
+    if (!empty($form['project'])) {
+      // If we have a project in the $form, it's adding a new release, so
+      // force the group audience to match the parent project for this release.
+      $project_nid = $form['project']['#value']->nid;
+      $form['og_nodeapi']['visible']['og_groups']['#default_value'] = array($project_nid);
+    }
+    // Either way, hide the OG UI.
+    $form['og_nodeapi']['#access'] = FALSE;
+  }
+}
+
+/**
+ * Alter the project_issue node form.
+ */
+function og_project_issue_node_form_alter(&$form, $form_state) {
+  if (variable_get('og_project_issue_automatic_audience', FALSE)) {
+    if (empty($form['nid']['#value'])) {
+      $project_nid = $form['project_info']['pid']['#value'];
+      $form['og_nodeapi']['visible']['og_groups']['#default_value'] = array($project_nid);
+    }
+    // Either way, hide the OG UI.
+    $form['og_nodeapi']['#access'] = FALSE;
+  }
+}
+
+/**
+ * Implement hook_og_links_alter().
+ *
+ * If the currently active group is a project node, fix the links in the group
+ * details block to create an issue or release to include the necessary URL
+ * elements to associate the issue or release with its parent project.
+ *
+ * @param $links
+ *   Reference to an array of links to create content in a group.
+ */
+function og_project_og_links_alter(&$links) {
+  $group = og_get_group_context();
+  if ($group->type == 'project_project') {
+    if (!empty($links['create_project_issue'])) {
+      $type_name = node_get_types('name', 'project_issue');
+      $links['create_project_issue'] = l(t('Create !type', array('!type' => $type_name)), 'node/add/project-issue/' . $group->project['uri'], array('attributes' => array('title' => t('Add a new !type in this group.', array('!type' => $type_name))), 'query' => "gids[]=$group->nid"));
+    }
+    if (!empty($links['create_project_release'])) {
+      $type_name = node_get_types('name', 'project_release');
+      $links['create_project_release'] = l(t('Create !type', array('!type' => $type_name)), 'node/add/project-release/' . $group->nid, array('attributes' => array('title' => t('Add a new !type in this group.', array('!type' => $type_name))), 'query' => "gids[]=$group->nid"));
+    }
+  }
+}
+
Index: og_project.settings.inc
===================================================================
RCS file: og_project.settings.inc
diff -N og_project.settings.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ og_project.settings.inc	31 Jul 2009 07:06:26 -0000
@@ -0,0 +1,61 @@
+<?php
+
+// $Id$
+
+/**
+ * @file
+ * Code for the settings page for OG Project.
+ */
+
+/**
+ * Form builder for the administrative settings page.
+ */
+function og_project_settings_form($form_state) {
+  $project_group_behavior = variable_get('og_content_type_usage_project_project', 'group_post_standard');
+  if ($project_group_behavior == 'group') {
+    $types = array(
+      'project_issue' => 'og_project_issue_automatic_audience',
+      'project_release' => 'og_project_release_automatic_audience',
+    );
+    foreach ($types as $type => $variable) {
+      if (module_exists($type)) {
+        $form['og_project_audience'][$variable] = _og_project_audience_setting($type, $variable);
+      }
+    }
+    if (!empty($form['og_project_audience'])) {
+      $placeholders['%project'] = node_get_types('name', 'project_project');
+      $form['og_project_audience']['#type'] = 'fieldset';
+      $form['og_project_audience']['#title'] = t('Automatic group audience for %project content', $placeholders);
+      $form['og_project_audience']['#description'] = t('Your site is configured with %project nodes as Organic Groups. Projects can also have other nodes associated with them, which you may want to have automatically posted to the corresponding Organic Group.', $placeholders);
+    }
+  }
+  if (!empty($form)) {
+    return system_settings_form($form);
+  }
+  return array();
+}
+
+/**
+ * Helper function to generate the settings form element for a given type.
+ *
+ * @param $type
+ *   Node type to add the audience setting for (e.g. 'project_issue').
+ * @param $variable
+ *   Name of the variable to use for the audience setting for the given type.
+ *
+ * @return
+ *   A Form API array defining a checkbox for the given node type and setting.
+ *
+ * @see og_project_settings_form()
+ */
+function _og_project_audience_setting($type, $variable) {
+  $placeholders['%project'] = node_get_types('name', 'project_project');
+  $placeholders['%node_type'] = node_get_types('name', $type);
+  return array(
+    '#title' => t('Automatically set group audience for %node_type content', $placeholders),
+    '#type' => 'checkbox',
+    '#default_value' => variable_get($variable, FALSE),
+    '#description' => t('If enabled, the group audience field for %node_type content will automatically be set to the %project that the %node_type belongs to.', $placeholders),
+  );
+}
+
