Code Duplication    Length = 13-15 lines in 6 locations

main/inc/lib/course_description.lib.php 1 location

@@ 216-228 (lines=13) @@
213
214
        $last_id  = Database::insert($table, $params);
215
216
        if ($last_id > 0) {
217
            $sql = "UPDATE $table SET id = iid WHERE iid = $last_id";
218
            Database::query($sql);
219
220
            // insert into item_property
221
            api_item_property_update(
222
                api_get_course_info(),
223
                TOOL_COURSE_DESCRIPTION,
224
                $last_id,
225
                'CourseDescriptionAdded',
226
                api_get_user_id()
227
            );
228
        }
229
230
        return 1;
231
    }

main/inc/lib/glossary.lib.php 1 location

@@ 125-138 (lines=14) @@
122
                'session_id' => $session_id,
123
            ];
124
            $id = Database::insert($t_glossary, $params);
125
            if ($id) {
126
127
                $sql = "UPDATE $t_glossary SET glossary_id = $id WHERE iid = $id";
128
                Database::query($sql);
129
130
                //insert into item_property
131
                api_item_property_update(
132
                    api_get_course_info(),
133
                    TOOL_GLOSSARY,
134
                    $id,
135
                    'GlossaryAdded',
136
                    api_get_user_id()
137
                );
138
            }
139
140
            $_SESSION['max_glossary_display'] = GlossaryManager::get_max_glossary_item();
141
            // display the feedback message

main/inc/lib/notebook.lib.php 1 location

@@ 75-88 (lines=14) @@
72
        ];
73
        $id = Database::insert($table, $params);
74
75
        if ($id > 0) {
76
            $sql = "UPDATE $table SET notebook_id = $id WHERE iid = $id";
77
            Database::query($sql);
78
79
            //insert into item_property
80
            api_item_property_update(
81
                api_get_course_info(),
82
                TOOL_NOTEBOOK,
83
                $id,
84
                'NotebookAdded',
85
                api_get_user_id()
86
            );
87
            return $id;
88
        }
89
    }
90
91
    /**

main/survey/survey.lib.php 2 locations

@@ 322-336 (lines=15) @@
319
320
            $params = array_merge($params, $extraParams);
321
            $survey_id = Database::insert($table_survey, $params);
322
            if ($survey_id > 0) {
323
324
                $sql = "UPDATE $table_survey SET survey_id = $survey_id
325
                        WHERE iid = $survey_id";
326
                Database::query($sql);
327
328
                // Insert into item_property
329
                api_item_property_update(
330
                    api_get_course_info(),
331
                    TOOL_SURVEY,
332
                    $survey_id,
333
                    'SurveyAdded',
334
                    api_get_user_id()
335
                );
336
            }
337
338
            if ($values['survey_type'] == 1 && !empty($values['parent_id'])) {
339
                SurveyManager::copy_survey($values['parent_id'], $survey_id);
@@ 667-680 (lines=14) @@
664
            Database::insert($table_survey, $params);
665
            $new_survey_id = Database::insert_id();
666
667
            if ($new_survey_id) {
668
                $sql = "UPDATE $table_survey SET survey_id = $new_survey_id
669
                        WHERE iid = $new_survey_id";
670
                Database::query($sql);
671
672
                // Insert into item_property
673
                api_item_property_update(
674
                    api_get_course_info(),
675
                    TOOL_SURVEY,
676
                    $new_survey_id,
677
                    'SurveyAdded',
678
                    api_get_user_id()
679
                );
680
            }
681
        } else {
682
            $new_survey_id = intval($new_survey_id);
683
        }

main/inc/lib/blog.lib.php 1 location

@@ 135-148 (lines=14) @@
132
            ];
133
			$this_blog_id = Database::insert($tbl_blogs, $params);
134
135
			if ($this_blog_id > 0) {
136
                $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id";
137
                Database::query($sql);
138
139
				// insert into item_property
140
                api_item_property_update(
141
                    api_get_course_info(),
142
                    TOOL_BLOGS,
143
                    $this_blog_id,
144
                    'BlogAdded',
145
                    api_get_user_id()
146
                );
147
			}
148
149
			// Make first post. :)
150
            $params = [
151
				'post_id' => 0,