Code Duplication    Length = 6-21 lines in 3 locations

main/newscorm/learnpath.class.php 1 location

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

main/forum/forumfunction.inc.php 2 locations

@@ 768-788 (lines=21) @@
765
        ];
766
767
        $last_id = Database::insert($table_forums, $params);
768
        if ($last_id > 0) {
769
770
            $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $last_id";
771
            Database::query($sql);
772
773
            api_item_property_update(
774
                $courseInfo,
775
                TOOL_FORUM,
776
                $last_id,
777
                'ForumAdded',
778
                api_get_user_id(),
779
                $group_id
780
            );
781
782
            api_set_default_visibility(
783
                $last_id,
784
                TOOL_FORUM,
785
                $group_id,
786
                $courseInfo
787
            );
788
        }
789
        $return_message = get_lang('ForumAdded');
790
        if ($returnId) {
791
@@ 4924-4929 (lines=6) @@
4921
            $safe_post_id = (int) $post_id;
4922
            $safe_id_attach = (int) $id_attach;
4923
            // Storing the attachments if any.
4924
            if ($result) {
4925
                $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']."'
4926
                       WHERE c_id = $course_id AND id = '$safe_id_attach'";
4927
                Database::query($sql);
4928
                api_item_property_update($_course, TOOL_FORUM_ATTACH, $safe_id_attach, 'ForumAttachmentUpdated', api_get_user_id());
4929
            }
4930
        }
4931
    }
4932
}