Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
586 changes: 290 additions & 296 deletions public/main/inc/lib/PortfolioController.php

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions public/main/inc/lib/PortfolioNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ class PortfolioNotifier
public static function notifyTeachersAndAuthor(PortfolioComment $comment)
{
$item = $comment->getItem();
$course = $item->getCourse();
$session = $item->getSession();
$itemResourceLink = $item->getFirstResourceLink();
$course = $itemResourceLink->getCourse();
$session = $itemResourceLink->getSession();

$messageSubject = sprintf(
get_lang('[Portfolio] New comment in post %s'),
$item->getTitle(true)
);
$userIdListToSend = [];
$userIdListToSend[] = $comment->getItem()->getUser()->getId();
$userIdListToSend[] = $comment->getItem()->resourceNode->getCreator()->getId();

$cidreq = api_get_cidreq_params(
$course ? $course->getCode() : '',
Expand Down Expand Up @@ -58,7 +59,7 @@ public static function notifyTeachersAndAuthor(PortfolioComment $comment)

$messageContent .= '<br><br><figure>'
.'<blockquote>'.$comment->getExcerpt().'</blockquote>'
.'<figcaption>'.$comment->getAuthor()->getFullName().'</figcaption>'
.'<figcaption>'.$comment->resourceNode->getCreator()->getFullName().'</figcaption>'
.'</figure>';

foreach ($userIdListToSend as $userIdToSend) {
Expand All @@ -69,7 +70,6 @@ public static function notifyTeachersAndAuthor(PortfolioComment $comment)
0,
false,
false,
[],
false
);
}
Expand All @@ -78,7 +78,7 @@ public static function notifyTeachersAndAuthor(PortfolioComment $comment)
private static function getCourseTitle(CourseEntity $course, ?SessionEntity $session = null): string
{
if ($session) {
return "{$course->getTitle()} ({$session->getName()})";
return "{$course->getTitle()} ({$session->getTitle()})";
}

return $course->getTitle();
Expand Down
11 changes: 9 additions & 2 deletions src/CoreBundle/Entity/PortfolioComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Chamilo\CoreBundle\Entity;

use Cocur\Slugify\Slugify;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Stringable;
Expand All @@ -24,7 +25,7 @@ class PortfolioComment extends AbstractResource implements ResourceInterface, St
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
private ?int $id = null;

#[ORM\ManyToOne(targetEntity: Portfolio::class, inversedBy: 'comments')]
#[ORM\JoinColumn(name: 'item_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
Expand Down Expand Up @@ -143,7 +144,13 @@ public function setVisibility(int $visibility): self

public function getResourceName(): string
{
return 'portfolio_comment_'.$this->id;
if ($this->id) {
return 'portfolio_comment_'.$this->id;
}

return Slugify::create()->slugify(
$this->date->format('c')
);
}

public function setResourceName(string $name): static
Expand Down
13 changes: 13 additions & 0 deletions src/CoreBundle/Framework/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository;
use Chamilo\CoreBundle\Repository\Node\MessageAttachmentRepository;
use Chamilo\CoreBundle\Repository\Node\PersonalFileRepository;
use Chamilo\CoreBundle\Repository\Node\PortfolioCommentRepository;
use Chamilo\CoreBundle\Repository\Node\PortfolioRepository;
use Chamilo\CoreBundle\Repository\Node\SocialPostAttachmentRepository;
use Chamilo\CoreBundle\Repository\Node\TicketMessageAttachmentRepository;
use Chamilo\CoreBundle\Repository\Node\UsergroupRepository;
use Chamilo\CoreBundle\Repository\Node\UserRepository;
use Chamilo\CoreBundle\Repository\PluginRepository;
use Chamilo\CoreBundle\Repository\PromotionRepository;
use Chamilo\CoreBundle\Repository\ResourceFileRepository;
use Chamilo\CoreBundle\Repository\ResourceNodeRepository;
use Chamilo\CoreBundle\Repository\SequenceRepository;
use Chamilo\CoreBundle\Repository\SequenceResourceRepository;
Expand Down Expand Up @@ -710,6 +712,12 @@ public static function getPortfolioRepository(): PortfolioRepository
return self::$container->get(PortfolioRepository::class);
}

public static function getPortfolioCommentRepository(): PortfolioCommentRepository
{
/** @var PortfolioRepository $repo */
return self::$container->get(PortfolioCommentRepository::class);
}

public static function getPortfolioCategoryHelper(): PortfolioCategoryHelper
{
/** @var PortfolioCategoryHelper $helper */
Expand All @@ -720,4 +728,9 @@ public static function getSearchIndexPathResolver(): SearchIndexPathResolver
{
return self::$container->get(SearchIndexPathResolver::class);
}

public static function getResourceFileRepository(): ResourceFileRepository
{
return self::$container->get(ResourceFileRepository::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function up(Schema $schema): void

$comment->setParent($resourceParent);

$resourceNode = $portfolioRepo->addResourceNode(
$resourceNode = $commentRepo->addResourceNode(
$comment,
$author,
$resourceParent,
Expand Down
44 changes: 44 additions & 0 deletions src/CoreBundle/Migrations/Schema/V200/Version20260116085000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/* For licensing terms, see /license.txt */

namespace Chamilo\CoreBundle\Migrations\Schema\V200;

use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;

final class Version20260116085000 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return "Fix wrong resource type for portfolio comments";
}

public function up(Schema $schema): void
{
$itemsType = $this->connection->fetchAssociative(
'SELECT id FROM resource_type WHERE title = ?',
['portfolio_items']
);
$commentsType = $this->connection->fetchAssociative(
'SELECT id FROM resource_type WHERE title = ?',
['portfolio_comments']
);

if (empty($itemsType) || empty($commentsType)) {
return;
}

$this->addSql(sprintf(
'UPDATE resource_node rn INNER JOIN portfolio_comment pc ON rn.id = pc.resource_node_id SET rn.resource_type_id = %d WHERE rn.resource_type_id = %d',
$commentsType['id'],
$itemsType['id']
));
}

public function down(Schema $schema): void
{
}
}
Loading
Loading