| 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 |
| 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); |
| 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. |
| 265 |
$q[$term->vid] = $term->name; |
$q[$term->vid] = $term->name; |
| 266 |
} |
} |
| 267 |
} |
} |
|
return $q; |
|
| 268 |
} |
} |
| 269 |
|
return $q; |
| 270 |
} |
} |
| 271 |
|
|
| 272 |
/** |
/** |
| 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); |
| 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); |