Allow ecshop users to log in to evaluate for optional anonymous evaluation

Source: Internet
Author: User

ECSHOP The default program is when the user login, the product evaluation is not able to anonymously evaluation.

Some stores set up only login reviews, but customers don't want to show their account names. This is where it comes in handy.

1 Replace the Add_comment method with the following code at the bottom of the comment.php

/** * Add comment content  * * @access   public * @param    object  $cmt  * @return   Void */function add_comment ($CMT) {    /* comment requires approval */    $ status = 1-  $GLOBALS [' _cfg '] [' Comment_check '];      $user _id =  Empty ($_session[' user_id ')? 0:  $_session[' user_id '];     $email  = empty ($cmt->email)?  $_SESSION[ ' Email ': Trim ($cmt->email);     $user _name = empty ($cmt->username)?  $_ session[' user_name ': Trim ($cmt->username);     $email  = htmlspecialchars ($email);      $user _name = htmlspecialchars ($user _name);             //file_put_contents (' Test.txt ', $CMT->nimingis);     $nimingis = $CMT->nimingis;    if ($nimingis) {   &nbsp, $user _id=0;     $user _name= str_mid_replace ($_session[' user_name ']);         }            /* Save comments */     $sql  =  "INSERT into"   $GLOBALS [' ECs ']->table (' comment ').             "(Comment_type, Id_value, email, user_name, Content, Comment_rank, Add_time, ip_address, status, parent_id, user_id) VALUES " .             "('"  . $CMT->type.  "', '"  . $CMT->id.  "', ' $email ', ' $user _name ', '  . $CMT->content. "', '". $CMT->rank. "',". Gmtime (). "," ". Real_ip ()." ', ' $status ', ' 0 ', ' $user _id ') ";      $result  =  $GLOBALS [' DB ']->query ($sql);     clear_cache_files (' Comments_list.lbi ');     /*if ($status > 0)    &nbSp {        add_feed ($GLOBALS [' DB ']->insert_id (), comment_goods);     }*/    return  $result;}   //string intercept     function str_mid_replace ($string) {    if   (!  $string  | |!isset ($string [1])  return  $string;      $len  = strlen ($string);     $starNum  = floor ($len  /2);      $noStarNum  =  $len  -  $starNum;     $leftNum  = ceil ($noStarNum  /2);     $rightNum  =  $noStarNum  -  $leftNum;       $result  = substr ($string, 0,  $leftNum);     $result  .= str_repeat (' * ',  $starNum);     $result  .= substr ($string,   $len-$rightNum);      return $Result;}  

2. Increased in the Submitcomment method in Comments.lbi

1 Cmt.nimingis = frm.elements[' Nimingis '].checked;

3. Add in HTML code

<!--{if $smarty .session.user_name}--> <tr> <td width= "Up" align= "right" > Anonymous:</td> <TD width= "631" >{$lang. Anonymous}<input type= "checkbox" Name= "Nimingis" value= "" ></td> </tr>         ; <!--{/if}-->

Allow ecshop users to log in to evaluate for optional anonymous evaluation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.