You are here

function taxonomy_facets_node_submit in Taxonomy Facets 7.3

File

./taxonomy_facets.module, line 585

Code

function taxonomy_facets_node_submit($node, $form, &$form_state) {
  if (variable_get('taxonomy_facets_show_subnodes_checkbox', FALSE)) {

    // Only concerned about taxo faceted node types, as per user selection
    $node_types = variable_get('taxonomy_facets_content_type_options', array());
    $nodeTypes = array();
    foreach ($node_types as $key => $value) {
      if ($value !== 0) {
        $nodeTypes[] = $value;
      }
    }
    $type = $form_state['values']['type'];
    if (in_array($type, $nodeTypes)) {

      // Get vocabulary ids of vocabularies used for taxo facets.
      $deltas = variable_get('taxo_faceted_block_ids', array());

      // Load all taxo faceted vocabularies.
      foreach ($deltas as $delta) {
        $vid = variable_get("taxonomy_facets_{$delta}_tid", 2);
        $vocabulary = taxonomy_vocabulary_load($vid);
        $taxo_facet_vocabs[] = $vocabulary;
        $taxo_facet_vocabs_names[] = $vocabulary->machine_name;
      }

      // Get all fields of type taxonomy reference for this node type.
      foreach (field_info_instances('node', $type) as $key => $value) {
        $field_info = field_info_field($key);
        if ($field_info['type'] == 'taxonomy_term_reference') {

          // Is this field taxo facets vocabulary field.
          $vocabulary_name = $field_info['settings']['allowed_values'][0]['vocabulary'];
          if (in_array($vocabulary_name, $taxo_facet_vocabs_names)) {
            $filed_name = $field_info['field_name'];

            // Now get value of this field and perform check.
            $value = field_get_items('node', $node, $filed_name);
            taxonomy_facets_check_if_node_in_parents($value, $vocabulary_name, $filed_name);
          }
        }
      }
    }
  }
}