Example #1
0
function listComments($articleid)
{
    $comments = getComments($articleid);
    $no_comments = count($comments);
    $i = 0;
    if ($no_comments > 0) {
        h3("Kommentarer");
    }
    table_open();
    foreach ($comments as $comment) {
        $i++;
        $author = getAuthorOfArticle($comment['articleid']);
        $author_username = getAuthorOfArticleUsername($comment['articleid']);
        tr_open();
        td_open(1);
        if ($i == $no_comments) {
            makeAnchor("lastcomment", "");
        }
        if (strlen($comment['title']) > 0) {
            div_open();
            h2($comment['title']);
            div_close();
        }
        articleMetaInfo($author, $author_username, make_date($comment['date_posted']), make_time($comment['time_posted']));
        div_open("textbody");
        echo makeReadyForPrint(nl2br($comment['body']));
        div_close();
        div_open("showarticlelink");
        if (isset($_SESSION['valid_admin'])) {
            //echo printAdminCommentsMenu($comment['articleid']);
            echo printAuthorArticlesMenu($comment['articleid']);
        } else {
            if (isset($_SESSION['valid_user'])) {
                if ($_SESSION['valid_user'] == $author_username) {
                    if ($i == $no_comments) {
                        echo printAuthorArticlesMenu($comment['articleid']);
                    }
                }
            }
        }
        div_close();
        td_close();
        tr_close();
    }
    table_close();
}
Example #2
0
function mayDeleteArticle($articleid)
{
    if (isset($_SESSION['valid_admin'])) {
        return 1;
    } else {
        if (isset($_SESSION['valid_user'])) {
            if ($_SESSION['valid_user'] == getAuthorOfArticleUsername($articleid)) {
                return 1;
            }
        }
    }
    return 0;
}