Exemple #1
0
            <div class="form-horizontal">
                <h2 class="render-title"><?php 
_e('Comment Settings');
?>
</h2>

                <div class="form-row">
                    <div class="form-label"><?php 
_e('Default comment settings');
?>
</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>
        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;
        }
Exemple #3
0
                        <form action="<?php 
echo osc_admin_base_url(true);
?>
" method="post">
                            <input type="hidden" name="page" value="settings" />
                            <input type="hidden" name="action" value="comments_post" />
                            
                            <div style="float: left; width: 50%;">
                                <fieldset>
                                    <legend><?php 
_e('Settings');
?>
</legend>
                                    <input style="height: 20px; padding-left: 4px;padding-top: 4px;" type="checkbox" <?php 
echo osc_comments_enabled() ? 'checked="true"' : '';
?>
 name="enabled_comments" id="enabled_comments" value="1" />
                                    <label for="enabled_comments"><?php 
_e('Comments enabled');
?>
</label>
                                    <br/>
                                    <input style="height: 20px; padding-left: 4px;padding-top: 4px;" type="checkbox" onclick="checkbox_change();" <?php 
echo osc_moderate_comments() == -1 ? '' : 'checked="true"';
?>
 name="moderate_comments" id="moderate_comments" value="1" />
                                    <label for="moderate_comments"><?php 
_e('Moderate comments');
?>
</label>
Exemple #4
0
</button>
                    </div>
                </div>
            </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 
        }
Exemple #5
0
<?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(){