/[drupal]/contributions/modules/taxonomy_other/taxonomy_other.module
ViewVC logotype

Diff of /contributions/modules/taxonomy_other/taxonomy_other.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.4.3, Tue Jun 17 18:21:11 2008 UTC revision 1.1.4.4, Thu Jun 19 19:37:05 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: taxonomy_other.module,v 1.1.4.2 2008/06/15 16:21:53 rellis Exp $  // $Id: taxonomy_other.module,v 1.1.4.3 2008/06/17 18:21:11 rellis Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 207  function taxonomy_other_node_form_valida Line 207  function taxonomy_other_node_form_valida
207        // Queue the new term for creation on node insert/update.        // Queue the new term for creation on node insert/update.
208        $name = $form['taxonomy']['taxonomy_other_' . $vid];        $name = $form['taxonomy']['taxonomy_other_' . $vid];
209        taxonomy_other_queue('', $vid, $name);        taxonomy_other_queue('', $vid, $name);
       // Remove the related taxonomy value.  
       form_set_value(array('#parents' => array('taxonomy', $vid)), '');  
210      }      }
211      elseif ($form['taxonomy'][$vid] == 'taxonomy_other' && taxonomy_other_required($vid)) {      elseif ($form['taxonomy'][$vid] == 'taxonomy_other' && taxonomy_other_required($vid)) {
212        $vocabulary = taxonomy_get_vocabulary($vid);        $vocabulary = taxonomy_get_vocabulary($vid);
# Line 235  function taxonomy_other_required($vid, $ Line 233  function taxonomy_other_required($vid, $
233   * - If $vid and $name are specified, save the term in the static queue.   * - If $vid and $name are specified, save the term in the static queue.
234   * - If $nid and $vid are specified, retrieve the term from the queue.   * - If $nid and $vid are specified, retrieve the term from the queue.
235   * - If only $nid is specified, retrieve all the terms from the static and database queue.   * - If only $nid is specified, retrieve all the terms from the static and database queue.
236     * - If $nid is empty, retrieve the terms from the static queue.
237   *   *
238   * @param $nid   * @param $nid
239   *   Node id.   *   Node id.
# Line 266  function taxonomy_other_queue($nid = '', Line 265  function taxonomy_other_queue($nid = '',
265          $q[$term->vid] = $term->name;          $q[$term->vid] = $term->name;
266        }        }
267      }      }
     return $q;  
268    }    }
269      return $q;
270  }  }
271    
272  /**  /**
# Line 301  function taxonomy_other_save(&$node, $vi Line 300  function taxonomy_other_save(&$node, $vi
300      db_query("INSERT INTO {taxonomy_other_term} (tid) VALUES (%d)", $term['tid']);      db_query("INSERT INTO {taxonomy_other_term} (tid) VALUES (%d)", $term['tid']);
301    }    }
302    
   // Remove text field entry from taxonomy.  
   unset($node->taxonomy['taxonomy_other_' . $vid]);  
   
303    // Assign term to node.    // Assign term to node.
304    $node->taxonomy[$vid] = $term['tid'];    $node->taxonomy[$vid] = $term['tid'];
305    taxonomy_node_save($node->nid, $node->taxonomy);    taxonomy_node_save($node->nid, $node->taxonomy);
# Line 332  function taxonomy_other_get_tids($vid) { Line 328  function taxonomy_other_get_tids($vid) {
328   * Implementation of hook_nodeapi().   * Implementation of hook_nodeapi().
329   */   */
330  function taxonomy_other_nodeapi(&$node, $op) {  function taxonomy_other_nodeapi(&$node, $op) {
331    if ($op == 'insert' || $op == 'update') {    if ($op == 'submit') {
332        // Clean up $node->taxonomy before the taxonomy module sees it.
333        foreach (array_keys(taxonomy_other_queue($node->nid)) as $vid) {
334          unset($node->taxonomy[$vid]);
335          unset($node->taxonomy['taxonomy_other_' . $vid]);
336        }
337      }
338      elseif ($op == 'insert' || $op == 'update') {
339      foreach (taxonomy_other_queue($node->nid) as $vid => $name) {      foreach (taxonomy_other_queue($node->nid) as $vid => $name) {
340        if ($node->status) {        if ($node->status) {
341          taxonomy_other_save($node, $vid, $name);          taxonomy_other_save($node, $vid, $name);

Legend:
Removed from v.1.1.4.3  
changed lines
  Added in v.1.1.4.4

  ViewVC Help
Powered by ViewVC 1.1.2