function connect_node_settings_form() { drupal_add_css(drupal_get_path('module', 'connect') . '/connect.css'); $form = array(); $child = NULL; $p_nid = arg(1); $parent = node_load($p_nid); $actions = connect_get_actions($parent->nid); //var_dump($actions); // test for requirements $requirements_message = ''; foreach ($actions as $function) { $this_OK = _connect_hook_check_requirements($parent, $child, $function, 'parent'); if ($this_OK !== TRUE) { $requirements_message .= $this_OK; } } if (!empty($requirements_message)) { $requirements_message = 'The following items need to to be configured for your actions to work properly:<br />' . $requirements_message; drupal_set_message($requirements_message); } // store the parent nid $form['parent_id'] = array('#type' => 'value', '#value' => $parent->nid); // required variables $map = connect_get_map($parent->nid); $required = connect_get_required_vars($parent, $child); //var_dump($map); //var_dump($required); if (!empty($required['variables'])) { $form['campaign_variables'] = array('#tree' => TRUE); foreach ($required['variables'] as $action => $vars) { $description = $action_list[$action]; $form['campaign_variables']["variables_{$action}"] = array('#type' => 'fieldset', '#title' => $description['title']); foreach ($vars as $key => $formitem) { $form['campaign_variables']["variables_{$action}"][$key] = $formitem; } if ($action == 'connect_action_basic') { $form['campaign_variables']["variables_{$action}"]['#weight'] = -1; } } } // parent node fields //var_dump($required['parent']); if (!empty($required['parent'])) { $options = connect_get_node_fields($parent->type); $form['variables_parent'] = array('#type' => 'fieldset', '#title' => 'Required fields in parent/campaign node', '#tree' => TRUE); $form['variables_parent']['message'] = array('#value' => '<em>' . t('The selected functions store or use information from the campaign/parent node. Please identify which fields in the parent node correspond to the function settings below.') . '</em>'); foreach ($required['parent'] as $key => $desc) { $form['variables_parent'][$key] = array('#type' => 'select', '#title' => $desc, '#options' => $options, '#default_value' => isset($map[$key]) ? $map[$key] : '', '#required' => TRUE); } } // child node fields if (connect_node_options($parent->nid, 'participant_type')) { if (!empty($required['child'])) { //var_dump($required['child']); $form['variables_child'] = array('#type' => 'fieldset', '#title' => 'Required fields in child/participant node', '#tree' => TRUE); $form['variables_child']['message'] = array('#value' => '<em>' . t('The selected functions store or use information from the participant/child node. Please identify which fields in the child node correspond to the function settings below.') . '</em>'); $child_type = connect_node_options($parent->nid, 'participant_type'); $options = connect_get_node_fields($child_type); foreach ($required['child'] as $key => $desc) { $form['variables_child'][$key] = array('#type' => 'select', '#title' => $desc, '#options' => $options, '#default_value' => isset($map[$key]) ? $map[$key] : '', '#required' => TRUE); } } } else { $form['variables_child']['message'] = array('#value' => t('Please select a participant type and return here to set up your variables.')); } $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); //var_dump($form); return $form; }
/** * allows participant-generated content to replace the parent content */ function connect_action_content_replace(&$parent, &$child, $op = '', $target = 'child') { switch ($op) { case 'requires': $return = array(); $return['parent'] = array('subject_replace_parent' => 'Content replace: the subject that can be rewritten.', 'body_replace_parent' => 'Content replace: the body that can be rewritten.'); $return['child'] = array('subject_replace_child' => 'Content replace: the subject participant\'s version.', 'body_replace_child' => 'Content replace: the body participant\'s version.'); return $return; case 'form_alter': $map = connect_get_map($parent->nid); $field = array('subject' => $map['subject_replace_child'], 'body' => $map['body_replace_child']); // filter text if required $cck_info = _content_type_info(); $cck_vars = $cck_info['content types'][connect_node_options($parent->nid, 'participant_type')]['fields']; $text = array('subject' => connect_value('subject_replace_parent', $parent, $child, 'parent'), 'body' => connect_value('body_replace_parent', $parent, $child, 'parent')); if ($cck_vars[$field['subject']]['text_processing'] == 0) { $text['subject'] = strip_tags($text['subject']); } if ($cck_vars[$field['body']]['text_processing'] == 0) { $text['body'] = strip_tags($text['body']); } $child[$field['subject']][0]['#default_value']['value'] = $text['subject']; $child[$field['body']][0]['#default_value']['value'] = $text['body']; break; case 'insert': if ($target == 'child') { $addition = array('subject' => connect_value('subject_replace_child', $parent, $child, 'child'), 'body' => connect_value('body_replace_child', $parent, $child, 'child')); connect_value('subject_replace_parent', $parent, $child, 'parent', $addition['subject']); connect_value('body_replace_parent', $parent, $child, 'parent', $addition['body']); } break; } }