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

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