示例#1
0
</div>
                    <div class="form-controls">
                        <div class="form-label-checkbox">
                            <label>
                                <input type="checkbox" <?php 
echo osc_comments_enabled() ? 'checked="checked"' : '';
?>
 name="enabled_comments" value="1" /> <?php 
_e('Allow people to post comments on listings');
?>
                            </label>
                        </div>
                        <div class="form-label-checkbox">
                            <label>
                                <input type="checkbox" <?php 
echo osc_reg_user_post_comments() ? 'checked="checked"' : '';
?>
 name="reg_user_post_comments" value="1" /> <?php 
_e('Users must be registered and logged in to comment');
?>
                            </label>
                        </div>
                        <div class="form-label-checkbox">
                            <label>
                                <input type="checkbox" <?php 
echo osc_moderate_comments() == -1 ? '' : 'checked="checked"';
?>
 name="moderate_comments" value="1" /> <?php 
_e('A comment is being held for moderation');
?>
                            </label>
示例#2
0
        public function add_comment()
        {

            if(!osc_comments_enabled()) {
                return 7;
            }

            $aItem  = $this->prepareDataForFunction('add_comment');


            $authorName     = trim(strip_tags($aItem['authorName']));
            $authorEmail    = trim(strip_tags($aItem['authorEmail']));
            $body           = trim(strip_tags($aItem['body']));
            $title          = trim(strip_tags($aItem['title']));
            $itemId         = $aItem['id'];
            $userId         = $aItem['userId'];
            $status_num     = -1;

            $banned = osc_is_banned(trim(strip_tags($aItem['authorEmail'])));
            if($banned==1 || $banned==2) {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentTitle', $title);
                Session::newInstance()->_setForm('commentBody', $body);
                Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail);
                return 5;
            }

            $item = $this->manager->findByPrimaryKey($itemId);
            View::newInstance()->_exportVariableToView('item', $item);
            $itemURL = osc_item_url();
            $itemURL = '<a href="'.$itemURL.'" >'.$itemURL.'</a>';

            Params::setParam('itemURL', $itemURL);

            if(osc_reg_user_post_comments() && !osc_is_web_user_logged_in()) {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentTitle', $title);
                Session::newInstance()->_setForm('commentBody', $body);
                return 6;
            }

            if( !preg_match('|^.*?@.{2,}\..{2,3}$|', $authorEmail)) {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentTitle', $title);
                Session::newInstance()->_setForm('commentBody', $body);
                return 3;
            }

            if( ($body == '') ) {
                Session::newInstance()->_setForm('commentAuthorName', $authorName);
                Session::newInstance()->_setForm('commentAuthorEmail', $authorEmail);
                Session::newInstance()->_setForm('commentTitle', $title);
                return 4;
            }

            $num_moderate_comments = osc_moderate_comments();
            if($userId==null) {
                $num_comments = 0;
            } else {
                $user         = User::newInstance()->findByPrimaryKey($userId);
                $num_comments = $user['i_comments'];
            }

            if ($num_moderate_comments == -1 || ($num_moderate_comments != 0 && $num_comments >= $num_moderate_comments)) {
                $status     = 'ACTIVE';
                $status_num = 2;
            } else {
                $status     = 'INACTIVE';
                $status_num = 1;
            }

            if (osc_akismet_key()) {
                require_once LIB_PATH . 'Akismet.class.php';
                $akismet = new Akismet(osc_base_url(), osc_akismet_key());
                $akismet->setCommentAuthor($authorName);
                $akismet->setCommentAuthorEmail($authorEmail);
                $akismet->setCommentContent($body);
                $akismet->setPermalink($itemURL);

                $status = $akismet->isCommentSpam() ? 'SPAM' : $status;
                if($status == 'SPAM') {
                    $status_num = 5;
                }
            }

            $mComments = ItemComment::newInstance();
            $aComment  = array('dt_pub_date'    => date('Y-m-d H:i:s')
                              ,'fk_i_item_id'   => $itemId
                              ,'s_author_name'  => $authorName
                              ,'s_author_email' => $authorEmail
                              ,'s_title'        => $title
                              ,'s_body'         => $body
                              ,'b_active'       => ($status=='ACTIVE' ? 1 : 0)
                              ,'b_enabled'      => 1
                              ,'fk_i_user_id'   => $userId);

            osc_run_hook('before_add_comment', $aComment);

            if( $mComments->insert($aComment) ) {
                $commentID = $mComments->dao->insertedId();
                if($status_num == 2 && $userId != null) { // COMMENT IS ACTIVE
                    $user = User::newInstance()->findByPrimaryKey($userId);
                    if( $user ) {
                        User::newInstance()->update( array( 'i_comments' => $user['i_comments'] + 1)
                                                    ,array( 'pk_i_id'    => $user['pk_i_id'] ) );
                    }
                }

                //Notify admin
                if ( osc_notify_new_comment() ) {
                    osc_run_hook('hook_email_new_comment_admin', $aItem);
                }

                //Notify user
                if ( osc_notify_new_comment_user() ) {
                    osc_run_hook('hook_email_new_comment_user', $aItem);
                }

                osc_run_hook( 'add_comment', $commentID );

                return $status_num;
            }

            return -1;
        }
示例#3
0
文件: item.php 项目: nsswaga/OSClass
<?php

$is_expired = osc_item_is_expired();
$is_user = osc_logged_user_id() != osc_item_user_id();
$is_can_contact = osc_reg_user_can_contact() && osc_is_web_user_logged_in() || !osc_reg_user_can_contact();
$is_comments_enabled = osc_comments_enabled();
$is_can_comment = osc_reg_user_post_comments() && osc_is_web_user_logged_in() || !osc_reg_user_post_comments();
?>
<!DOCTYPE html>
<html dir="ltr" lang="<?php 
echo str_replace('_', '-', osc_current_user_locale());
?>
">
    <head>
        <?php 
