File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
src/Chamilo/CoreBundle/Entity Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -3974,6 +3974,20 @@ private function createCommentForm(Portfolio $item): string
3974
3974
$ form ->addButtonSave (get_lang ('Save ' ));
3975
3975
3976
3976
if ($ form ->validate ()) {
3977
+ if ($ this ->session
3978
+ && true === api_get_configuration_value ('portfolio_show_base_course_post_in_sessions ' )
3979
+ && !$ item ->getSession ()
3980
+ ) {
3981
+ $ duplicate = $ item ->duplicateInSession ($ this ->session );
3982
+
3983
+ $ this ->em ->persist ($ duplicate );
3984
+ $ this ->em ->flush ();
3985
+
3986
+ $ item = $ duplicate ;
3987
+
3988
+ $ formAction = $ this ->baseUrl .http_build_query (['action ' => 'view ' , 'id ' => $ item ->getId ()]);
3989
+ }
3990
+
3977
3991
$ values = $ form ->exportValues ();
3978
3992
3979
3993
$ parentComment = $ this ->em ->find (PortfolioComment::class, $ values ['parent ' ]);
Original file line number Diff line number Diff line change @@ -407,4 +407,22 @@ public function isDuplicatedInSessionId(int $sessionId): bool
407
407
{
408
408
return $ this ->duplicates ->exists (fn ($ key , Portfolio $ duplicated ): bool => $ duplicated ->session && $ duplicated ->session ->getId () === $ sessionId );
409
409
}
410
+
411
+ public function reset ()
412
+ {
413
+ $ this ->id = null ;
414
+ $ this ->duplicates = new ArrayCollection ();
415
+ $ this ->comments = new ArrayCollection ();
416
+ }
417
+
418
+ public function duplicateInSession (Session $ session ): Portfolio
419
+ {
420
+ $ duplicate = clone $ this ;
421
+ $ duplicate ->reset ();
422
+
423
+ $ duplicate ->setSession ($ session );
424
+ $ this ->addDuplicate ($ duplicate );
425
+
426
+ return $ duplicate ;
427
+ }
410
428
}
You can’t perform that action at this time.
0 commit comments