Code Duplication    Length = 6-21 lines in 3 locations

main/lp/learnpath.class.php 1 location

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

main/forum/forumfunction.inc.php 2 locations

@@ 765-785 (lines=21) @@
762
        ];
763
764
        $last_id = Database::insert($table_forums, $params);
765
        if ($last_id > 0) {
766
            $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $last_id";
767
            Database::query($sql);
768
769
            api_item_property_update(
770
                $courseInfo,
771
                TOOL_FORUM,
772
                $last_id,
773
                'ForumAdded',
774
                api_get_user_id(),
775
                $group_id
776
            );
777
778
            api_set_default_visibility(
779
                $last_id,
780
                TOOL_FORUM,
781
                $group_id,
782
                $courseInfo
783
            );
784
        }
785
        $return_message = get_lang('ForumAdded');
786
        if ($returnId) {
787
            return $last_id;
788
        }
@@ 4907-4912 (lines=6) @@
4904
            $safe_post_id = (int) $post_id;
4905
            $safe_id_attach = (int) $id_attach;
4906
            // Storing the attachments if any.
4907
            if ($result) {
4908
                $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']."'
4909
                       WHERE c_id = $course_id AND id = '$safe_id_attach'";
4910
                Database::query($sql);
4911
                api_item_property_update($_course, TOOL_FORUM_ATTACH, $safe_id_attach, 'ForumAttachmentUpdated', api_get_user_id());
4912
            }
4913
        }
4914
    }
4915
}