Code Duplication    Length = 8-12 lines in 3 locations

main/inc/lib/api.lib.php 3 locations

@@ 2330-2341 (lines=12) @@
2327
                }
2328
2329
                // If the end date was set.
2330
                if (!empty($row['access_end_date'])) {
2331
                    // Only if date_start said that it was ok
2332
                    if ($visibility == SESSION_AVAILABLE) {
2333
                        if ($now < api_strtotime($row['access_end_date'], 'UTC')) {
2334
                            // Date still available
2335
                            $visibility = SESSION_AVAILABLE;
2336
                        } else {
2337
                            // Session ends
2338
                            $visibility = $row['visibility'];
2339
                        }
2340
                    }
2341
                }
2342
            }
2343
2344
            /* If I'm a coach the visibility can change in my favor depending in
@@ 2350-2358 (lines=9) @@
2347
2348
            if ($is_coach) {
2349
                // Test end date.
2350
                if (!empty($row['coach_access_end_date'])) {
2351
                    $endDateCoach = api_strtotime($row['coach_access_end_date'], 'UTC');
2352
2353
                    if ($endDateCoach >= $now) {
2354
                        $visibility = SESSION_AVAILABLE;
2355
                    } else {
2356
                        $visibility = SESSION_INVISIBLE;
2357
                    }
2358
                }
2359
2360
                // Test start date.
2361
                if (!empty($row['coach_access_start_date'])) {
@@ 2361-2368 (lines=8) @@
2358
                }
2359
2360
                // Test start date.
2361
                if (!empty($row['coach_access_start_date'])) {
2362
                    $start = api_strtotime($row['coach_access_start_date'], 'UTC');
2363
                    if ($start < $now) {
2364
                        $visibility = SESSION_AVAILABLE;
2365
                    } else {
2366
                        $visibility = SESSION_INVISIBLE;
2367
                    }
2368
                }
2369
            }
2370
        } else {
2371
            $visibility = SESSION_INVISIBLE;