Beispiel #1
0
 function save_vote_comment($id, $user, $ip, $ua, $vote)
 {
     global $wpdb, $table_prefix;
     $ua = str_replace("'", "''", $ua);
     $ua = substr($ua, 0, 250);
     $post = $wpdb->get_row("select comment_post_ID from {$wpdb->comments} where comment_ID = " . $id);
     $post_id = $post->comment_post_ID;
     $sql = sprintf("SELECT * FROM %sgdsr_data_article WHERE post_id = %s", $table_prefix, $post_id);
     $post_data = $wpdb->get_row($sql);
     if ($post_data->moderate_comments == "" || $post_data->moderate_comments == "N" || $post_data->moderate_comments == "V" && $user > 0 || $post_data->moderate_comments == "U" && $user == 0) {
         gdsrBlgDB::add_vote_comment($id, $user, $ip, $ua, $vote);
     } else {
         $modsql = sprintf("INSERT INTO %sgdsr_moderate (id, vote_type, user_id, vote, voted, ip, user_agent) VALUES (%s, 'comment', %s, %s, '%s', '%s', '%s')", $table_prefix, $id, $user, $vote, str_replace("'", "''", current_time('mysql')), $ip, $ua);
         $wpdb->query($modsql);
     }
 }
Beispiel #2
0
 function moderation_approve($ids, $ids_array)
 {
     global $wpdb, $table_prefix;
     $sql = sprintf("select * from %s where record_id in %s", $table_prefix . "gdsr_moderate", $ids);
     $rows = $wpdb->get_results($sql);
     foreach ($rows as $row) {
         if ($row->vote_type == "article") {
             gdsrBlgDB::add_vote($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote);
         }
         if ($row->vote_type == "comment") {
             gdsrBlgDB::add_vote_comment($row->id, $row->user_id, $row->ip, $row->user_agent, $row->vote);
         }
     }
     gdsrAdmDB::moderation_delete($ids);
 }