Same name and namespace in other branches
  1. 4.6.x modules/blogapi.module \blogapi_mt_get_post_categories()
  2. 4.7.x modules/blogapi.module \blogapi_mt_get_post_categories()
  3. 5.x modules/blogapi/blogapi.module \blogapi_mt_get_post_categories()

Blogging API callback. Returns a list of the taxonomy terms that are assigned to a particular node.

1 string reference to 'blogapi_mt_get_post_categories'
blogapi_xmlrpc in modules/blogapi/blogapi.module
Implementation of hook_xmlrpc().

File

modules/blogapi/blogapi.module, line 520
Enable users to post using applications that support XML-RPC blog APIs.

Code

function blogapi_mt_get_post_categories($postid, $username, $password) {
  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  }
  $node = node_load($postid);
  $terms = module_invoke('taxonomy', 'node_get_terms', $node, 'tid');
  $categories = array();
  foreach ($terms as $term) {
    $term_name = $term->name;
    foreach (module_invoke('taxonomy', 'get_parents', $term->tid, 'tid') as $parent) {
      $term_name = $parent->name . '/' . $term_name;
    }
    $categories[] = array(
      'categoryName' => $term_name,
      'categoryId' => $term->tid,
      'isPrimary' => TRUE,
    );
  }
  return $categories;
}