function connect_block_view($nid = 0) { $return = array(); $parent_node = node_load($nid); if ($parent_node) { $parent_node =& _connect_parent_node($parent_node); // only display if the block option is turned on //$parent_actions = connect_get_actions($nid); if (!in_array('connect_action_provide_block', connect_get_actions($nid))) { return; } // require a CAPTCHA on the form? if (!_connect_captcha_test('connect_form_block')) { return; } // visibility control $visibility = connect_node_options($nid, 'provide_block_visibility'); if ($visibility > 0) { $parent_path = "node/{$nid}"; $current_path = arg(0) . '/' . arg(1); if ($visibility == CONNECT_BLOCK_NOT_PARENT && $parent_path == $current_path || $visibility == CONNECT_BLOCK_PARENT_ONLY && $parent_path != $current_path) { return; } } $form = drupal_get_form('connect_form_block', 'block', $nid); $text = connect_node_options($nid, 'provide_block_text'); $link = empty($text) ? '' : '<p>» ' . l($text, "node/{$nid}") . '</p>'; $return['subject'] = $parent_node->title; $return['content'] = $form . $link; } return $return; }
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; }