2929use OCA \Deck \BadRequestException ;
3030use OCA \Deck \Db \Acl ;
3131use OCA \Deck \Db \AssignedUsersMapper ;
32+ use OCA \Deck \Db \AssignedUsers ;
33+ use OCA \Deck \Db \AssignedLabelsMapper ;
34+ use OCA \Deck \Db \AssignedLabels ;
3235use OCA \Deck \Db \BoardMapper ;
3336use OCA \Deck \Db \Card ;
3437use OCA \Deck \Db \CardMapper ;
@@ -52,6 +55,7 @@ class StackService {
5255 private $ boardService ;
5356 private $ cardService ;
5457 private $ assignedUsersMapper ;
58+ private $ assignedLabelsMapper ;
5559 private $ attachmentService ;
5660
5761 private $ activityManager ;
@@ -70,6 +74,7 @@ public function __construct(
7074 BoardService $ boardService ,
7175 CardService $ cardService ,
7276 AssignedUsersMapper $ assignedUsersMapper ,
77+ AssignedLabelsMapper $ assignedLabelsMapper ,
7378 AttachmentService $ attachmentService ,
7479 ActivityManager $ activityManager ,
7580 EventDispatcherInterface $ eventDispatcher ,
@@ -85,6 +90,7 @@ public function __construct(
8590 $ this ->boardService = $ boardService ;
8691 $ this ->cardService = $ cardService ;
8792 $ this ->assignedUsersMapper = $ assignedUsersMapper ;
93+ $ this ->assignedLabelsMapper = $ assignedLabelsMapper ;
8894 $ this ->attachmentService = $ attachmentService ;
8995 $ this ->activityManager = $ activityManager ;
9096 $ this ->eventDispatcher = $ eventDispatcher ;
@@ -417,6 +423,7 @@ public function clone($id, $boardId, $userId) {
417423 );
418424
419425 $ cards = $ this ->cardMapper ->findAll ($ id );
426+ $ c = [];
420427 foreach ($ cards as $ card ) {
421428
422429 $ newCard = new Card ();
@@ -439,40 +446,42 @@ public function clone($id, $boardId, $userId) {
439446 );
440447
441448 if ($ boardId === $ stack ->getBoardId ()) {
442- $ labels = $ this ->labelMapper ->findAll ($ card ->getId ());
443- $ labels = $ this ->labelMapper ->findAssignedLabelsForCard ($ card ->id );
444-
449+
450+ $ assignedLabels = $ this ->assignedLabelsMapper ->find ($ card ->getId ());
445451 $ l = [];
446- foreach ($ labels as $ label ) {
447- $ l = $ this ->cardMapper ->assignLabel ($ newCard ->getId (), $ label ->getId ());
452+ foreach ($ assignedLabels as $ assignedLabel ) {
453+
454+ $ assignment = $ assignedLabel ;
455+ $ assignment ->setCardId ($ newCard ->getId ());
456+ $ assignment = $ this ->assignedLabelsMapper ->insert ($ assignment );
457+
458+
459+ // $assignment = new AssignedLabels();
460+ // $assignment->setCardId($newCard->getId());
461+ // $assignment->setLabel($assignedLabel);
462+ // $assignment = $this->assignedLabelsMapper->insert($assignment);
463+ $ l [] = $ assignment ;
448464 }
449465 $ newCard ->setLabels ($ l );
450466
451-
452467 $ assignedUsers = $ this ->assignedUsersMapper ->find ($ card ->getId ());
453- /* foreach ($assignedUsers as $assignedUser) {
454- $u = $this->assignmentService->assignUser($newCard->getId(), $assignedUser->getId());
455- $newCard->setAssignedUsers($u);
456- } */
457-
458- //attachments???
459-
460-
461-
468+ $ u = [];
469+ foreach ($ assignedUsers as $ assignedUser ) {
470+ $ assignment = new AssignedUsers ();
471+ $ assignment ->setCardId ($ newCard ->getId ());
472+ $ assignment ->setParticipant ($ assignedUser ->getParticipant ());
473+ $ assignment ->setType ($ assignedUser ->getType ());
474+ $ assignment = $ this ->assignedUsersMapper ->insert ($ assignment );
475+ $ u [] = $ assignment ;
476+ }
477+ $ newCard ->setAssignedUsers ($ u );
478+ $ c [] = $ newCard ;
462479
463480 }
464481
465482 }
466483
467- $ createdCards = $ this ->cardMapper ->findAll ($ newStack ->getId ());
468- $ newStack ->setCards ($ createdCards );
469-
470-
471-
472-
473-
474-
475-
484+ $ newStack ->setCards ($ c );
476485 return $ newStack ;
477486 }
478487}
0 commit comments