You are here

function blogapi_status_error_check in Drupal 6

Same name and namespace in other branches
  1. 5 modules/blogapi/blogapi.module \blogapi_status_error_check()

Check that the user has permission to save the node with the chosen status.

Return value

TRUE if no error, or the blogapi_error().

2 calls to blogapi_status_error_check()
blogapi_blogger_edit_post in modules/blogapi/blogapi.module
Blogging API callback. Modifies the specified blog node.
blogapi_blogger_new_post in modules/blogapi/blogapi.module
Blogging API callback. Inserts a new blog post as a node.

File

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

Code

function blogapi_status_error_check($node, $original_status) {
  $node = (object) $node;
  $node_type_default = variable_get('node_options_' . $node->type, array(
    'status',
    'promote',
  ));

  // If we don't have the 'administer nodes' permission and the status is
  // changing or for a new node the status is not the content type's default,
  // then return an error.
  if (!user_access('administer nodes') && ($node->status != $original_status || empty($node->nid) && $node->status != in_array('status', $node_type_default))) {
    if ($node->status) {
      return blogapi_error(t('You do not have permission to publish this type of post. Please save it as a draft instead.'));
    }
    else {
      return blogapi_error(t('You do not have permission to save this post as a draft. Please publish it instead.'));
    }
  }
  return TRUE;
}