Code Duplication    Length = 6-21 lines in 3 locations

main/forum/forumfunction.inc.php 2 locations

@@ 766-786 (lines=21) @@
763
        ];
764
765
        $last_id = Database::insert($table_forums, $params);
766
        if ($last_id > 0) {
767
            $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $last_id";
768
            Database::query($sql);
769
770
            api_item_property_update(
771
                $courseInfo,
772
                TOOL_FORUM,
773
                $last_id,
774
                'ForumAdded',
775
                api_get_user_id(),
776
                $group_id
777
            );
778
779
            api_set_default_visibility(
780
                $last_id,
781
                TOOL_FORUM,
782
                $group_id,
783
                $courseInfo
784
            );
785
        }
786
        $return_message = get_lang('ForumAdded');
787
        if ($returnId) {
788
            return $last_id;
789
        }
@@ 4812-4817 (lines=6) @@
4809
            $safe_post_id = (int) $post_id;
4810
            $safe_id_attach = (int) $id_attach;
4811
            // Storing the attachments if any.
4812
            if ($result) {
4813
                $sql = "UPDATE $table_forum_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', post_id = '$safe_post_id', size ='".$attachment['size']."'
4814
                       WHERE c_id = $course_id AND id = '$safe_id_attach'";
4815
                Database::query($sql);
4816
                api_item_property_update($_course, TOOL_FORUM_ATTACH, $safe_id_attach, 'ForumAttachmentUpdated', api_get_user_id());
4817
            }
4818
        }
4819
    }
4820
}

main/lp/learnpath.class.php 1 location

@@ 858-872 (lines=15) @@
855
856
                $id = Database::insert($tbl_lp, $params);
857
858
                if ($id > 0) {
859
                    $sql = "UPDATE $tbl_lp SET id = iid WHERE iid = $id";
860
                    Database::query($sql);
861
862
                    // Insert into item_property.
863
                    api_item_property_update(
864
                        $courseInfo,
865
                        TOOL_LEARNPATH,
866
                        $id,
867
                        'LearnpathAdded',
868
                        $userId
869
                    );
870
                    api_set_default_visibility($id, TOOL_LEARNPATH, 0, $courseInfo, $session_id, $userId);
871
                    return $id;
872
                }
873
                break;
874
        }
875
    }