blogapi_status_error_check

Versions
5 – 6
blogapi_status_error_check($node, $original_status)

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 functions call 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.

Code

modules/blogapi/blogapi.module, line 321

<?php
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;
}
?>
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.