You are here

function _vkxp_process_node in VK CrossPoster 6.3

Same name and namespace in other branches
  1. 7.2 vkxp.module \_vkxp_process_node()
  2. 7 vkxp.module \_vkxp_process_node()

Process node and send it to VK if needed.

Parameters

$node: Node object during insert/update.

1 call to _vkxp_process_node()
vkxp_nodeapi in ./vkxp.module
Implementation of hook_nodeapi().

File

./vkxp.module, line 142

Code

function _vkxp_process_node($node) {

  // Get all flags to see if node could be crossposted.
  $vkxp_enabled = variable_get('vkxp_node_enabled_' . $node->type, NULL);
  $access_token = variable_get('vkxp_access_token', NULL);
  $user_access = user_access('post to vkontakte');
  $post_node = isset($node->vkxp_post_this_node) ? $node->vkxp_post_this_node : FALSE;

  // Check requiered data to post.
  if ($vkxp_enabled && $access_token && $user_access && $post_node) {

    // Get node data that will be crossposted.
    $message = _vkxp_get_node_message($node);
    $images = _vkxp_get_node_images($node);
    $url = url('node/' . $node->nid, array(
      'absolute' => TRUE,
    ));

    // Post node to VK.
    _vkxp_post_to_wall($message, $images, $url);
  }
}