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

@@ 4710-4727 (lines=18) @@
4707
                    'session_id' => $session_id
4708
                ];
4709
                $document_id = Database::insert($table, $params);
4710
                if ($document_id) {
4711
4712
                    $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
4713
                    Database::query($sql);
4714
4715
                    api_item_property_update(
4716
                        $course_info,
4717
                        TOOL_DOCUMENT,
4718
                        $document_id,
4719
                        'FolderCreated',
4720
                        api_get_user_id(),
4721
                        0,
4722
                        0,
4723
                        null,
4724
                        null,
4725
                        $session_id
4726
                    );
4727
                }
4728
            }
4729
        }
4730

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,

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
    }