osc_current_web_theme_path('head.php');
?>
        <script type="text/javascript" src="<?php 
echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.js');
?>
"></script>
        <script type="text/javascript" src="<?php 
echo osc_current_web_theme_js_url('bootstrap-modal.js');
?>
"></script>
        <link href="<?php 
echo osc_current_web_theme_js_url('fancybox/jquery.fancybox-1.3.4.css');
?>
" rel="stylesheet" type="text/css" />
        <script type="text/javascript">
            $(document).ready(function(){
示例#4
0
            </form>
            <?php 
            ContactForm::js_validation();
            ?>
            <?php 
        }
    }
}
?>
        </div>

        <?php 
if (osc_comments_enabled()) {
    ?>
        <?php 
    if (osc_reg_user_post_comments() && osc_is_web_user_logged_in() || !osc_reg_user_post_comments()) {
        ?>
        <div id="comments">
            <?php 
        if (osc_count_item_comments() >= 1) {
            ?>
            <h2 class="title">
                <?php 
            _e('Comments', 'osclasswizards');
            ?>
            </h2>
            <?php 
        }
        ?>
            <ul id="comment_error_list">
            </ul>
示例#5
0
function item_comments()
{
    if (osc_reg_user_post_comments() && osc_is_web_user_logged_in() || !osc_reg_user_post_comments()) {
        ?>
        <div id="comments" class="box">
            <?php 
        if (osc_count_item_comments() >= 1) {
            ?>
            <h2>
                <?php 
            _e('Comments', 'pop');
            ?>
 (<?php 
            echo osc_count_item_comments();
            ?>
)
            </h2>
            <?php 
        }
        ?>
         
            <?php 
        CommentForm::js_validation();
        ?>
            <?php 
        if (osc_count_item_comments() >= 1) {
            ?>
            <div class="comments_list">
                <?php 
            while (osc_has_item_comments()) {
                ?>
                <div class="comment">
                    
                     <div class="user-avatar" style="background-image: url('<?php 
                echo osc_current_web_theme_url('images/seller-default.png');
                ?>
')"></div>
                    <?php 
                if (osc_comment_author_name()) {
                    ?>
                    <h4><em><?php 
                    echo osc_comment_author_name();
                    ?>
:</em></h4>
                    <?php 
                } else {
                    ?>
                    <h4><em><?php 
                    echo osc_comment_author_email();
                    ?>
:</em></h4>
                    <?php 
                }
                ?>
                    <div class="date">
                    <?php 
                echo osc_comment_pub_date();
                ?>
                    </div>
                    <p class="body"><?php 
                echo nl2br(osc_comment_body());
                ?>
 </p>
                    <?php 
                if (osc_comment_user_id() && osc_comment_user_id() == osc_logged_user_id()) {
                    ?>
                    <a rel="nofollow" href="<?php 
                    echo osc_delete_comment_url();
                    ?>
" title="<?php 
                    _e('Delete your comment', 'pop');
                    ?>
">
                            <?php 
                    _e('Delete', 'pop');
                    ?>
                        </a>
                    <?php 
                }
                ?>
                </div>
                <?php 
            }
            ?>
                <div class="pagination">
                    <?php 
            echo osc_comments_pagination();
            ?>
                </div>
            </div>
            <?php 
        }
        ?>
            <div class="comment_form">
               
                <h2>
                    <?php 
        _e('Leave your comment', 'pop');
        ?>
                </h2>
                <div class="resp-wrapper">
                     <ul id="comment_error_list" class="error_list">
                    </ul>
                    <form action="<?php 
        echo osc_base_url(true);
        ?>
" method="post" name="comment_form" id="comment_form">
                        <fieldset>
                            <input type="hidden" name="action" value="add_comment" />
                            <input type="hidden" name="page" value="item" />
                            <input type="hidden" name="id" value="<?php 
        echo osc_item_id();
        ?>
" />
                            <?php 
        if (osc_is_web_user_logged_in()) {
            ?>
                            <input type="hidden" name="authorName" value="<?php 
            echo osc_esc_html(osc_logged_user_name());
            ?>
" />
                            <input type="hidden" name="authorEmail" value="<?php 
            echo osc_logged_user_email();
            ?>
" />
                            <?php 
        } else {
            ?>
                            <div class="form-group col-md-6">
                                <label class="control-label" for="authorName">
                                    <?php 
            _e('Name', 'pop');
            ?>
                                </label>
                                <div class="controls">
                                    <?php 
            CommentForm::author_input_text();
            ?>
                                </div>
                            </div>
                            <div class="form-group col-md-6">
                                <label class="control-label" for="authorEmail">
                                    <?php 
            _e('Email', 'pop');
            ?>
                                </label>
                                <div class="controls">
                                    <?php 
            CommentForm::email_input_text();
            ?>
                                </div>
                            </div>
                            <?php 
        }
        ?>

                            <div class="form-group col-md-12">
                                <label class="control-label" for="body">
                                    <?php 
        _e('Comment', 'pop');
        ?>
                                </label>
                                <div class="controls textarea">
                                    <?php 
        CommentForm::body_input_textarea();
        ?>
                                </div>
                            </div>
                            <div class="actions col-md-12">
                                <button type="submit" class="btn btn-primary">
                                    <?php 
        _e('Send', 'pop');
        ?>
                                </button>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
        <?php 
    }
    ?>
 <?php 
}