Code Duplication    Length = 14-15 lines in 2 locations

admin/letter.php 1 location

@@ 378-392 (lines=15) @@
375
            }
376
377
            //create items in attachments
378
            foreach ($uploaded_files as $file) {
379
                $attachmentObj = $xnewsletter->getHandler('attachment')->create();
380
                //Form attachment_letter_id
381
                $attachmentObj->setVar('attachment_letter_id', $letter_id);
382
                //Form attachment_name
383
                $attachmentObj->setVar('attachment_name', $file['name']);
384
                //Form attachment_type
385
                $attachmentObj->setVar('attachment_type', $file['type']);
386
                //Form attachment_submitter
387
                $attachmentObj->setVar('attachment_submitter', $xoopsUser->uid());
388
                //Form attachment_created
389
                $attachmentObj->setVar('attachment_created', time());
390
391
                $xnewsletter->getHandler('attachment')->insert($attachmentObj);
392
            }
393
            //create item in protocol
394
            $protocolObj = $xnewsletter->getHandler('protocol')->create();
395
            $protocolObj->setVar('protocol_letter_id', $letter_id);

letter.php 1 location

@@ 497-510 (lines=14) @@
494
            }
495
496
            // create items in attachments
497
            foreach ($uploaded_files as $file) {
498
                $attachmentObj = $xnewsletter->getHandler('attachment')->create();
499
                //Form attachment_letter_id
500
                $attachmentObj->setVar('attachment_letter_id', $letter_id);
501
                //Form attachment_name
502
                $attachmentObj->setVar('attachment_name', $file['name']);
503
                //Form attachment_type
504
                $attachmentObj->setVar('attachment_type', $file['origname']);
505
                //Form attachment_submitter
506
                $attachmentObj->setVar('attachment_submitter', $xoopsUser->uid());
507
                //Form attachment_created
508
                $attachmentObj->setVar('attachment_created', time());
509
                $xnewsletter->getHandler('attachment')->insert($attachmentObj);
510
            }
511
            //create item in protocol
512
            $protocolObj = $xnewsletter->getHandler('protocol')->create();
513
            $protocolObj->setVar('protocol_letter_id', $letter_id);