<?php

if (!AuthenticationManager::isAuthenticated()) {
    Util::redirect('/');
}
$channels = DataManager::getChannelsForUser(AuthenticationManager::getAuthenticatedUser()->getId());
$favoritesAdded = false;
$unreadAdded = false;
?>

<!-- Page Heading -->
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">
            Overview
        </h1>
    </div>
</div>
<!-- /.row -->


<div class="row">
    <div class="col-lg-12 col-md-12">
        <h3>Favorites by channel</h3>
        <?php 
foreach ($channels as $channel) {
    $posts = DataManager::getFavoritesByChannel($channel->getId());
    ?>

            <?php 
    if (count($posts) > 0) {
<div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav side-nav">
        <?php 
if (AuthenticationManager::isAuthenticated()) {
    ?>
            <li><h4>Channels</h4></li>
            <?php 
    foreach (DataManager::getChannelsForUser(AuthenticationManager::getAuthenticatedUser()->getId()) as $channel) {
        ?>
                <li>
                    <a href="<?php 
        echo "?view=channel&id=" . $channel->getId();
        ?>
">
                        <i class="fa fa-fw fa-bookmark-o"></i><?php 
        echo $channel->getName();
        ?>
                    </a>
                </li>
            <?php 
    }
    ?>
        <?php 
} else {
    ?>
            <li><h5>Login to view channels</h5></li>
        <?php 
}
?>
    </ul>
</div>