|
|
|
|
@ -166,6 +166,7 @@ switch ($action) { |
|
|
|
|
case 'get_forum_thread': |
|
|
|
|
$lpId = isset($_GET['lp']) ? intval($_GET['lp']) : 0; |
|
|
|
|
$lpItemId = isset($_GET['lp_item']) ? intval($_GET['lp_item']) : 0; |
|
|
|
|
$sessionId = api_get_session_id(); |
|
|
|
|
|
|
|
|
|
if (empty($lpId) || empty($lpItemId)) { |
|
|
|
|
echo json_encode([ |
|
|
|
|
@ -180,39 +181,69 @@ switch ($action) { |
|
|
|
|
api_get_user_id() |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$forum = $learningPath->getForum(); |
|
|
|
|
|
|
|
|
|
$lpItem = $learningPath->getItem($lpItemId); |
|
|
|
|
|
|
|
|
|
if (empty($forum)) { |
|
|
|
|
if (empty($lpItem)) { |
|
|
|
|
echo json_encode([ |
|
|
|
|
'error' => true, |
|
|
|
|
]); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$lpItem = $learningPath->getItem($lpItemId); |
|
|
|
|
$forum = $learningPath->getForum($sessionId); |
|
|
|
|
|
|
|
|
|
if (empty($lpItem)) { |
|
|
|
|
if (empty($forum)) { |
|
|
|
|
require_once '../../forum/forumfunction.inc.php'; |
|
|
|
|
|
|
|
|
|
$forumCategory = getForumCategoryByTitle( |
|
|
|
|
get_lang('LearningPaths'), |
|
|
|
|
$course_id, |
|
|
|
|
$sessionId |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($forumCategory)) { |
|
|
|
|
$forumCategoryId = store_forumcategory( |
|
|
|
|
[ |
|
|
|
|
'lp_id' => 0, |
|
|
|
|
'forum_category_title' => get_lang('LearningPaths'), |
|
|
|
|
'forum_category_comment' => null |
|
|
|
|
], |
|
|
|
|
[], |
|
|
|
|
false |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$forumCategoryId = $forumCategory['cat_id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$forumId = $learningPath->createForum($forumCategoryId); |
|
|
|
|
} else { |
|
|
|
|
$forumId = $forum['forum_id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$basisForumThread = $lpItem->getForumThread($course_id); |
|
|
|
|
|
|
|
|
|
if (empty($basisForumThread)) { |
|
|
|
|
echo json_encode([ |
|
|
|
|
'error' => true, |
|
|
|
|
]); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$forumThread = $lpItem->getForumThread($course_id, api_get_session_id()); |
|
|
|
|
$forumThread = $lpItem->getForumThread($course_id, $sessionId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($forumThread)) { |
|
|
|
|
echo json_encode([ |
|
|
|
|
'error' => true, |
|
|
|
|
]); |
|
|
|
|
break; |
|
|
|
|
$lpItem->createForumTthread($forumId); |
|
|
|
|
|
|
|
|
|
$forumThread = $lpItem->getForumThread($course_id, $sessionId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$forumThreadId = $forumThread['thread_id']; |
|
|
|
|
|
|
|
|
|
echo json_encode([ |
|
|
|
|
'error' => false, |
|
|
|
|
'forumId' => intval($forum['forum_id']), |
|
|
|
|
'threadId' => intval($forumThread['thread_id']) |
|
|
|
|
'threadId' => intval($forumThreadId) |
|
|
|
|
]); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
|