Browse Source

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

Angel Fernando Quiroz Campos 8 years ago
parent
commit
c52a47a9b4
1 changed files with 5 additions and 3 deletions
  1. 5 3
      main/webservices/api/v2.php

+ 5 - 3
main/webservices/api/v2.php

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