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/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,

main/survey/survey.lib.php 2 locations

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