function _feedapi_inherit_do_inherit in FeedAPI 5
Same name and namespace in other branches
- 6 feedapi_inherit/feedapi_inherit.module \_feedapi_inherit_do_inherit()
Inherit the feed's taxonomy and og data to the given feed item. Todo: split this into a function for taxonomy and another one for og - easier maintainable.
1 call to _feedapi_inherit_do_inherit()
- feedapi_inherit_nodeapi in feedapi_inherit/
feedapi_inherit.module - Implementation of hook_nodeapi().
File
- feedapi_inherit/
feedapi_inherit.module, line 83 - Inherit group and taxonomy settings from feeds to news items This is an add on processor for FeedAPI
Code
function _feedapi_inherit_do_inherit(&$item_node, $feed_node) {
$inherit_taxonomy = TRUE;
$inherit_og = TRUE;
if ($feed_node->feed->settings['processors']['feedapi_inherit']) {
$inherit_taxonomy = $feed_node->feed->settings['processors']['feedapi_inherit']['inherit_taxonomy'];
$inherit_og = $feed_node->feed->settings['processors']['feedapi_inherit']['inherit_og'];
}
// Pass on taxonomy data
if ($inherit_taxonomy && module_exists('taxonomy')) {
$terms = taxonomy_node_get_terms($feed_node->nid);
foreach ($terms as $tid => $term) {
if (!$item_node->taxonomy[$tid]) {
$item_node->taxonomy[$tid] = $term;
}
}
}
// Pass on group data
if ($inherit_og && module_exists('og')) {
if (isset($feed_node->og_public)) {
if (!isset($item_node->og_public)) {
$item_node->og_public = 1;
}
$item_node->og_public = $item_node->og_public & $feed_node->og_public;
}
if (isset($feed_node->og_groups)) {
if (!is_array($item_node->og_groups)) {
$item_node->og_groups = array();
}
$item_node->og_groups = array_merge($feed_node->og_groups, $item_node->og_groups);
foreach ($item_node->og_groups as $gid) {
if ($gid != 0) {
$transformed_groups[$gid] = $gid;
}
}
$item_node->og_groups = $transformed_groups;
}
if (isset($feed_node->og_groups_names)) {
if (!is_array($item_node->og_groups_names)) {
$item_node->og_groups_names = array();
}
$item_node->og_groups_names = array_merge($feed_node->og_groups_names, $item_node->og_groups_names);
}
}
}