Ejemplo n.º 1
0
function topicCheckReader($topic_id, $user_id)
{
    $topic = topicGetById($topic_id);
    $private_flag = topicCheckPrivate($topic_id);
    $user_flag = topicCheckFlags($topic_id, array("[" . $user_id . "]"));
    $user_flag = $user_flag[0];
    $author_flag = $topic["author_id"] == $user_id;
    $moder_flag = topicCheckModerator($topic["id"], $user_id);
    $admin_flag = userCheckAdministrator($user_id);
    return $private_flag && ($user_flag || $author_flag || $moder_flag) || !$private_flag || $admin_flag;
}
Ejemplo n.º 2
0
 $posts = postGetByTopicId(intval($topic["id"]));
 echo "<h1>" . stringDecode($topic["title"]) . "</h1>";
 if (topicCheckModerator($topic["id"], $user["id"]) || userCheckAdministrator($user["id"])) {
     echo "<a href=\"index.php?edittopic&topic_id=" . $_GET["topic_id"] . "\">Edit topic</a>";
 }
 $topics = topicGetByIdRange($_GET["topic_id"], 0, 5);
 if (count($topics) > 0) {
     echo "<br /> <br /> <p class=\"item_top\"> <b> Sub-topics: </b> </p> <br />";
     for ($i = 0; $i < count($topics); $i++) {
         echo "<a href=\"index.php?topic_id=" . intval($topics[$i]["id"]) . "\">" . stringDecode($topics[$i]["title"]) . "</a> <br />";
     }
 }
 echo "<br /> <br /> <p class=\"item_top\"> <b> Topic posts: </b> </p> <br />";
 for ($i = 0; $i < count($posts); $i++) {
     $author = userGetById($posts[$i]["author_id"]);
     if (topicCheckModerator($topic["id"], $user["id"]) || userCheckAdministrator($user["id"]) || $posts[$i]["author_id"] == $user["id"]) {
         $actions = "<a href=\"index.php?editpost&post_id=" . $posts[$i]["id"] . "\">[Edit]</a>  <a href=\"index.php?droppost&post_id=" . $posts[$i]["id"] . "\">[Delete]</a>";
     }
     echo "<p class=\"item_top\">" . stringDecode($posts[$i]["created"]) . ", by <a href=\"index.php?user_id=" . $author["id"] . "\">" . stringDecode($author["nickname"]) . "</a> " . $actions . " </p>";
     echo chunk_split(stringDecode($posts[$i]["message"]));
     echo "<br /><br />";
 }
 if (userExistsById($user["id"])) {
     echo "<p class=\"item_top\">Post reply</p>";
     echo "<form action=\"index.php?reply\" method=\"post\">";
     echo "<textarea name=\"message\"></textarea><br />";
     echo "<input type=\"hidden\" name=\"topic\" value=\"" . intval($_GET["topic_id"]) . "\" />";
     echo "<input type=\"submit\" value=\"post\" />";
     echo "</form>";
     echo "<br /><br />";
     echo "<br /><br />";