Fix forum creation

pull/3064/head
Julio 5 years ago
parent 6e4d413151
commit 516b3b4c29
  1. 33
      public/main/forum/forumfunction.inc.php
  2. 9
      public/main/forum/index.php

@ -2925,7 +2925,7 @@ function store_thread(
$repo = Container::getForumPostRepository();
$em = $repo->getEntityManager();
$repo->addResourceToCourseWithParent(
$resourceNode,
$post,
$thread->getResourceNode(),
ResourceLink::VISIBILITY_PUBLISHED,
$user,
@ -3280,15 +3280,9 @@ function show_add_post_form(CForumForum $current_forum, CForumThread $thread, $a
}
if ($postId) {
$postInfo = get_post_information($postId);
if ($postInfo) {
$threadId = $postInfo['thread_id'];
}
if (isset($values['give_revision']) && 1 == $values['give_revision']) {
$extraFieldValues = new ExtraFieldValue('forum_post');
$revisionLanguage = isset($values['extra_revision_language']) ? $values['extra_revision_language'] : '';
$params = [
'item_id' => $postId,
'extra_revision_language' => $revisionLanguage,
@ -3320,7 +3314,7 @@ function show_add_post_form(CForumForum $current_forum, CForumThread $thread, $a
$url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&'.http_build_query(
[
'forum' => $forumId,
'thread' => $threadId,
'thread' => $thread->getIid(),
]
);
@ -3535,11 +3529,6 @@ function newThread(CForumForum $current_forum, $form_values = '', $showPreview =
$postId = $newThread->getThreadLastPost();
if ($postId) {
$postInfo = get_post_information($postId);
if ($postInfo) {
$threadId = $postInfo['thread_id'];
}
if (isset($values['give_revision']) && 1 == $values['give_revision']) {
$extraFieldValues = new ExtraFieldValue('forum_post');
$revisionLanguage = isset($values['extra_revision_language']) ? $values['extra_revision_language'] : '';
@ -3573,7 +3562,7 @@ function newThread(CForumForum $current_forum, $form_values = '', $showPreview =
$url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&'.http_build_query(
[
'forum' => $forumId,
'thread' => $threadId,
'thread' => $newThread->getIid(),
]
);
@ -3953,7 +3942,7 @@ function store_reply(CForumForum $current_forum, CForumThread $thread, $values,
$em = $repo->getEntityManager();
$repo->addResourceToCourseWithParent(
$resourceNode,
$post,
$thread->getResourceNode(),
ResourceLink::VISIBILITY_PUBLISHED,
$user,
@ -4701,11 +4690,8 @@ function handle_mail_cue($content, $id)
/**
* This function sends the mails for the mail notification.
*
* @param array $userInfo
* @param array $forum
*/
function send_mail($userInfo, CForumForum $forum, CForumThread $thread, $postInfo = [])
function send_mail($userInfo, CForumForum $forum, CForumThread $thread, CForumPost $postInfo = null)
{
if (empty($userInfo) || empty($forum) || empty($thread)) {
return false;
@ -4732,8 +4718,8 @@ function send_mail($userInfo, CForumForum $forum, CForumThread $thread, $postInf
}
$email_body .= $courseInfoTitle;
if (!empty($postInfo) && isset($postInfo['post_text'])) {
$text = cut(strip_tags($postInfo['post_text']), 100);
if (!empty($postInfo)) {
$text = cut(strip_tags($postInfo->getPostText()), 100);
if (!empty($text)) {
$email_body .= get_lang('Message').": <br />\n ";
$email_body .= $text;
@ -5904,13 +5890,14 @@ function send_notifications(CForumForum $forum, CForumThread $thread, $post_id =
$users_to_be_notified_by_forum = get_notifications('forum', $forum->getIid());
// User who subscribed to the thread
$users_to_be_notified_by_thread = [];
if (!$thread) {
$users_to_be_notified_by_thread = get_notifications('thread', $thread->getIid());
}
$postInfo = [];
$postInfo = null;
if (!empty($post_id)) {
$postInfo = get_post_information($post_id);
$postInfo = Container::getForumPostRepository()->find($post_id);
}
// Merging the two

@ -425,12 +425,9 @@ if (is_array($forumCategories)) {
$_user['status']
);
if ('0' != $forum->getForumOfGroup()) {
$my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name'])
? $all_groups[$forum['forum_of_group']]['name']
: null;
$my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id'])
? $all_groups[$forum['forum_of_group']]['id']
: null;
$forumOfGroup = $forum->getForumOfGroup();
$my_all_groups_forum_name = $all_groups[$forumOfGroup]['name'] ?? null;
$my_all_groups_forum_id = $all_groups[$forumOfGroup]['id'] ?? null;
$group_title = api_substr($my_all_groups_forum_name, 0, 30);
$forumInfo['forum_group_title'] = $group_title;
}

Loading…
Cancel
Save