You are here

function blogapi_mt_publish_post in Blog API 7

Blogging API callback. Publishes the given node.

1 string reference to 'blogapi_mt_publish_post'
blogapi_xmlrpc in ./blogapi.module
Implement hook_xmlrpc().

File

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

Code

function blogapi_mt_publish_post($postid, $username, $password) {
  $user = blogapi_validate_user($username, $password);
  if (!$user->uid) {
    return blogapi_error($user);
  }
  $node = node_load($postid);
  if (!$node) {
    return blogapi_error(t('Invalid post.'));
  }

  // Nothing needs to be done if already published.
  if ($node->status) {
    return;
  }
  if (!node_access('update', $node) || !user_access('administer nodes')) {
    return blogapi_error(t('You do not have permission to update this post.'));
  }
  $node->status = 1;
  node_save($node);
  return TRUE;
}