Code Duplication    Length = 13-18 lines in 6 locations

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

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

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

@@ 136-149 (lines=14) @@
133
            ];
134
            $id = Database::insert($t_glossary, $params);
135
136
            if ($id) {
137
                $sql = "UPDATE $t_glossary SET glossary_id = $id WHERE iid = $id";
138
                Database::query($sql);
139
140
                //insert into item_property
141
                api_item_property_update(
142
                    api_get_course_info(),
143
                    TOOL_GLOSSARY,
144
                    $id,
145
                    'GlossaryAdded',
146
                    api_get_user_id()
147
                );
148
            }
149
            // display the feedback message
150
            if ($showMessage) {
151
                Display::addFlash(
152
                    Display::return_message(get_lang('TermAdded'))

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

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

main/survey/survey.lib.php 2 locations

@@ 326-340 (lines=15) @@
323
324
            $params = array_merge($params, $extraParams);
325
            $survey_id = Database::insert($table_survey, $params);
326
            if ($survey_id > 0) {
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
                self::copy_survey($values['parent_id'], $survey_id);
343
            }
@@ 673-686 (lines=14) @@
670
            Database::insert($table_survey, $params);
671
            $new_survey_id = Database::insert_id();
672
673
            if ($new_survey_id) {
674
                $sql = "UPDATE $table_survey SET survey_id = $new_survey_id
675
                        WHERE iid = $new_survey_id";
676
                Database::query($sql);
677
678
                // Insert into item_property
679
                api_item_property_update(
680
                    api_get_course_info(),
681
                    TOOL_SURVEY,
682
                    $new_survey_id,
683
                    'SurveyAdded',
684
                    api_get_user_id()
685
                );
686
            }
687
        } else {
688
            $new_survey_id = intval($new_survey_id);
689
        }

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

@@ 4784-4801 (lines=18) @@
4781
                    'session_id' => $session_id
4782
                ];
4783
                $document_id = Database::insert($table, $params);
4784
                if ($document_id) {
4785
4786
                    $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
4787
                    Database::query($sql);
4788
4789
                    api_item_property_update(
4790
                        $course_info,
4791
                        TOOL_DOCUMENT,
4792
                        $document_id,
4793
                        'FolderCreated',
4794
                        api_get_user_id(),
4795
                        0,
4796
                        0,
4797
                        null,
4798
                        null,
4799
                        $session_id
4800
                    );
4801
                }
4802
            }
4803
        }
4804