function blogapi_new_post in Blog API 7.2
Creates a new node. Utility function for backend modules.
2 calls to blogapi_new_post()
- blogapi_blogger_new_post in modules/
blogapi_blogger/ blogapi_blogger.module - Service callback for blogger.newPost
- blogapi_metaweblog_new_post in modules/
blogapi_metaweblog/ blogapi_metaweblog.module - Service callback for metaWeblog.newPost
File
- ./
blogapi.module, line 496 - Enable users to post using applications that support BlogAPIs.
Code
function blogapi_new_post($username, $password, $postdata) {
// Validate the user.
$user = blogapi_validate_user($username, $password);
if (!node_access('create', $postdata['type'], $user)) {
return services_error(t('You do not have permission to create this type of post.'), 403);
}
blogapi_validate_content_type($postdata['type']);
// @todo make more beautiful reassigning
// Get the node type defaults.
$node_type_default = variable_get('node_options_' . $postdata['type'], array(
'status',
'promote',
));
$node = new stdClass();
$node->type = $postdata['type'];
$node->promote = in_array('promote', $node_type_default);
$node->uid = $user->uid;
$node->status = $postdata['status'];
$node->name = $user->name;
$node->title = $postdata['title'];
$node->language = LANGUAGE_NONE;
$node->body = array(
LANGUAGE_NONE => array(
array(
'format' => filter_default_format($user),
'value' => $postdata['body'],
),
),
);
if (empty($postdata['date']) && user_access('administer nodes')) {
$node->date = format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i:s O');
}
return blogapi_submit_node($node, $node);
}