Code Duplication    Length = 34-37 lines in 2 locations

main/newscorm/learnpathItem.class.php 1 location

@@ 4213-4249 (lines=37) @@
4210
        $course_info = api_get_course_info();
4211
        $filepath = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/';
4212
4213
        if (!is_dir($filepath . 'audio')) {
4214
            mkdir(
4215
                $filepath . 'audio',
4216
                api_get_permissions_for_new_directories()
4217
            );
4218
            $audio_id = add_document(
4219
                $course_info,
4220
                '/audio',
4221
                'folder',
4222
                0,
4223
                'audio'
4224
            );
4225
            api_item_property_update(
4226
                $course_info,
4227
                TOOL_DOCUMENT,
4228
                $audio_id,
4229
                'FolderCreated',
4230
                api_get_user_id(),
4231
                null,
4232
                null,
4233
                null,
4234
                null,
4235
                api_get_session_id()
4236
            );
4237
            api_item_property_update(
4238
                $course_info,
4239
                TOOL_DOCUMENT,
4240
                $audio_id,
4241
                'invisible',
4242
                api_get_user_id(),
4243
                null,
4244
                null,
4245
                null,
4246
                null,
4247
                api_get_session_id()
4248
            );
4249
        }
4250
4251
        $key = 'file';
4252

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']);