Code Duplication    Length = 8-12 lines in 3 locations

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

@@ 2197-2208 (lines=12) @@
2194
                }
2195
2196
                // If the end date was set.
2197
                if (!empty($row['access_end_date'])) {
2198
                    // Only if date_start said that it was ok
2199
                    if ($visibility == SESSION_AVAILABLE) {
2200
                        if ($now < api_strtotime($row['access_end_date'], 'UTC')) {
2201
                            // Date still available
2202
                            $visibility = SESSION_AVAILABLE;
2203
                        } else {
2204
                            // Session ends
2205
                            $visibility = $row['visibility'];
2206
                        }
2207
                    }
2208
                }
2209
            }
2210
2211
            /* If I'm a coach the visibility can change in my favor depending in
@@ 2217-2225 (lines=9) @@
2214
2215
            if ($is_coach) {
2216
                // Test end date.
2217
                if (!empty($row['coach_access_end_date'])) {
2218
                    $endDateCoach = api_strtotime($row['coach_access_end_date'], 'UTC');
2219
2220
                    if ($endDateCoach >= $now) {
2221
                        $visibility = SESSION_AVAILABLE;
2222
                    } else {
2223
                        $visibility = SESSION_INVISIBLE;
2224
                    }
2225
                }
2226
2227
                // Test start date.
2228
                if (!empty($row['coach_access_start_date'])) {
@@ 2228-2235 (lines=8) @@
2225
                }
2226
2227
                // Test start date.
2228
                if (!empty($row['coach_access_start_date'])) {
2229
                    $start = api_strtotime($row['coach_access_start_date'], 'UTC');
2230
                    if ($start < $now) {
2231
                        $visibility = SESSION_AVAILABLE;
2232
                    } else {
2233
                        $visibility = SESSION_INVISIBLE;
2234
                    }
2235
                }
2236
            }
2237
        } else {
2238
            $visibility = SESSION_INVISIBLE;