function blogapi_metaweblog_get_category_list

6.x blogapi.module blogapi_metaweblog_get_category_list($blogid, $username, $password)

Blogging API callback. Returns a list of the taxonomy terms that can be associated with a blog node.

1 call to blogapi_metaweblog_get_category_list()
blogapi_mt_get_category_list in drupal-6.x/modules/blogapi/blogapi.module
1 string reference to 'blogapi_metaweblog_get_category_list'
blogapi_xmlrpc in drupal-6.x/modules/blogapi/blogapi.module
Implementation of hook_xmlrpc().

File

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

Code

function blogapi_metaweblog_get_category_list($blogid, $username, $password) {
  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  }

  if (($error = _blogapi_validate_blogid($blogid)) !== TRUE) {
    // Return an error if not configured type.
    return $error;
  }

  $vocabularies = module_invoke('taxonomy', 'get_vocabularies', $blogid, 'vid');
  $categories = array();
  if ($vocabularies) {
    foreach ($vocabularies as $vocabulary) {
      $terms = module_invoke('taxonomy', 'get_tree', $vocabulary->vid, 0, -1);
      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);
      }
    }
  }
  return $categories;
}