Code Duplication    Length = 8-12 lines in 3 locations

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

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