diff -urp includes/og.rules.inc includes/og.rules.inc
--- includes/og.rules.inc 2008-10-29 21:57:56.000000000 +0200
+++ includes/og.rules.inc 2008-11-25 16:34:04.000000000 +0200
@@ -105,6 +105,17 @@ function og_rules_action_info() {
),
'module' => 'Organic groups',
),
+ 'og_rules_action_add_group_node' => array(
+ 'label' => t('Add group node settings to content'),
+ 'arguments' => array(
+ 'node' => array(
+ 'type' => 'node',
+ 'label' => t('Content that will become a group node'),
+ ),
+ ),
+ 'help' => t("When creating a group node organic groups module requires some group settings. This action should be used after 'Add new content' action, that adds a group node type content, and will result with a new group node.", array('@group-node-type' => url('admin/og/og'))),
+ 'module' => 'Organic groups',
+ ),
);
}
@@ -131,7 +142,6 @@ function og_rules_action_subscribe_user_
);
}
-
/**
* Action: Unsubscribe user from group.
*/
@@ -140,6 +150,29 @@ function og_rules_action_remove_user($us
}
/**
+ * Action:Add group node settings to content.
+ */
+function og_rules_action_add_group_node($node, $settings) {
+ foreach ($settings['og_fieldset']['og_settings'] as $key => $value){
+ $node->$key = $value;
+ }
+ return array('node' => $node);
+}
+
+/**
+ * Action:Add group node settings to content form.
+ */
+function og_rules_action_add_group_node_form($settings, &$form) {
+ $node = !empty($settings['og_fieldset']['og_settings']) ? $settings['og_fieldset']['og_settings'] : array();
+ $og_form = og_group_form($node, array());
+ $form['settings']['og_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Organic groups form settings'),
+ );
+ $form['settings']['og_fieldset']['og_settings'] = $og_form;
+}
+
+/**
* Implementation of hook_rules_condition_info().
*/
function og_rules_condition_info() {
diff -urp og.module og.module
--- og.module 2008-11-21 19:09:31.000000000 +0200
+++ og.module 2008-11-25 16:10:20.000000000 +0200
@@ -1308,10 +1308,10 @@ function og_group_form($node, $form_stat
'#maxlength' => 150,
'#required' => TRUE,
'#description' => t('A brief description for the group details block and the group directory.'),
- '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_description') : -4,
+ '#weight' => !empty($node->type) && module_exists('content') ? content_extra_field_weight($node->type, 'og_description') : -4,
);
- $default = isset($node->nid) ? $node->og_selective : OG_OPEN;
+ $default = isset($node->og_selective) ? $node->og_selective : OG_OPEN;
$options = array(
t('Open - membership requests are accepted immediately.'),
t('Moderated - membership requests must be approved.'),
@@ -1324,7 +1324,7 @@ function og_group_form($node, $form_stat
'#required' => TRUE,
'#default_value' => $default,
'#options' => $options,
- '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_selective') : 0,
+ '#weight' => !empty($node->type) && module_exists('content') ? content_extra_field_weight($node->type, 'og_selective') : 0,
'#description' => t('How should membership requests be handled in this group? When you select closed, users will not be able to join or leave.')
);
@@ -1352,8 +1352,8 @@ function og_group_form($node, $form_stat
$form['og_register'] = array(
'#type' => 'checkbox',
'#title' => t('Registration form'),
- '#default_value' => $node->nid ? $node->og_register : $default,
- '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_register') : 0,
+ '#default_value' => isset($node->og_register) ? $node->og_register : $default,
+ '#weight' => !empty($node->type) && module_exists('content') ? content_extra_field_weight($node->type, 'og_register') : 0,
'#description' =>t('May users join this group during registration? If checked, a corresponding checkbox will be added to the registration form.'),
);
break;
@@ -1383,8 +1383,8 @@ function og_group_form($node, $form_stat
$form['og_directory'] = array(
'#type' => 'checkbox',
'#title' => t('List in groups directory'),
- '#default_value' => $node->nid ? $node->og_directory : $default,
- '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_directory') : 0,
+ '#default_value' => isset($node->og_directory) ? $node->og_directory : $default,
+ '#weight' => !empty($node->type) && module_exists('content') ? content_extra_field_weight($node->type, 'og_directory') : 0,
'#description' => t('Should this group appear on the list of groups page (requires OG Views module)? Disabled if the group is set to private group.', array('@url' => url('og'))));
break;
}
@@ -1396,7 +1396,7 @@ function og_group_form($node, $form_stat
'#title' => t('Group language'),
'#default_value' => $node->og_language,
'#options' => array('' => t('Language neutral')) + $languages,
- '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'og_language') : 0,
+ '#weight' => !empty($node->type) && module_exists('content') ? content_extra_field_weight($node->type, 'og_language') : 0,
'#description' => t('Selecting a different locale will change the interface language for all group pages and emails. Users who have chosen a preferred language always see their chosen language.'),
);
}