function joomla_myblog_update_node in Joomla to Drupal 7.2
Same name and namespace in other branches
- 7 joomla_myblog.module \joomla_myblog_update_node()
1 call to joomla_myblog_update_node()
- joomla_myblog_joomla in ./
joomla_myblog.module - Implements hook_joomla().
File
- ./
joomla_myblog.module, line 151
Code
function joomla_myblog_update_node($node = NULL, $jcontent = NULL) {
if ($node === NULL) {
return;
}
db_set_active('joomla');
// Check to see if there is a myblog tag for this content item
$myblogcategory = db_query('SELECT mcc.category,mc.name FROM {myblog_content_categories} mcc JOIN {myblog_categories} mc on mc.id = mcc.category WHERE mcc.contentid = :contentid', array(
':contentid' => $jcontent->id,
))
->fetchObject();
db_set_active();
// If this is not a myblog content item, there's nothing left to do
if (!is_object($myblogcategory) && !$myblogcategory->category) {
return;
}
// Get the taxonomy term id for this myblog category
$myblog_map = db_query('SELECT * FROM {joomla_myblog_categories} WHERE myblogcategoryid = :myblogcategoryid', array(
':myblogcategoryid' => $myblogcategory->category,
))
->fetch();
$vid = joomla_myblog_get_vocabulary_id();
if (!$myblog_map) {
// Create a new taxonomy term
$term = new stdClass();
$term->name = $myblogcategory->name;
$term->vid = $vid;
taxonomy_term_save($term);
$myblog_map = new stdClass();
$myblog_map->myblogcategoryid = $myblogcategory->category;
$myblog_map->tid = $term->tid;
drupal_write_record('joomla_myblog_categories', $myblog_map);
}
// Create a node <-> taxonomy link
$term_node = new stdClass();
$term_node->tid = $myblog_map->tid;
$term_node->nid = $node->nid;
drupal_write_record('taxonomy_term_index', $term_node);
}