Forums: fix add forum attachment using resources

pull/3741/head
Julio Montoya 5 years ago
parent 172c97a4d8
commit a15a934a9f
  1. 15
      public/main/forum/forumfunction.inc.php
  2. 4
      public/main/forum/viewthread.php
  3. 4
      src/CourseBundle/Entity/CForumThread.php

@ -2386,7 +2386,7 @@ function saveThread(
->setThreadSticky($values['thread_sticky'] ?? 0)
->setThreadTitleQualify($values['calification_notebook_title'] ?? '')
->setThreadQualifyMax($values['numeric_calification'] ?? 0)
->setThreadWeight(isset($values['weight_calification']) ? (int) $values['weight_calification'] : 0)
->setThreadWeight($values['weight_calification'] ?? 0)
->setThreadPeerQualify(isset($values['thread_peer_qualify']) ? (bool) $values['thread_peer_qualify'] : false)
->setSessionId($sessionId)
->setLpItemId(isset($values['lp_item_id']) ? (int) $values['lp_item_id'] : 0)
@ -2498,13 +2498,13 @@ function saveThread(
$repo = Container::getForumPostRepository();
$repo->create($post);
$postId = $post->getIid();
$thread->setThreadLastPost($postId);
$thread->setThreadLastPost($post);
$em = Database::getManager();
$em->persist($thread);
$em->flush();
$postId = $post->getIid();
$logInfo = [
'tool' => TOOL_FORUM,
'tool_id' => $values['forum_id'],
@ -4326,8 +4326,8 @@ function store_move_post($values)
->setCId($course_id)
->setThreadTitle($post->getPostTitle())
->setForum($post->getForum())
->setThreadPosterId($post->getUser()->getId())
->setThreadLastPost($post->getIid())
->setUser($post->getUser())
->setThreadLastPost($post)
->setThreadDate($post->getPostDate())
->setParent($post->getForum())
->addCourseLink(
@ -4811,7 +4811,6 @@ function add_forum_attachment_file($file_comment, CForumPost $post)
return;
}
$new_file_name = uniqid('');
$safe_file_comment = Database::escape_string($file_comment);
$user = api_get_user_entity(api_get_user_id());
@ -4834,6 +4833,8 @@ function add_forum_attachment_file($file_comment, CForumPost $post)
$repo = Container::getForumAttachmentRepository();
$repo->create($attachment);
$repo->addFile($attachment, $file);
$repo->update($attachment);
/*$last_id_file = Database::insert(
$agenda_forum_attachment,

@ -659,8 +659,8 @@ foreach ($posts as $post) {
$repo = Container::getForumAttachmentRepository();
/** @var \Chamilo\CourseBundle\Entity\CForumAttachment $attachment */
foreach ($attachments as $attachment) {
$post['post_attachments'] .= Display::return_icon('attachment.png', get_lang('Attachment'));
$url = $repo->getResourceFileDownloadUrl($attachment);
$post['post_attachments'] .= Display::returnFontAwesomeIcon('paperclip');
$url = $repo->getResourceFileDownloadUrl($attachment).'?'.api_get_cidreq();
$post['post_attachments'] .= Display::url($attachment->getFilename(), $url);
$post['post_attachments'] .= '<span class="forum_attach_comment" >'.$attachment->getComment().'</span>';
if ((1 == $forumEntity->getAllowEdit() && $post['user_id'] == $userId) ||

@ -423,7 +423,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
*/
public function setThreadQualifyMax($threadQualifyMax): self
{
$this->threadQualifyMax = $threadQualifyMax;
$this->threadQualifyMax = (float) $threadQualifyMax;
return $this;
}
@ -471,7 +471,7 @@ class CForumThread extends AbstractResource implements ResourceInterface
*/
public function setThreadWeight($threadWeight): self
{
$this->threadWeight = $threadWeight;
$this->threadWeight = (float) $threadWeight;
return $this;
}

Loading…
Cancel
Save