Fix save a new forum post with Api Rest - refs #8366

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent 96e083b830
commit c52a47a9b4
  1. 8
      main/webservices/api/v2.php

@ -169,20 +169,22 @@ try {
case Rest::ACTION_SAVE_FORUM_POST: case Rest::ACTION_SAVE_FORUM_POST:
if ( if (
empty($_POST['title']) || empty($_POST['text']) || empty($_POST['thread']) || empty($_POST['forum']) || empty($_POST['title']) || empty($_POST['text']) || empty($_POST['thread']) || empty($_POST['forum']) ||
empty($_POST['notify']) || empty($_POST['parent']) || empty($_POST['course']) empty($_POST['course'])
) { ) {
throw new Exception(get_lang('NoData')); throw new Exception(get_lang('NoData'));
} }
$courseId = intval($_POST['course']); $courseId = intval($_POST['course']);
$notify = !empty($_POST['notify']);
$parentId = !empty($_POST['parent']) ? intval($_POST['parent']) : null;
$postValues = [ $postValues = [
'post_title' => $_POST['title'], 'post_title' => $_POST['title'],
'post_text' => nl2br($_POST['text']), 'post_text' => nl2br($_POST['text']),
'thread_id' => $_POST['thread'], 'thread_id' => $_POST['thread'],
'forum_id' => $_POST['forum'], 'forum_id' => $_POST['forum'],
'post_notification' => $_POST['notify'], 'post_notification' => $notify,
'post_parent_id' => $_POST['parent'] 'post_parent_id' => $parentId
]; ];
$data = $restApi->saveForumPost($postValues, $forumId, $courseId); $data = $restApi->saveForumPost($postValues, $forumId, $courseId);

Loading…
Cancel
Save