Skip to content

Commit d0d7cb6

Browse files
committed
Portfolio: fix index page
1 parent 740729b commit d0d7cb6

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

public/main/inc/lib/PortfolioController.php

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -521,23 +521,18 @@ public function addItem(): void
521521

522522
if ($form->validate()) {
523523
$values = $form->exportValues();
524-
$currentTime = new DateTime(
525-
api_get_utc_datetime(),
526-
new DateTimeZone('UTC')
527-
);
528524

529525
$portfolio = new Portfolio();
530526
$portfolio
531527
->setTitle($values['title'])
532528
->setContent($values['content'])
533-
->setUser($this->owner)
534-
->setCourse($this->course)
535-
->setSession($this->session)
529+
->setCreator($this->owner)
530+
->setParent($this->owner)
531+
->addCourseLink($this->course, $this->session)
536532
->setCategory(
537533
$this->em->find(PortfolioCategory::class, $values['category'])
538534
)
539-
->setCreationDate($currentTime)
540-
->setUpdateDate($currentTime);
535+
;
541536

542537
$this->em->persist($portfolio);
543538
$this->em->flush();
@@ -549,9 +544,9 @@ public function addItem(): void
549544

550545
$this->processAttachments(
551546
$form,
552-
$portfolio->getUser(),
547+
$this->owner,
553548
$portfolio->getId(),
554-
PortfolioAttachment::TYPE_ITEM
549+
Portfolio::TYPE_ITEM
555550
);
556551

557552
Container::getEventDispatcher()->dispatch(
@@ -561,7 +556,7 @@ public function addItem(): void
561556

562557
if (1 == api_get_course_setting('email_alert_teachers_new_post')) {
563558
if ($this->session) {
564-
$messageCourseTitle = "{$this->course->getTitle()} ({$this->session->getName()})";
559+
$messageCourseTitle = "{$this->course->getTitle()} ({$this->session->getTitle()})";
565560

566561
$teachers = SessionManager::getCoachesByCourseSession(
567562
$this->session->getId(),
@@ -825,7 +820,7 @@ public function editItem(Portfolio $item): void
825820
$form,
826821
$item->getUser(),
827822
$item->getId(),
828-
PortfolioAttachment::TYPE_ITEM
823+
Portfolio::TYPE_ITEM
829824
);
830825

831826
Display::addFlash(
@@ -2149,7 +2144,7 @@ public function exportPdf(HttpRequest $httpRequest)
21492144
$pdfContent .= '<p>'.get_lang('Course').': ';
21502145

21512146
if ($this->session) {
2152-
$pdfContent .= $this->session->getName().' ('.$this->course->getTitle().')';
2147+
$pdfContent .= $this->session->getTitle().' ('.$this->course->getTitle().')';
21532148
} else {
21542149
$pdfContent .= $this->course->getTitle();
21552150
}
@@ -2376,7 +2371,7 @@ public function exportZip(HttpRequest $httpRequest)
23762371
$item->getComments()->count(),
23772372
$item->getScore(),
23782373
$itemCourse->getTitle(),
2379-
$itemSession ? $itemSession->getName() : null,
2374+
$itemSession ? $itemSession->getTitle() : null,
23802375
];
23812376
}
23822377

@@ -2638,11 +2633,11 @@ public function downloadAttachment(HttpRequest $httpRequest)
26382633

26392634
$originOwnerId = 0;
26402635

2641-
if (PortfolioAttachment::TYPE_ITEM === $attachment->getOriginType()) {
2636+
if (Portfolio::TYPE_ITEM === $attachment->getOriginType()) {
26422637
$item = $em->find(Portfolio::class, $attachment->getOrigin());
26432638

26442639
$originOwnerId = $item->getUser()->getId();
2645-
} elseif (PortfolioAttachment::TYPE_COMMENT === $attachment->getOriginType()) {
2640+
} elseif (Portfolio::TYPE_COMMENT === $attachment->getOriginType()) {
26462641
$comment = $em->find(PortfolioComment::class, $attachment->getOrigin());
26472642

26482643
$originOwnerId = $comment->getAuthor()->getId();
@@ -2692,11 +2687,11 @@ public function deleteAttachment(HttpRequest $httpRequest)
26922687
$originOwnerId = 0;
26932688
$itemId = 0;
26942689

2695-
if (PortfolioAttachment::TYPE_ITEM === $attachment->getOriginType()) {
2690+
if (Portfolio::TYPE_ITEM === $attachment->getOriginType()) {
26962691
$item = $em->find(Portfolio::class, $attachment->getOrigin());
26972692
$originOwnerId = $item->getUser()->getId();
26982693
$itemId = $item->getId();
2699-
} elseif (PortfolioAttachment::TYPE_COMMENT === $attachment->getOriginType()) {
2694+
} elseif (Portfolio::TYPE_COMMENT === $attachment->getOriginType()) {
27002695
$comment = $em->find(PortfolioComment::class, $attachment->getOrigin());
27012696
$originOwnerId = $comment->getAuthor()->getId();
27022697
$itemId = $comment->getItem()->getId();
@@ -2724,7 +2719,7 @@ public function deleteAttachment(HttpRequest $httpRequest)
27242719

27252720
$url = $this->baseUrl.http_build_query(['action' => 'view', 'id' => $itemId]);
27262721

2727-
if (PortfolioAttachment::TYPE_COMMENT === $attachment->getOriginType() && isset($comment)) {
2722+
if (Portfolio::TYPE_COMMENT === $attachment->getOriginType() && isset($comment)) {
27282723
$url .= '#comment-'.$comment->getId();
27292724
}
27302725

@@ -3046,7 +3041,7 @@ public function editComment(PortfolioComment $comment)
30463041
$form,
30473042
$comment->getAuthor(),
30483043
$comment->getId(),
3049-
PortfolioAttachment::TYPE_COMMENT
3044+
Portfolio::TYPE_COMMENT
30503045
);
30513046

30523047
Container::getEventDispatcher()->dispatch(
@@ -4018,7 +4013,7 @@ private function createCommentForm(Portfolio $item): string
40184013
$form,
40194014
$comment->getAuthor(),
40204015
$comment->getId(),
4021-
PortfolioAttachment::TYPE_COMMENT
4016+
Portfolio::TYPE_COMMENT
40224017
);
40234018

40244019
Container::getEventDispatcher()->dispatch(
@@ -4191,7 +4186,7 @@ private function getItemsInHtmlFormatted(array $items): array
41914186
$metadata = '<ul class="list-unstyled text-muted">';
41924187

41934188
if ($itemSession) {
4194-
$metadata .= '<li>'.get_lang('Course').': '.$itemSession->getName().' ('
4189+
$metadata .= '<li>'.get_lang('Course').': '.$itemSession->getTitle().' ('
41954190
.$itemCourse->getTitle().') </li>';
41964191
} elseif ($itemCourse) {
41974192
$metadata .= '<li>'.get_lang('Course').': '.$itemCourse->getTitle().'</li>';

src/CoreBundle/Entity/Portfolio.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#[ORM\Entity]
2121
class Portfolio extends AbstractResource implements ResourceInterface, Stringable
2222
{
23-
use UserTrait;
24-
2523
public const TYPE_ITEM = 1;
2624
public const TYPE_COMMENT = 2;
2725

0 commit comments

Comments
 (0)