Code Duplication    Length = 14-15 lines in 2 locations

admin/letter.php 1 location

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

letter.php 1 location

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