Code Duplication    Length = 13-18 lines in 6 locations

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/course_description.lib.php 1 location

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

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

@@ 4697-4714 (lines=18) @@
4694
                    'session_id' => $session_id
4695
                ];
4696
                $document_id = Database::insert($table, $params);
4697
                if ($document_id) {
4698
4699
                    $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
4700
                    Database::query($sql);
4701
4702
                    api_item_property_update(
4703
                        $course_info,
4704
                        TOOL_DOCUMENT,
4705
                        $document_id,
4706
                        'FolderCreated',
4707
                        api_get_user_id(),
4708
                        0,
4709
                        0,
4710
                        null,
4711
                        null,
4712
                        $session_id
4713
                    );
4714
                }
4715
            }
4716
        }
4717

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/blog.lib.php 1 location

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