Code Duplication    Length = 34-37 lines in 2 locations

main/newscorm/learnpath.class.php 1 location

@@ 1289-1322 (lines=34) @@
1286
        if (is_array($audio) && !empty ($audio['tmp_name']) && $audio['error'] === 0) {
1287
            // Create the audio folder if it does not exist yet.
1288
            $filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/';
1289
            if (!is_dir($filepath . 'audio')) {
1290
                mkdir($filepath . 'audio', api_get_permissions_for_new_directories());
1291
                $audio_id = add_document(
1292
                    $_course,
1293
                    '/audio',
1294
                    'folder',
1295
                    0,
1296
                    'audio'
1297
                );
1298
                api_item_property_update(
1299
                    $_course,
1300
                    TOOL_DOCUMENT,
1301
                    $audio_id,
1302
                    'FolderCreated',
1303
                    api_get_user_id(),
1304
                    null,
1305
                    null,
1306
                    null,
1307
                    null,
1308
                    api_get_session_id()
1309
                );
1310
                api_item_property_update(
1311
                    $_course,
1312
                    TOOL_DOCUMENT,
1313
                    $audio_id,
1314
                    'invisible',
1315
                    api_get_user_id(),
1316
                    null,
1317
                    null,
1318
                    null,
1319
                    null,
1320
                    api_get_session_id()
1321
                );
1322
            }
1323
1324
            // Upload file in documents.
1325
            $pi = pathinfo($audio['name']);

main/newscorm/learnpathItem.class.php 1 location

@@ 4223-4259 (lines=37) @@
4220
        $course_info = api_get_course_info();
4221
        $filepath = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/';
4222
4223
        if (!is_dir($filepath . 'audio')) {
4224
            mkdir(
4225
                $filepath . 'audio',
4226
                api_get_permissions_for_new_directories()
4227
            );
4228
            $audio_id = add_document(
4229
                $course_info,
4230
                '/audio',
4231
                'folder',
4232
                0,
4233
                'audio'
4234
            );
4235
            api_item_property_update(
4236
                $course_info,
4237
                TOOL_DOCUMENT,
4238
                $audio_id,
4239
                'FolderCreated',
4240
                api_get_user_id(),
4241
                null,
4242
                null,
4243
                null,
4244
                null,
4245
                api_get_session_id()
4246
            );
4247
            api_item_property_update(
4248
                $course_info,
4249
                TOOL_DOCUMENT,
4250
                $audio_id,
4251
                'invisible',
4252
                api_get_user_id(),
4253
                null,
4254
                null,
4255
                null,
4256
                null,
4257
                api_get_session_id()
4258
            );
4259
        }
4260
4261
        $key = 'file';
4262