You are here

function webform_menu_component_load in Webform 6.3

Same name and namespace in other branches
  1. 6.2 webform.module \webform_menu_component_load()
  2. 7.4 webform.module \webform_menu_component_load()
  3. 7.3 webform.module \webform_menu_component_load()

Menu loader callback. Load a webform component if the given cid is a valid.

File

./webform.module, line 376

Code

function webform_menu_component_load($cid, $nid, $type) {
  module_load_include('inc', 'webform', 'includes/webform.components');
  if ($cid == 'new') {
    $components = webform_components();
    $component = in_array($type, array_keys($components)) ? array(
      'type' => $type,
      'nid' => $nid,
      'name' => $_GET['name'],
      'mandatory' => $_GET['mandatory'],
      'pid' => $_GET['pid'],
      'weight' => $_GET['weight'],
    ) : FALSE;
  }
  else {
    $node = node_load($nid);
    $component = isset($node->webform['components'][$cid]) ? $node->webform['components'][$cid] : FALSE;
  }
  if ($component) {
    webform_component_defaults($component);
  }
  return $component;
}