Exemplo n.º 1
0
 function cache_comments($post_id)
 {
     global $gdsr_cache_posts_cmm_data, $gdsr_cache_posts_cmm_log, $gdsr_cache_posts_cmm_thumbs_log, $userdata;
     $user_id = is_object($userdata) ? $userdata->ID : 0;
     $to_get = array();
     $data = GDSRDBCache::get_comments($post_id);
     foreach ($data as $row) {
         $id = $row->comment_id;
         $gdsr_cache_posts_cmm_data->set($id, $row);
         $to_get[] = $id;
     }
     if (count($to_get) > 0) {
         $logs = GDSRDBCache::get_logs($to_get, $user_id, "comment", $_SERVER["REMOTE_ADDR"], $this->o["cmm_logged"] != 1, $this->o["cmm_allow_mixed_ip_votes"] == 1);
         foreach ($logs as $id => $value) {
             $gdsr_cache_posts_cmm_log->set($id, $value == 0);
         }
         if ($this->o["thumbs_active"] == 1) {
             $logs_thumb = GDSRDBCache::get_logs($to_get, $user_id, "cmmthumb", $_SERVER["REMOTE_ADDR"], $this->o["cmm_logged"] != 1, $this->o["cmm_allow_mixed_ip_votes"] == 1);
             foreach ($logs_thumb as $id => $value) {
                 $gdsr_cache_posts_cmm_thumbs_log->set($id, $value == 0);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Renders result of comment integration of multi rating for specific comment
  *
  * @param int $comment_id initial rating value
  * @param object $post_id post id
  * @param int $multi_set_id id of the multi rating set to use
  * @param int $template_id id of the template to use
  * @param string $stars_set set to use for rendering
  * @param int $stars_size set size to use for rendering
  * @param string $stars_set_ie6 set to use for rendering in ie6
  * @param string $avg_stars_set set to use for rendering of average value
  * @param int $avg_stars_size set size to use for rendering of average value
  * @param string $avg_stars_set_ie6 set to use for rendering of average value in ie6
  */
 function comment_integrate_multi_result($comment_id, $post_id, $multi_set_id, $template_id, $stars_set = 'oxygen', $stars_size = 20, $stars_set_ie6 = 'oxygen_gif', $avg_stars_set = 'oxygen', $avg_stars_size = 20, $avg_stars_set_ie6 = 'oxygen_gif')
 {
     if (!$this->g->is_cached_integration_mur) {
         global $gdsr_cache_integation_mur;
         $data = GDSRDBCache::get_integration($post_id, 'multis');
         foreach ($data as $row) {
             $id = $row->multi_id . "_" . $row->comment_id;
             $gdsr_cache_integation_mur->set($id, $row);
         }
         $this->g->is_cached_integration_mur = true;
     }
     $value = wp_gdget_integration_mur($comment_id, $multi_set_id);
     if (is_serialized($value) && !is_null($value)) {
         $value = unserialize($value);
         $set = gd_get_multi_set($multi_set_id);
         $weight_norm = array_sum($set->weight);
         $avg_rating = $i = 0;
         $votes = array();
         foreach ($value as $md) {
             $single_vote = array();
             $single_vote['votes'] = 1;
             $single_vote['score'] = $md;
             $single_vote['rating'] = $md;
             $avg_rating += $md * $set->weight[$i] / $weight_norm;
             $votes[] = $single_vote;
             $i++;
         }
         $avg_rating = @number_format($avg_rating, 1);
         if ($avg_rating > 0) {
             $style = $stars_set == '' ? $this->g->o['mur_style'] : $stars_set;
             $style = $this->g->is_ie6 ? $stars_set_ie6 == "" ? $this->g->o['mur_style_ie6'] : $stars_set_ie6 : $style;
             return GDSRRenderT2::render_rmb($template_id, array('votes' => $votes, 'post_id' => $post_id, 'set' => $set, 'avg_rating' => $avg_rating, 'style' => $style, 'size' => $stars_size, 'avg_style' => $this->g->is_ie6 ? $avg_stars_set_ie6 : $avg_stars_set, 'avg_size' => $avg_stars_size));
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
Exemplo n.º 3
0
 /**
  * Renders result of comment integration of multi rating for specific comment
  *
  * @param int $comment_id initial rating value
  * @param object $post_id post id
  * @param int $multi_set_id id of the multi rating set to use
  * @param int $template_id id of the template to use
  * @param string $stars_set set to use for rendering
  * @param int $stars_size set size to use for rendering
  * @param string $stars_set_ie6 set to use for rendering in ie6
  * @param string $avg_stars_set set to use for rendering of average value
  * @param int $avg_stars_size set size to use for rendering of average value
  * @param string $avg_stars_set_ie6 set to use for rendering of average value in ie6
  */
 function comment_integrate_multi_result($comment_id, $post_id, $multi_set_id, $template_id, $stars_set = "oxygen", $stars_size = 20, $stars_set_ie6 = "oxygen_gif", $avg_stars_set = "oxygen", $avg_stars_size = 20, $avg_stars_set_ie6 = "oxygen_gif")
 {
     if (!$this->g->is_cached_integration_mur) {
         global $gdsr_cache_integation_mur;
         $data = GDSRDBCache::get_integration($post_id, "multis");
         foreach ($data as $row) {
             $id = $row->multi_id . "_" . $row->comment_id;
             $gdsr_cache_integation_mur->set($id, $row);
         }
         $this->g->is_cached_integration_mur = true;
     }
     $value = wp_gdget_integration_mur($comment_id, $multi_set_id);
     if (is_serialized($value) && !is_null($value)) {
         $value = unserialize($value);
         $set = gd_get_multi_set($multi_set_id);
         $weight_norm = array_sum($set->weight);
         $avg_rating = $i = 0;
         $votes = array();
         foreach ($value as $md) {
             $single_vote = array();
             $single_vote["votes"] = 1;
             $single_vote["score"] = $md;
             $single_vote["rating"] = $md;
             $avg_rating += $md * $set->weight[$i] / $weight_norm;
             $votes[] = $single_vote;
             $i++;
         }
         $avg_rating = @number_format($avg_rating, 1);
         if ($avg_rating > 0) {
             $style = $stars_set == "" ? $this->g->o["mur_style"] : $stars_set;
             $style = $this->g->is_ie6 ? $stars_set_ie6 == "" ? $this->g->o["mur_style_ie6"] : $stars_set_ie6 : $style;
             return GDSRRenderT2::render_rmb($template_id, array("votes" => $votes, "post_id" => $post_id, "set" => $set, "avg_rating" => $avg_rating, "style" => $style, "size" => $stars_size, "avg_style" => $this->g->is_ie6 ? $avg_stars_set_ie6 : $avg_stars_set, "avg_size" => $avg_stars_size));
         } else {
             return "";
         }
     } else {
         return "";
     }
 }