<?php $postId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; $post = DataManager::getPostById($postId); $user = AuthenticationManager::getAuthenticatedUser(); if (!DataManager::isPostLastInChannel($post) || $user == null || $user->getId() != $post->getUserId()) { $error = "You can only edit or delete a post if it has been created by you and is the last one in it's channel."; } $channel = DataManager::getChannelById($post->getChannelId()); if ($post == null || $channel == null) { Util::redirect('/'); } ?> <!-- Page Heading --> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> Edit post <small>in channel <i><?php echo $channel->getName(); ?> </i></small> </h1> </div> </div> <!-- /.row --> <?php if (isset($error)) { ?>