コード例 #1
0
 function render_thumb_article_actual($settings)
 {
     $rd_post_id = intval($settings[1]);
     $rd_is_page = intval($settings[2]);
     $post_author = intval($settings[3]);
     $post_date = intval($settings[4]);
     $rd_unit_width = $settings[7];
     $override["tpl"] = intval($settings[5]);
     $override["read_only"] = intval($settings[6]);
     $override["style"] = $this->g->g->thumbs[$settings[8]]->folder;
     $override["style_ie6"] = $this->g->g->thumbs[$settings[9]]->folder;
     $rd_unit_style = $this->g->is_ie6 ? $override["style_ie6"] : $override["style"];
     $rd_user_id = intval($settings[10]);
     $dbg_allow = "F";
     $already_voted = false;
     $allow_vote = $override["read_only"] == 0;
     $allow_vote = apply_filters("gdsr_allow_vote_thumb_article", $allow_vote, $rd_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";
     }
     if ($override["read_only"] == 1) {
         $dbg_allow = "RO";
     }
     $post_data = wp_gdget_post($rd_post_id);
     if (is_null($post_data) || !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_articles = $post_data->recc_rules_articles != "I" ? $post_data->recc_rules_articles : $this->g->get_post_rule_value($rd_post_id, "recc_rules_articles", "recc_default_voterules_articles");
     if ($rules_articles == "H") {
         return "";
     }
     if ($allow_vote) {
         if ($rules_articles == "" || $rules_articles == "A" || $rules_articles == "U" && $rd_user_id > 0 || $rules_articles == "V" && $rd_user_id == 0) {
             $allow_vote = true;
         } else {
             $allow_vote = false;
             $dbg_allow = "R_" . $rules_articles;
         }
     }
     if ($allow_vote) {
         if ($this->g->o["author_vote"] == 1 && $rd_user_id == $post_author) {
             $allow_vote = false;
             $dbg_allow = "A";
         }
     }
     $remaining = 0;
     $deadline = '';
     $expiry_type = 'N';
     if ($allow_vote && ($post_data->expiry_type == 'D' || $post_data->expiry_type == 'T' || $post_data->expiry_type == 'I')) {
         $expiry_type = $post_data->expiry_type != 'I' ? $post_data->expiry_type : $this->g->get_post_rule_value($rd_post_id, "expiry_type", "default_timer_type");
         $expiry_value = $post_data->expiry_type != 'I' ? $post_data->expiry_value : $this->g->get_post_rule_value($rd_post_id, "expiry_value", "default_timer_value");
         switch ($expiry_type) {
             case "D":
                 $remaining = gdsrFrontHelp::expiration_date($expiry_value);
                 $deadline = $expiry_value;
                 break;
             case "T":
                 $remaining = gdsrFrontHelp::expiration_countdown($post_date, $expiry_value);
                 $deadline = gdsrFrontHelp::calculate_deadline($remaining);
                 break;
         }
         if ($remaining < 1) {
             gdsrBlgDB::lock_post($rd_post_id);
             $allow_vote = false;
             $dbg_allow = "T";
         }
     }
     $already_voted = !wp_gdget_thumb_postlog($rd_post_id);
     if ($allow_vote) {
         $allow_vote = !$already_voted;
         if (!$allow_vote) {
             $dbg_allow = "D";
         }
     }
     if ($allow_vote) {
         $allow_vote = gdsrFrontHelp::check_cookie($rd_post_id, "artthumb");
         if (!$allow_vote) {
             $dbg_allow = "C";
         }
     }
     $votes = $score = $votes_plus = $votes_minus = 0;
     if ($rules_articles == "A" || $rules_articles == "N") {
         $votes = $post_data->user_recc_plus + $post_data->user_recc_minus + $post_data->visitor_recc_plus + $post_data->visitor_recc_minus;
         $score = $post_data->user_recc_plus - $post_data->user_recc_minus + $post_data->visitor_recc_plus - $post_data->visitor_recc_minus;
         $votes_plus = $post_data->user_recc_plus + $post_data->visitor_recc_plus;
         $votes_minus = $post_data->user_recc_minus + $post_data->visitor_recc_minus;
     } else {
         if ($rules_articles == "V") {
             $votes = $post_data->visitor_recc_plus + $post_data->visitor_recc_minus;
             $score = $post_data->visitor_recc_plus - $post_data->visitor_recc_minus;
             $votes_plus = $post_data->visitor_recc_plus;
             $votes_minus = $post_data->visitor_recc_minus;
         } else {
             $votes = $post_data->user_recc_plus + $post_data->user_recc_minus;
             $score = $post_data->user_recc_plus - $post_data->user_recc_minus;
             $votes_plus = $post_data->user_recc_plus;
             $votes_minus = $post_data->user_recc_minus;
         }
     }
     $debug = $rd_user_id == 0 ? "V" : "U";
     $debug .= $rd_user_id == $post_author ? "A" : "N";
     $debug .= ":" . $dbg_allow . " [" . STARRATING_VERSION . "]";
     $tags_css = array("CSS_BLOCK" => $this->g->o["srb_class_block"], "CSS_HEADER" => $this->g->o["srb_class_header"], "CSS_STARS" => $this->g->o["srb_class_stars"], "CSS_TEXT" => $this->g->o["srb_class_text"]);
     $template_id = $override["tpl"];
     $rating_block = GDSRRenderT2::render_tab($template_id, array("already_voted" => $already_voted, "post_id" => $rd_post_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["thumb_header_text"], "debug" => $debug, "wait_msg" => $this->loader_article_thumb, "time_restirctions" => $expiry_type, "time_remaining" => $remaining, "time_date" => $deadline));
     return $rating_block;
 }