Наследование: extends BaseController
Пример #1
0
include 'core/connect.php';
include 'nav.php';
include 'Controllers/class.TopicController.inc';
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
    //someone is calling the file directly, which we don't want
    //echo 'This file cannot be called directly.';
    header("Location: index.php");
} else {
    //check for sign in status
    if (!$_SESSION['signed_in']) {
        echo 'You must be signed in to post a reply.';
    } else {
        //a real user posted a real reply
        $sql = "INSERT INTO \r\n\t\t\t\t\tposts(post_content,\r\n\t\t\t\t\t\t  post_date,\r\n\t\t\t\t\t\t  post_topic,\r\n\t\t\t\t\t\t  post_by) \r\n\t\t\t\tVALUES ('" . $_POST['reply-content'] . "',\r\n\t\t\t\t\t\tNOW(),\r\n\t\t\t\t\t\t" . mysql_real_escape_string($_GET['id']) . ",\r\n\t\t\t\t\t\t" . $_SESSION['user_id'] . ")";
        $result = mysql_query($sql);
        if (!$result) {
            echo 'Your reply has not been saved, please try again later.';
        } else {
            $id = $_GET['id'];
            $o = new TopicController($id);
            $c = $o->getReplyCount() + 1;
            // now update reply
            //echo $c;
            $sql = "UPDATE topics SET reply_count='{$c}' WHERE topic_id = '{$id}'";
            // $sql = "UPDATE reply_count='$c' FROM topics WHERE topic_id = '$id'";
            mysql_query($sql);
            header("Location: topic.php?id=" . htmlentities($_GET['id']));
            echo 'Your reply has been saved, check out <a href="topic.php?id=' . htmlentities($_GET['id']) . '">the topic</a>.';
        }
    }
}
Пример #2
0
});
$routes->get('/kirjaudu', function () {
    UserController::login();
});
$routes->post('/kirjaudu', function () {
    UserController::login();
});
$routes->get('/kirjauduulos', function () {
    UserController::logout();
});
$routes->get('/keskustelu-:id', function ($id) {
    TopicController::messages($id);
});
$routes->post('/keskustelu-:id', function ($id) {
    TopicController::addMessage($id);
});
$routes->get('/hiekkalaatikko-:id', function ($id) {
    HelloWorldController::sandbox($id);
});
$routes->get('/rekisterointi', function () {
    HelloWorldController::rekisterointi();
});
$routes->post('/rekisterointi', function () {
    UserController::register();
});
$routes->get('/luokeskustelu', function () {
    HelloWorldController::luokeskustelu();
});
$routes->post('/luokeskustelu', function () {
    TopicController::createTopic();
});
 public function test_change_sequence_for_topic()
 {
     $this->mySetup(__DIR__ . "/different_sequence_topic_table.xml");
     $controller = new TopicController([], Response::REQUEST_METHOD_GET, array());
     $response = $controller->getResponse();
     $json = json_decode($response->getBody(), true);
     $sequence_element_1 = $json['topics'][0]['sequence'];
     $sequence_element_2 = $json['topics'][1]['sequence'];
     self::assertEquals(1, $sequence_element_2, 'Topic 2, first element');
     self::assertEquals(2, $sequence_element_1, 'Topic 1, second element');
 }
Пример #4
0
    UserController::handleLogin();
});
$routes->get('/register', function () {
    UserController::register();
});
$routes->post('/register', function () {
    UserController::handleRegister();
});
$routes->post('/logout', function () {
    UserController::logout();
});
$routes->post('/groups/new', function () {
    GroupController::store();
});
$routes->post('/groups/:group_id/new', function ($group_id) {
    TopicController::store($group_id);
});
$routes->get('/groups/:group_id', function ($group_id) {
    ForumController::topics($group_id);
});
$routes->get('/groups/:group_id/edit', function ($group_id) {
    GroupController::edit($group_id);
});
$routes->post('/groups/:group_id/edit', function ($group_id) {
    GroupController::update($group_id);
});
$routes->post('/groups/:group_id/expel/:user_id', function ($group_id, $user_id) {
    GroupController::expel($group_id, $user_id);
});
$routes->post('/groups/:group_id/invite', function ($group_id) {
    GroupController::invite($group_id);
Пример #5
0
    	  <tr>
    		<th>Topic</th>
    		<th>Created at</th>
    	  </tr>';	
    	
    while($row = mysql_fetch_assoc($result))
    {				
    	echo '<tr>';
    		echo '<td class="leftpart">';
    			echo '<h3><a href="topic.php?id=' . $row['topic_id'] . '">' . $row['topic_subject'] . '</a><br /><h3>';
    		echo '</td>';
    		echo '<td class="rightpart">';
    			echo date('d-m-Y', strtotime($row['topic_date']));
    		echo '</td>';
    	echo '</tr>';
    }
    */
    while ($row = mysql_fetch_assoc($result)) {
        $id = $row['topic_id'];
        $tpic = new TopicController($id);
        $title = "<a href=\"topic.php?id=" . $id . "\">" . $row['topic_subject'] . "</a>";
        $creator = $tpic->getCreator();
        $replyCount = $tpic->getReplyCount();
        $lastUpdate = $tpic->getLastUpdate();
        // List of topics
        echo "<div class=\"topic\" id=\"usertopic\">\r\n\t\t<div id=\"name\">{$title}</div>\r\n\t\t<div id=\"created-by\">{$creator}</div>\r\n\t\t<div id=\"reply-count\">{$replyCount}</div>\r\n\t\t<div id=\"last-update\">{$lastUpdate}</div>\r\n\t</div>";
    }
}
echo "<br><a href='thread.php?topic={$id}'>Create post</a><br>";
//Close the category container
echo "\n</div>";