function joomla_myblog_update_node in Joomla to Drupal 7
Same name and namespace in other branches
- 7.2 joomla_myblog.module \joomla_myblog_update_node()
1 call to joomla_myblog_update_node()
File
- ./
joomla_myblog.module, line 162
Code
function joomla_myblog_update_node($node = NULL, $contentid = 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' => $contentid,
))
->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->description = $myblogcategory->name;
$term->vid = $vid;
drupal_write_record('taxonomy_term_data', $term);
$term_hierarchy = new stdClass();
$term_hierarchy->tid = $term->tid;
$term_hierarchy->parent = 0;
drupal_write_record('taxonomy_term_hierarchy', $term_hierarchy);
$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_index', $term_node);
}