Location: PHPKode > projects > Gnew > Gnew-2013.1/comments/reply.php
<?php
// -----------------------------------------------------------------------------
// $Id: reply.php 682 2013-03-28 14:17:41Z raoul $
//
// Copyright (C) 2013 Raoul Proença
// License: GNU GPL version 3 (see copying.txt file)
// Website: http://www.gnew.fr/
// -----------------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------

include('./../includes/common.php');

page_header($lang['COMMENTS_REPLY']);

// Comments in news enabled?
if ($settings['news_commenting'] == 0)
{
    error_template($lang['ERROR_COMMENTING_DISABLED']);
}
// User logged?
elseif ($_SESSION['user_id'] > 0)
{
    // Check query
    if (!empty($_GET['comment_id']) && string_is_int($_GET['comment_id']))
    {
        $sql->query('SELECT t1.story_id, t1.news_id, t1.user_id, t1.comment_active, t1.comment_subject, t1.comment_text, t1.comment_creation, t1.comment_edition, t1.edition_id, t1.edition_name, t2.user_avatar, t2.user_name, t2.user_signature
                     FROM ' . TABLE_COMMENTS . ' AS t1
                     INNER JOIN ' . TABLE_USERS . ' AS t2
                                 ON (t2.user_id = t1.user_id)
                     WHERE t1.comment_id = \'' . $_GET['comment_id'] . '\'');
        $table_comments = $sql->fetch();
        // Check comment
        if (!$table_comments['story_id'])
        {
            error_template($lang['ERROR_NO_DATA']);
        }
        elseif ($table_comments['comment_active'] == 0)
        {
            error_template($lang['ERROR_COMMENT_HIDDEN']);
        }
        else
        {
            if ($settings['allow_html'])
            {
                $html_support = $lang['HTML_ENABLED'];
            }
            else
            {
                $html_support = $lang['HTML_DISABLED'];
            }
            /********
             * News *
             ********/
            $sql->query('SELECT t1.category_id, t1.user_id, t1.news_source, t1.news_subject, t1.news_text, t1.news_creation, t1.news_edition, t1.edition_id, t1.edition_name, t2.category_image, t2.category_name, t3.user_name
                         FROM ' . TABLE_NEWS . ' AS t1
                         INNER JOIN ' . TABLE_CATEGORIES . ' AS t2
                                     ON (t2.category_id = t1.category_id AND t2.category_level IN (\'2\', \'4\'))
                         INNER JOIN ' . TABLE_USERS . ' AS t3
                                     ON (t3.user_id = t1.user_id)
                         WHERE t1.news_active = \'1\'
                         AND t1.news_id = \'' . $table_comments['news_id'] . '\'');
            $table_news = $sql->fetch();
            if ($table_news['news_edition'])
            {
                $news_edited = sprintf($lang['EDITED_BY'], $table_news['edition_id'], $table_news['edition_name'], format_date($table_news['news_edition']));
            }
            else
            {
                $news_edited = '';
            }
            if ($table_news['news_source'])
            {
                $news_source = undo_escape_sequences($table_news['news_source']);
                $news_source = sprintf($lang['SOURCE'], $news_source);
            }
            else
            {
                $news_source = '<!-- empty -->';
            }
            $news_text = undo_escape_sequences($table_news['news_text']);
            $news_text = cut_text($news_text, './../news/index.php?news_id=' . $table_comments['news_id']);
            /************
             * Comments *
             ************/
            if ($table_comments['comment_edition'])
            {
                $comment_edited = sprintf($lang['EDITED_BY'], $table_comments['edition_id'], $table_comments['edition_name'], format_date($table_comments['comment_edition']));
            }
            else
            {
                $comment_edited = '';
            }
            if (!empty($table_comments['user_signature']))
            {
                $user_signature = '<br />&#45;&#45;<br />' . $table_comments['user_signature'];
            }
            else
            {
                $user_signature = '';
            }
            $comment_text = undo_escape_sequences($table_comments['comment_text']);
            $template->set_file('reply', 'comments/reply.htpl');
            $template->set_var(array('CATEGORY_ID' => $table_news['category_id'],
                                     'CATEGORY_IMAGE' => $table_news['category_image'],
                                     'CATEGORY_NAME' => $table_news['category_name'],
                                     'COMMENT_EDITED' => $comment_edited,
                                     'COMMENT_ID' => $_GET['comment_id'],
                                     'COMMENT_POSTED' => sprintf($lang['POSTED_BY'], $table_comments['user_id'], $table_comments['user_name'], format_date($table_comments['comment_creation'])),
                                     'COMMENT_SUBJECT' => $table_comments['comment_subject'],
                                     'COMMENT_TEXT' => $comment_text,
                                     'EMOTICONS_LIST' => get_emoticons_list(0),
                                     'HTML_SUPPORT' => $html_support,
                                     'NEWS_EDITED' => $news_edited,
                                     'NEWS_ID' => $table_comments['news_id'],
                                     'NEWS_POSTED' => sprintf($lang['POSTED_BY'], $table_news['user_id'], $table_news['user_name'], format_date($table_news['news_creation'])),
                                     'NEWS_SOURCE' => $news_source,
                                     'NEWS_SUBJECT' => $table_news['news_subject'],
                                     'NEWS_TEXT' => $news_text,
                                     'STORY_ID' => $table_comments['story_id'],
                                     'USER_AVATAR' => $table_comments['user_avatar'],
                                     'USER_SIGNATURE' => $user_signature));
            $template->parse('reply', null, false, array(TABLE_CATEGORIES, TABLE_COMMENTS, TABLE_EMOTICONS, TABLE_NEWS, TABLE_USERS));
        }
    }
    else
    {
        error_template($lang['ERROR_NO_DATA']);
    }
}
else
{
    error_template($lang['ERROR_USER_OFFLINE']);
}

page_footer();

?>
Return current item: Gnew