Code Duplication    Length = 6-21 lines in 3 locations

main/forum/forumfunction.inc.php 2 locations

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

main/lp/learnpath.class.php 1 location

@@ 866-880 (lines=15) @@
863
                ];
864
                $id = Database::insert($tbl_lp, $params);
865
866
                if ($id > 0) {
867
                    $sql = "UPDATE $tbl_lp SET id = iid WHERE iid = $id";
868
                    Database::query($sql);
869
870
                    // Insert into item_property.
871
                    api_item_property_update(
872
                        $courseInfo,
873
                        TOOL_LEARNPATH,
874
                        $id,
875
                        'LearnpathAdded',
876
                        $userId
877
                    );
878
                    api_set_default_visibility($id, TOOL_LEARNPATH, 0, $courseInfo, $session_id, $userId);
879
                    return $id;
880
                }
881
                break;
882
        }
883
    }