Code Duplication    Length = 13-18 lines in 7 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 ($last_id > 0)?1:0;
231
    }

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

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

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

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

@@ 4630-4647 (lines=18) @@
4627
                    'session_id' => $session_id
4628
                ];
4629
                $document_id = Database::insert($table, $params);
4630
                if ($document_id) {
4631
4632
                    $sql = "UPDATE $table SET id = iid WHERE iid = $document_id";
4633
                    Database::query($sql);
4634
4635
                    api_item_property_update(
4636
                        $course_info,
4637
                        TOOL_DOCUMENT,
4638
                        $document_id,
4639
                        'FolderCreated',
4640
                        api_get_user_id(),
4641
                        0,
4642
                        0,
4643
                        null,
4644
                        null,
4645
                        $session_id
4646
                    );
4647
                }
4648
            }
4649
        }
4650