You are here

function blogapi_metaweblog_new_post in Blog API 7.2

Same name and namespace in other branches
  1. 8 modules/blogapi_metaweblog/blogapi_metaweblog.module \blogapi_metaweblog_new_post()
  2. 7 blogapi.module \blogapi_metaweblog_new_post()

Service callback for metaWeblog.newPost

1 string reference to 'blogapi_metaweblog_new_post'
blogapi_metaweblog_services_resources in modules/blogapi_metaweblog/blogapi_metaweblog.module
Implements hook_services_resources().

File

modules/blogapi_metaweblog/blogapi_metaweblog.module, line 261
Provides MetaWeblog services for BlogAPI

Code

function blogapi_metaweblog_new_post($blogid, $username, $password, $content, $publish) {
  $postdata = array(
    'type' => $blogid,
    'status' => $publish,
    'title' => $content['title'],
    'body' => $content['description'],
  );
  if (module_exists('comment') && array_key_exists('mt_allow_comments', $content)) {
    switch ($content['mt_allow_comments']) {
      case 0:
        $postdata['comment'] = COMMENT_NODE_HIDDEN;
        break;
      case 1:
        $postdata['comment'] = COMMENT_NODE_OPEN;
        break;
      case 2:
        $postdata['comment'] = COMMENT_NODE_CLOSED;
        break;
    }
  }
  $body = $postdata['body'];
  if (isset($content['mt_excerpt'])) {
    $body = $content['mt_excerpt'] . '<!--break-->' . $body;
  }
  if (isset($content['mt_text_more'])) {
    $body = $body . '<!--extended-->' . $content['mt_text_more'];
  }
  $node_id = blogapi_new_post($username, $password, $postdata);
  if (is_numeric($node_id)) {

    // If this operation is successful, we're supposed to return a string from
    // metaweblog.newPost.
    return (string) $node_id;
  }
  else {

    // Otherwise, there is a problem, so just pass through what we got back from
    // blogapi_new_post().
    return $node_id;
  }
}