Code Duplication    Length = 17-18 lines in 2 locations

lib.php 2 locations

@@ 189-206 (lines=18) @@
186
 * @param object $bigbluebuttonbn  An object from the form in mod_form.php
187
 * @return int The id of the newly inserted bigbluebuttonbn record
188
 */
189
function bigbluebuttonbn_add_instance($bigbluebuttonbn) {
190
    global $DB;
191
    // Excecute preprocess.
192
    bigbluebuttonbn_process_pre_save($bigbluebuttonbn);
193
    // Pre-set initial values.
194
    $bigbluebuttonbn->presentation = bigbluebuttonbn_get_media_file($bigbluebuttonbn);
195
    // Insert a record.
196
    $bigbluebuttonbn->id = $DB->insert_record('bigbluebuttonbn', $bigbluebuttonbn);
197
    // Encode meetingid.
198
    $bigbluebuttonbn->meetingid = bigbluebuttonbn_unique_meetingid_seed();
199
    // Set the meetingid column in the bigbluebuttonbn table.
200
    $DB->set_field('bigbluebuttonbn', 'meetingid', $bigbluebuttonbn->meetingid, array('id' => $bigbluebuttonbn->id));
201
    // Log insert action.
202
    bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTONBN_LOG_EVENT_ADD);
203
    // Complete the process.
204
    bigbluebuttonbn_process_post_save($bigbluebuttonbn);
205
    return $bigbluebuttonbn->id;
206
}
207
208
/**
209
 * Given an object containing all the necessary data,
@@ 216-232 (lines=17) @@
213
 * @param object $bigbluebuttonbn  An object from the form in mod_form.php
214
 * @return bool Success/Fail
215
 */
216
function bigbluebuttonbn_update_instance($bigbluebuttonbn) {
217
    global $DB;
218
    // Excecute preprocess.
219
    bigbluebuttonbn_process_pre_save($bigbluebuttonbn);
220
    // Pre-set initial values.
221
    $bigbluebuttonbn->id = $bigbluebuttonbn->instance;
222
    $bigbluebuttonbn->presentation = bigbluebuttonbn_get_media_file($bigbluebuttonbn);
223
    // Update a record.
224
    $DB->update_record('bigbluebuttonbn', $bigbluebuttonbn);
225
    // Get the meetingid column in the bigbluebuttonbn table.
226
    $bigbluebuttonbn->meetingid = (string)$DB->get_field('bigbluebuttonbn', 'meetingid', array('id' => $bigbluebuttonbn->id));
227
    // Log update action.
228
    bigbluebuttonbn_log($bigbluebuttonbn, BIGBLUEBUTTONBN_LOG_EVENT_EDIT);
229
    // Complete the process.
230
    bigbluebuttonbn_process_post_save($bigbluebuttonbn);
231
    return true;
232
}
233
234
/**
235
 * Given an ID of an instance of this module,