Exemplo n.º 1
0
 function comment_save($comment_id)
 {
     global $userdata;
     $user_id = is_object($userdata) ? $userdata->ID : 0;
     $user = intval($user_id);
     $ip = $_SERVER["REMOTE_ADDR"];
     if ($this->post_comment["review"] > -1) {
         $comment_data = GDSRDatabase::get_comment_data($comment_id);
         if (count($comment_data) == 0) {
             GDSRDatabase::add_empty_comment($comment_id, $this->post_comment["post_id"], $this->post_comment["review"]);
         } else {
             GDSRDatabase::save_comment_review($comment_id, $this->post_comment["review"]);
         }
     }
     $std_minimum = $this->o["int_comment_std_zero"] == 1 ? -1 : 0;
     $mur_minimum = $this->o["int_comment_mur_zero"] == 1 ? 0 : 1;
     $id = $this->post_comment["post_id"];
     if ($this->post_comment["standard_rating"] > $std_minimum) {
         $votes = $this->post_comment["standard_rating"];
         $ua = $this->o["save_user_agent"] == 1 ? $_SERVER["HTTP_USER_AGENT"] : "";
         $allow_vote = true;
         if ($this->o["cmm_integration_prevent_duplicates"] == 1) {
             $allow_vote = intval($votes) <= $this->o["stars"];
             if ($allow_vote) {
                 $allow_vote = gdsrFrontHelp::check_cookie($id);
             }
             if ($allow_vote) {
                 $allow_vote = gdsrBlgDB::check_vote($id, $user, 'article', $ip, false, false);
             }
         }
         if ($allow_vote) {
             gdsrBlgDB::save_vote($id, $user, $ip, $ua, $votes, $comment_id);
             if ($this->o["cmm_integration_prevent_duplicates"] == 1) {
                 gdsrFrontHelp::save_cookie($id);
             }
             do_action("gdsr_vote_rating_article_integrate", $id, $user, $votes);
         }
     }
     if ($this->post_comment["multi_id"] > 0 && $this->post_comment["multi_rating"] != "") {
         $set_id = $this->post_comment["multi_id"];
         $set = gd_get_multi_set($set_id);
         $values = explode("X", $this->post_comment["multi_rating"]);
         $allow_vote = true;
         foreach ($values as $v) {
             if ($v > $set->stars || $v < $mur_minimum) {
                 $allow_vote = false;
                 break;
             }
         }
         if ($this->o["cmm_integration_prevent_duplicates"] == 1) {
             if ($allow_vote) {
                 $allow_vote = gdsrFrontHelp::check_cookie($id . "#" . $set_id, "multis");
             }
             if ($allow_vote) {
                 $allow_vote = GDSRDBMulti::check_vote($id, $user, $set_id, 'multis', $ip, false, false);
             }
         }
         if ($allow_vote) {
             $ip = $_SERVER["REMOTE_ADDR"];
             $ua = $this->o["save_user_agent"] == 1 ? $_SERVER["HTTP_USER_AGENT"] : "";
             $data = GDSRDatabase::get_post_data($id);
             GDSRDBMulti::save_vote($id, $set->multi_id, $user, $ip, $ua, $values, $data, $comment_id);
             GDSRDBMulti::recalculate_multi_averages($id, $set->multi_id, "", $set, true);
             if ($this->o["cmm_integration_prevent_duplicates"] == 1) {
                 gdsrFrontHelp::save_cookie($id . "#" . $set_id, "multis");
             }
             do_action("gdsr_vote_rating_multis_integrate", $id, $user, $set_id, $values);
         }
     }
 }
Exemplo n.º 2
0
 function comment_edit_review($comment_content)
 {
     if ($_POST['gdsr_comment_edit'] == "edit") {
         $post_id = $_POST["comment_post_ID"];
         $comment_id = $_POST["comment_ID"];
         if (isset($_POST["gdsr_cmm_review"])) {
             $value = $_POST["gdsr_cmm_review"];
         } else {
             $value = -1;
         }
         $comment_data = GDSRDatabase::get_comment_data($comment_id);
         if (count($comment_data) == 0) {
             GDSRDatabase::add_empty_comment($comment_id, $post_id, $value);
         } else {
             GDSRDatabase::save_comment_review($comment_id, $value);
         }
     }
     return $comment_content;
 }