Code Duplication    Length = 22-23 lines in 2 locations

main/inc/lib/thematic.lib.php 2 locations

@@ 994-1015 (lines=22) @@
991
                    $user_id
992
                );
993
994
            } else {
995
                // insert
996
                $params = [
997
                    'c_id' => $this->course_int_id,
998
                    'thematic_id' => $thematic_id,
999
                    'title' => $title,
1000
                    'description' => $description,
1001
                    'description_type' => $description_type
1002
                ];
1003
                $last_id = Database::insert($tbl_thematic_plan, $params);
1004
                if ($last_id) {
1005
                    $sql = "UPDATE $tbl_thematic_plan SET id = iid WHERE iid = $last_id";
1006
                    Database::query($sql);
1007
                    api_item_property_update(
1008
                        $_course,
1009
                        'thematic_plan',
1010
                        $last_id,
1011
                        "ThematicPlanAdded",
1012
                        $user_id
1013
                    );
1014
                }
1015
            }
1016
        } else {
1017
            // insert
1018
            $params = [
@@ 1016-1038 (lines=23) @@
1013
                    );
1014
                }
1015
            }
1016
        } else {
1017
            // insert
1018
            $params = [
1019
                'c_id' => $this->course_int_id,
1020
                'thematic_id' => $thematic_id,
1021
                'title' => $title,
1022
                'description' => $description,
1023
                'description_type' => $description_type
1024
            ];
1025
            $last_id = Database::insert($tbl_thematic_plan, $params);
1026
1027
            if ($last_id) {
1028
                $sql = "UPDATE $tbl_thematic_plan SET id = iid WHERE iid = $last_id";
1029
                Database::query($sql);
1030
                api_item_property_update(
1031
                    $_course,
1032
                    'thematic_plan',
1033
                    $last_id,
1034
                    "ThematicPlanAdded",
1035
                    $user_id
1036
                );
1037
            }
1038
        }
1039
1040
        return $affected_rows;
1041
    }