Example #1
0
<?php

$channelId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$channel = DataManager::getChannelById($channelId);
if ($channel === null || !AuthenticationManager::isAuthenticated()) {
    Util::redirect('/');
}
?>

<!-- Page Heading -->
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">
            <?php 
echo $channel->getName();
?>
        </h1>
    </div>
</div>
<!-- /.row -->

<div id="messages" class="row"></div>

<div class="row">
    <div class="col-lg-8">
        <form class="form-horizontal" id="addNewPost">
            <div>
                <input type="text" class="form-control" name="title" placeholder="Title" id="postTitle" required>
                <textarea class="form-control" rows="3" placeholder="Text" name="text" id="postText"
                          required></textarea>
                <button type="submit" class="btn btn-default">Submit</button>
Example #2
0
<?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)) {
    ?>