Index: modules/blogapi.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blogapi.module,v retrieving revision 1.34 diff -u -r1.34 blogapi.module --- modules/blogapi.module 23 Nov 2004 22:20:41 -0000 1.34 +++ modules/blogapi.module 29 Nov 2004 19:51:11 -0000 @@ -59,11 +59,15 @@ $user = blogapi_validate_user($params[1], $params[2]); if ($user->uid) { - $struct = new xmlrpcval(array('url' => new xmlrpcval(url('blog/' . $user->uid, NULL, NULL, true)), - 'blogid' => new xmlrpcval($user->uid), - 'blogName' => new xmlrpcval($user->name . "'s blog")), + $types = _blogapi_get_node_types(); + $structs = array(); + foreach ($types as $type) { + $structs[] = new xmlrpcval(array('url' => new xmlrpcval(url('blog/' . $user->uid, NULL, NULL, true)), + 'blogid' => new xmlrpcval($type, 'string'), + 'blogName' => new xmlrpcval($user->name . ": " . $type)), 'struct'); - $resp = new xmlrpcval(array($struct), 'array'); + } + $resp = new xmlrpcval($structs, 'array'); return new xmlrpcresp($resp); } else { @@ -86,7 +90,7 @@ 'firstname' => new xmlrpcval($name[0], 'string'), 'nickname' => new xmlrpcval($user->name, 'string'), 'email' => new xmlrpcval($user->mail, 'string'), - 'url' => new xmlrpcval(url('blog/view/' . $user->uid, NULL, NULL, true), 'string')), + 'url' => new xmlrpcval(url('blog/' . $user->uid, NULL, NULL, true), 'string')), 'struct'); return new xmlrpcresp($struct); } @@ -112,7 +116,7 @@ } $edit = array(); - $edit['type'] = 'blog'; + $edit['type'] = _blogapi_blogid($params[0]); $edit['uid'] = $user->uid; $edit['name'] = $user->name; $edit['promote'] = variable_get('node_promote_blog', 1); @@ -280,7 +284,9 @@ * associated with a blog node. */ function blogapi_get_category_list($req_params) { - $vocabularies = module_invoke('taxonomy', 'get_vocabularies', 'blog', 'vid'); + $params = blogapi_convert($req_params); + $type = _blogapi_blogid($params[0]); + $vocabularies = module_invoke('taxonomy', 'get_vocabularies', $type, 'vid'); $categories = array(); if ($vocabularies) { foreach ($vocabularies as $vocabulary) { @@ -361,7 +367,8 @@ return blogapi_error($user); } - $result = db_query_range('SELECT n.nid, n.title,'. ($bodies ? ' n.body,' : '') ." n.created, u.name FROM {node} n, {users} u WHERE n.uid=u.uid AND n.type = 'blog' AND n.uid = %d ORDER BY n.created DESC", $user->uid, 0, $params[3]); + $type = _blogapi_blogid($params[0]); + $result = db_query_range('SELECT n.nid, n.title,'. ($bodies ? ' n.body,' : '') ." n.created, u.name FROM {node} n, {users} u WHERE n.uid=u.uid AND n.type = '%s' AND n.uid = %d ORDER BY n.created DESC", $type, $user->uid, 0, $params[3]); while ($blog = db_fetch_object($result)) { $xmlrpcval = _blogapi_get_post($blog, $bodies); $blogs[] = $xmlrpcval; @@ -516,7 +523,7 @@ } if ($may_cache) { - $items[] = array('path' => 'blogapi', 'title' => t('RSD'), 'callback' => 'blogapi_blogapi', 'access' => user_access('access_content'), 'type' => MENU_CALLBACK); + $items[] = array('path' => 'blogapi', 'title' => t('RSD'), 'callback' => 'blogapi_blogapi', 'access' => user_access('access content'), 'type' => MENU_CALLBACK); } return $items; @@ -653,5 +660,27 @@ } return new xmlrpcval($xmlrpcval, 'struct'); +} + +function _blogapi_blogid($id) { + if (is_numeric($id)) { + return 'blog'; + } + else { + return $id; + } +} + +function _blogapi_get_node_types() { + global $user; + + $types = array(); + foreach (node_list() as $type) { + if (node_access('create', $type)) { + $types[] = $type; + } + } + + return $types; } ?>