예제 #1
0
 function render_thumb_comment_actual($settings)
 {
     if ($this->g->o["comments_active"] != 1) {
         return "";
     }
     $post_id = intval($settings[1]);
     $comment_id = intval($settings[2]);
     $comment_author = intval($settings[3]);
     $rd_is_page = intval($settings[4]);
     $post_author = intval($settings[5]);
     $user_id = intval($settings[6]);
     $override["tpl"] = intval($settings[7]);
     $override["read_only"] = intval($settings[8]);
     $override["size"] = intval($settings[9]);
     $override["style"] = $this->g->g->thumbs[$settings[10]]->folder;
     $override["style_ie6"] = $this->g->g->thumbs[$settings[11]]->folder;
     $dbg_allow = "F";
     $already_voted = false;
     $allow_vote = $override["read_only"] == 0;
     $allow_vote = apply_filters("gdsr_allow_vote_thumb_comment", $allow_vote, $post_id);
     if ($this->g->is_ban && $this->g->o["ip_filtering"] == 1) {
         if ($this->g->o["ip_filtering_restrictive"] == 1) {
             return "";
         } else {
             $allow_vote = false;
         }
         $dbg_allow = "B";
     }
     $rd_unit_width = $override["size"];
     $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"];
     $rd_post_id = intval($post_id);
     $rd_user_id = intval($user_id);
     $rd_comment_id = intval($comment_id);
     $post_data = wp_gdget_post($rd_post_id);
     if (!is_object($post_data)) {
         GDSRDatabase::add_default_vote($rd_post_id, $rd_is_page);
         $post_data = wp_gdget_post($rd_post_id);
         $this->g->c[$rd_post_id] = 1;
     }
     $rules_comments = $post_data->recc_rules_comments != "I" ? $post_data->recc_rules_comments : $this->g->get_post_rule_value($rd_post_id, "recc_rules_comments", "recc_default_voterules_comments");
     if ($rules_comments == "H") {
         return "";
     }
     $comment_data = wp_gdget_comment($rd_comment_id);
     if (count($comment_data) == 0) {
         GDSRDatabase::add_empty_comment($rd_comment_id, $rd_post_id);
         $comment_data = wp_gdget_comment($rd_comment_id);
     }
     if ($allow_vote) {
         if ($this->g->o["cmm_author_vote"] == 1 && $rd_user_id == $comment_author && $rd_user_id > 0) {
             $allow_vote = false;
             $dbg_allow = "A";
         }
     }
     if ($allow_vote) {
         if ($rules_comments == "" || $rules_comments == "A" || $rules_comments == "U" && $rd_user_id > 0 || $rules_comments == "V" && $rd_user_id == 0) {
             $allow_vote = true;
         } else {
             $allow_vote = false;
             $dbg_allow = "R_" . $rules_comments;
         }
     }
     $already_voted = !wp_gdget_thumb_commentlog($rd_comment_id);
     if ($allow_vote) {
         $allow_vote = !$already_voted;
         if (!$allow_vote) {
             $dbg_allow = "D";
         }
     }
     if ($allow_vote) {
         $allow_vote = gdsrFrontHelp::check_cookie($rd_comment_id, "cmmthumb");
         if (!$allow_vote) {
             $dbg_allow = "C";
         }
     }
     $votes = $score = $votes_plus = $votes_minus = 0;
     if ($rules_comments == "A" || $rules_comments == "N") {
         $votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus + $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
         $score = $comment_data->user_recc_plus - $comment_data->user_recc_minus + $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
         $votes_plus = $comment_data->user_recc_plus + $comment_data->visitor_recc_plus;
         $votes_minus = $comment_data->user_recc_minus + $comment_data->visitor_recc_minus;
     } else {
         if ($rules_comments == "V") {
             $votes = $comment_data->visitor_recc_plus + $comment_data->visitor_recc_minus;
             $score = $comment_data->visitor_recc_plus - $comment_data->visitor_recc_minus;
             $votes_plus = $comment_data->visitor_recc_plus;
             $votes_minus = $comment_data->visitor_recc_minus;
         } else {
             $votes = $comment_data->user_recc_plus + $comment_data->user_recc_minus;
             $score = $comment_data->user_recc_plus - $comment_data->user_recc_minus;
             $votes_plus = $comment_data->user_recc_plus;
             $votes_minus = $comment_data->user_recc_minus;
         }
     }
     $debug = $rd_user_id == 0 ? "V" : "U";
     $debug .= $rd_user_id == $comment_author ? "A" : "N";
     $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]";
     $tags_css = array();
     $tags_css["CMM_CSS_BLOCK"] = $this->g->o["cmm_class_block"];
     $tags_css["CMM_CSS_HEADER"] = $this->g->o["srb_class_header"];
     $tags_css["CMM_CSS_STARS"] = $this->g->o["cmm_class_stars"];
     $tags_css["CMM_CSS_TEXT"] = $this->g->o["cmm_class_text"];
     $template_id = $override["tpl"];
     $rating_block = GDSRRenderT2::render_tcb($template_id, array("already_voted" => $already_voted, "comment_id" => $rd_comment_id, "votes" => $votes, "score" => $score, "votes_plus" => $votes_plus, "votes_minus" => $votes_minus, "style" => $rd_unit_style, "unit_width" => $rd_unit_width, "allow_vote" => $allow_vote, "user_id" => $rd_user_id, "tags_css" => $tags_css, "header_text" => $this->g->o["header_text"], "debug" => $debug, "wait_msg" => $this->loader_comment_thumb));
     return $rating_block;
 }