blogapi_blogger_edit_post

Versions
4.6 – 6
blogapi_blogger_edit_post($appkey, $postid, $username, $password, $content, $publish)

Blogging API callback. Modifies the specified blog node.

Code

modules/blogapi.module, line 229

<?php
function blogapi_blogger_edit_post($appkey, $postid, $username, $password, $content, $publish) {

  $user = blogapi_validate_user($username, $password);

  if (!$user->uid) {
    return blogapi_error($user);
  }

  $node = node_load(array('nid' => $postid));
  if (!$node) {
    return blogapi_error(message_na());
  }
  // Let the teaser be re-generated.
  unset($node->teaser);

  if (!node_access('update', $node)) {
    return blogapi_error(message_access());
  }

  $node->status = $publish;

  // check for bloggerAPI vs. metaWeblogAPI
  if (is_array($content)) {
    $node->title = $content['title'];
    $node->body = $content['description'];
    _blogapi_mt_extra($node, $content);
  }
  else {
    $node->title = blogapi_blogger_title($content);
    $node->body = $content;
  }

  $node = node_validate($node);

  if ($errors = form_get_errors()) {
    return blogapi_error(implode("\n", $errors));
  }

  $terms = module_invoke('taxonomy', 'node_get_terms', $node->nid, 'tid');
  foreach ($terms as $term) {
    $node->taxonomy[] = $term->tid;
  }
  $nid = node_save($node);
  if ($nid) {
    watchdog('content', t('%type: updated %title using blog API.', array('%type' => '<em>'. t($node->type) .'</em>', '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), "node/$nid"));
    return true;
  }

  return blogapi_error(t('Error storing post.'));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.